i am studying Win32Asm ,i have read the tutorial about child window controls that icezelion wrote.i have one question about the codes he wrote.

WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
    .IF uMsg==WM_DESTROY
        invoke PostQuitMessage,NULL
        invoke CreateWindowEx,WS_EX_CLIENTEDGE, ADDR EditClassName,NULL,\
                        WS_CHILD or WS_VISIBLE or WS_BORDER or ES_LEFT or\
        mov  hwndEdit,eax
        invoke SetFocus, hwndEdit
        invoke CreateWindowEx,NULL, ADDR ButtonClassName,ADDR ButtonText,\
                        WS_CHILD or WS_VISIBLE or BS_DEFPUSHBUTTON,\
        mov  hwndButton,eax
        mov eax,wParam
        .IF lParam==0
            .IF ax==IDM_HELLO
                invoke SetWindowText,hwndEdit,ADDR TestString
            .ELSEIF ax==IDM_CLEAR
                invoke SetWindowText,hwndEdit,NULL
            .ELSEIF  ax==IDM_GETTEXT
                invoke GetWindowText,hwndEdit,ADDR buffer,512
                invoke MessageBox,NULL,ADDR buffer,ADDR AppName,MB_OK
                invoke DestroyWindow,hWnd
            .IF ax==ButtonID
                shr eax,16
                .IF ax==BN_CLICKED
                    invoke SendMessage,hWnd,WM_COMMAND,IDM_GETTEXT,0
        invoke DefWindowProc,hWnd,uMsg,wParam,lParam
    xor    eax,eax
WndProc endp

Who can tell me, what does the "mov  hwndButton,eax "  make sense?  i deleted this code,and the program run correctly as i did it before.
Posted on 2005-07-27 14:05:22 by Abuseyourdna
If you don't use that handle, then it's useless.
Posted on 2005-07-27 14:27:33 by ti_mo_n
Doesn't hurt saving it though :)
Posted on 2005-07-27 17:06:49 by JimmyClif
It hurts the performance XD :lol:
Posted on 2005-07-27 18:27:05 by ti_mo_n
I'm guessing Abuseyourdna doesn't understand what the hwndButton variable is. So real quick, CreateWindowEx returns
a "handle" when it's called. Return values are, as far as you should be conserned right now, always returned in the EAX
register. That example stores the handle by moving data from EAX and copying it into hwndButton. The reason this is
done is for later reference to the child window (control). Say for example, you wish to hide the button later on in your
program. This can be done by inserting:

invoke ShowWindow,hwndButton,SW_HIDE

This keeps you from having to call GetDlgItem each time you want to reference the control's handle. In that example,
you will notice there is nothing else using hwndButton. So if you remove it, it doesn't hurt the execution of the program,
only decreases the size of the executable by about 4 bytes.

Bryant Keller
Posted on 2005-07-27 22:15:12 by Synfire
only decreases the size of the executable by about 4 bytes.

Actually it decreases the code block's size by 4 bytes, which will decrease executable's size in VERY RARE occassions ;) Something like [100/BLOCK_ALIGNMENT] % chance for that, if I'm not wrong (it's 5:43AM already :P ).

Good Night :)
Posted on 2005-07-27 22:46:09 by ti_mo_n
thx for all your help.
Posted on 2005-07-28 03:59:54 by Abuseyourdna