By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,837 Members | 1,195 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,837 IT Pros & Developers. It's quick & easy.

WaitCursor and mouse locked in QueryContinueDrag

P: n/a
While developing a drag&drop enabled application I found out this
"strange" behaviour: if I put a message box into the QueryContinueDrag
event handler the message box is shown but the mouse cursor is set to
WaitCursor (Hourglass) and I can't click on OK or on X, so that the
only way to close the message box is via the keyboard, by pressing
SPACE key.

The most strange thing is that if I place two message boxes, only the
first one is affected by the issue described: it seems that the
unloading of the first message box someway "resets" the mouse.
The steps to reproduce this are simple:
1) Create a new Windows Forms Project
2) Place a ListView control on the form
3) Paste the following code:
====8<===CODE================================
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
ListView1.View = View.List
ListView1.Items.Add("test")
End Sub
Private Sub ListView1_ItemDrag(ByVal sender As Object, ByVal e As
System.Windows.Forms.ItemDragEventArgs) Handles ListView1.ItemDrag
If e.Button = Windows.Forms.MouseButtons.Left Then
ListView1.DoDragDrop("something to drag",
DragDropEffects.Move)
End If
End Sub
Private Sub ListView1_QueryContinueDrag(ByVal sender As Object,
ByVal e As System.Windows.Forms.QueryContinueDragEventArgs) Handles
ListView1.QueryContinueDrag
If e.Action = DragAction.Drop Then
MsgBox("First Message") 'press SPACEBAR to hide this
MsgBox("Second message") 'this can be hidden the usual
way
End If
End Sub
====8<===CODE - END==========================
4) Run the application
3) Try to drag&drop the "test" item somewhere
I'm using Visual Studio 2005 ver. 8.0.50727.42
Any Suggestion?
Thanks
Roberto

Aug 20 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
I have the same version. There is no difference between the 2 msgboxes:
I need to press enter in either case.

Tommaso

Roberto Reale ha scritto:
While developing a drag&drop enabled application I found out this
"strange" behaviour: if I put a message box into the QueryContinueDrag
event handler the message box is shown but the mouse cursor is set to
WaitCursor (Hourglass) and I can't click on OK or on X, so that the
only way to close the message box is via the keyboard, by pressing
SPACE key.

The most strange thing is that if I place two message boxes, only the
first one is affected by the issue described: it seems that the
unloading of the first message box someway "resets" the mouse.
The steps to reproduce this are simple:
1) Create a new Windows Forms Project
2) Place a ListView control on the form
3) Paste the following code:
====8<===CODE================================
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
ListView1.View = View.List
ListView1.Items.Add("test")
End Sub
Private Sub ListView1_ItemDrag(ByVal sender As Object, ByVal e As
System.Windows.Forms.ItemDragEventArgs) Handles ListView1.ItemDrag
If e.Button = Windows.Forms.MouseButtons.Left Then
ListView1.DoDragDrop("something to drag",
DragDropEffects.Move)
End If
End Sub
Private Sub ListView1_QueryContinueDrag(ByVal sender As Object,
ByVal e As System.Windows.Forms.QueryContinueDragEventArgs) Handles
ListView1.QueryContinueDrag
If e.Action = DragAction.Drop Then
MsgBox("First Message") 'press SPACEBAR to hide this
MsgBox("Second message") 'this can be hidden the usual
way
End If
End Sub
====8<===CODE - END==========================
4) Run the application
3) Try to drag&drop the "test" item somewhere
I'm using Visual Studio 2005 ver. 8.0.50727.42
Any Suggestion?
Thanks
Roberto
Aug 20 '06 #2

P: n/a
I finally worked it out!

I found out that when QueryContinueDrag is fired, mouse control is not
automatically given to the form. This must be done manually, by setting the
"Capture" property to True for the form itself.

For the sample project used in this thread, the QueryContinueDrag becomes:

====8<===CODE================================

Private Sub ListView1_QueryContinueDrag(ByVal sender As Object, ByVal e As
System.Windows.Forms.QueryContinueDragEventArgs) Handles
ListView1.QueryContinuedrag

If e.Action = DragAction.Drop Then

Me.Capture = True ' <- gains mouse control

MsgBox("First Message") 'press SPACEBAR to hide this
MsgBox("Second message") 'this can be hidden the usual way
End If

End Sub

====8<===CODE - END============================

I'd like to stress that I found this solution on my own, not on official
documentation (except for the "Capture" property reference), so I can't
assure that this is the best/officially suggested solution to this issue. It
works anyway :-)

Hope this helps!

Roberto

"to**************@uniroma1.it" wrote:
I have the same version. There is no difference between the 2 msgboxes:
I need to press enter in either case.

Tommaso

Roberto Reale ha scritto:
While developing a drag&drop enabled application I found out this
"strange" behaviour: if I put a message box into the QueryContinueDrag
event handler the message box is shown but the mouse cursor is set to
WaitCursor (Hourglass) and I can't click on OK or on X, so that the
only way to close the message box is via the keyboard, by pressing
SPACE key.

The most strange thing is that if I place two message boxes, only the
first one is affected by the issue described: it seems that the
unloading of the first message box someway "resets" the mouse.
The steps to reproduce this are simple:
1) Create a new Windows Forms Project
2) Place a ListView control on the form
3) Paste the following code:
====8<===CODE================================
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
ListView1.View = View.List
ListView1.Items.Add("test")
End Sub
Private Sub ListView1_ItemDrag(ByVal sender As Object, ByVal e As
System.Windows.Forms.ItemDragEventArgs) Handles ListView1.ItemDrag
If e.Button = Windows.Forms.MouseButtons.Left Then
ListView1.DoDragDrop("something to drag",
DragDropEffects.Move)
End If
End Sub
Private Sub ListView1_QueryContinueDrag(ByVal sender As Object,
ByVal e As System.Windows.Forms.QueryContinueDragEventArgs) Handles
ListView1.QueryContinueDrag
If e.Action = DragAction.Drop Then
MsgBox("First Message") 'press SPACEBAR to hide this
MsgBox("Second message") 'this can be hidden the usual
way
End If
End Sub
====8<===CODE - END==========================
4) Run the application
3) Try to drag&drop the "test" item somewhere
I'm using Visual Studio 2005 ver. 8.0.50727.42
Any Suggestion?
Thanks
Roberto

Aug 21 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.