Announcements

Announcement: We’re aware of an issue affecting starting a new topic from category pages and creating new blog posts. New topics can still be started directly from the relevant board. Learn more here.

Drag drop from Tree or List removes the selected item?

Drag drop from Tree or List removes the selected item?

Anonymous
Not applicable
361 Views
6 Replies
Message 1 of 7

Drag drop from Tree or List removes the selected item?

Anonymous
Not applicable
When I drag/drop from a list or tree (using OLESetData and OLEStartDrag)
and drag the file into AutoCAD to cause the "_Insert" command, the list
view (or tree) then removes that item from the list. I don't want the
item removed.

Is there a property set somewhere to prevent this? I tried all of the
effects, but nothing - in fact, some of the effects prevents the
"insert" command.

Here's my code:

//set the list or tree to ccOLEAutomatic

//listview is called "lstResults"
//selected file is called "file"

Private Sub lstResults_OLESetData(Data As MSComctlLib.DataObject,
DataFormat As Integer)
Data.Files.Add file
End Sub

Private Sub lstResults_OLEStartDrag(Data As MSComctlLib.DataObject,
AllowedEffects As Long)
Data.Clear
Data.SetData , vbCFFiles
End Sub

*thanks to Randall Rath for the code on this!

This will cause the "insert" command, but removes the list item.

Any ideas?

Thanks as always,

Colin Mitchell
TURCK Inc.
0 Likes
362 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable
In the OLEStartDrag event handler, the third parameter
specifies what the allowed "effects" are:

vbDropEffectNone
vbDropEffectCopy
vbDropEffectMove

So, I would try setting it to vbDropEffectCopy.

Colin Mitchell wrote:
>
> When I drag/drop from a list or tree (using OLESetData and OLEStartDrag)
> and drag the file into AutoCAD to cause the "_Insert" command, the list
> view (or tree) then removes that item from the list. I don't want the
> item removed.
>
> Is there a property set somewhere to prevent this? I tried all of the
> effects, but nothing - in fact, some of the effects prevents the
> "insert" command.
>
> Here's my code:
>
> //set the list or tree to ccOLEAutomatic
>
> //listview is called "lstResults"
> //selected file is called "file"
>
> Private Sub lstResults_OLESetData(Data As MSComctlLib.DataObject,
> DataFormat As Integer)
> Data.Files.Add file
> End Sub
>
> Private Sub lstResults_OLEStartDrag(Data As MSComctlLib.DataObject,
> AllowedEffects As Long)
> Data.Clear
> Data.SetData , vbCFFiles
> End Sub
>
> *thanks to Randall Rath for the code on this!
>
> This will cause the "insert" command, but removes the list item.
>
> Any ideas?
>
> Thanks as always,
>
> Colin Mitchell
> TURCK Inc.

--
/*********************************************************/
/* Tony Tanzillo Design Automation Consulting */
/* Programming & Customization for AutoCAD & Compatibles */
/* ----------------------------------------------------- */
/* [email protected] */
/* http://ourworld.compuserve.com/homepages/tonyt */
/*********************************************************/
0 Likes
Message 3 of 7

Anonymous
Not applicable
Sorry, I should have described more fully that I tried all of the
"AllowedEffects" with varied success:

vbDropEffectNone: does not allow a drag into AutoCAD, also does not allow drag
to desktop/windows explorer.
vbDropEffectCopy: opens the AutoCAD file (rather than inserting it into the
current drawing), allows drag to desktop/explorer. Does not remove list item
from list.
vbDropEffectMove: inserts the file into AutoCAD, allows drag to
desktop/explorer, but moves the file to the new location. Does not remove the
list item from list.

Not specifying any "vbDropEffects" results in inserting the AutoCAD file into
the current drawing, allows a "copy" drag to desktop/explorer, but removes the
list item from the list.

**Does anyone have a solution that provides the following:

Drag from tree/list to AutoCAD, which causes an "_Insert" command, allows
a "copy" to desktop, and does not remove the list item?

Thanks as always,

Colin Mitchell
TURCK Inc.

Tony Tanzillo wrote:

