Click here to Skip to main content
15,884,425 members
Please Sign up or sign in to vote.
2.00/5 (3 votes)
See more:
Hi,
How can we create our own MESSAGE in MFC?

I Googled but i didn't get any concrete idea on this and also the steps to create the same. So kindly please guide me to understand and create own message in MFC.
Thanks :)
Posted
Comments
Manfred Rudolf Bihy 31-May-11 18:02pm    
Please reconsider you question. Title talks about a message handler whereas you question itself talks about a creating your own message. "Unclear" is putting it kindly.

you can use any UINT value as a messege value. But it should be unique from already existing values. So generally what we does to create a user defined message is

#define MY_CUSTOM_MSG WM_APP + 1

you can sent/post the message using the sendmessage or postmessage function.

And you can add an event handler for this message inside the messagemap as follows.

ON_MESSAGE( MY_CUSTOM_MSG, OnMyMessage )

It is important that you define the OnMyMessage as follows

LRESULT OnMyMessage (WPARAM wParam, LPARAM lParam);

Please note that this kind of message is local to your process, if you want to sent message from one process to another, then you have to create the mesasge using RegisterWindowMessage[^] function. The message map entry for this type of message is ON_REGISTERED_MESSAGE.
 
Share this answer
 
Comments
Chandrasekharan P 1-Jun-11 0:17am    
Well Explained. my 5
Naveen 1-Jun-11 0:24am    
Joined a new company and in here all the external mails and social networking sites are blocked. So back in codeproject and MSDN for time pass :)
ShilpiP 1-Jun-11 1:22am    
+ 5 :)
Chandrasekharan P 1-Jun-11 1:08am    
Good.. and All the best in your new environment :)
And its worth to be here in code project :)
Albert Holguin 1-Jun-11 16:20pm    
There's a few things that aren't quite true in your explanation... but its sufficient for OP... my 4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900