Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing the drag drop mouse pointer

Status
Not open for further replies.

RMasters

Programmer
Nov 14, 2000
36
0
0
GB
When performing a drag and drop the mouse pointer defaults to the standard drag drop images. I want to alter these defaults to my own images, is this possible?

Thanks for any help in advance.
 
Did you ever find the answer to ths?
How is it done?
 
You can set cursors during the GiveFeedback event, something like the following:
Code:
Private Sub DragSource(ByVal sender As Object, ByVal e As GiveFeedbackEventArgs) Handles DragSource.GiveFeedback

e.UseDefaultCursors = False
If ((e.Effect And DragDropEffects.Move) = DragDropEffects.Move) Then
    Cursor.Current = New Cursor(...)
Else
    Cursor.Current = New Cursor(...)
End If

End Sub

Then just reset Cursor = Cursors.Default when you're done.
 
I can't get the GiveFeedback ti fire. Any ideas?
 
I just read that article before I wrote this.
My code is so simple.
I have a label1 and a textbox2
Here's the code:

Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
		TextBox2.AllowDrop = True
End Sub


Private Sub Label1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label1.MouseDown
		Debug.WriteLine("Label1_MouseDown b4 Drop")
		' This is the start of a D&D operation
		' Start a drag.
		'                 Data to drag, What effects? 
		DoDragDrop(Label1.Text, DragDropEffects.Copy)
		'Note: The DragDropEffects enumeration merely describes 
		' the cursors (effects) that can be presented during the operation, 
		' it will not enforce that the object will ultimately be moved as a 
		' result of the successful drag drop operation.
		Debug.WriteLine("Label1_MouseDown after Drop")
End Sub


Private Sub TextBox2_DragOver(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles TextBox2.DragOver
		Debug.WriteLine("TextBox2_DragOver")
End Sub


Private Sub TextBox2_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles TextBox2.DragEnter

		Debug.WriteLine("TextBox2_DragEnter")

		'	' This is the second phase of a D&D operation
		'	'Check for any data to drop
		'If e.Data.GetDataPresent(GetType(Label)) Then
		'Debug.WriteLine(sender.GetType)
		'Debug.WriteLine(e.Data, e.AllowedEffect)

		If e.Data.GetDataPresent(DataFormats.Text) Then
			' There is Label data. Allow copy.
			e.Effect = DragDropEffects.Copy

			' Highlight the control.
			TextBox2.BorderStyle = BorderStyle.FixedSingle
		Else
			' There is no Label. Prohibit drop.
			e.Effect = DragDropEffects.None
		End If
End Sub


Private Sub TextBox2_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles TextBox2.DragDrop
		Debug.WriteLine("TextBox2_DragDrop")

		TextBox2.Text = e.Data.GetData(DataFormats.Text).ToString

End Sub



Private Sub TextBox2_DragLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox2.DragLeave
		Debug.WriteLine("TextBox2_DragLeave")

End Sub


'**** put this in just in case - no good ****
Private Sub TextBox2_GiveFeedback(ByVal sender As Object, ByVal e As System.Windows.Forms.GiveFeedbackEventArgs) Handles TextBox2.GiveFeedback
		Debug.WriteLine("TextBox2_GiveFeedback")

		e.UseDefaultCursors = False
		If ((e.Effect And DragDropEffects.Move) = DragDropEffects.Move) Then
			Cursor.Current = Cursors.Hand
		Else
			Cursor.Current = Cursors.SizeAll
		End If
End Sub


'**** this should be the one that gies feedback ****
Private Sub Label1_GiveFeedback(ByVal sender As Object, ByVal e As System.Windows.Forms.GiveFeedbackEventArgs) Handles Label1.GiveFeedback
		Debug.WriteLine("Label1_GiveFeedback")

		e.UseDefaultCursors = False
		If ((e.Effect And DragDropEffects.Move) = DragDropEffects.Move) Then
			Cursor.Current = Cursors.Hand
		Else
			Cursor.Current = Cursors.SizeAll
		End If


End Sub

I can't get either one to fire. I even put in a dragover.
No good.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top