D-Pad Navigation

Discussion in 'Questions (Windows Mobile)' started by Dave Mitchell, May 1, 2008.

  1. Dave Mitchell

    Dave Mitchell Member Licensed User

    I guess you need to walk before you run. I am trying to intercept the D-Pad key presses so I can hop around controls in a form. I have tried using ControlName_KeyPress (SpecialKey) but when I compile and run it on the PPC, nothing happens. I suspect this need is common but I can't find an example on the forum (not looking hard enough?). Can this be used for DPad navigation?
    Thanks, Dave

    Sub Globals
    'Declare the global variables here.
    End Sub

    Sub App_Start
    Form1.Show
    form1.Focus
    End Sub

    Sub ControlName_KeyPress (SpecialKey)
    Msgbox (SpecialKey)
    End Sub
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    The form never gets the focus if there are any other controls on it that can be focused.
    One solution is to change the form's KeyPreview property using the Door library: http://www.basic4ppc.com/forum/showthread.php?t=2038 (first example).
    After adding this code you can use Form1_KeyPress event to handle the D-Pad buttons.
     
  3. Dave Mitchell

    Dave Mitchell Member Licensed User

    Thanks so much for the response. I still must not be getting it, the following code does not display any msgbox when the D-Pad keys are pressed.
    Thanks, dave

    ' Uses door.dll, ofrm is an object
    Sub Globals
    'Declare the global variables here.
    End Sub

    Sub App_Start
    Form1.Show
    ofrm.New1(false)
    ofrm.FromControl("Form1")
    ofrm.SetProperty("KeyPreview",true)
    End Sub

    Sub ControlName_KeyPress (SpecialKey)
    Msgbox (SpecialKey)
    End Sub
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    You should change Sub ControlName_KeyPress to Sub Form1_KeyPress.
     
  5. Dave Mitchell

    Dave Mitchell Member Licensed User

    Pretty silly. Thanks it works fine. Dave
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice