Re: Win32Lib Question

new topic     » goto parent     » topic index » view thread      » older message » newer message

Irv Mullins wrote:

> If you have a window with zero controls, it works. Add a listbox,
> for example, and the keystrokes are no longer trapped.

That's because the listbox has focus, and keys are sent to the control with
focus. When there are controls on a window and that window gets focus,
Win32Lib tries to give it to a control that can get focus (has WS_TABSTOP
attribute). Don't mess with the attribute, though - Win32Lib also uses it to
set the tab key behavior.

In theory, you could change Win32Lib to automatically send all key events to
the main window, changing the calls:

   elsif iMsg = WM_KEYDOWN then
      if onKeyDown[ id ] != -1 then
         call_proc( onKeyDown[ id ], {wParam} )
      end if

   (etc...)

into:

   elsif iMsg = WM_KEYDOWN then
      if onKeyDown[ mainWindow ] != -1 then
         call_proc( onKeyDown[ mainWindow ], {wParam} )
      end if

    (etc...)

But I wouldn't suggest it - I mention it only to clarify what's happening in
the code. Instead, just attach the same handler to each control:

    onKeyPress [Win] = routine_id("kep")
    onKeyPress [Button1] = routine_id("kep")
    onKeyPress [Button2] = routine_id("kep")
    onKeyPress [List1] = routine_id("kep")

Hope this helps!

-- David Cuny

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu