ComboboxGadget; Bind event for keyUp

Windows specific forum
HanPBF
Enthusiast
Enthusiast
Posts: 564
Joined: Fri Feb 19, 2010 3:42 am

ComboboxGadget; Bind event for keyUp

Post by HanPBF »

Hello!

I want to be notified if a user pressed enter in a combobox.

Is it possible to do that with a hook into the gadget to capture that event?

I don't want to use a window hook -> modularization...
I don't want to use a global window event loop by AddShortcutKey -> modularization...

O.k. found something at RSBasic:

Code: Select all

Structure KBDLLHOOKSTRUCT
   vkCode.l
   scanCode.l
   flags.l
   time.l
   dwExtraInfo.l
 EndStructure


Procedure.l KeyboardHook(nCode, wParam, *p.KBDLLHOOKSTRUCT)
  If wParam = #WM_KEYDOWN Or wParam = #WM_SYSKEYDOWN Or wParam = #WM_KEYUP Or wParam = #WM_SYSKEYUP
    If *p\vkCode = 13
    	debug "KeyboardHook; enter"
      ProcedureReturn 1
    EndIf
  EndIf
  ProcedureReturn CallNextHookEx_(0, nCode, wParam, *p)
EndProcedure

SetWindowsHookEx_(#WH_KEYBOARD_LL, @KeyboardHook(), GetModuleHandle_(*Combobox\Sheet\PB), 0)

And it works!!!

What special is this not to enable simply a BindGadgetEvent for some more events for ComboboBoxGadget????

@RSBasic: thanks a lot!
HanPBF
Enthusiast
Enthusiast
Posts: 564
Joined: Fri Feb 19, 2010 3:42 am

Re: ComboboxGadget; Bind event for keyUp

Post by HanPBF »

Hello RSBasic,

thanks again for the great example.

How can I get the gadget from that hook; normally I use EventGadget.
Ist it in dwExtraInfo?


Really apreciate any help!

Thanks!
HanPBF
Enthusiast
Enthusiast
Posts: 564
Joined: Fri Feb 19, 2010 3:42 am

Re: ComboboxGadget; Bind event for keyUp

Post by HanPBF »

aah... GetActiveGadget()...
Post Reply