• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Archived

This topic is now archived and is closed to further replies.

Subotron

Difference between WM_CLOSE, WM_QUIT and WM_DESTROY and what to do with them

7 posts in this topic

When I see example WindowProc functions most of the time they handle different messages including these: WM_QUIT WM_DESTROY WM_CLOSE I was wondering, what are the differences between these 3, when do they occur and what should I do when they occur? To give an example, say if WM_QUIT means you clicked on the cross that closes an application, you should probably destroy everything and free the allocated memory. But if WM_DESTROY would mean everything is destroyed, you would only do PostQuitMessage(0) right? That brings me to another question, what are the last commands given to close an application? I always see PostQuitMessage(0) but what does it really do, when should I use it and are there other things I need to do? (like if I do this in the end of the WinApi function, should I still return 0 afterwards to lose the function?) Thanks in advance for the feedback!
0

Share this post


Link to post
Share on other sites
WM_CLOSE means the user clicked the close button on the title bar (opr Alt+F4), but that doesn't close the window. Most times you call DestroyWindow(hWnd); to destroy the window, but if you don't do anything, the window won't be closed.
afaik the WM_DESTROY message is sent when the window is destroyed, and WM_QUIT when the application is about to quit. after this message, the program leaves the message loop.

My Site

[edited by - Quasar3D on January 22, 2003 5:01:49 AM]
0

Share this post


Link to post
Share on other sites
I''ll elaborate a bit...

WM_CLOSE indicates a request to close a window, such as by clicking on the x. This is a good time to ask the user if they want to save their work, etc. Calling DefWindowProc will destroy the window, while returning zero will leave the window intact.
WM_DESTROY indicates that a window is being destroyed. If it''s the main window that''s being destroyed, this is a popular place to call PostQuitMessage(0) (which just adds a WM_QUIT message to the message queue).
WM_QUIT indicates that the application should quit. If I recall correctly, it can be generated by ctrl-alt-deleting the application (can anyone confirm this?), but most of the time, you''ll receive it because you sent it to yourself in response to WM_DESTROY. Receiving a WM_QUIT is the termination condition in the message pump.
0

Share this post


Link to post
Share on other sites
BeerHunter, no, ctl-alt-del does not generate a WM_QUIT, afaik and iirc. but it''s been a while since i''ve done any testing on all Windows platforms, so maybe some are different. i think the application''s process is forced closed instead by killing the main thread. i''m pretty sure this is the case because most of my apps write their settings after exiting the msg loop and this will not occur if the app is killed. i also just tested this on my XP box and the app receives no WM_QUIT when killed via Task Manager.
0

Share this post


Link to post
Share on other sites
BeerHunter, are you saying that an app that doesn''t supoport the WM_QUIT message can''t be CADed? I doubt it...

0

Share this post


Link to post
Share on other sites
I''m not all that fluent in Win32 API (I just know enough to get OpenGL to fullscreen render mode), but I know a few times when VC++ errored on me, I''ve seen something peculiar. Every once in a while, VC++ will freeze during compiling and linking (thnx M$ =-) and if I click on the ''x'' to close it, it gives me an error message "cannot exit, build in progress" (also, trying to cancel the build from the build menu didn''t do anything , so don''t say I blame M$ without cause!) However, when I give VC++ the three-fingered salute, it pauses for a while like it normally does, and then pops up a window saying the same thing as when I tried to close the app normally: "cannot exit, build in progress"... and then a second later, the program terminates despite its warning =-|

This is reason to believe that CAD''ing an app does allow for some kind of interface with the program before it pulls the plug on it.

"You TK''ed my chicken!"
0

Share this post


Link to post
Share on other sites
Tac-Tics, what OS version? the VC++ IDE definitely doesn''t work that way for me under XP. that''s why when i start it back up after a kill or system crash it no longer loads up my current project. i''ve also "spy++"''d the msg stream going to killed apps and they never receive any msgs after the kill request.

also, it''s not that hard to use a shell hook and capture the CAD request that way. maybe that''s what VC++ is doing. (just some more useless Win32 API trivia.)
0

Share this post


Link to post
Share on other sites
quote:
Original post by Enselic
BeerHunter, are you saying that an app that doesn''t supoport the WM_QUIT message can''t be CADed?
Uh, no. I never said that. Where did that come from?

...

I''ve done a quick test, and, in fact, it didn''t send a WM_QUIT to the application, but a WM_CLOSE to the main window. If the application ignores the message, it can be forcibly terminated, as we all know, but before that, it sends messages.
0

Share this post


Link to post
Share on other sites