This has to do with creating a dialog box as main.
This is NOT my code, I am just tearing through it to study it.
Ok, this is HIS code:
call GetModuleHandleA ; module base
mov hInst, eax ; save it
sub edx,edx
push edx ; lParam WM_INITDIALOG
push offset _dlgproc ; dialog proc
push edx ; parent handle
push IDD_DIALOG1 ; ID
push eax ; module base
call DialogBoxParamA
jmp _normal_exit ; Only here when dialog is closed
and I wanted to simplify it to this:
call GetModuleHandleA ; module base
mov hInst, eax ; save it
invoke DialogBoxParamA, NULL, addr _dlgproc, NULL, IDD_DIALOG1, hInst
and it don't work. Says invalid argument 2.
Any ideas why this is happening?
Giovanni,
Try this from the MASM32 example code. Its in example2\resdlg2 .
.code
start:
invoke GetModuleHandle, NULL
mov hInstance, eax
; -------------------------------------------
; Call the dialog box stored in resource file
; -------------------------------------------
invoke DialogBoxParam,hInstance,ADDR dlgname,0,ADDR WndProc,0
invoke ExitProcess,eax
Trope
When you use the invoke, the parameters are pushed in the reverse order; i.e. the last parameter is pushed first, followed by the second-to-last, etc.., the first parameter being pushed last.
When you look at the description of an API in the Win32 Programmer's Reference, the parameters would be listed in the sequence they should appear following invoke. And the last parameter listed would be the first one pushed.
Raymond