Drag-n-Drop

V

VR

I am trying to use a custom cursor during drag-drop
operation between 2 ListViews. So, I have a code that at
the time GiveFeedback() is called creates a new cursor
based on the icon and text of the dragged item:

private void listView2_GiveFeedback
(
object sender,
System.Windows.Forms.GiveFeedbackEventArgs e
)
{
string szText = ...;
Bitmap oBitmap = new Bitmap(...);
Cursor oNewCursor = CreateCursor(oBitmap, szText);

e.UseDefaultCursors = false;
this.Cursor = oNewCursor;
}


The problem is that once I stop dragging the item, my
mouse cursor turns back to normal, when it's over listview
controls, but over the form it still looks like the custom
cursor I created.

I suspect that somewhere I have to set UseDefaultCursors
back to true, as well as I should set the cursor itself
back to Cursors.Arrow.

The question is where should I do it? Which other event
has the same parameters so I would have access to
UseDefaultCursors?

Thanks,
VR
 
J

Jeffrey Tan[MSFT]

Hi VR,

If you want to set the cursor back to default when it is not on the
LIstView control, you can
determine if the e.Effect is DragDropEffects.Move.

Something like this:

private void Form1_GiveFeedback(object sender,
System.Windows.Forms.GiveFeedbackEventArgs e)
{
e.UseDefaultCursors =false;
try
{
if((e.Effect & DragDropEffects.Move )==DragDropEffects.Move )
{
Cursor.Current=new Cursor("3dgarro.cur");
}
else
{
Cursor.Current =Cursors.Default ;
}
}
catch(Exception ex)
{
MessageBox.Show (ex.Message );
}
}

HTH.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| Content-Class: urn:content-classes:message
| From: "VR" <[email protected]>
| Sender: "VR" <[email protected]>
| Subject: Drag-n-Drop
| Date: Tue, 26 Aug 2003 18:35:22 -0700
| Lines: 35
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Thread-Index: AcNsO3tqDy5++BOHTIqwg3wyleQWzA==
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Newsgroups: microsoft.public.dotnet.languages.csharp
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:179698
| NNTP-Posting-Host: TK2MSFTNGXA09 10.40.1.161
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| I am trying to use a custom cursor during drag-drop
| operation between 2 ListViews. So, I have a code that at
| the time GiveFeedback() is called creates a new cursor
| based on the icon and text of the dragged item:
|
| private void listView2_GiveFeedback
| (
| object sender,
| System.Windows.Forms.GiveFeedbackEventArgs e
| )
| {
| string szText = ...;
| Bitmap oBitmap = new Bitmap(...);
| Cursor oNewCursor = CreateCursor(oBitmap, szText);
|
| e.UseDefaultCursors = false;
| this.Cursor = oNewCursor;
| }
|
|
| The problem is that once I stop dragging the item, my
| mouse cursor turns back to normal, when it's over listview
| controls, but over the form it still looks like the custom
| cursor I created.
|
| I suspect that somewhere I have to set UseDefaultCursors
| back to true, as well as I should set the cursor itself
| back to Cursors.Arrow.
|
| The question is where should I do it? Which other event
| has the same parameters so I would have access to
| UseDefaultCursors?
|
| Thanks,
| VR
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top