Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Controls
  New Posts New Posts RSS Feed - MISSING: TabControl MouseDown, KeyDown/KUp Events
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

MISSING: TabControl MouseDown, KeyDown/KUp Events

 Post Reply Post Reply
Author
Message
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1354
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Topic: MISSING: TabControl MouseDown, KeyDown/KUp Events
    Posted: 18 July 2008 at 12:12am
Control has MouseMove and MouseUp, but not MouseDown. Has neither KeyUp or KeyDown events.

I would like to be able to determine if the user has switched tabs via keyboard or mouse so that I can choose whether to automatically focus a child control (mouse interaction) or not (keyboard interaction). These events would allow me to accomplish this.


Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6

Back to Top
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1354
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 19 July 2008 at 12:35am
I've found a work-around to accomplish the above goal (in case anyone else has a similar requirement).

In a module place this code:


Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer

Private Const KEY_MASK As Integer = &HFF80

Public Function IsKeyDown(KeyCode As Long) As Boolean
    IsKeyDown = GetKeyState(KeyCode) And KEY_MASK
End Function


Then, on your form with the TabControl:


Private Sub TabControl1_BeforeItemClick(ByVal Item As XtremeSuiteControls.ITabControlItem, Cancel As Variant)
   If Not (IsKeyDown(vbKeyLeft) Or IsKeyDown(vbKeyRight)) Then
      SOMEOTHERCONTROL.SetFocus
   End If
End Sub


Essentially, we are checking to see if either of the cursor keys are being pressed when the TabControl is about to change the selected tab. If so, then the focus will remain on the TabControl (so the user can continue navigating the tabs with the keyboard). If not, we'll assume that the user clicked a tab with the mouse, and then move the focus to some other control where they presumably want to start typing directly.


Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.156 seconds.