> In the OLEStartDrag event handler, the third parameter
> specifies what the allowed "effects" are:
>
> vbDropEffectNone
> vbDropEffectCopy
> vbDropEffectMove
>
> So, I would try setting it to vbDropEffectCopy.
>
> Colin Mitchell wrote:
> >
> > When I drag/drop from a list or tree (using OLESetData and OLEStartDrag)
> > and drag the file into AutoCAD to cause the "_Insert" command, the list
> > view (or tree) then removes that item from the list. I don't want the
> > item removed.
> >
> > Is there a property set somewhere to prevent this? I tried all of the
> > effects, but nothing - in fact, some of the effects prevents the
> > "insert" command.
> >
> > Here's my code:
> >
> > //set the list or tree to ccOLEAutomatic
> >
> > //listview is called "lstResults"
> > //selected file is called "file"
> >
> > Private Sub lstResults_OLESetData(Data As MSComctlLib.DataObject,
> > DataFormat As Integer)
> > Data.Files.Add file
> > End Sub
> >
> > Private Sub lstResults_OLEStartDrag(Data As MSComctlLib.DataObject,
> > AllowedEffects As Long)
> > Data.Clear
> > Data.SetData , vbCFFiles
> > End Sub
> >
> > *thanks to Randall Rath for the code on this!
> >
> > This will cause the "insert" command, but removes the list item.
> >
> > Any ideas?
> >
> > Thanks as always,
> >
> > Colin Mitchell
> > TURCK Inc.
>
> --
> /*********************************************************/
> /* Tony Tanzillo Design Automation Consulting */
> /* Programming & Customization for AutoCAD & Compatibles */
> /* ----------------------------------------------------- */
> /* [email protected] */
> /* http://ourworld.compuserve.com/homepages/tonyt */
> /*********************************************************/
0 Likes
Message 4 of 7

Anonymous
Not applicable
Looks like an AutoCAD problem. If the file is dropped in the
drawing view, it should be inserted regardless of whether it's
a copy or move.

Colin Mitchell wrote:
>
> Sorry, I should have described more fully that I tried all of the
> "AllowedEffects" with varied success:
>
> vbDropEffectNone: does not allow a drag into AutoCAD, also does not allow drag
> to desktop/windows explorer.
> vbDropEffectCopy: opens the AutoCAD file (rather than inserting it into the
> current drawing), allows drag to desktop/explorer. Does not remove list item
> from list.
> vbDropEffectMove: inserts the file into AutoCAD, allows drag to
> desktop/explorer, but moves the file to the new location. Does not remove the
> list item from list.
>
> Not specifying any "vbDropEffects" results in inserting the AutoCAD file into
> the current drawing, allows a "copy" drag to desktop/explorer, but removes the
> list item from the list.
>
> **Does anyone have a solution that provides the following:
>
> Drag from tree/list to AutoCAD, which causes an "_Insert" command, allows
> a "copy" to desktop, and does not remove the list item?
>
> Thanks as always,
>
> Colin Mitchell
> TURCK Inc.
>
> Tony Tanzillo wrote:
>
> > In the OLEStartDrag event handler, the third parameter
> > specifies what the allowed "effects" are:
> >
> > vbDropEffectNone
> > vbDropEffectCopy
> > vbDropEffectMove
> >
> > So, I would try setting it to vbDropEffectCopy.
> >
> > Colin Mitchell wrote:
> > >
> > > When I drag/drop from a list or tree (using OLESetData and OLEStartDrag)
> > > and drag the file into AutoCAD to cause the "_Insert" command, the list
> > > view (or tree) then removes that item from the list. I don't want the
> > > item removed.
> > >
> > > Is there a property set somewhere to prevent this? I tried all of the
> > > effects, but nothing - in fact, some of the effects prevents the
> > > "insert" command.
> > >
> > > Here's my code:
> > >
> > > //set the list or tree to ccOLEAutomatic
> > >
> > > //listview is called "lstResults"
> > > //selected file is called "file"
> > >
> > > Private Sub lstResults_OLESetData(Data As MSComctlLib.DataObject,
> > > DataFormat As Integer)
> > > Data.Files.Add file
> > > End Sub
> > >
> > > Private Sub lstResults_OLEStartDrag(Data As MSComctlLib.DataObject,
> > > AllowedEffects As Long)
> > > Data.Clear
> > > Data.SetData , vbCFFiles
> > > End Sub
> > >
> > > *thanks to Randall Rath for the code on this!
> > >
> > > This will cause the "insert" command, but removes the list item.
> > >
> > > Any ideas?
> > >
> > > Thanks as always,
> > >
> > > Colin Mitchell
> > > TURCK Inc.
> >
> > --
> > /*********************************************************/
> > /* Tony Tanzillo Design Automation Consulting */
> > /* Programming & Customization for AutoCAD & Compatibles */
> > /* ----------------------------------------------------- */
> > /* [email protected] */
> > /* http://ourworld.compuserve.com/homepages/tonyt */
> > /*********************************************************/

