OLE Drag'n Drop in TreeView-OCX

Chris Kelleher

Administrator
Staff member
Hi,

In the TreeView control it should be relative simple to drag a node to
another node (according to the HELP-file) but I only have an example in VB6
which doesn't seem to work for VB5 (control edition). The knowledge base
didn't give me any clues either.
Any help appreciated.

With regards,

John Kattestaart
john@kattestaart.demon.nl
 

Chris Kelleher

Administrator
Staff member
Hi John,
I can't offer any help if you need to use the 5.0 MS Common Controls, but
I do have a possible explanation of what's going on.
We've seen a problem with the OleDragDrop(Data, Effect, Button, Shift, x,
y) event of the MS ListView and Treeview controls. Basically, to get the
object being dropped you need to use that Data parameter to get
Data.Files.Item(x). But it looks as if in the VB 5 version of the controls
(in comctl32.ocx), you can't actually get the Files property unless the
container did compile-time binding of the property. Progress only does
runtime binding, so it doesn't work with Progress (it's also possible to
write VB code that doesn't work with this object, if you force VB to do
runtime binding with it). The VB 6 versions of the controls (in
mscomctl.ocx) seem to work fine with either compile-time or runtime binding.

--Wayne Henshaw
--Progress Software
 

Ken Liesegang

New Member
<div align=""><font size="2" face="Arial" color="#000000"> <BLOCKQUOTE><font size="1" face="Arial, Verdana">quote:</font><HR>Originally posted by progresstalk:
Hi John,
I can't offer any help if you need to use the 5.0 MS Common Controls, but
I do have a possible explanation of what's going on.
We've seen a problem with the OleDragDrop(Data, Effect, Button, Shift, x,
y) event of the MS ListView and Treeview controls. Basically, to get the
object being dropped you need to use that Data parameter to get
Data.Files.Item(x). But it looks as if in the VB 5 version of the controls
(in comctl32.ocx), you can't actually get the Files property unless the
container did compile-time binding of the property. Progress only does
runtime binding, so it doesn't work with Progress (it's also possible to
write VB code that doesn't work with this object, if you force VB to do
runtime binding with it). The VB 6 versions of the controls (in
mscomctl.ocx) seem to work fine with either compile-time or runtime binding.

--Wayne Henshaw
--Progress Software

<HR></BLOCKQUOTE>
I am having a problem with doing Drag and Drop using mscomctl.ocx. I can identify the drag item ok, but I am unable to ID the drop target.
In the OLEDragDrop event I am trying to use the HITTEST method to ID the drop target, but I am not getting a valid handle.

Is this the same problem you were having, or was yours with the Drag object, rather than the Drop object?

Thanks in advance for any help/direction.

When using the hittest method, on VB6 in progress
</font></div>
 

Ken Liesegang

New Member
<BLOCKQUOTE><font size="1" face="Arial, Verdana">quote:</font><HR>Originally posted by progresstalk:
Hi John,
I can't offer any help if you need to use the 5.0 MS Common Controls, but
I do have a possible explanation of what's going on.
We've seen a problem with the OleDragDrop(Data, Effect, Button, Shift, x,
y) event of the MS ListView and Treeview controls. Basically, to get the
object being dropped you need to use that Data parameter to get
Data.Files.Item(x). But it looks as if in the VB 5 version of the controls
(in comctl32.ocx), you can't actually get the Files property unless the
container did compile-time binding of the property. Progress only does
runtime binding, so it doesn't work with Progress (it's also possible to
write VB code that doesn't work with this object, if you force VB to do
runtime binding with it). The VB 6 versions of the controls (in
mscomctl.ocx) seem to work fine with either compile-time or runtime binding.

--Wayne Henshaw
--Progress Software

<HR></BLOCKQUOTE>
Let me explain a bit further. I don't have trouble accessing any object in the tree view control; I have trouble identifying which object is the drop target. In the terminology of your response; I don't know what x is in Data.File.Item(x).

Thanks for your offer to help.

Text
 

bendaluz

New Member
Hi,
I have been trying to do this for a very long time, and after a large amount of head scratching and generally being annoyed, I sorted the thing out. Here's the deal: First you have the x and y coordinates passed to you by the DragDrop trigger. These are in pixels, but the hittest method requires the parameters in twips. The are 1440 twips per inch (that is constant), but the number of pixels per inch depends on the screen resolution. You can find this out using an API call:

RUN GetDC IN hpApi
(INPUT default-window:hwnd,
OUTPUT hdc).
RUN GetDeviceCaps IN hpApi
(INPUT hdc,
INPUT 88,
OUTPUT i$pixelsx).
RUN GetDeviceCaps IN hpApi
(INPUT hdc,
INPUT 90,
OUTPUT i$pixelsy).
RUN ReleaseDC IN hpApi
(INPUT default-window:hwnd,
INPUT hdc,
OUTPUT ok).

It is then a simple job to convert the pixels x and y to twips and then use the result in the hittest method. Unfortunately, I think due to a bug in the OCX, the y coordinate is multiplied by -1. So this probably explains why you cannot find out which node you are dropping onto. I know it stopped me for a long time!
Anyway, hope this helps.

<BLOCKQUOTE><font size="1" face="Arial, Verdana">quote:</font><HR>Originally posted by Ken Liesegang:
<div align=""><font size="2" face="Arial" color="#000000">
Originally posted by progresstalk:
Hi John,
I can't offer any help if you need to use the 5.0 MS Common Controls, but
I do have a possible explanation of what's going on.
We've seen a problem with the OleDragDrop(Data, Effect, Button, Shift, x,
y) event of the MS ListView and Treeview controls. Basically, to get the
object being dropped you need to use that Data parameter to get
Data.Files.Item(x). But it looks as if in the VB 5 version of the controls
(in comctl32.ocx), you can't actually get the Files property unless the
container did compile-time binding of the property. Progress only does
runtime binding, so it doesn't work with Progress (it's also possible to
write VB code that doesn't work with this object, if you force VB to do
runtime binding with it). The VB 6 versions of the controls (in
mscomctl.ocx) seem to work fine with either compile-time or runtime binding.

--Wayne Henshaw
--Progress Software

<HR></BLOCKQUOTE>
I am having a problem with doing Drag and Drop using mscomctl.ocx. I can identify the drag item ok, but I am unable to ID the drop target.
In the OLEDragDrop event I am trying to use the HITTEST method to ID the drop target, but I am not getting a valid handle.

Is this the same problem you were having, or was yours with the Drag object, rather than the Drop object?

Thanks in advance for any help/direction.

When using the hittest method, on VB6 in progress
</font></div>
 
Top