Click here to Skip to main content
16,016,789 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: What is purpose of padding of 2-2 bytes in debug build?? Pin
John R. Shaw16-May-07 22:08
John R. Shaw16-May-07 22:08 
GeneralRe: What is purpose of padding of 2-2 bytes in debug build?? Pin
SandipG 17-May-07 1:01
SandipG 17-May-07 1:01 
GeneralRe: What is purpose of padding of 2-2 bytes in debug build?? Pin
John R. Shaw17-May-07 1:53
John R. Shaw17-May-07 1:53 
Questionhow to control parallel pins using window xp visual C++ ?? HELP PLZZ Pin
*Roxanna*16-May-07 18:12
*Roxanna*16-May-07 18:12 
QuestionAbout PostQuitMessage Function Pin
fd012900216-May-07 16:24
fd012900216-May-07 16:24 
AnswerRe: About PostQuitMessage Function Pin
Stephen Hewitt16-May-07 17:04
Stephen Hewitt16-May-07 17:04 
QuestionRe: About PostQuitMessage Function Pin
fd012900216-May-07 19:02
fd012900216-May-07 19:02 
AnswerRe: About PostQuitMessage Function Pin
Arman S.16-May-07 20:01
Arman S.16-May-07 20:01 
There is a queue status flag assigned per queue. When the thread is running it can request (GetQueueStatus) the status of its queue and observe its value (QS_PAINT, QS_QUIT, ...). This request happens when the thread calls GetMessage or PeekMessage APIs. Based in the status returned, this APIs process the appropriete message from the queue and return the control.

Now PostQuitMessage doesn't post a WM_QUIT message into the queue but only set QS_QUIT flag on queue status. Then if GetMessage [or PeekMessage] meet QS_QUIT flag, they return WM_QUIT message as if it were in the queue itself.

In contrast, PostThreadMessage posts the WM_QUIT message into the queue without settiong the QS_QUIT flag. So the GetMessage [or PeekMessage] gets the WM_QUIT message from the queue really.

Why so? Actually there are two reasons.

*) Security. It might be possible that the system will fail to reserve memory for another queue entry and thus the WM_QUIT message will not enter the queue. The point is that if the app wants to quit, it should quit surely.
*) Low level priority. WM_QUIT should be processed after all the messages from the queue are processed. This is important because it will allow the application finish its job and then [when no posted messages waiting] to exit. The idea is that when GetMessage detects QS_QUIT flag, it returns WM_QUIT [this is virtual message] only when the queue becomes empty and thus ensuring that the WM_QUIT is processed the last.


--
=====
Arman

GeneralRe: About PostQuitMessage Function Pin
Moak16-May-07 22:17
Moak16-May-07 22:17 
GeneralRe: About PostQuitMessage Function Pin
Arman S.17-May-07 0:41
Arman S.17-May-07 0:41 
GeneralRe: About PostQuitMessage Function Pin
fd012900217-May-07 1:36
fd012900217-May-07 1:36 
GeneralRe: About PostQuitMessage Function Pin
Moak17-May-07 2:10
Moak17-May-07 2:10 
Questionconsuming a webservice from a Win32 DLL Pin
rluckwell16-May-07 13:54
rluckwell16-May-07 13:54 
AnswerRe: consuming a webservice from a Win32 DLL Pin
led mike16-May-07 16:08
led mike16-May-07 16:08 
Question32bit app calling NtOpenKey fails on x64 Pin
JeffRoz16-May-07 13:37
JeffRoz16-May-07 13:37 
QuestionWindows Toolbar and... Pin
Chirieac16-May-07 12:09
Chirieac16-May-07 12:09 
QuestionCode Pin
Joseph_B16-May-07 11:52
Joseph_B16-May-07 11:52 
AnswerRe: Code Pin
toxcct16-May-07 12:06
toxcct16-May-07 12:06 
AnswerRe: Code Pin
Christian Graus16-May-07 15:31
protectorChristian Graus16-May-07 15:31 
AnswerRe: Code Pin
vijay_aroli16-May-07 19:27
vijay_aroli16-May-07 19:27 
AnswerRe: Code Pin
John R. Shaw16-May-07 22:19
John R. Shaw16-May-07 22:19 
GeneralRe: Code Pin
Hamid_RT16-May-07 22:37
Hamid_RT16-May-07 22:37 
GeneralRe: Code Pin
John R. Shaw16-May-07 23:14
John R. Shaw16-May-07 23:14 
Question[Message Deleted] Pin
Arris7416-May-07 10:12
Arris7416-May-07 10:12 
AnswerRe: Question about CImageList::Create Pin
David Crow16-May-07 10:25
David Crow16-May-07 10:25 

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.