--
/*********************************************************/
/* Tony Tanzillo Design Automation Consulting */
/* Programming & Customization for AutoCAD & Compatibles */
/* ----------------------------------------------------- */
/* [email protected] */
/* http://ourworld.compuserve.com/homepages/tonyt */
/*********************************************************/
0 Likes
Message 5 of 7

Anonymous
Not applicable
Make sure that your OLEDropMode is set to 1 (manual)

Joe

Colin Mitchell wrote in message
news:[email protected]...
> Sorry, I should have described more fully that I tried all of the
> "AllowedEffects" with varied success:
>
> vbDropEffectNone: does not allow a drag into AutoCAD, also does not allow
drag
> to desktop/windows explorer.
> vbDropEffectCopy: opens the AutoCAD file (rather than inserting it into
the
> current drawing), allows drag to desktop/explorer. Does not remove list
item
> from list.
> vbDropEffectMove: inserts the file into AutoCAD, allows drag to
> desktop/explorer, but moves the file to the new location. Does not remove
the
> list item from list.
>
> Not specifying any "vbDropEffects" results in inserting the AutoCAD file
into
> the current drawing, allows a "copy" drag to desktop/explorer, but removes
the
> list item from the list.
>
> **Does anyone have a solution that provides the following:
>
> Drag from tree/list to AutoCAD, which causes an "_Insert" command,
allows
> a "copy" to desktop, and does not remove the list item?
>
> Thanks as always,
>
> Colin Mitchell
> TURCK Inc.
>
>
>
>
> Tony Tanzillo wrote:
>
> > In the OLEStartDrag event handler, the third parameter
> > specifies what the allowed "effects" are:
> >
> > vbDropEffectNone
> > vbDropEffectCopy
> > vbDropEffectMove
> >
> > So, I would try setting it to vbDropEffectCopy.
> >
> > Colin Mitchell wrote:
> > >
> > > When I drag/drop from a list or tree (using OLESetData and
OLEStartDrag)
> > > and drag the file into AutoCAD to cause the "_Insert" command, the
list
> > > view (or tree) then removes that item from the list. I don't want the
> > > item removed.
> > >
> > > Is there a property set somewhere to prevent this? I tried all of the
> > > effects, but nothing - in fact, some of the effects prevents the
> > > "insert" command.
> > >
> > > Here's my code:
> > >
> > > file://set the list or tree to ccOLEAutomatic
> > >
> > > file://listview is called "lstResults"
> > > file://selected file is called "file"
> > >
> > > Private Sub lstResults_OLESetData(Data As MSComctlLib.DataObject,
> > > DataFormat As Integer)
> > > Data.Files.Add file
> > > End Sub
> > >
> > > Private Sub lstResults_OLEStartDrag(Data As MSComctlLib.DataObject,
> > > AllowedEffects As Long)
> > > Data.Clear
> > > Data.SetData , vbCFFiles
> > > End Sub
> > >
> > > *thanks to Randall Rath for the code on this!
> > >
> > > This will cause the "insert" command, but removes the list item.
> > >
> > > Any ideas?
> > >
> > > Thanks as always,
> > >
> > > Colin Mitchell
> > > TURCK Inc.
> >
> > --
> > /*********************************************************/
> > /* Tony Tanzillo Design Automation Consulting */
> > /* Programming & Customization for AutoCAD & Compatibles */
> > /* ----------------------------------------------------- */
> > /* [email protected] */
> > /* http://ourworld.compuserve.com/homepages/tonyt */
> > /*********************************************************/
>
>
>
0 Likes
Message 6 of 7

