467,188 Members | 1,426 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,188 developers. It's quick & easy.

WaitCursor and mouse locked in QueryContinueDrag

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
  • viewed: 2444
Share:
2 Replies
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
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.

Similar topics

2 posts views Thread by seash | last post: by
2 posts views Thread by KarenP | last post: by
reply views Thread by StriderBob | last post: by
2 posts views Thread by Lenster | last post: by
1 post views Thread by =?Utf-8?B?bWdvbnphbGVzMw==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.