Announcement

Collapse
No announcement yet.

Keyboard Input

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Keyboard Input

    I now have need of keyboard input into my program and thought
    I'd just trap the WM_KEYUP key. What I want to do is just get
    all keys for a given dialog, passing most of them on and
    acting on a few. I don't need to have the keyboard input just
    for the button that has the focus, but I'd like to learn how
    to do that as well. And down the road I'd like to peek at
    the keys before they are given to a TEXT EDIT control.

    I thought this should work. It doesn't. There must be some
    setup required!?

    --------------------------------------------------------------
    #COMPILE EXE
    #REGISTER NONE
    $INCLUDE "WIN32API.INC"
    GLOBAL Speeds() AS STRING
    GLOBAL hDlg AS LONG

    CALLBACK FUNCTION CBIndex()
    SELECT CASE CBMSG
    CASE %WM_KEYUP
    MSGBOX"Hi there"
    END SELECT
    END FUNCTION

    FUNCTION PBMAIN()
    DIM Speeds(5:49) AS STRING
    FOR i&=5 TO 49:speeds(i&)=" "+RIGHT$(STR$(100+i&),2)+" ":NEXT
    DIALOG NEW 0,"Morse Academy",,,320,240,_
    %WS_CAPTION OR %WS_SYSMENU OR %WS_THICKFRAME OR %WS_MAXIMIZEBOX OR _
    %WS_MINIMIZEBOX OR %DS_CONTEXTHELP,0 TO hDlg
    IF hDlg=0 THEN EXIT FUNCTION ' Error occurred
    CONTROL ADD COMBOBOX,hDlg,200,Speeds(),10,10,80,110,_
    %CBS_DROPDOWNLIST OR %LBS_WANTKEYBOARDINPUT CALL CBIndex()
    COMBOBOX SELECT hDlg,200,5
    DIALOG SHOW MODAL hDlg, CALL CBIndex()
    END FUNCTION

  • #2
    joe --
    why do you think that a style for listboxes should work for combo boxes ?
    if you want to receive keyboard message - see, for example, http://www.powerbasic.com/support/pb...ead.php?t=1839

    ------------------

    Comment


    • #3
      thanks semem! the code you refered me to seems to work
      quite well. i now know what mode less means, amd have a whole
      range of new ways to communicate with a dialog.

      lance seems to have raised a concern about the code in the
      thread:
      http://www.powerbasic.com/support/pb...ad.php?t=12662

      "hmmmm... i'll ask r&d about this, but (although i'm not privvy
      to how the ddt engine works internally) i would suspect that the
      ddt engine may "misbehave" as you are effectively intercepting
      the messages in the thread's message queue, and removing them
      from the dialog doevents loop... whether it may introduce
      subtle bugs into your application is the big question."

      i wonder if there has been any further information. (lance?)

      the code is straigtforward -- looks like a loop in the kernal
      of an os. i'll continue down this path.

      thanks again for the help!
      ---------------------------------------------------------------
      btw my question should have been better studied before i started
      the thread. my only excuse was that we had friends visiting
      and my wife was pushing me out the door to a dinner. had i
      looked around i might have found you thread or other info on
      keyboard input.


      ------------------

      Comment


      • #4
        No negative comments to date. As this is not an "officially recognized" technique, you'll have to use it at your own risk.


        ------------------
        Lance
        PowerBASIC Support
        mailto:[email protected][email protected]</A>
        Lance
        mailto:[email protected]

        Comment

        Working...
        X