Anonymous
Not applicable
Isn't OLEDropMode is for setting whether THAT CONTROL (in this case a listview)
can be dropped to?

Nevertheless, I tried it, but with no success.

cbm

Joe Sutphin wrote:

> Make sure that your OLEDropMode is set to 1 (manual)
>
> Joe
>
> Colin Mitchell wrote in message
> news:[email protected]...
> > Sorry, I should have described more fully that I tried all of the
> > "AllowedEffects" with varied success:
> >
> > vbDropEffectNone: does not allow a drag into AutoCAD, also does not allow
> drag
> > to desktop/windows explorer.
> > vbDropEffectCopy: opens the AutoCAD file (rather than inserting it into
> the
> > current drawing), allows drag to desktop/explorer. Does not remove list
> item
> > from list.
> > vbDropEffectMove: inserts the file into AutoCAD, allows drag to
> > desktop/explorer, but moves the file to the new location. Does not remove
> the
> > list item from list.
> >
> > Not specifying any "vbDropEffects" results in inserting the AutoCAD file
> into
> > the current drawing, allows a "copy" drag to desktop/explorer, but removes
> the
> > list item from the list.
> >
> > **Does anyone have a solution that provides the following:
> >
> > Drag from tree/list to AutoCAD, which causes an "_Insert" command,
> allows
> > a "copy" to desktop, and does not remove the list item?
> >
> > Thanks as always,
> >
> > Colin Mitchell
> > TURCK Inc.
> >
> >
> >
> >
> > Tony Tanzillo wrote:
> >
> > > In the OLEStartDrag event handler, the third parameter
> > > specifies what the allowed "effects" are:
> > >
> > > vbDropEffectNone
> > > vbDropEffectCopy
> > > vbDropEffectMove
> > >
> > > So, I would try setting it to vbDropEffectCopy.
> > >
> > > Colin Mitchell wrote:
> > > >
> > > > When I drag/drop from a list or tree (using OLESetData and
> OLEStartDrag)
> > > > and drag the file into AutoCAD to cause the "_Insert" command, the
> list
> > > > view (or tree) then removes that item from the list. I don't want the
> > > > item removed.
> > > >
> > > > Is there a property set somewhere to prevent this? I tried all of the
> > > > effects, but nothing - in fact, some of the effects prevents the
> > > > "insert" command.
> > > >
> > > > Here's my code:
> > > >
> > > > file://set the list or tree to ccOLEAutomatic
> > > >
> > > > file://listview is called "lstResults"
> > > > file://selected file is called "file"
> > > >
> > > > Private Sub lstResults_OLESetData(Data As MSComctlLib.DataObject,
> > > > DataFormat As Integer)
> > > > Data.Files.Add file
> > > > End Sub
> > > >
> > > > Private Sub lstResults_OLEStartDrag(Data As MSComctlLib.DataObject,
> > > > AllowedEffects As Long)
> > > > Data.Clear
> > > > Data.SetData , vbCFFiles
> > > > End Sub
> > > >
> > > > *thanks to Randall Rath for the code on this!
> > > >
> > > > This will cause the "insert" command, but removes the list item.
> > > >
> > > > Any ideas?
> > > >
> > > > Thanks as always,
> > > >
> > > > Colin Mitchell
> > > > TURCK Inc.
> > >
> > > --
> > > /*********************************************************/
> > > /* Tony Tanzillo Design Automation Consulting */
> > > /* Programming & Customization for AutoCAD & Compatibles */
> > > /* ----------------------------------------------------- */
> > > /* [email protected] */
> > > /* http://ourworld.compuserve.com/homepages/tonyt */
> > > /*********************************************************/
> >
> >
> >
0 Likes
Message 7 of 7

Anonymous
Not applicable
Here is the solution for all future peoples:

To drag a file from a listview or tree view into AutoCAD,

//set the list or tree to ccOLEAutomatic

//listview is called "lstResults"
//selected file is called "file"

Private Sub lstResults_OLESetData(Data As MSComctlLib.DataObject,
DataFormat As Integer)
Data.Files.Add file
End Sub

Private Sub lstResults_OLEStartDrag(Data As MSComctlLib.DataObject, AllowedEffects
As Long)
Data.Clear
Data.SetData , vbCFFiles
End Sub

THEN,

