Sign in to follow this  

I think DefWindowProc is just a message processer.

This topic is 4376 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Sometimes messages generate other messages as a result of DefWindowProc processing. For example, suppose you run HELLOWIN and you eventually click the Close button, or suppose you select Close from the system menu using either the keyboard or the mouse. DefWindowProc processes this keyboard or mouse input. When it detects that you have selected the Close option, it sends a WM_SYSCOMMAND message to the window procedure. WndProc passes this message to DefWindowProc. DefWindowProc responds by sending a WM_CLOSE message to the window procedure. WndProc again passes this message to DefWindowProc. DefWindowProc responds to the WM_CLOSE message by calling DestroyWindow. DestroyWindow causes Windows to send a WM_DESTROY message to the window procedure. WndProc finally responds to this message by calling PostQuitMessage to put a WM_QUIT message in the message queue. This message causes the message loop in WinMain to terminate and the program to end. ----petzold It seem to DefWindowProc is also responsible for processes this keyboard or mouse input? DefWindowProc processes this keyboard or mouse input. When it detects that you have selected the Close option, it sends a WM_SYSCOMMAND message to the window procedure. the WM_SYSCOMMAND is sent by DefWindowProc ???????

Share this post


Link to post
Share on other sites
I'm pretty sure the DefWindowProc sends the WM_SYSCOMMAND messages. For the mouse and keyboard input messages, those are AFAIK processed in the TranslateMessage call (which itself calls the window proc chain down to DefWindowProc) and converted to the appropriate actions (activating windows, dragging by the caption, turning WM_KEYDOWNs in WM_CHAR messages).

I'd reckon the DefWindowProc is the heart of the Windows system as it does all the actions on the messages which it receives (which can result in other messages being sent).

Share this post


Link to post
Share on other sites
Whenever you do not handle a message in your winproc function, you can let windows handle it with DefWindowProc. This function takes care that standard functionality always happen.

Depending on the messages that it receives it might send other messages back to your window event queue, including system messages. These messages are always send although you do not have to respond to them.

Share this post


Link to post
Share on other sites

This topic is 4376 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this