Print Page | Close Window

MISSING: TabControl MouseDown, KeyDown/KUp Events

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Controls
Forum Description: Topics Related to Codejock Controls
URL: http://forum.codejock.com/forum_posts.asp?TID=11481
Printed Date: 05 October 2024 at 8:01pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: MISSING: TabControl MouseDown, KeyDown/KUp Events
Posted By: jpbro
Subject: MISSING: TabControl MouseDown, KeyDown/KUp Events
Date 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




Replies:
Posted By: jpbro
Date 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




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net