Private Sub lstResults_OLECompleteDrag(Effect As Long)
Effect = 1
End Sub

I originally had trouble because I placed the "effect" in the StartDrag event. If
you place the "effect" in the CompleteDrag event it works correctly.

Rockin!

cbm

Colin Mitchell wrote:

> Isn't OLEDropMode is for setting whether THAT CONTROL (in this case a listview)
> can be dropped to?
>
> Nevertheless, I tried it, but with no success.
>
> cbm
>
> Joe Sutphin wrote:
>
> > Make sure that your OLEDropMode is set to 1 (manual)
> >
> > Joe
> >
> > Colin Mitchell wrote in message
> > news:[email protected]...
> > > Sorry, I should have described more fully that I tried all of the
> > > "AllowedEffects" with varied success:
> > >
> > > vbDropEffectNone: does not allow a drag into AutoCAD, also does not allow
> > drag
> > > to desktop/windows explorer.
> > > vbDropEffectCopy: opens the AutoCAD file (rather than inserting it into
> > the
> > > current drawing), allows drag to desktop/explorer. Does not remove list
> > item
> > > from list.
> > > vbDropEffectMove: inserts the file into AutoCAD, allows drag to
> > > desktop/explorer, but moves the file to the new location. Does not remove
> > the
> > > list item from list.
> > >
> > > Not specifying any "vbDropEffects" results in inserting the AutoCAD file
> > into
> > > the current drawing, allows a "copy" drag to desktop/explorer, but removes
> > the
> > > list item from the list.
> > >
> > > **Does anyone have a solution that provides the following:
> > >
> > > Drag from tree/list to AutoCAD, which causes an "_Insert" command,
> > allows
> > > a "copy" to desktop, and does not remove the list item?
> > >
> > > Thanks as always,
> > >
> > > Colin Mitchell
> > > TURCK Inc.
> > >
> > >
> > >
> > >
> > > Tony Tanzillo wrote:
> > >
> > > > In the OLEStartDrag event handler, the third parameter
> > > > specifies what the allowed "effects" are:
> > > >
> > > > vbDropEffectNone
> > > > vbDropEffectCopy
> > > > vbDropEffectMove
> > > >
> > > > So, I would try setting it to vbDropEffectCopy.
> > > >
> > > > Colin Mitchell wrote:
> > > > >
> > > > > When I drag/drop from a list or tree (using OLESetData and
> > OLEStartDrag)
> > > > > and drag the file into AutoCAD to cause the "_Insert" command, the
> > list
> > > > > view (or tree) then removes that item from the list. I don't want the
> > > > > item removed.
> > > > >
> > > > > Is there a property set somewhere to prevent this? I tried all of the
> > > > > effects, but nothing - in fact, some of the effects prevents the
> > > > > "insert" command.
> > > > >
> > > > > Here's my code:
> > > > >
> > > > > file://set the list or tree to ccOLEAutomatic
> > > > >
> > > > > file://listview is called "lstResults"
> > > > > file://selected file is called "file"
> > > > >
> > > > > Private Sub lstResults_OLESetData(Data As MSComctlLib.DataObject,
> > > > > DataFormat As Integer)
> > > > > Data.Files.Add file
> > > > > End Sub
> > > > >
> > > > > Private Sub lstResults_OLEStartDrag(Data As MSComctlLib.DataObject,
> > > > > AllowedEffects As Long)
> > > > > Data.Clear
> > > > > Data.SetData , vbCFFiles
> > > > > End Sub
> > > > >
> > > > > *thanks to Randall Rath for the code on this!
> > > > >
> > > > > This will cause the "insert" command, but removes the list item.
> > > > >
> > > > > Any ideas?
> > > > >
> > > > > Thanks as always,
> > > > >
> > > > > Colin Mitchell
> > > > > TURCK Inc.
> > > >
> > > > --
> > > > /*********************************************************/
> > > > /* Tony Tanzillo Design Automation Consulting */
> > > > /* Programming & Customization for AutoCAD & Compatibles */
> > > > /* ----------------------------------------------------- */
> > > > /* [email protected] */
> > > > /* http://ourworld.compuserve.com/homepages/tonyt */
> > > > /*********************************************************/
> > >
> > >
> > >
0 Likes