Home / Tips / VC++ Tips / VC++: What are the series of actions that take place when I try to close a window?

“Chishiki” is Japanese for “knowledge.” e-chishiki.com aims to bring software developers, information security professionals, IT executives and other IT pros a rich body of knowledge in the form of articles, interviews, tutorials and technical discussions. Our contributors are among the biggest names in the Indian IT industry and include noted authors, educators and practitioners.

VC++: What are the series of actions that take place when I try to close a window?


What are the series of actions that take place when I try to close a window?


When we try to close an application by clicking on the close button, a WM_CLOSE message is sent to our application. If we do not handle this message then it is passed on to the default window procedure. The default window procedure destroys the window by calling the ::DestroyWindow( ) API function. This function places a WM_DESTROY message in the message queue of our application. If we do not handle this message once again the default window procedure gets a shot at it. Following WM_DESTROY, is another message called WM_NCDESTROY. In reaction to this message a handler OnNcDestroy( ) gets called. This handler calls another function・b>PostNcDestroy( ). It is in this function that the ::PostQuitMessage( ) function is called. This function places a message WM_QUIT in the message queue. When this message is retrieved, the message loop is terminated. This ultimately leads to termination of the application.

Comments

Log in or create a user account to comment.

On Sale From April 2008

Let Us C
8th Ed.
C programming classic & best seller. 1 million+ copies sold!

Y. Kanetkar

On Sale From April 2008

Introduction to Object Oriented Programming & C++

Y. Kanetkar

On Sale From Fall 2008

Microsoft .NET Framework: Web Application Security

Vijay Mukhi

On Sale From Nolvember 2008

Quest C++ Courseware
12+ hours of instructional audio and animated slides.

Y. Kanetkar Asang Dani

On Sale From November 2008

A Programmer's Guide to Web Application Security

Vijay Mukhi

Latest Forum Posts