Strange behavior!
Tech-Archive recommends: Speed Up your PC by fixing your registry
Hi, i met a strange behavior when used PostMessage and DialogBox!
the code looks like this:
first, i call PostMessage() to post 2 messages to certain window(for
example hWnd) somewhere, it looks like,
void DoTest(HWND hWnd)
{
....
PostMessage(hWnd,WM_MSG1,0,0);
//...do something....
PostMessage(hWnd,WM_MSG2,0,0);
.....
}
then, In the hWnd's WndProc, the message process code looks like:
.......
case WM_MSG1:
//...
DialogBox(hInt,IDD_DLG1,hWnd,DLG1Proc);
break;
case WM_MSG2:
//...
DialogBox(hInt,IDD_DLG2,hWnd,DLG2Proc);
break;
...........
the result is: the IDD_DLG2 popups before than IDD_DLG1 !!!
why?
.
Relevant Pages
- Re: MFC and Worker Thread issue
... situations such as the thread has terminated before the window was created but has no way ... CWnd* which is the message sink and it is created before the thread (with its HWND value) ... which does never see PostMessage or HWND. ... Callbacks add their own problems; I try to avoid them if at all possible. ... (microsoft.public.vc.mfc) - Re: pointer problem
... > PostMessage(hWnd, messageID, wParam, (LPARAM) pMessage); ... PostMessage posts the message and then control reverts to your ... buffer which existed at some time in the past. ... (microsoft.public.vc.language) - Re: Worker thread in VC++ 6
... PostMessage to find a simpler usage explanation. ... It is a common myth that a CWnd* cannot be passed across a thread boundary; ... "A CWnd* may be passed across a thread boundary, but the HWND may not be operated upon by ... There is absolutely no reason to think that the main window is a major ... (microsoft.public.vc.mfc) - Re: Calling Screensaver
... Public Declare Function GetDesktopWindow Lib "user32" As Long ... Dim hwnd As Long ... PostMessage hwnd, WM_SYSCOMMAND, SC_SCREENSAVE, ByVal 0& ... (microsoft.public.vb.general.discussion) - Re: illegal cross thread operation by PostMessage
... >> valid to call PostMessage from another thread. ... > partial class Form1: Form ... When calling PostMessage from the non UI thread, ... the Handle (HWND) from the non owning thread, which is now checked by the ... (microsoft.public.dotnet.languages.csharp) |
|