The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: raleeper on August 30, 2011, 04:41:26 AM

Title: Windows Procedure; "Application should return 0 if it processes (WM_KEYDOWN)"
Post by: raleeper on August 30, 2011, 04:41:26 AM
1.  Why?.  If  I pass the message to the default windows procedure what will the os do with it (I don't need details)?

2.  If the app looks at the key and decides to ignore it, does that count as having processed it?

Thanks, ral
Title: Re: Windows Procedure; "Application should return 0 if it processes (WM_KEYDOWN)"
Post by: dedndave on August 30, 2011, 05:21:47 AM
1) well, it says "should"   :P
you chose a very benign case, as not much happens either way
but, it is best to follow the recommended procedure
subtle little things can happen if you do not
for some WM messages, the results are not subtle at all   :bg

2) if your window has keyboard focus, the key press "belongs to you"
that means that if you have examined it and decided to ignore it, it has been fully processed

this kind of stuff becomes more obvious if you have a child window
for some messages, the OS sends unhandled messages up or down the chain of windows until it is processed
WM_PAINT is a good example
Title: Re: Windows Procedure; "Application should return 0 if it processes (WM_KEYDOWN)"
Post by: ToutEnMasm on August 30, 2011, 06:10:20 AM

Quote
1.  Why?.  If  I pass the message to the default windows procedure what will the os do with it (I don't need details)?
This return value is used by the OS to do something or not .It is this answer he wait.
Quote
2.  If the app looks at the key and decides to ignore it, does that count as having processed it?
Most of the keyboard keys  create just  messages send to all windows.No more thing is made.
EXCEPT for some keyboard shorcut like CTRL-C
EXCEPT for some keyboard shorcut used by controls like Richedit.
You can filter those keys (and suppress her action) if you don't return them back
You can also add furher actions and return them

Title: Re: Windows Procedure; "Application should return 0 if it processes (WM_KEYDOWN)"
Post by: Geryon on August 30, 2011, 09:55:34 AM
Quote from: raleeper on August 30, 2011, 04:41:26 AM
1.  Why?.  If  I pass the message to the default windows procedure what will the os do with it (I don't need details)
You don't want to know the details, however you are asking the details.
Simple answer: "An application should return zero if it processes this message. "
Title: Re: Windows Procedure; "Application should return 0 if it processes (WM_KEYDOWN)"
Post by: Tedd on August 30, 2011, 11:39:41 AM
Rephrase it to "Application should return 0 if it does not want any further action to be taken in response to this message"

Makes sense now?
Title: Re: Windows Procedure; "Application should return 0 if it processes (WM_KEYDOWN)"
Post by: raleeper on August 30, 2011, 12:22:59 PM
Quote from: Tedd on August 30, 2011, 11:39:41 AM
Rephrase it to "Application should return 0 if it does not want any further action to be taken in response to this message"

Makes sense now?


Yes.  That clarifies.


Thanks, Robert