If Invoked by Access Key, Click Event Handled Before LostFocusLast reviewed: June 21, 1995Article ID: Q99875 |
The information in this article applies to:
- Standard and Professional Editions of Microsoft Visual Basic for Windows, versions 2.0 and 3.0- Microsoft Visual Basic programming system for Windows, version 1.0 - Standard and Professional Editions of Microsoft Visual Basic for MS-DOS, version 1.0
SUMMARYBelow is an example showing that the Click and LostFocus events occur in different order depending upon whether you cause the click event with the mouse or the keyboard (with an access key). This behavior is by design. When the focus changes between controls, the Click event can occur before the LostFocus event in some situations. This is mainly because certain events (including GotFocus, LostFocus, and clicking the button with the mouse) are posted to a message queue and other events, such as ALT+V from the keyboard, are issued directly. To force the code for the LostFocus event to always execute before the Click event code, place a DoEvents statement at the beginning of the Click event code.
MORE INFORMATION
Steps to Reproduce Behavior1. Draw a text box (Text1) and a command button (Command1) on the defaultForm1. The difference in behavior is not a bug. It is by design. In order make the Text1_LostFocus event occur first, place a DoEvents statement (or function) at the beginning of the Click event code for the Command1 button.
|
Additional reference words: 1.00 2.00 3.00 B_VBMSDOS
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |