.if uMsg==WM_CLOSE
invoke EndDialog,hWnd,NULL
.elseif uMsg==WM_KEYUP
mov eax,wParam
.if eax==VK_ESCAPE
invoke PostQuitMessage,NULL
.endif
......
but when I press esc,why doesn't it work?
I used Ollydbg debug it,it can't break,is there any other conditions?
invoke EndDialog,hWnd,NULL
.elseif uMsg==WM_KEYUP
mov eax,wParam
.if eax==VK_ESCAPE
invoke PostQuitMessage,NULL
.endif
......
but when I press esc,why doesn't it work?
I used Ollydbg debug it,it can't break,is there any other conditions?
Ok i assume by looking @ your code it works without the debugger. I have that problem when using GDI to debug window procedures you have to consider that the window will not have the focus when you break. Have you placed the break-point @ invoke PostQuitMessat,NULL ? Then you'll see if your app is working with VK_ESCAPE.
From MDSN: WM_KEYUP:
The WM_KEYUP message is posted to the window with the keyboard focus when a nonsystem key is released. A nonsystem key is a key that is pressed when the ALT key is not pressed, or a keyboard key that is pressed when a window has the keyboard focus.
From MDSN: WM_KEYUP:
The WM_KEYUP message is posted to the window with the keyboard focus when a nonsystem key is released. A nonsystem key is a key that is pressed when the ALT key is not pressed, or a keyboard key that is pressed when a window has the keyboard focus.
Have you placed the break-point @ invoke PostQuitMessat,NULL
of cource,if it can break,it will be ok!
.if uMsg==WM_CLOSE
invoke EndDialog,hWnd,NULL
.elseif uMsg==WM_KEYUP
mov eax,wParam
.if eax==VK_ESCAPE
invoke PostQuitMessage,NULL
.endif
First off, if you are using a dialog the ESC key is intercepted by the dialog handler and not sent to your app except as an ID_CANCEL notification in WM_COMMAND. You can modify this behavior by responding to the WM_GETDLGCODE message and returning DLGC_WANTALLKEYS. Second you should NEVER use PostQuitMessage in a dialog procedure, just EndDialog when you recieve a WM_CLOSE. If you wish to end your app on the ESC key then call EndDialog or use :
invoke PostMessage, hWnd, WM_CLOSE, 0, 0
instead of the PostQuitMessage
Thanks,could you tell me how to use?
......
.elseif uMsg==WM_CLOSE
invoke EndDialog,hWnd,NULL
.elseif uMsg==WM_GETDLGCODE
.if eax==DLGC_WANTALLKEYS
mov eax,wParam
.if eax==VK_ESCAPE
nvoke PostMessage,hWnd,WM_CLOSE,0,0
.endif
.endif
......
debug:
004012D3 |> 817D 0C 87000>CMP DWORD PTR SS:,87
004012DA |. 75 1D JNZ SHORT water.004012F9
004012DC |. 83F8 04 CMP EAX,4 //set breakpoint here, it can't break!
004012DF |. 75 24 JNZ SHORT water.00401305
004012E1 |. 8B45 10 MOV EAX,DWORD PTR SS:
004012E4 |. 83F8 1B CMP EAX,1B
004012E7 |. 75 0E JNZ SHORT water.004012F7
004012E9 |. 6A 00 PUSH 0 ; /lParam = 0
004012EB |. 6A 00 PUSH 0 ; |wParam = 0
004012ED |. 6A 10 PUSH 10 ; |Message = WM_CLOSE
004012EF |. FF75 08 PUSH DWORD PTR SS: ; |hWnd
004012F2 |. E8 F5000000 CALL <JMP.&user32.PostMessageA> ; PostMessageA
if ".if eax==DLGC_WANTALLKEYS" isn't correct,I think when I press any key,it will break on "004012DC |. 83F8 04 CMP EAX,4 ",but he didn't!
......
.elseif uMsg==WM_CLOSE
invoke EndDialog,hWnd,NULL
.elseif uMsg==WM_GETDLGCODE
.if eax==DLGC_WANTALLKEYS
mov eax,wParam
.if eax==VK_ESCAPE
nvoke PostMessage,hWnd,WM_CLOSE,0,0
.endif
.endif
......
debug:
004012D3 |> 817D 0C 87000>CMP DWORD PTR SS:,87
004012DA |. 75 1D JNZ SHORT water.004012F9
004012DC |. 83F8 04 CMP EAX,4 //set breakpoint here, it can't break!
004012DF |. 75 24 JNZ SHORT water.00401305
004012E1 |. 8B45 10 MOV EAX,DWORD PTR SS:
004012E4 |. 83F8 1B CMP EAX,1B
004012E7 |. 75 0E JNZ SHORT water.004012F7
004012E9 |. 6A 00 PUSH 0 ; /lParam = 0
004012EB |. 6A 00 PUSH 0 ; |wParam = 0
004012ED |. 6A 10 PUSH 10 ; |Message = WM_CLOSE
004012EF |. FF75 08 PUSH DWORD PTR SS: ; |hWnd
004012F2 |. E8 F5000000 CALL <JMP.&user32.PostMessageA> ; PostMessageA
if ".if eax==DLGC_WANTALLKEYS" isn't correct,I think when I press any key,it will break on "004012DC |. 83F8 04 CMP EAX,4 ",but he didn't!
please help me!~
Masm8 - i think it might be this.
MSDN
WM_GETDLGCODE
....
Return Values
The return value is one or more of the following values, indicating which type of input the application processes
...
in your code you have the following...
i think it should be..
Then process the WM_CHAR;WM_KEYUP etc.
Do mind that i havn't worked with this Window Message before but it is my guess.
Black iCE
MSDN
WM_GETDLGCODE
....
Return Values
The return value is one or more of the following values, indicating which type of input the application processes
...
in your code you have the following...
...
.elseif uMsg==WM_GETDLGCODE
.if eax==DLGC_WANTALLKEYS
...
i think it should be..
...
.elseif uMsg==WM_GETDLGCODE
mov eax,DLGC_WANTALLKEYS
ret
...
Then process the WM_CHAR;WM_KEYUP etc.
Do mind that i havn't worked with this Window Message before but it is my guess.
Black iCE
ths
But it didn't work,the dialog didn't receive any message from keyboard except input in editbox.
But it didn't work,the dialog didn't receive any message from keyboard except input in editbox.
So you say you get now input from the edit box?
The WM_GETDLGCODE message and the returned values are useful only with user-defined dialog box controls or standard controls modified by subclassing
Masm8 do you mind posting your source up so that i may take a look and see what is wrong.
Black iCE
The WM_GETDLGCODE message and the returned values are useful only with user-defined dialog box controls or standard controls modified by subclassing
Masm8 do you mind posting your source up so that i may take a look and see what is wrong.
Black iCE
OK,thanks.