BUG: CommandButton Receives Keystroke from Open Dialog

Last reviewed: February 13, 1998
Article ID: Q181010
The information in this article applies to:
  • Windows CE Toolkit for Visual Basic 5.0, version 1.0

SYMPTOMS

If a CommandButton has the focus and is used to open a MessageBox, InputBox, or form, when you use the ENTER key to close the MessageBox, InputBox, or form the Click event procedure of the CommandCutton executes.

CAUSE

The ENTER key strokes returned from an open dialog or other form are interpreted by a CommandButton as a Click event.

RESOLUTION

There are two workarounds for this problem.

  1. Close the open MessageBox, InputBox or form with a mouse (or stylus) action.

  2. When a MessageBox or InputBox is called from a CommandButton, add code to set the focus to the next control in the CommandButton Click event procedure, such as:

          Msgbox "All Done"
          Text1.SetFocus
    

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

This problem occurs when using the ENTER key to close a Messagebox, an InputBox, or another form:

  • With a MessageBox, use the ENTER key to dismiss it.
  • With the InputBox function, the user can TAB to the desired button (OK, Yes, No, etc.) and select it with the ENTER key.
  • With another form that has a CLOSE button, the user can TAB to it and select it with the ENTER key.

Steps to Reproduce Behavior

  1. Open a new Windows CE project in Visual Basic. Form1 is created by default.

  2. Add a CommandButton and TextBox to Form1; they will be named Command1 and Text1 by default.

  3. Add the following code to Form1:

          Private Sub Command1_Click()
    
             MsgBox "Command1.Click"
          End Sub
    
          Private Sub Text1_Click()
             MsgBox "Text1.Click"
          End Sub
    
    

  4. Press F5 to run the project.

  5. Click on Command1. Use the ENTER key to close the MessageBox dialog and note that the Command1 Click event procedure runs again.

  6. Close the MessageBox dialog using a mouse or stylus by clicking OK. Note that the CommandButton Click event procedure does not repeat.

  7. Click on Text1. Use the ENTER key to close the MessageBox dialog and note that the TextBox Click event procedure does not repeat.

REFERENCES

Books Online for Microsoft Windows CE Toolkit for Visual Basic 5.0


Additional query words: wce vbce
Keywords : vb5all vbce WinCE
Version : WINDOWS:1.0
Platform : WINDOWS
Issue type : kbbug
Solution Type : kbnofix


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 13, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.