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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Custom Cursor Problem

Status
Not open for further replies.

amarti44

Programmer
Feb 16, 2001
23
0
0
US
Hi:

I have a form with a Image control and I want to change the mouse pointer to a custom cursor when the mouse is over that control and return to the default one once it leaves the control. I followed a tip in the MSDN Library (which is incompleted, by the way). In this, using MouseMove and DragOver events and setting the DragIcon property of the Image control to the desired cursor you apparently solve the problem. Something like this:

Private Sub Image1_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
If (State = 1) Then 'They forgot this if to trigger the
'event only when the mouse leave the
'control.
Image1.Drag 0 'turn off the custom cursor
End If
End Sub

Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Image1.Drag 1 'turn on the custom cursor
End Sub

Like I said this apparently works. But I also want to trigger a click event when the user click over the Image control. Using this approach the click event is not triggered.

Any suggestion...

Thanks in Advance

Alberto
 
Hi Alberto

What about in the click event itself

Private Sub Command1_Click()
me.MousePointer = vbCustom 'change cursor on click
code
code
code
me.MousePointer = vbDefault 'change back before exit
End Sub

Jon
 
Hey Alberto, I may be misunderstanding what you want to do,
but couldn't you just use the property

Image1.MousePointer = LoadPicture(&quot;<custom icon file location>&quot;)

s-)

 
Actually, I just tried out my suggestion and discovered you have to set both the MousePointer and MouseIcon properties.
You need to set MousePointer to 99 (custom file)
and then set MouseIcon to the file location.
e.g.

Private Sub Form_load()
Image1.MousePointer = 99
Image1.MouseIcon = LoadPicture(&quot;C:\Program Files\Microsoft Visual Studio\Common\Graphics\Cursors\DragPict.cur&quot;)
End Sub

sorry about the last one.
X-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top