Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to unlock the DataGrid after dblclick showing a modal dialog

DataGrid

How to unlock the DataGrid after dblclick showing a modal dialog

by  Amador  Posted    (Edited  )
The datagrid control uses the sequence of MouseDown, MouseUp, MouseDown, MouseUp to fire a double click event. When you open a Modal dialog in the double click event, for some reason, the last MouseUp message is sent to the modal dialog, but not to the DataGrid. When the modal dialog is closed, the DataGrid is still waiting for the MouseUp Message, so the problem Occurs.

A similar problem is addressed in <http://support.microsoft.com/?id=305101>

To work aroud the problem the MouseUp message has to be sent manually to the Datagrid by calling the mouse_event API. See the next example:

Option Explicit

Private Declare Sub mouse_event Lib "user32" ( _
ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, _
ByVal cButtons As Long, ByVal dwExtraInfo As Long)

Private Const MOUSEEVENTF_LEFTUP = &H4

Private Sub DataGrid1_DblClick()
With DataGrid1
frmCalendar.Show vbModal
.Text = CStr(gDate)

End With

mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0

End Sub
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top