I created a dialog based mfc project in which another dialog can be started with a new thread. My question is that how can i send some messages to the newly started dialog in the main dialog? TIA.
Sorry I didn't make my question clear I knew how to send messages with Post/SendMessage but does it mean that I need to make the dialog a global variable? I hate this I don't know how to visit this dialog class in the Main Dialog. Because the dialog is started with a thread.
You only need to have a handle to the dialog if you want to send it messages. Since this is all about sending messages, you might consider sending this handle to the main dialog using SendMessage
( Sorry I don't know how to edit my posted messages )
The dialog is started within the newly created thread, in other word, the dialog is not a member of the main dialog. I tried to use AfxGetApp->m_pMainWnd to visit the main dialog, failed. And I also tried to post some messages to the thread based dialog from main dialog but no way was found. Of course I can visit this dialog by clarfying it as a global variable, but it's not a good one. So what I gonna do? Thanks!
You can send a pointer to the main dialog into the newly created thread. This way you can "visit" it from within the second dialog.
>>And I also tried to post some messages to the thread based dialog from main dialog but no way was found.
How did you do this? You'll need a handle to the dialog to be able to send messages to it, don't you?
If all you want is communication between the two dialogs, I would suggest you send in a pointer to the main dialog when creating the second thread. Then, from the second thread, send in a pointer to the second dialog by creating some method called "Set2ndDlgPtr" or something like that....
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.