I'm having trouble getting silktest to "grab" an element in an OLETreeView in a VB6 application. I can select an element in the tree and then I would like to click on it and drag it into another tree control.
Select actually highlights the node, but it does not actually pass control to the element.
I tried to use the GetItemRect method to get the coordinates of the highlighted element, but those coordinates don't correspond to the coordinates I need to use for the click method. The GetItemRect coordinates seem to give it's location relative to the entire tree (including the off-screen portion of the tree) and the click method wants coordinates relative to the visible frame on the screen.
I have searched this forum as well as Segue's site and I haven't found anything that directly addresses what I am trying to do. Any help would be appreciated.
My situation does not parallel yours exactly, but I had a very similar problem in a Java Application. I needed to grab a selected node from one treeview, drag it and drop it on another treeview at a specified location.
The key for me was to forget the BeginDrag and EndDrag methods in favor of the BeginDragAt and EndDragAt methods. These, of course require coordinates.
As you did, I used the RECT approach to determine exactly where the upper left corner of my node was. The coordinates I got were relative to the treeview rectangle, so screen resolution did not matter. Once I had the RECT of my node and the drop point, I added 5 pixels to the x,y coordinates of each to guarantee I was actually "in" the spot I wanted to be.
If you can work around your RECT issue this may help.
If the Select method works correctly -- and it sounds as if it does -- you can use the Cursor class to grab the current coordinates of the object in order to start your BeginDragAt as DJGray suggested.
I haven't tried the above...just "scribbled" it down here. My math may be wrong to calculate where the x and Y position are in the TreeView object. (May need more coffee.)
When a select on a OLETreeView occurs, the cursor does not actually move to the item, the item just has it's 'selected' property set to TRUE (I.E.: this._SetItemProp ("Nodes", 0, iItem, "Selected", TRUE)). The only thing that I can think of that might work is determining which item is highlighted and thus possibly returning a coordinate based upon that. Anyone have any info on returning that?
Thanks to DCreed for pointing in the direction that led to a solution for the tree of origin (OLETreeView). Our solution was different but your suggestion redirected our thinking.
I am now having a problem with a SSOLETree which is the destination tree for my drag operation. I can't get it to recognize any named elements using any of the methods I want to use. I can perform method operations with frame coordinates but I need this to be data driven and obviously an element's coordinates are values that constantly change.