BUG: ListView Item Not Released after Modal Dialog DismissedLast reviewed: October 16, 1996Article ID: Q150209 |
The information in this article applies to:
SYMPTOMSIf a Modal dialog box is invoked in the ItemClick event of a ListItem in the ListView control, and the modal dialog box is dismissed, the item stays attached to the mouse pointer and moving the mouse pointer drags the item.
STATUSMicrosoft has confirmed this to be an issue in the Microsoft products listed at the beginning of this article. Microsoft is researching this issue and will post new information here in the Microsoft Knowledge Base as it becomes available.
WORKAROUNDDo not invoke the modal dialog box directly from the ItemClick event. One alternative is to enable a timer where the modal dialog box is invoked. Set the timer's Enabled property to True and wait in a loop until the dialog box is shown. Then allow the ItemClick event to continue. For example, instead of showing a MsgBox in the ItemClick event for the ListView control, do the following:
Timer1.Enabled = True Do While Timer1.Enabled = True DoEvents Loop 'Rest of code follows.and in the Timer event, invoke the Modal dialog box:
MsgBox "hi" Timer1.Enabled = FalseWhen the modal dialog box is dismissed, the Timer control is disabled. Consequently, the loop in the ItemClick event remains and instructions after the loop are processed only after the modal dialog is dismissed. To make the modal dialog appear quickly, set the Interval of the Timer control at Design time to a small value such as 100. Also, disable the Timer at Design time so it does not fire an event when the program starts.
Steps To Reproduce the Problem
Private Sub timer1_Timer() s = Inputbox("Please enter a string") timer1.Enabled = False End SubPlace the declaration of the string so it is at the Form level. That is, place the following line of code into the General Declarations section of the Form:
Dim s As StringFinally, modify the code in the ItemClick event to:
Private Sub ListView1_ItemClick(ByVal Item As ListItem) timer1.Enabled = True Do While timer1.Enabled = True DoEvents Loop Debug.Print s End SubRun the project. Notice that the ListView item does not drag with the mouse pointer after the modal dialog is dismissed. Note that the print out of the strings to the Debug window is correct because this behavior only occurs after the modal InputBox has been dismissed.
|
Additional reference words: 4.00 vb4win vb432 buglist4.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |