简体   繁体   中英

MFC PostMessage from main project to UI thread

I'm programming a very big software. It has a lot of projects inside it.

One of my projects is a UI thread. I want to post messages to this UI thread, from the main project.

When I use PostThreadMessage (after getting the thread by GetCurrentThreadId() ), everything works fine, except the times when a MessageBox is open...

So I want to send messages from the main project by PostMessage. How exactly can I send messages in that way? how do I know which window to send the message to?

Thanks

If it is an UI thread then you must have a primary window created in that thread. Just post message to this window. That's it.

EDIT 1: If it is another process, then probably you can create a hidden window with some unique title with special characters and underscores and use FindWindow API to find that window or use EnumWindows to enumerate top level windows and match the title.

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