Click here to Skip to main content
16,005,206 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralWAP PAP Application Pin
Socket_Layer26-Nov-03 1:04
Socket_Layer26-Nov-03 1:04 
GeneralBeep in Windows 2000 Pin
cberam26-Nov-03 0:35
cberam26-Nov-03 0:35 
GeneralRe: Beep in Windows 2000 Pin
Johnny ²26-Nov-03 0:54
Johnny ²26-Nov-03 0:54 
GeneralSqlBindParameter problem Pin
pankajdaga25-Nov-03 23:33
pankajdaga25-Nov-03 23:33 
Generalshared memory Pin
Shanmuga Sundar25-Nov-03 22:56
Shanmuga Sundar25-Nov-03 22:56 
GeneralRe: shared memory Pin
Antti Keskinen26-Nov-03 1:46
Antti Keskinen26-Nov-03 1:46 
GeneralMessageBox in separate Thread Pin
Cedric Moonen25-Nov-03 22:42
Cedric Moonen25-Nov-03 22:42 
GeneralRe: MessageBox in separate Thread Pin
Antti Keskinen26-Nov-03 2:02
Antti Keskinen26-Nov-03 2:02 
In short:
Provide the support thread a pointer to the CWinApp-object of your main thread. Use this pointer to access the m_pMainWnd member and through it, the CWnd-wrapper of the main window.

More detail:
Considering that this is a single-process program, it would be possible for you to use pointers. Cross-thread pointers are a working and a valid solution for all types of applications. If you use MFC, however, you must remember to synchronize the threads properly.

This way, the support thread, once created, should have a pointer to the CWinApp-object of the main thread, and subsequently, it would have access to the m_pMainWnd variable of CWinApp, which is a CWnd-pointer to the application's main window, residing in the main thread. You could use this pointer's AfxMessageBox method to pop up a message box in the main thread's context without any errors. Just remember to pause the plot-messages when the messagebox is active, because no other messages are handled while a modal dialog (messagebox) is visible.

Communication is the key. Make communication functions and variables between your threads. Make the main thread 'speak' to the support thread, and vice versa. Let them know how the other one is doing, and what it is doing.

-Antti Keskinen

----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
GeneralRe: MessageBox in separate Thread Pin
Cedric Moonen26-Nov-03 2:10
Cedric Moonen26-Nov-03 2:10 
GeneralRe: MessageBox in separate Thread Pin
RChin26-Nov-03 3:48
RChin26-Nov-03 3:48 
GeneralRe: MessageBox in separate Thread Pin
Cedric Moonen26-Nov-03 3:56
Cedric Moonen26-Nov-03 3:56 
GeneralRe: MessageBox in separate Thread Pin
Antti Keskinen26-Nov-03 3:54
Antti Keskinen26-Nov-03 3:54 
QuestionHow To extract icon of the associated file? Pin
Prakash Nadar25-Nov-03 22:18
Prakash Nadar25-Nov-03 22:18 
AnswerRe: How To extract icon of the associated file? Pin
Ravi Bhavnani26-Nov-03 4:54
professionalRavi Bhavnani26-Nov-03 4:54 
AnswerRe: How To extract icon of the associated file? Pin
Peter Molnar26-Nov-03 13:30
Peter Molnar26-Nov-03 13:30 
Generalwindow.h Pin
styve25-Nov-03 21:54
styve25-Nov-03 21:54 
GeneralRe: window.h Pin
Prakash Nadar25-Nov-03 22:09
Prakash Nadar25-Nov-03 22:09 
GeneralRe: window.h Pin
ZoogieZork26-Nov-03 5:30
ZoogieZork26-Nov-03 5:30 
GeneralAppend files Pin
chadell25-Nov-03 21:43
chadell25-Nov-03 21:43 
GeneralRe: Append files Pin
Shanmuga Sundar25-Nov-03 22:52
Shanmuga Sundar25-Nov-03 22:52 
GeneralRe: Append files Pin
chadell25-Nov-03 23:01
chadell25-Nov-03 23:01 
GeneralStatic Libraries Pin
sweep12325-Nov-03 21:42
sweep12325-Nov-03 21:42 
QuestionVC++.NET: Microsoft ADO Data Control ? Pin
Maxwell Chen25-Nov-03 21:19
Maxwell Chen25-Nov-03 21:19 
AnswerRe: VC++.NET: Microsoft ADO Data Control ? Pin
DrSerge25-Nov-03 23:56
DrSerge25-Nov-03 23:56 
AnswerRe: VC++.NET: Microsoft ADO Data Control ? Pin
Anonymous26-Nov-03 8:24
Anonymous26-Nov-03 8:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.