I created a dialog box using DialogPoxParam(), but I can't get any keyboard control from the dialog box's callback function.
Anyone know how?
lets see your code!
smurf
The following program should display a message anytime you press anykey, but it doesn't.
.386
.model flat,stdcall
option CaseMap:none
include C:\masm32\include\windows.inc ;Windows constant definitions
include C:\masm32\include\kernel32.inc ;List of kernel32.dll functions
include C:\masm32\include\user32.inc ;List of user32.dll functions
includelib C:\masm32\lib\kernel32.lib ;links to kernel32.lib
includelib C:\masm32\lib\user32.lib ;links to user32.lib
.data
MyWindow db "This is my first window",0
msg db "This function doesn't work",0
.data?
hInstance HINSTANCE ?
.const
IDD_DIALOG1 equ 1
.code
DlgProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
.if uMsg==WM_INITDIALOG
.elseif uMsg==WM_KEYDOWN
Invoke MessageBox,NULL,addr msg,addr MyWindow,MB_OK
.ELSEIF uMsg==WM_CLOSE
invoke EndDialog, hWnd, NULL
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret
DlgProc endp
Starts_Here:
invoke GetModuleHandle, NULL
mov hInstance,eax
invoke DialogBoxParam,hInstance,IDD_DIALOG1,NULL,addr DlgProc,NULL
invoke ExitProcess,eax
End Starts_Here
Have you tried using a keyboard hook? See Icz's tutorials on Windows Hooks. You could get the hook to return the character as either wParam or lParam to the main program.