오후 1:20 2002-09-19
조경민 bro@shinbiro.com
UI 스레드로 날린 PostThreadMesage가 사라질때
==================================================================

모달 다이얼로그 박스가 떠있거나, 윈도우를 사용자가 움직이거나 리사이즈
하고 있을때에는 그 윈도우의 실행 스레드 UI 스레드에게 PostThreadMessage
한것이 안가게 된다.
이럴땐 해당 윈도우로 그냥 PostMessage해야한다.


PRB: PostThreadMessage Messages Lost When Posted to UI Thread

Q183116


--------------------------------------------------------------------------------
The information in this article applies to:

Microsoft Win32 Software Development Kit (SDK)

--------------------------------------------------------------------------------


SYMPTOMS
Messages sent to a UI thread through PostThreadMessage are lost
if the messages are posted while the user is manipulating a window
owned by the thread. Messages might be lost if they are sent while
the user moves or resizes the window or if the window is a modal
dialog box.



CAUSE
When an UI thread is involved in modal behavior, the thread pumps messages in a message loop internal to the modal system rather than in the thread's main message loop. Messages that are posted to a window can still be dispatched to the window procedure of the target window, because the messages are associated with a window. However, thread messages need to be handled directly by the message loop, because they cannot be automatically dispatched elsewhere. Since the secondary message loop does not know about the thread message, it will be dropped.



RESOLUTION
Rather than using PostThreadMessage to post messages to a UI thread, use PostMessage to post messages to a window owned by that thread. Since messages directed to a window can be dispatched by a secondary message loop, the messages is still handled properly, even when the thread is not running in its primary message loop.

To use this method, the thread must create a window that lives throughout the period that it must receive messages, and the application sending the messages must have a handle to that window available.



STATUS
This behavior is by design.

Additional query words:

Keywords : kbOSWinNT kbOSWin2000 kbSDKWin32 kbGrpDSUser kbOSWin kbWndw kbWndwMsg
Issue type : kbprb
Technology : kbWin32SDKSearch kbAudDeveloper kbSDKSearch kbWin32sSearch


Last Reviewed: July 9, 2000
ⓒ 2001 Microsoft Corporation. All rights reserved. Terms of Use.




--------------------------------------------------------------------------------
Send feedback to MSDN.Look here for MSDN Online resources.

'KB > MFC/Win32' 카테고리의 다른 글

디버그 컨디션  (0) 2004.03.19
URL캐쉬없애기  (0) 2004.03.19
TSQL 구문 여러개 날려주기  (0) 2004.03.19
Winsock SNDBUF에 관하여  (0) 2004.03.19
regsvr32 -u와 같은 코드  (0) 2004.03.19

+ Recent posts