It was easy, but im very new in asm generally. So i made this program, what it does is;
Closing app when pressing exit, and via menu-> exit.

there is a button named "what is this" that opens a dialog that tells what this is.. but when pressing OK on the dialog, it just opens a new dialog, and so on.. you need to alt+f4 it down, here is source.

.Const

.Data?
hInstance DWord ?
.Data
AboutCaption DB "StonedhawK ASM test", 0, 13, 10
AboutText DB "win32 assembly programming test application..", 13, 10, "stonedhawk", 13, 10, "http://www.stonedhawk.net/"
.Code

Window1Procedure Proc Private hWnd:HWND, uMsg:ULONG, wParam:WPARAM, lParam:LPARAM
.If uMsg == WM_CREATE

.ElseIf uMsg == WM_CLOSE
Invoke IsModal, hWnd
.If Eax
Invoke EndModal, hWnd, IDCANCEL
Return TRUE
.EndIf

.ElseIf uMsg == WM_COMMAND
LoWord wParam ; Get low word from wParam (control ID)
.If Ax == IDC_WINDOW1_BUTTON1 ; Check if it is from Button1
HiWord wParam ; Get high word from wParam (action)
.If Ax == BN_CLICKED ; Check if Button1 has been clicked
Invoke SendMessage, hWnd, WM_CLOSE, 0, 0
Return TRUE
.EndIf
.EndIf
    .If Ax == IDC_WINDOW1_BUTTON2
    Shr Eax, 16
    .If Ax == BN_CLICKED
    Invoke MessageBox, NULL, Addr AboutText, Addr AboutCaption, MB_OK
.EndIf
.EndIf
LoWord wParam
.If Ax == IDM_WINDOW1_EXIT ; Check if it is from Button1
HiWord wParam ; Get high word from wParam (action)
.If Ax == BN_CLICKED ; Check if Button1 has been clicked
Invoke SendMessage, hWnd, WM_CLOSE, 0, 0
Return TRUE
.EndIf
.EndIf
.EndIf
Return FALSE
Window1Procedure EndP



;.If Ax == IDC_WINDOW1_BUTTON1
;Invoke SendMessage, hWnd, WM_CLOSE, 0, 0
;Return TRUE

Window1Edit1 Proc Private hWnd:HWND, uMsg:ULONG, wParam:WPARAM, lParam:LPARAM
Return FALSE
Window1Edit1 EndP


Thanks,
StonedhawK
Posted on 2005-09-08 18:02:43 by StonedhawK
Hi StonedhawK,

The problem is in the WM_COMMAND message. Let's see:

- Firstl, you should use .If and .ElseIf directives so that when a message is processed it finishes its execution.

- Second, the first you do in the WM_COMMAND message is geting the low word of the wParam, so the register Eax loses its high word value. When you process the IDC_WINDOW1_BUTTON2 message, you try to get the high word from the register Eax, but it doesn't have it already, so you should use HiWord wParam.

Third, after invoking the message box you should return TRUE so that there is no further processing.

For your program to work properly, the code for WM_COMMAND message would look like this:


.ElseIf uMsg == WM_COMMAND
LoWord wParam ; Get low word from wParam (control ID)
.If Ax == IDC_WINDOW1_BUTTON1 ; Check if it is from Button1
HiWord wParam ; Get high word from wParam (action)
.If Ax == BN_CLICKED ; Check if Button1 has been clicked
Invoke SendMessage, hWnd, WM_CLOSE, 0, 0
Return TRUE
.EndIf
    .ElseIf Ax == IDC_WINDOW1_BUTTON2
    HiWord wParam ;Shr Eax, 16
    .If Ax == BN_CLICKED
    Invoke MessageBox, NULL, Addr AboutText, Addr AboutCaption, MB_OK
    Return TRUE
.EndIf
.ElseIf Ax == IDM_WINDOW1_EXIT ; Check if it is from Button1
HiWord wParam ; Get high word from wParam (action)
.If Ax == BN_CLICKED ; Check if Button1 has been clicked
Invoke SendMessage, hWnd, WM_CLOSE, 0, 0
Return TRUE
.EndIf
.EndIf
.EndIf



Thanks for using Easy Code.

Regards,

Ramon
Posted on 2005-09-10 02:54:14 by rsala
thank you, i really appreciate your help.
this helps me and my interest for asm programming

yours,
StonedhawK
Posted on 2005-09-10 22:10:28 by StonedhawK
You're welcome StonedhawK.

Regards,

Ramon
Posted on 2005-09-11 05:46:20 by rsala