Author Topic: WM_CHAR in dialogbox procedure  (Read 546 times)

dedndave

  • Member
  • *****
  • Posts: 8752
  • Still using Abacus 2.0
    • DednDave
Re: WM_CHAR in dialogbox procedure
« Reply #15 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

jj2007

  • Member
  • *****
  • Posts: 7765
  • Assembler is fun ;-)
    • MasmBasic
Re: WM_CHAR in dialogbox procedure
« Reply #16 on: September 01, 2017, 02:02:19 AM »
trying to sneak up on me, eh ?  :P

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

jimg

  • Member
  • **
  • Posts: 196
Re: WM_CHAR in dialogbox procedure
« Reply #17 on: September 01, 2017, 03:08:25 AM »
Dave!

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

jimg

  • Member
  • **
  • Posts: 196
Re: WM_CHAR in dialogbox procedure
« Reply #18 on: September 01, 2017, 03:19:36 AM »
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:
Code: [Select]
        inv GetCurrentThreadId
        inv SetWindowsHookEx,WH_MSGFILTER,addr MyMessageHook,0,eax
        mov hHook,eax
hook proc:
Code: [Select]
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:
Code: [Select]
invoke UnhookWindowsHookEx, hHook
Easy, and gives me everything I wanted  :bgrin:

RuiLoureiro

  • Member
  • ****
  • Posts: 671
Re: WM_CHAR in dialogbox procedure
« Reply #19 on: September 01, 2017, 04:02:12 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