Creating user defined messages and events in MFC
-
Hi, I would like to get hints as to how to create messages in MFC. I wanted to sense the serial port buffer and then if the bytes received is above a threshold I would like to post a message and handle it with a function. How could it be done. The main issue is creating message or events to be handled.
-
Hi, I would like to get hints as to how to create messages in MFC. I wanted to sense the serial port buffer and then if the bytes received is above a threshold I would like to post a message and handle it with a function. How could it be done. The main issue is creating message or events to be handled.
That is not a difficult task. You have to: 1. define your own message, choosen inside the user messages range. 2. Create the message handler with proper signature. 3. add an entry in your class message map. all of the above steps are well shown in the following documentation page: http://msdn2.microsoft.com/en-us/library/k35k2bfs(VS.80).aspx[^] :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
[my articles] -
Hi, I would like to get hints as to how to create messages in MFC. I wanted to sense the serial port buffer and then if the bytes received is above a threshold I would like to post a message and handle it with a function. How could it be done. The main issue is creating message or events to be handled.
In addition to CPallini's reply... I would recommend using messages ID(s) in the range WM_APP through 0xBFFF instead of a WM_USER-based ID as shown in the MS sample code. That way there's much less of a chance your message will conflict with any messages used by certain private window classes. You can also get a system-wide unique message ID with RegisterWindowMessage(). Mark
Mark Salsbery Microsoft MVP - Visual C++ :java: