Microsoft KB Archive/129894

= PRB: Can't Get Tabstrip Control to Support Hot-Key Activation =

Article ID: 129894

Article Last Modified on 11/18/2003

-

APPLIES TO


 * Microsoft Visual Basic 4.0 Standard Edition
 * Microsoft Visual Basic 4.0 Professional Edition
 * Microsoft Visual Basic 4.0 Enterprise Edition

-



This article was previously published under Q129894



SYMPTOMS
When a Microsoft Tabstrip Control is used in a program, you cannot activate it by using hot keys. The control allows you to underline characters in the captions on the tabs by using the ampersand (&) character, but this doesn't enable a hot key that will activate the tab. This behavior is by design.



RESOLUTION
If you want the tabs to be activated by hot keys, use the following method. To be able to use the Tabstrip control, you need to make sure the 'Windows Common Controls' control is included in your project.

Steps to Create Tabstrip with Hot-Keys
 Start a new project in Visual Basic. Form1 is created by default. Set the KeyPreview property of Form1 to True in the Properties window. Add a Tabstrip (TabStrip1) to the form. Double-click the Custom property of the Tabstrip in the Properties window to bring up the Tabstrip Control Properties window. In the tabs section of the Tabstrip Control Properties window, add three tabs with the following captions: &First, &Second, and &Third. Close the Tabstrip Control Properties window by clicking the OK button.  Add the following code to the KeyDown event of the form: If Shift = 4 Then Select Case KeyCode Case Asc("f"), Asc("F") TabStrip1.Tabs(1).Selected = True KeyCode = 0 Case Asc("s"), Asc("S") TabStrip1.Tabs(2).Selected = True KeyCode = 0 Case Asc("t"), Asc("T") TabStrip1.Tabs(3).Selected = True KeyCode = 0 End Select End If                       </li> Press the F5 key to run the program. Notice that as you press ALT-F, ALT-S, or ALT-T, the appropriate tab is selected.</li></ol>

<div class="status_section">

STATUS
This behavior is by design. The Microsoft Tabstrip functions the way it does in order to preserve system resources. As you use this control, you will notice that it is missing other features that third-party tab controls provide. This gives you, the programmer, better control over your system. You can implement only those features that you really need and not waste valuable system resources on features you don't need.

Additional query words: 4.00 vb4win vb4all

Keywords: kbprb kbcode KB129894

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.