简体   繁体   中英

Receive PostMessage messages for MFC Dialog

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM