Microsoft KB Archive/138528

= PRB: GotFocus Occurs Before Click Event When Option Selected =

Article ID: 138528

Article Last Modified on 1/11/2001

-

APPLIES TO


 * Microsoft Visual Basic 4.0 Standard Edition
 * Microsoft Visual Basic 4.0 Professional Edition
 * Microsoft Visual Basic 4.0 Professional Edition
 * Microsoft Visual Basic 4.0 16-bit Enterprise Edition
 * Microsoft Visual Basic 4.0 32-Bit Enterprise Edition
 * Microsoft Visual Basic 3.0 Professional Edition
 * Microsoft Visual Basic 3.0 Professional Edition

-



This article was previously published under Q138528



SYMPTOMS
The GotFocus event occurs before a Click event for an option button when an access key instead of the mouse is used to select the option. This is different from the behavior of command buttons and check boxes where the Click event occurs before the GotFocus event when an access key is used to select the control.



STATUS
Microsoft is researching this behavior and will post new information here in the Microsoft Knowledge Base as it becomes available.



MORE INFORMATION
The order of the GotFocus and Click events depends on how the control was selected. A mouse click generates a GotFocus event followed by a Click event for Command buttons, Check boxes, and Option buttons.

The order of the GotFocus and Click events reverse for command buttons and check boxes when an access key is used. The following table lists the events in the order in which they occur for each type of control. Type of Control         MouseClick               Access Key Command Button          GotFocus, Click          Click, GotFocus Check Box               GotFocus, Click          Click, GotFocus Option Button           GotFocus, Click          GotFocus, Click

Steps to Reproduce Behavior
 Start a new project in Visual Basic. Form1 is created by default.  On Form1, place a command button, two option buttons, and a check box. Set the following properties for each control:   Control             Name           Caption Command Button     Command1       &Command1

Option Buttons     Option1        &Option1 Option2       Option2

Check Box          Check1         C&heck1   In the Click event for each control, place the following line of code: Debug.Print Me.ActiveControl.Caption " Click"   In the GotFocus event for each control, place the following line of code: Debug.Print Me.ActiveControl.Caption " GotFocus"  Run the example by pressing the F5 key. To bring the Debug window to the foreground, on the View menu, click Debug Window in Visual Basic 4.0, or on the Window menu, click Debug in Visual Basic 3.0.</li> Click each control, and note the order in which the events take place. Then select each control by using the access keys:

ALT+C for the command button

ALT+O for the first option button

ALT+H for the check box control.

</li></ol>

Additional query words: 3.00 4.00 vb4win vb4all

Keywords: kbprb KB138528

-

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

© Microsoft Corporation. All rights reserved.