Tabcontrol Demo: Ctrl-Tab

Started by Wilko Verweij, August 31, 2012, 12:50:11 PM

Previous topic - Next topic

Wilko Verweij

Hi all,
The TabControl demo which is part of FireFly, does not respond to Ctrl-Tab to switch to the next tab. For a project, I am using this tabcontrol but like to add response to Ctrl-Tab. Which message should I use to intercept this key-combination?
Any help is appreciated.
Wilko

Paul Squires

Maybe there is a better way to do this but the following works okay. Place the code in FF_PUMPHOOK.

   If GetFocus() = HWND_FRMMAINFORM_TABCONTROL1 Then
     
      Local nNumTabs As Long
      Local nCurrTab As Long
     
      If (Msg.message = %WM_KEYDOWN) And (msg.wParam = %VK_TAB) Then
         nNumTabs = FF_TabControl_GetTabCount( HWND_FRMMAINFORM_TABCONTROL1 ) - 1   ' make it zero based
         nCurrTab = FF_TabControl_GetSelectedTab( HWND_FRMMAINFORM_TABCONTROL1 )    ' already zero based
     
         If GetAsyncKeyState(%VK_CONTROL) And &H8000 <> 0 Then
            If GetAsyncKeyState(%VK_SHIFT) And &H8000 <> 0 Then
               ' Ctrl+SHIFT+TAB has been pressed. Move one tab to the left.
               nCurrTab = nCurrTab - 1
               If nCurrTab < 0 Then nCurrTab = nNumTabs
            Else   
               ' Ctrl+TAB has been pressed. Move one tab to the right.
               nCurrTab = nCurrTab + 1
               If nCurrTab > nNumTabs Then nCurrTab = 0
            End If
            FF_TabControl_SetTabFocus HWND_FRMMAINFORM_TABCONTROL1, nCurrTab
            Function = %TRUE
            Exit Function
         End If   
      End If
   End If   

Paul Squires
PlanetSquires Software

Wilko Verweij

Thank you for your fast answer. I will try.
Wilko