I added the lines (which mark with ***) in the WndProc procedure, but they didn't work:(



WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
.if uMsg==WM_CREATE
invoke CreateWindowEx,WS_EX_CLIENTEDGE,ADDR EditClass,NULL,\
WS_CHILD+WS_VISIBLE+WS_BORDER,20,\
20,300,25,hWnd,NULL,\
hInstance,NULL
mov hwndEdit,eax
invoke SetFocus,eax
;-----------------------------------------
; Subclass it!
;-----------------------------------------
invoke SetWindowLong,hwndEdit,GWL_WNDPROC,addr EditWndProc
mov OldWndProc,eax
[red]*** .elseif (uMsg==WM_KEYDOWN)
*** mov eax, wParam
*** .if (al==VK_ESCAPE)
*** invoke PostQuitMessage, NULL
*** .endif[/red]
.elseif uMsg==WM_DESTROY
invoke PostQuitMessage,NULL
.else
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.endif
xor eax,eax
ret
WndProc endp

EditWndProc PROC hEdit:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
.if uMsg==WM_CHAR
mov eax,wParam
.if (al>="0" && al<="9") || (al>="A" && al<="F") || (al>="a" && al<="f") || al==VK_BACK
.if al>="a" && al<="f"
sub al,20h
.endif
invoke CallWindowProc,OldWndProc,hEdit,uMsg,eax,lParam
ret
.endif
.elseif uMsg==WM_KEYDOWN
mov eax,wParam
.if al==VK_RETURN
invoke MessageBox,hEdit,addr Message,addr AppName,MB_OK+MB_ICONINFORMATION
invoke SetFocus,hEdit
.else
invoke CallWindowProc,OldWndProc,hEdit,uMsg,wParam,lParam
ret
.endif
.else
invoke CallWindowProc,OldWndProc,hEdit,uMsg,wParam,lParam
ret
.endif
xor eax,eax
ret
EditWndProc endp


What's wrong with me???
Posted on 2002-08-25 18:24:50 by Iceberg
hi Iceberg,
it seems that doesn't have much sense...
the message WM_CREATE is received when the proggie is in phase of "creation" and not when it's fully loaded.
if you want to close the proggie using the ESC key, you have to add something like this in the EditWndProc proc :


mov eax,wParam
.if (al==VK_RETURN)
invoke MessageBox,hEdit,addr Message,addr AppName,MB_OK+MB_ICONINFORMATION
invoke SetFocus,hEdit
.elseif (al==VK_ESCAPE)
invoke PostQuitMessage, NULL
.else
invoke CallWindowProc,OldWndProc,hEdit,uMsg,wParam,lParam
.endif


hope it helps!

bye,
ZaiRoN
Posted on 2002-08-26 05:46:57 by ZaiRoN
Thanks, ZaiRoN.
But I think it will work when EditWndProc calls the CallWindowProc function.
So that means I can't answer the WM_KEYDOWN message in original WndProc?
Posted on 2002-08-26 15:50:12 by Iceberg
So that means I can't answer the WM_KEYDOWN message in original WndProc?

no!
you can put it in the original WndProc but not inside 'if uMsg == WM_CRATE'.
put it in the '.else if uMsg == WM_COMMAND'...

regards,
ZaiRoN
Posted on 2002-08-27 10:12:11 by ZaiRoN