473,382 Members | 1,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

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
2 2693
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: seash | last post by:
H i had set WaitCursor for some processing in my application, This works fine for my Windowsform, but i want to extend this wait cursor to all other programs i.e only waitcursor(hourglass) should...
2
by: KarenP | last post by:
In my Windows Forms application, while executing a process that takes some time, I am changing the cursor to the hourglass by setting Cursor.Current = Cursors.WaitCursor. This is working just...
0
by: StriderBob | last post by:
In a simple two form project, use a button on each form to Show() the other form and Hide() the current form. Add MouseEnter and MouseLeave events to both buttons so they change the image on each...
2
by: Lenster | last post by:
I am trying to show an hourglass mouse cursor and disable the main form whilst waiting for some activity to finish. The problem I have come across is that as soon as you disable the main form the...
10
by: Just Me | last post by:
Does Me.Cursor.Current=Cursors.WaitCursor set the current property of Me.Cursor to Cursors.WaitCursor And Me.Cursor.Current=Cursors.Default set the Me.Current property to something (default)...
6
by: Lars | last post by:
Hi, I have created a simple custom PrintPreviewDialog consisting of a simple standard PrintPreviewControl (.NET 1.1) on a WindowsForm with a few buttons (for printing, zooming, etc.). It is...
0
by: Gamey | last post by:
I have an application that NEEDS (don't ask) to handle additional mouse and keyboard processing during DoDragDrop. Normally, DoDragDrop kindly squashes all keyboard and mouse events. Alternate,...
0
by: BenN | last post by:
Hi there, I am working on an old database (Access 2000) at my work creating reports etc. however whoever developed this database has locked or unbound mouse button 2 and most of the toolbars,...
1
by: =?Utf-8?B?bWdvbnphbGVzMw==?= | last post by:
I am unable to find the documentation on rotating the WaitCursor. ----- code --------- try { this.Cursor = Cursors.WaitCursor; // more code } catch
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.