Click here to Skip to main content
15,881,248 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Setting Focus to a Dialog on Clicking it. Pin
d358207727-Jun-11 0:53
d358207727-Jun-11 0:53 
GeneralRe: Setting Focus to a Dialog on Clicking it. Pin
pix_programmer27-Jun-11 2:05
pix_programmer27-Jun-11 2:05 
QuestionON_COMMAND not working on mfc Pin
Mohibur Rashid26-Jun-11 5:28
professionalMohibur Rashid26-Jun-11 5:28 
AnswerRe: ON_COMMAND not working on mfc Pin
Richard MacCutchan26-Jun-11 6:04
mveRichard MacCutchan26-Jun-11 6:04 
GeneralRe: ON_COMMAND not working on mfc Pin
Mohibur Rashid26-Jun-11 12:32
professionalMohibur Rashid26-Jun-11 12:32 
GeneralRe: ON_COMMAND not working on mfc Pin
Richard MacCutchan26-Jun-11 21:23
mveRichard MacCutchan26-Jun-11 21:23 
GeneralRe: ON_COMMAND not working on mfc Pin
Mohibur Rashid26-Jun-11 21:28
professionalMohibur Rashid26-Jun-11 21:28 
GeneralRe: ON_COMMAND not working on mfc Pin
Iain Clarke, Warrior Programmer26-Jun-11 22:01
Iain Clarke, Warrior Programmer26-Jun-11 22:01 
johny10151981 wrote:
Since when
TEXT_2
is a command?


Since you put it in the ON_COMMAND macro.

Another example of an ON_COMMAND macro:
ON_COMMAND(ID_FILE_NEW, OnFileNew)


The ON_COMMAND macro in a message map is a way of telling the message mapper what to do with a WM_COMMAND windows message that has WPARAM=command id. In the case I wrote, wParam equals ID_FILE_NEW.
In the case you wrote, wParam equals TEXT2.

So, unless somewhere else in your code issues WM_COMMAND,wParam==TEXT2, your function will never get called. That other place could be window's menu handler, or the MFC code behind a toolbar, or a dialog button, or...

In another reply, you say TEXT2 is a macro. Do you mean:
#define TEXT2  1234

or something more complex?

Another problem you could be having is message routing. MFC does lots of work behind the scenes to give your objects the ability to response to commands. For example, CDocument never has a window, but it can respond to WM_COMMANDs.

Read this classic article from 1995. The re-read it. Then program a bit, then re-reread it. If you can't absorb it pretty well, you will struggle with MFC, and most windows programs. .Net may do things differently, but many of the principles are the same.
Meandering Through the Maze of MFC Message and Command Routing[^]

Don't forget to bookmark it!

Iain.
I am one of "those foreigners coming over here and stealing our jobs". Yay me!

GeneralRe: ON_COMMAND not working on mfc Pin
Richard MacCutchan26-Jun-11 22:48
mveRichard MacCutchan26-Jun-11 22:48 
GeneralRe: ON_COMMAND not working on mfc Pin
Iain Clarke, Warrior Programmer26-Jun-11 23:00
Iain Clarke, Warrior Programmer26-Jun-11 23:00 
GeneralRe: ON_COMMAND not working on mfc Pin
Mohibur Rashid26-Jun-11 22:49
professionalMohibur Rashid26-Jun-11 22:49 
GeneralRe: ON_COMMAND not working on mfc Pin
Iain Clarke, Warrior Programmer26-Jun-11 22:59
Iain Clarke, Warrior Programmer26-Jun-11 22:59 
GeneralRe: ON_COMMAND not working on mfc Pin
Mohibur Rashid26-Jun-11 23:18
professionalMohibur Rashid26-Jun-11 23:18 
GeneralRe: ON_COMMAND not working on mfc Pin
Iain Clarke, Warrior Programmer26-Jun-11 23:35
Iain Clarke, Warrior Programmer26-Jun-11 23:35 
GeneralRe: ON_COMMAND not working on mfc Pin
Mohibur Rashid26-Jun-11 23:50
professionalMohibur Rashid26-Jun-11 23:50 
GeneralRe: ON_COMMAND not working on mfc Pin
Iain Clarke, Warrior Programmer26-Jun-11 22:08
Iain Clarke, Warrior Programmer26-Jun-11 22:08 
AnswerRe: ON_COMMAND not working on mfc Pin
Mark Salsbery26-Jun-11 6:22
Mark Salsbery26-Jun-11 6:22 
GeneralRe: ON_COMMAND not working on mfc [modified] Pin
Mohibur Rashid26-Jun-11 12:23
professionalMohibur Rashid26-Jun-11 12:23 
GeneralRe: ON_COMMAND not working on mfc Pin
Mark Salsbery26-Jun-11 13:50
Mark Salsbery26-Jun-11 13:50 
GeneralRe: ON_COMMAND not working on mfc Pin
Mohibur Rashid26-Jun-11 19:11
professionalMohibur Rashid26-Jun-11 19:11 
GeneralRe: ON_COMMAND not working on mfc Pin
Stefan_Lang27-Jun-11 4:32
Stefan_Lang27-Jun-11 4:32 
QuestionCalling Funciton of Other class Pin
Mohibur Rashid25-Jun-11 23:28
professionalMohibur Rashid25-Jun-11 23:28 
AnswerRe: Calling Funciton of Other class Pin
Richard MacCutchan26-Jun-11 2:30
mveRichard MacCutchan26-Jun-11 2:30 
GeneralRe: Calling Funciton of Other class Pin
Mohibur Rashid26-Jun-11 2:54
professionalMohibur Rashid26-Jun-11 2:54 
GeneralRe: Calling Funciton of Other class Pin
Richard MacCutchan26-Jun-11 5:16
mveRichard MacCutchan26-Jun-11 5:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.