BUG: RichTextBox Control Prevents Click Event from Firing

Last reviewed: October 3, 1996
Article ID: Q149699
The information in this article applies to:
  • Professional and Enterprise Editions of Microsoft Visual Basic for, 32-bit only, Windows, version 4.0

SYMPTOMS

After double-clicking on the RichTextBox, the Click event for other controls does not fire the next time the left mouse button is pressed.

STATUS

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

MORE INFORMATION

Steps to Reproduce Behavior

  1. Start a new project in Visual Basic. Form1 is created by default. Add a RichTextBox and a CommandButton to the form. Their names become RichTextBox1 and Command1 by default.

  2. Add the following code to the CommandButton's Click event:

       Private Sub Command1_Click()
          MsgBox "Click Event!"
       End Sub
    
    

  3. Run the project. Double-click on the RichTextBox and click once on the CommandButton. The Click event will not fire on the first click. After the first click, everything functions normally.

WORKAROUND

  1. Place the following code in the Declarations portion of the form:

       Private Declare Function SendMessage Lib "user32" Alias _
          "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
          ByVal wParam As Long, lParam As Long) As Long
    
       Const MOUSEEVENTF_LEFTUP = &H4
       Const WM_LBUTTONUP = &H202
    
    

  2. Place the following code in the DblClick event for the RichTextBox:

       Private Sub RichTextBox1_DblClick()
          Dim retval As Long
          retval = SendMessage(RichTextBox1.hwnd, WM_LBUTTONUP, 0, 0)
       End Sub
    


Additional reference words: 4.00 vb4win vb432 RTF
KBCategory: kbusage kbbuglist
KBSubcategory: PrgCtrls



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: October 3, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.