Click to See Complete Forum and Search --> : How do I set up my own message in message map?


DHunter21
August 6th, 1999, 04:31 PM
Hi,

I want to setup my own message (MM_REFRESH), and I don't know what exactly to do. Funny how none of my 5 books say anything on this.. hehe.

Anyways, I thought that I should enter
afx_msg void OnRefreshTerm();
to the message map in the header file. I then thought I should add ON_MM_REFRESH() to the message map in the cpp file.

What am I doing wrong here? I want MM_REFRESH to execute OnRefreshTerm().
Iwould also like to know what the proper way to call the message is. (ie this->SendMessage(MM_REFRESH, ???, ???);

Thanks

James Armstrong
August 6th, 1999, 05:48 PM
In the message map you should put:

ON_MESSAGE(MM_REFRESH, OnRefreshTerm)

HTH,

James Armstrong

Brad
August 6th, 1999, 05:50 PM
MFC doesn't know about your message, so it's not going to have a pre-defined macro (#define) called ON_MM_REFRESH. Instead, you have to use ON_MESSAGE in your message map, like this:
ON_MESSAGE(MM_REFRESH, OnRefreshTerm)


If you are sending from the saying object (sending to "this"), then just call SendMessage(MM_REFRESH, ...). The other two parameters depend on what the function that handles the message expects for wParam and lParam.

Hope this helps,
Brad

sohayla
August 6th, 1999, 06:01 PM
The first thing you want to do is to place a constant that represents the message in the overall header file:
#define WM_REFRESH (WM_USER+1)
Next connect the message to the handler with the macro in the message map:

BEGIN_MESSAGE_MAP(.. , ..)
ON_MESSAGE(WM_REFRESH,OnRefresh())
END_MESSAGE_MAP()

Lastly, place prototype of OnRefresh in the class header and write the fuction itself.

Enjoy........

DHunter21
August 8th, 1999, 12:17 AM
You guys rule.. thanks