The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: ninjarider on August 19, 2005, 03:19:38 PM

Title: windows messages
Post by: ninjarider on August 19, 2005, 03:19:38 PM
would the following code be correct
wndproc ...
...
.elseif umsg==WM_KEYDOWN
  mov kd[wParam], 1
.elseif umsg==WM_KEYUP
  mov kd[wParam], 0
.endif
Title: Re: windows messages
Post by: Tedd on August 19, 2005, 05:05:39 PM
The logic is okay.
The instructions are a little off though. But I assume it's meant to be just pseudo code :wink
Title: Re: windows messages
Post by: czDrillard on August 19, 2005, 05:33:06 PM
Hi ninjarider,

Only thing I can add is don't forget to xor eax,eax and ret if your appĀ  processes either one of these messages.

best regards,

czDrillard
Title: Re: windows messages
Post by: ninjarider on August 19, 2005, 07:30:44 PM
when u clear eax does that tell widows that the message has been handled. or is that just good ethics
Title: Re: windows messages
Post by: roticv on August 20, 2005, 12:03:12 AM
The former I believe.
Title: Re: windows messages
Post by: Mark Jones on August 20, 2005, 06:13:46 AM
Be sure to look up WM_KEY* in the WIN32.HLP file. This will tell you all you need to know. :)
Title: Re: windows messages
Post by: QvasiModo on August 22, 2005, 11:22:54 PM
Quote from: ninjarider on August 19, 2005, 07:30:44 PM
when u clear eax does that tell widows that the message has been handled. or is that just good ethics

The first, for most if not all window messages.
Title: Re: windows messages
Post by: hutch-- on August 23, 2005, 12:06:14 AM
ninjarider,

When a windows message specifies "return 0" it literally means zero EAX then call a RET.


    xor eax, eax
    ret


Note that it is not normally required for message procesing but if you use a DlgProc, it requires that you clear EAX before the procedure ends. This is not the same as closing a DlgProc but if you don't clear EAX, you will get some strange display problems with a dialog.

You exit a normal WndProc with the return value from,

    invoke DefWindowProc,hWin,uMsg,wParam,lParam

What is happening is that when a message requires a return value of ZERO you exit the WndProc BEFORE the Default processing where if you do a normal exit, you pass the default return value back to the OS.