Hi,
in the \masm32\examples\dialogs\simple\simple.asm file there is the following code in the dialog proc
.elseif uMsg == WM_COMMAND
.if wParam == IDCANCEL
jmp quit_dialog
.endif
in the SDK it says the low word of wParam contains the control identifier, & the high word contains the notification msg. Am thinking on the lines that,..in the above example IDCANCEL would be in the low-word & the high-word of wParam would contain a notification msg like BN_CLICKED or something for the button - in any case how does comparing the entire wParam dword work proper ? (unless it was for a menu where the high-word of wParam would be 0)
T Y
It works because:
BN_CLICKED equ 0
Hello,
It's a case who this work,better is to use this:
Quote
.elseif uMsg == WM_COMMAND
HIWORD wParam ;events of controls listbox .. are here
mov edx,eax ;sample :TCN_SELCHANGE
LOWORD wParam ;ID of commands in eax
mov ebx,lParam ; handle of control
.if eax == IDCANCEL
;always work with no question
.endif
xmetal, thanks a lot for clearing that up.
toutenasm, thx for the code...- or i could just use 'rol' or something i guess to get at the high-word.
Perhaps this help
Quote
HIWORD MACRO ParamFen
mov eax,ParamFen
shr eax,16
ENDM
LOWORD MACRO ParamFen
mov eax,ParamFen
and eax,0FFFFh
ENDM
Or this:
movzx eax,word ptr [wParam] ; low-order word in eax
movzx edx,word ptr [wParam+2] ; high-order word in edx
Quote from: xmetal on February 14, 2008, 04:52:50 AM
Or this:
movzx eax,word ptr [wParam] ; low-order word in eax
movzx edx,word ptr [wParam+2] ; high-order word in edx
Hi xmetal,
I was going to post that a bit earlier, it is the way I do it as well, but I decided that I have posted against useless macros enough and didn't want to sound like the "insane old anti-macro guy" again. But it boggles the mind that people will invent macros that perform the same function as a single opcode.
Donkey
Such macros can mimic common HLL macros (http://msdn2.microsoft.com/en-us/library/ms674885(VS.85).aspx), providing meaningful names that are easier to read and easier to type. I think most beginners would have an easier time with:
mov eax, loword(wParam)
mov edx, hiword(wParam)
Than with:
mov eax, wParam
shr eax, 16
mov edx, wParam
and edx, 0FFFFh
Or even:
movzx eax, word ptr wParam
movzx edx, word ptr wParam+2
But one problem is that a straightforward implementation of the macros would need to alter a register, and because this would be hidden from the programmer it could be a problem.
loword MACRO dwordparam
movzx eax, WORD PTR dwordparam
EXITM <eax>
ENDM
hiword MACRO dwordparam
movzx eax, WORD PTR dwordparam+2
EXITM <eax>
ENDM
I can see a way around this, but IMO it's too involved and adds too many instructions to be worth using.
loword MACRO dwordparam
IFNDEF @@_scratch_dword_@@
.data?
@@_scratch_dword_@@ dd ?
.code
ENDIF
push eax
movzx eax, WORD PTR dwordparam
mov @@_scratch_dword_@@, eax
pop eax
EXITM <@@_scratch_dword_@@>
ENDM