Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / November 2004

Tip: Looking for answers? Try searching our database.

return value of WM_QUIT

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bonj - 15 Nov 2004 14:13 GMT
Hi
I am having an issue with a window I am creating - in its wndproc, if I call
PostMessage(hWnd, WM_QUIT, 0, 0) in response to WM_DESTROY, then GetMessage
returns a non-zero value and the loop carries on. But if I post quit message
in response to WM_CLOSE - it works fine!
I thought you were supposed to post WM_QUIT in response to WM_DESTROY though?
Alexander Grigoriev - 15 Nov 2004 15:01 GMT
You're not supposed to use PostMessage for WM_QUIT. Use PostQuitMessage
instead.

> Hi
> I am having an issue with a window I am creating - in its wndproc, if I
[quoted text clipped - 6 lines]
> I thought you were supposed to post WM_QUIT in response to WM_DESTROY
> though?
Bonj - 15 Nov 2004 15:09 GMT
Please read my other posts on the same issue for the reasons as to why I don't.

> You're not supposed to use PostMessage for WM_QUIT. Use PostQuitMessage
> instead.
[quoted text clipped - 9 lines]
> > I thought you were supposed to post WM_QUIT in response to WM_DESTROY
> > though?
Alexander Grigoriev - 16 Nov 2004 04:36 GMT
Anyway, during WM_DESTROY, HWND may be already invalid. Actually, the reason
for failure is that when you do GetMessage, the window will already be
destroyed and the message will be discarded as invalid.

You're better with PostThreadMessage(GetCurrentThreadId(), WM_QUIT).

> Please read my other posts on the same issue for the reasons as to why I
> don't.
[quoted text clipped - 12 lines]
>> > I thought you were supposed to post WM_QUIT in response to WM_DESTROY
>> > though?
Bonj - 18 Nov 2004 14:12 GMT
I eventually found the cause of this ish.
It was that I was calling
while(GeMessage(&msg, hWnd, 0, 0) != 0)
instead of
while(GetMessage(&msg, NULL, 0, 0) != 0)

and due to this, PostQuitMessage doesn't actually post a message to the
hWnd, just to the thread. So the WM_QUIT message was being issued correctly,
it just wasn't getting through!

> Anyway, during WM_DESTROY, HWND may be already invalid. Actually, the
> reason for failure is that when you do GetMessage, the window will already
[quoted text clipped - 19 lines]
>>> > I thought you were supposed to post WM_QUIT in response to WM_DESTROY
>>> > though?

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.