Microsoft KB Archive/223065

= FIX: Button Parameter of DataGrid MouseUp Event Always Equals 0 =

Article ID: 223065

Article Last Modified on 1/11/2001

-

APPLIES TO


 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition

-



This article was previously published under Q223065



SYMPTOMS
Using the MouseUp and MouseDown events of the DataGrid control, you see the following symptoms:
 * The Button argument of the DataGrid MouseUp event is 0, regardless of which mouse button is used.
 * When two mouse buttons are pressed together, the Button argument of the DataGrid MouseDown event is 3 and the Button argument is incorrect for the MouseUp event.



RESOLUTION
This behavior no longer occurs with the version of the DataGrid that ships with Visual Basic 6.0 Service Pack 3.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

This bug was corrected in Visual Studio 6.0 Service Pack 3. For more information about Visual Studio service packs, please see the following articles in the Microsoft Knowledge Base:

194022 INFO: Visual Studio 6.0 Service Packs, What, Where, Why

194295 HOWTO: Tell That Visual Studio 6.0 Service Packs Are Installed



MORE INFORMATION
The MouseDown event occurs when a mouse button is pressed over an object.

The MouseUp event is raised when a mouse button is released over an object.

The MouseMove event occurs when the mouse is moved over an object.

The Button argument is an integer that indicates which mouse button was used during a MouseDown, MouseUp, or MouseMove event.

The Button argument should be 0 if no button is used, 1 if the left button is used, 2 if the right button is used, or 4 if a middle button is used.

While the Button argument may be incorrect for the DataGrid MouseUp and MouseDown events, the Button argument is correct for the DataGrid's MouseMove event.

Steps to Reproduce Behavior
 In Microsoft Visual Basic 6.0, create a new standard EXE project. Form1 is created by default. From the Project menu, choose Components. Select the Microsoft DataGrid Control 6.0 (OLEDB) and then click OK. Add a DataGrid to the Form1. DataGrid1 is created by default.  Paste the following code into the code window for Form1: Private Sub DataGrid1_MouseUp(Button As Integer, Shift As Integer, X As   Single, Y As Single) Debug.Print "DataGrid1_MouseUp:" & Button End Sub

Private Sub DataGrid1_MouseDown(Button As Integer, Shift As Integer, X   As Single, Y As Single) Debug.Print "DataGrid1_MouseDown:" & Button End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As   Single, Y As Single) Debug.Print "Form_MouseUp:" & Button End Sub

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As   Single, Y As Single) Debug.Print "Form_MouseDown:" & Button End Sub  Before running the project, open the View menu, and select Immediate Window. The Immediate Window allows you to see the output of the Debug.Print statements at run-time (and later, back in design mode). Run the project.</li> Position the mouse pointer over the Form, but not over the DataGrid.

Perform the following sequence of mouse operations: <ol style="list-style-type: lower-alpha;"> Press (and hold) the left mouse button.</li> Press (and hold) the right mouse button.</li> Release the left mouse button.</li> Release the right mouse button.</li></ol>

You will see the following sequence in the Immediate Window:

<ul> Form_MouseDown: 1</li> Form_MouseDown: 2</li> Form_MouseUp: 1</li> Form_MouseUP: 2</li></ul>

NOTE: These are the correct mouse Button values.

</li> Position the mouse pointer over the DataGrid. Perform the following sequence of mouse operations: <ol style="list-style-type: lower-alpha;"> Press (and hold) the left mouse button.</li> Press (and hold) the right mouse button.</li> Release the left mouse button.</li> Release the right mouse button.</li></ol>

You will see the following sequence in the Immediate Window: <ul> DataGrid1_MouseDown: 1</li> <li>DataGrid1_MouseDown: 3</li> <li>DataGrid1_MouseUp: 2</li> <li>DataGrid1_MouseUP: 0</li></ul>

NOTE: These are not the correct mouse Button values. The correct sequence follows: <ul> <li>DataGrid1_MouseDown: 1</li> <li>DataGrid1_MouseDown: 2</li> <li>DataGrid1_MouseUp: 1</li> <li>DataGrid1_MouseUP: 2</li></ul> </li></ol>

Keywords: kbbug kbfix kbvs600sp3fix KB223065

-

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

© Microsoft Corporation. All rights reserved.