Archived

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

jonknet

DefWindowProc

Recommended Posts

Why not have DefWindowProc handle all messages for a window? Why make your own WndProc? What messages can and cant DefWindowProc handle? I realize if you are going to do some weird stuff with windows then its useful but what if you''re just making your own generic window, etc? Thanks Just Curious jonk

Share this post


Link to post
Share on other sites
Isn''t DefWindowProc(..) used to communicate back to the OS.
If I''m right then DefWindowProc(..) sends messages to the OS.. or the grandparent (har har HAR!). If you are doing a generic window and do not need to worry about the details then just ignore what WinMain throws at you


Share this post


Link to post
Share on other sites
DefWindowProc handles all of the other messages so then you won''t have to. your windows procedure handles ALL the messages that goes to the window. ALL. mouse movements, keyboard entries, movement, you name it it''s sent through as messages. so having

return DefWindowProc(...);

after the switch (notice that you dont'' break from the switch, you return from it -- at least that''s how most people do) to dump all the other messages to DefWindowProc.

Share this post


Link to post
Share on other sites
How would you respond to user input?
How would you display an image?
How would you play a sound?
How would you know when to do any of these?

Pretty interesting questions, huh?



To you it''s a Bently, to me it''s a blue car...
"Diddy"
P.Diddy

Share this post


Link to post
Share on other sites
I think the use of DefWindowProc isn''t understood yet...

Windows sends ALL messages to your program even if it isn''t relevant. If your program doesn''t need to use the message YOU need to send it back to Windows so windows can figure out what other program may be using it or if it should just be ignored because it isn''t relevant to any running programs. If you dont use DefWindowProc you will find out that you will crash your computer or it will act very funny while your program is running. Also if you forget to return DefWindowProc it should act funny. Do not that the latter wont compiler under an NT workstation. I tried it at schoo =).

"Ogun''s Laughter Is No Joke!!!" - Ogun Kills On The Right, A Nigerian Poem.

Share this post


Link to post
Share on other sites