473,569 Members | 2,834 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

WaitCursor and mouse locked in QueryContinueDr ag

While developing a drag&drop enabled application I found out this
"strange" behaviour: if I put a message box into the QueryContinueDr ag
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(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
ListView1.View = View.List
ListView1.Items .Add("test")
End Sub
Private Sub ListView1_ItemD rag(ByVal sender As Object, ByVal e As
System.Windows. Forms.ItemDragE ventArgs) Handles ListView1.ItemD rag
If e.Button = Windows.Forms.M ouseButtons.Lef t Then
ListView1.DoDra gDrop("somethin g to drag",
DragDropEffects .Move)
End If
End Sub
Private Sub ListView1_Query ContinueDrag(By Val sender As Object,
ByVal e As System.Windows. Forms.QueryCont inueDragEventAr gs) Handles
ListView1.Query ContinueDrag
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 2706
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 QueryContinueDr ag
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(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
ListView1.View = View.List
ListView1.Items .Add("test")
End Sub
Private Sub ListView1_ItemD rag(ByVal sender As Object, ByVal e As
System.Windows. Forms.ItemDragE ventArgs) Handles ListView1.ItemD rag
If e.Button = Windows.Forms.M ouseButtons.Lef t Then
ListView1.DoDra gDrop("somethin g to drag",
DragDropEffects .Move)
End If
End Sub
Private Sub ListView1_Query ContinueDrag(By Val sender As Object,
ByVal e As System.Windows. Forms.QueryCont inueDragEventAr gs) Handles
ListView1.Query ContinueDrag
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 QueryContinueDr ag 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 QueryContinueDr ag becomes:

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

Private Sub ListView1_Query ContinueDrag(By Val sender As Object, ByVal e As
System.Windows. Forms.QueryCont inueDragEventAr gs) Handles
ListView1.Query Continuedrag

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 QueryContinueDr ag
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(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
ListView1.View = View.List
ListView1.Items .Add("test")
End Sub
Private Sub ListView1_ItemD rag(ByVal sender As Object, ByVal e As
System.Windows. Forms.ItemDragE ventArgs) Handles ListView1.ItemD rag
If e.Button = Windows.Forms.M ouseButtons.Lef t Then
ListView1.DoDra gDrop("somethin g to drag",
DragDropEffects .Move)
End If
End Sub
Private Sub ListView1_Query ContinueDrag(By Val sender As Object,
ByVal e As System.Windows. Forms.QueryCont inueDragEventAr gs) Handles
ListView1.Query ContinueDrag
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
2413
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 appear on my screen irrespective of Mouse position on any application on the screen when i move mouse cursor(hour glass) from out of my application...
2
10078
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 fine, except that any mouse events generated during this wait period (such as clicking on a button, etc.), get processed once the processing is...
0
1443
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 button when they are NOT Clicked but the cursor enters their boundary. This setup works fine. If the mouse cursor enters the button on the...
2
2996
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 cursor returns to the default arrow. Does anyone know of an alternative approach ? It can be easily simulated with a project containing a single...
10
17315
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) stored in Me.Cursor. Or is Cursors.Default some process wide cursor shape? What is a correct statement?
6
6358
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 working fine, except for that I cannot figure out how display the waitcursor / hourglass while the preview is preparing to show the document *and then...
0
1599
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, more specific events, are used in their stead such as DragEnter, DragLeave, DragHover, GiveFeedback, and QueryContinueDrag. None of these give me...
0
1094
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, view menu's etc? Im assuming that the mouse button 2 has been disabled via VB but cant find it coded anywhere. Does anyone know what the code would be...
1
3788
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
7605
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7917
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8118
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7665
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7962
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6277
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5501
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
933
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.