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!

Treeview OleDragDrop changing mouse cursor

Status
Not open for further replies.

vaxman9

Programmer
Feb 26, 2002
79
US
Greetings all

I am creating a simple file cabinet for one of my applications using the Treeview for the control, allowing the users to move items around via D&D and the basic functionality is in and working.

I want to change the mouse cursor to something a bit less bland than the defaults, I have done this with the native controls in the past and have had success, but the Treeview control is not cooperating or I am missing something (more likely). It doesn't help that the Help file for the Treeview control is somewhat limited. Additionally, the Ole D&D events for the Treeview have different parameters than native VFP controls, so I am not sure I can rely on the VFP Help for Ole D&D operations as a guide.

Here's my setup:

Properties:
OleDragMode = 1
OleDropMode = 1

Events
OleStartDrag - sets the data I am moving and sets AllowedEffects to 3 (move/copy) , which gives me the default cursorDRAGCOPY.pngwhen over an accepting area or NODROP02.png when over a non-accepting area.

OleDragOver - sets effect appropriately for what is under the dragged item.

The OleGiveFeedBack event fires and I tried many different values (from the VPF help) for defaultcursors parameter to see if I could get any change. Regardless of the value I set, the mouse pointer remains the default.

Not a show stopper, more of a "wonder what I am missing" question.

Any pointers or suggestion would be welcomed and appreciated.

thanks
msc

MS Treeview Control 6.0 (SP4)
VFP9 SP2
 
Have you tried setting the MouseIcon property from within the oleStartDrag event? You would set it to the name of a custom cursor file, which you can create in any decent picture editor (or use one of the cursor that come with VFP).

Mike
 
Hi Mike -

Thanks for the reply.

I tried your suggestion, but the Treeview.MouseIcon is an object and won't accept a string value, I get a Type Mismatch

I tried creating an ImageList, adding my cursor to it and then setting the Treeview.MouseIcon = ImageList.listimages[1], but I still get the Type Mismatch error.

I like what I have with the Treeview but with the poor documentation, it does make it difficult to play with.

msc
 
Hello S

That did allow the Treeview.MouseIcon to get set properly, but still no change in the displayed cursor.

Thanks!
msc
 
Followup -

Being unable to let go of this, I played around some and I have been able to get custom cursors working in the Treeview D&D.

No matter what I tried with the Treeview.MouseIcon, nothing seemed to work. I decided to try using the Form.MousePointer and Form.MouseIcon and these allowed me to get it going

In OleGiveFeedBack event:
LPARAMETERS effect, defaultcursors
Code:
defaultcursors = .f.
thisform.MousePointer = 99 && Custom
if effect = 0 && No Drop
thisform.MouseIcon = <your NODROP cursor file>
else
thisform.MouseIcon = <your DROP cursor file> && I am only using 1 cursor for all 'allowable' drops
endif

Then in the OleCompleteDrag event
LPARAMETERS effect
thisform.MousePointer= 0 && Default, reset the mouse pointer

I am not 100% sure this is the correct method, but it does work. I tried setting Thisform.MousePointer in the OleStartDrag, but it did not work. Only setting it in OleGiveFeedBack would get the custom cursor to show.

Thanks Mike and Strongm for your suggestion, much appreciated.

msc
 
Good to hear that you have got it working. Thanks for letting us know.

When I suggested using MouseIcon, what I failed to mention was that you would also need to set MousePointer to 99. I see that you found that yourself.

Mike
 
Hey Mike,

I won't hold that against you 😉

Thanks much for the help
msc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top