News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

WM_CHAR in dialogbox procedure

Started by jimg, August 30, 2017, 11:09:52 AM

Previous topic - Next topic

dedndave

John (Sinsi) has the right answer - create a window with a WndProc

for dialog windows, the OS provides the actual WndProc and sends only
messages they felt were pertinent to the DlgProc, handling the rest internally


by the way, i see your 7366 post count, JJ
trying to sneak up on me, eh ?  :P

jj2007

Quote from: dedndave on September 01, 2017, 01:15:40 AMtrying to sneak up on me, eh ?  :P

I think everybody will be happy if you accept the challenge, Dave - keep posting :P

jimg

Dave!

Haven't seen a post from you in a while :)

jimg

So, since I really wanted a modal window, I kept at it.

I went looking for a way to get the keyboard input directly.  Looked up how to do a hook, something I haven't tried since dos days.
Found SetWindowsHook, but also found you could hook much more than just the keyboard, including the messages!

Hooked the messages and sure enough, I finally got WM_CHAR.   As a bonus, I now got the cursor keys in the WM_KEYDOWN which I was not getting in the modal dialog.

Simple code:

in init:

        inv GetCurrentThreadId
        inv SetWindowsHookEx,WH_MSGFILTER,addr MyMessageHook,0,eax
        mov hHook,eax

hook proc:
MyMessageHook proc code,wParam,lParam
    .if code==MSGF_DIALOGBOX
        mov ecx,lParam
        mov eax,[ecx].MSG.message
            .if eax==WM_CHAR
                invoke SendMessage,hInputSearchDialog,eax,[ecx].MSG.wParam,[ecx].MSG.lParam
            .endif
    .endif
    inv CallNextHookEx, hHook, code, wParam, lParam
ret
MyMessageHook endp

At exit:
invoke UnhookWindowsHookEx, hHook

Easy, and gives me everything I wanted  :bgrin:

RuiLoureiro

Quote from: dedndave on September 01, 2017, 01:15:40 AM
John (Sinsi) has the right answer - create a window with a WndProc

for dialog windows, the OS provides the actual WndProc and sends only
messages they felt were pertinent to the DlgProc, handling the rest internally


by the way, i see your 7366 post count, JJ
trying to sneak up on me, eh ?  :P
Hello Dave
                keep posting ! :t