JohnSantaFe
asked on
MFC user defined message
I'd like to create a user defined message to have a thread pass a message back to the main MFC application.
My understanding of how to do this is as follows;
1. Register the message:
static const int WMU_RUN_COMPLETE = RegisterWindowMessage("WMU _RUN_COMPL ETE");
2. Declare the function that will eventually handle the message;
afx_msg LRESULT OnRunComplete(WPARAM wParam, LPARAM lParam);
3. Add it to the message map;
ON_REGISTERED_MESSAGE (WMU_RUN_COMPLETE, OnRunComplete)
4. Register the same message name in my thread;
static const int WMU_RUN_COMPLETE = RegisterWindowMessage("WMU _RUN_COMPL ETE");
5. Send the message from my thread;
SendMessage(hwnd, MY_WM_RUN_COMPLETE, (WPARAM)0, (LPARAM)0);
I haven't even gotten to steps 4 and 5 yet. When I compile, I get an undeclared identifier, WMU_RUN_COMPLETE, because of the reference in the message map.
Where am I supposed to put the WMU_RUN_COMPLETE declaration and RegisterWindowMessage?
Note, this is a dialog based application and not a full document view app.
This is the first time I've tried this, so any other comments would be appreciated.
Thanks.
My understanding of how to do this is as follows;
1. Register the message:
static const int WMU_RUN_COMPLETE = RegisterWindowMessage("WMU
2. Declare the function that will eventually handle the message;
afx_msg LRESULT OnRunComplete(WPARAM wParam, LPARAM lParam);
3. Add it to the message map;
ON_REGISTERED_MESSAGE (WMU_RUN_COMPLETE, OnRunComplete)
4. Register the same message name in my thread;
static const int WMU_RUN_COMPLETE = RegisterWindowMessage("WMU
5. Send the message from my thread;
SendMessage(hwnd, MY_WM_RUN_COMPLETE, (WPARAM)0, (LPARAM)0);
I haven't even gotten to steps 4 and 5 yet. When I compile, I get an undeclared identifier, WMU_RUN_COMPLETE, because of the reference in the message map.
Where am I supposed to put the WMU_RUN_COMPLETE declaration and RegisterWindowMessage?
Note, this is a dialog based application and not a full document view app.
This is the first time I've tried this, so any other comments would be appreciated.
Thanks.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
I was trying to declare it as a public member of the clas : {
I moved it up out of the class but still in the .h file and that worked.
Thanks for the tip.