Announcement

Collapse
No announcement yet.

Tab trouble in Tab control

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

  • Dave Biggs
    replied
    James,
    There does indeed seem to be trouble wit' Tab key!. Did you send it in to support?

    The Tab key does work as expected in the sample TabControl.bas provided with PBWin8.
    In order to get the same kind of behaviour with the sample provided in PBWin9 you can use accelerator keys in the dialog as shown below.

    To take control of the Tab Key, create an accelerator table in PBMain & attach it to the main Dialog. (I had no luck trying to attach accelerators to the Tab pages themselves).
    Add a callback procedure for the Dialog and catch / process the TAB key there.
    Code:
    '....snip
    %AC_RETURN         = 2001
    %AC_TAB            = 2002
    [COLOR=slategray]GLOBAL hDlg AS LONG[/COLOR]
    '------------------/
     
    [COLOR=gray]FUNCTION PBMAIN () AS LONG[/COLOR]
    '...snip
      [COLOR=gray]LOCAL hBoldFont AS LONG[/COLOR]
      LOCAL hAccel    AS DWORD
      DIM AccelTbl(1) AS ACCELAPI         ' dim array of 'ACCELAPI' type
     
      AccelTbl(0).FVIRT   = %FVIRTKEY     ' flag indicates key member specifies a virtual-key code
      AccelTbl(0).KEY     = %VK_RETURN    ' = Enter key etc
      AccelTbl(0).CMD     = %AC_RETURN    ' accelerator ID for %WM_COMMAND / CB.CTL {LOWRD(WPARAM)} msg
     
      AccelTbl(1).FVIRT   = %FVIRTKEY
      AccelTbl(1).KEY     = %VK_TAB
      AccelTbl(1).CMD     = %AC_TAB
     
    '...snip
    [COLOR=gray]' Add a Tab control to the main dialog box[/COLOR]
    [COLOR=gray]CONTROL ADD TAB, hDlg, %ID_TAB, "", 1, 1, 298, 138[/COLOR]
      ' ensure visual cues work for tab control
      CONTROL SEND hDlg, %ID_TAB, %WM_UPDATEUISTATE, MAKLNG(%UIS_CLEAR, %UISF_HIDEFOCUS OR %UISF_HIDEACCEL), 0
     
    '...snip
       ACCEL ATTACH hDlg, AccelTbl() TO hAccel
    [COLOR=gray] ' Display the main dialog box[/COLOR]
    [COLOR=gray]DIALOG SHOW MODAL hDlg,[/COLOR] CALL DlgProc   ' ADDED , Call DlgProc
    '...snip
     
    CALLBACK FUNCTION DlgProc()
     LOCAL cTab, hTC AS LONG
      SELECT CASE AS LONG CB.MSG
     
        CASE %WM_COMMAND
          SELECT CASE AS LONG CB.CTL
        CASE %WM_INITDIALOG
          SetFocus GetDlgItem(CB.HNDL, %ID_TAB)
     
            CASE %AC_TAB
              SELECT CASE GetDlgCtrlID(GetFocus)
                CASE %ID_TAB                                                  ' focus is on the Tab control
                  TAB GET SELECT CBHNDL, %ID_TAB TO cTab
                  TAB GET DIALOG CBHNDL, %ID_TAB, cTab TO hTC                 ' handle of current tab page
                  SetFocus (hTC)
                  EXIT Function 
     
                CASE %ID_TAB1_BNSUBMIT, %ID_TAB2_CBCHOICES, %ID_TAB3_TEXTBOX  ' = last in TAB Order on this Tab page
                  SetFocus GetDlgItem(CB.HNDL, %ID_TAB)                       ' set focus to Tab control
                  EXIT FUNCTION
                END SELECT
              SetFocus GetNextDlgTabItem (GetParent(GetFocus), GetFocus, %False)
     
            CASE %AC_RETURN
              IF GetDlgCtrlID(GetFocus) = %ID_TAB1_BNSUBMIT THEN
                KeyBd_Event %VK_Space, 0, 0, 0: SLEEP 1
                KeyBd_Event %VK_Space, 0, %KEYEVENTF_KEYUP, 0: SLEEP 1
                EXIT FUNCTION
              END IF
              SetFocus GetNextDlgTabItem (GetParent(GetFocus), GetFocus, %False)
     
         END SELECT
      END SELECT
    END FUNCTION
    '------------------/DlgProc
    Attached Files

    Leave a comment:


  • James Graham-Eagle
    replied
    I should also have added that accelerator keys also don't seem to work within the Tab control.

    Leave a comment:


  • Rodney Hicks
    replied
    In the Samples\DDT\Tabcontrol file the texboxes on the Tab Control do not have the %WS_TABSTOP style set, therefore the Tab key doesn't function on them.

    Which, incidently, is not listed in the %styles for the CONTROL ADD LABEL but is implied in the %WS_GROUP explanation.

    And upon further reading, without any %styles set, the default %styles include the %WS_TABSTOP.

    So this should probably be sent in to support.
    Last edited by Rodney Hicks; 25 Oct 2008, 10:57 PM. Reason: add info

    Leave a comment:


  • James Graham-Eagle
    started a topic Tab trouble in Tab control

    Tab trouble in Tab control

    Using DDT and PBWin v9.0 ... I have a dialog with a Tab control. It appears that pressing the tab key does not move the focus from field to field the way it does without Tab controls. The same thing happens with the TabControl.bas example which shipped with the compiler - the tab button does not move the focus from the First Name field to the Last Name field. Am I missing something?
Working...
X