Reputation: 560
I have a dialog where the user is able to enter information and then press the Go button. When they press this button I disable the form elements (buttons etc) and create a worker thread using AfxBeginThread( ... )
. Once the worker thread has completed I want it to send a message to the UI thread so as to re-enable the form. I am using ::PostMessage( ... )
to send the message, but I can't find how to intercept these messages.
i've searched online (Link #1, Link #2, Link #3) but I can't find an understandable example of the code to implement my own message listener. In the header I can see some crazy define statements (started with DECLARE_MESSAGE_MAP()
) which looks like it may have something to do with it, but I can't figure it out.
Any help is much appreciated. Thanks.
Upvotes: 0
Views: 4879
Reputation: 10415
The message map is a table. For each message you are interested in it contains the message and a function pointer to the message handler function. To add a custom message to the map you add an ON_MESSAGE entry to the table. A tutorial example of doing this from a worker thread is here:
http://vcfaq.mvps.org/mfc/12.htm
Upvotes: 3