Connecting Tech Pros Worldwide Forums | Help | Site Map

Drag from a Windows Form and Drop in a non-dotNet application.

Dave
Guest
 
Posts: n/a
#1: Nov 15 '05
I need to add the ability to drag from a Windows Form and drop into a
non dotNet application. For example, having a generated image in my
app that I wish to drag out into explorer as a friendly way to save
it.

I have tried creating the object that I place into the DoDragDrop() by
inheriting the COM interfaces IDropSource and IDataObject with no
luck. If anyone can help I am very much open to suggestions.

Thanks in advance!
Dave

100
Guest
 
Posts: n/a
#2: Nov 15 '05

re: Drag from a Windows Form and Drop in a non-dotNet application.


Hi Dave,
[color=blue]
> I need to add the ability to drag from a Windows Form and drop into a
> non dotNet application.[/color]

Yes, you can do that. .NET applications use the same technology of dragging
and dropping as the others non-.NET applications
[color=blue]
>For example, having a generated image in my
> app that I wish to drag out into explorer as a friendly way to save
> it.[/color]

IMHO this is not completely possible. Objects D&D over windows explorer or
the desktop may be saved in a so called *shell scrap* files. Those *scarp*
files can contain embedded or linked objects, which afterwards can be linked
or embedded in some container, but IMHO you cannot save the data in some
native format (say if you D&D images in BMP or JPG). To have the explorer
create *scrap* file from data your dragged the datao bject has to carry
CF_EMBEDEDSOURCE and/or CF_LINKSOURCE data on it. But to open *scarp* files
your application has to be OLE container. There are other options for
*cached data formats* and *delay rendering* of course but anyways you cannot
save the data in any format you want. The data will be saved in *shell
scrap* files.
[color=blue]
>
> I have tried creating the object that I place into the DoDragDrop() by
> inheriting the COM interfaces IDropSource and IDataObject with no
> luck.[/color]

You don't need to create your own classes and inherit IDataObject You can
use DataObject class provided by the framework. This class is all you need
to make D&D and store data in the clipboard.

If you want to read more for *shell scrap* files you can find some info in
MSDN
ms-help://MS.MSDNQTR.2003FEB.1033/shellcc/platform/shell/programmersguide/sh
ell_basics/shell_basics_programming/transferring/datascenarios.htm#scrap

HTH
B\rgds
100


Dave
Guest
 
Posts: n/a
#3: Nov 15 '05

re: Drag from a Windows Form and Drop in a non-dotNet application.


Thank you 100 for your response. =) The ms-help isn't registered on
the computer I am currently on, but I believe I did find a similar, if
not the same article on MSDN.
http://msdn.microsoft.com/library/de...ascenarios.asp

I have read it and gained a some valuable insight.

The dragging of the image to the desktop was really just an example
that I thought of when asking the question. It may not have been as
proper of an example as I thought.

What I am trying to do is to use the mshtml stuff inside my .Net
application. I currently have it doing quite a bit, but the one thing
I cannot get it to do is accept a dragged string from my application.
Strings from non-dotNet apps are accepted just fine by it, but not
from any dotNet app that I have tried. This is the reason I was
attempting to use the COM IDropSource and IDataObject to create a
somewhat non-dotNet object to drop. One of the first things that I
tried was the .net DataObject that you spoke of, but that did not
help. =(

Thank you,
Dave


"100" <100@100.com> wrote in message news:<ecPKJfg2DHA.1744@TK2MSFTNGP12.phx.gbl>...[color=blue]
> Hi Dave,
>[color=green]
> > I need to add the ability to drag from a Windows Form and drop into a
> > non dotNet application.[/color]
>
> Yes, you can do that. .NET applications use the same technology of dragging
> and dropping as the others non-.NET applications
>[color=green]
> >For example, having a generated image in my
> > app that I wish to drag out into explorer as a friendly way to save
> > it.[/color]
>
> IMHO this is not completely possible. Objects D&D over windows explorer or
> the desktop may be saved in a so called *shell scrap* files. Those *scarp*
> files can contain embedded or linked objects, which afterwards can be linked
> or embedded in some container, but IMHO you cannot save the data in some
> native format (say if you D&D images in BMP or JPG). To have the explorer
> create *scrap* file from data your dragged the datao bject has to carry
> CF_EMBEDEDSOURCE and/or CF_LINKSOURCE data on it. But to open *scarp* files
> your application has to be OLE container. There are other options for
> *cached data formats* and *delay rendering* of course but anyways you cannot
> save the data in any format you want. The data will be saved in *shell
> scrap* files.
>[color=green]
> >
> > I have tried creating the object that I place into the DoDragDrop() by
> > inheriting the COM interfaces IDropSource and IDataObject with no
> > luck.[/color]
>
> You don't need to create your own classes and inherit IDataObject You can
> use DataObject class provided by the framework. This class is all you need
> to make D&D and store data in the clipboard.
>
> If you want to read more for *shell scrap* files you can find some info in
> MSDN
> ms-help://MS.MSDNQTR.2003FEB.1033/shellcc/platform/shell/programmersguide/sh
> ell_basics/shell_basics_programming/transferring/datascenarios.htm#scrap
>
> HTH
> B\rgds
> 100[/color]
100
Guest
 
Posts: n/a
#4: Nov 15 '05

re: Drag from a Windows Form and Drop in a non-dotNet application.


Hi Dave,[color=blue]
> Thank you 100 for your response. =) The ms-help isn't registered on
> the computer I am currently on, but I believe I did find a similar, if
> not the same article on MSDN.
>[/color]
http://msdn.microsoft.com/library/de...ascenarios.asp

Yes, this is the same article I was talking about.
[color=blue]
> What I am trying to do is to use the mshtml stuff inside my .Net
> application. I currently have it doing quite a bit, but the one thing
> I cannot get it to do is accept a dragged string from my application.
> Strings from non-dotNet apps are accepted just fine by it, but not
> from any dotNet app that I have tried. This is the reason I was
> attempting to use the COM IDropSource and IDataObject to create a
> somewhat non-dotNet object to drop. One of the first things that I
> tried was the .net DataObject that you spoke of, but that did not
> help. =([/color]

Actually what the drop target sees is COM interfaces so using DataObject or
not should be the same.

Reading you post I guess that the problem is in the data formats you
receive. It looks like your program is looking for format that don't exist
when you drag out from you application. Usually, programs like MSWord or
WordPad provide very rich dataobjects in terms of data formats. Thus the
chances that you find the format you want are big.

For example when I look at what the DataObject has when I set simple text I
get:
- System.String - this won't be understand by non-.NET application
- Unknown Clipboard Format
- CF_TEXT - almost all application will understand that

If you are not looking for any of the formats above you will not be able to
accept anything dropped form .NET application.

So, my suggestion is to use IDataObject-Viewer tool to check what the
differences in the formats comming form .NET and non-.NET applications are.
In cases that you haven't use that tool you can find it in the VS .NET
folder
in my computer it is located in
C:\Program Files\Microsoft Visual Studio .NET
2003\Common7\Tools\Bin\dobjview.exe

Just drag and drop some stuff on the tool window and it will show formats
the data carries.
And then you can make sure that your .NET application puts the same format
in the DataObject.
You said *mshtml stuff* if you are looking for HTML data format you'll find
such data comming from MSWord or IE for example but you won't find it if you
have string containing na HTML page and just do
new DataObject(str);
You should do
new DataObject(DataFormats,Html, str);

So make sure that the format(s) you are looking for comes when the drag is
originated from your application

HTH
B\rgds
100


[color=blue]
> "100" <100@100.com> wrote in message[/color]
news:<ecPKJfg2DHA.1744@TK2MSFTNGP12.phx.gbl>...[color=blue][color=green]
> > Hi Dave,
> >[color=darkred]
> > > I need to add the ability to drag from a Windows Form and drop into a
> > > non dotNet application.[/color]
> >
> > Yes, you can do that. .NET applications use the same technology of[/color][/color]
dragging[color=blue][color=green]
> > and dropping as the others non-.NET applications
> >[color=darkred]
> > >For example, having a generated image in my
> > > app that I wish to drag out into explorer as a friendly way to save
> > > it.[/color]
> >
> > IMHO this is not completely possible. Objects D&D over windows explorer[/color][/color]
or[color=blue][color=green]
> > the desktop may be saved in a so called *shell scrap* files. Those[/color][/color]
*scarp*[color=blue][color=green]
> > files can contain embedded or linked objects, which afterwards can be[/color][/color]
linked[color=blue][color=green]
> > or embedded in some container, but IMHO you cannot save the data in some
> > native format (say if you D&D images in BMP or JPG). To have the[/color][/color]
explorer[color=blue][color=green]
> > create *scrap* file from data your dragged the datao bject has to carry
> > CF_EMBEDEDSOURCE and/or CF_LINKSOURCE data on it. But to open *scarp*[/color][/color]
files[color=blue][color=green]
> > your application has to be OLE container. There are other options for
> > *cached data formats* and *delay rendering* of course but anyways you[/color][/color]
cannot[color=blue][color=green]
> > save the data in any format you want. The data will be saved in *shell
> > scrap* files.
> >[color=darkred]
> > >
> > > I have tried creating the object that I place into the DoDragDrop() by
> > > inheriting the COM interfaces IDropSource and IDataObject with no
> > > luck.[/color]
> >
> > You don't need to create your own classes and inherit IDataObject You[/color][/color]
can[color=blue][color=green]
> > use DataObject class provided by the framework. This class is all you[/color][/color]
need[color=blue][color=green]
> > to make D&D and store data in the clipboard.
> >
> > If you want to read more for *shell scrap* files you can find some info[/color][/color]
in[color=blue][color=green]
> > MSDN
> >[/color][/color]
ms-help://MS.MSDNQTR.2003FEB.1033/shellcc/platform/shell/programmersguide/sh[color=blue][color=green]
> > ell_basics/shell_basics_programming/transferring/datascenarios.htm#scrap
> >
> > HTH
> > B\rgds
> > 100[/color][/color]


Dave
Guest
 
Posts: n/a
#5: Nov 15 '05

re: Drag from a Windows Form and Drop in a non-dotNet application.


100, Thank you again for your post. I was not aware of the tool you
mentioned. I briefly looked into it, and at first glance appears to be
exactly what I need to figure this out. Thank you again for all your
help. =)

Dave


"100" <100@100.com> wrote in message news:<eJQCW8t2DHA.2636@TK2MSFTNGP09.phx.gbl>...[color=blue]
> Hi Dave,[color=green]
> > Thank you 100 for your response. =) The ms-help isn't registered on
> > the computer I am currently on, but I believe I did find a similar, if
> > not the same article on MSDN.
> >[/color]
> http://msdn.microsoft.com/library/de...ascenarios.asp
>
> Yes, this is the same article I was talking about.
>[color=green]
> > What I am trying to do is to use the mshtml stuff inside my .Net
> > application. I currently have it doing quite a bit, but the one thing
> > I cannot get it to do is accept a dragged string from my application.
> > Strings from non-dotNet apps are accepted just fine by it, but not
> > from any dotNet app that I have tried. This is the reason I was
> > attempting to use the COM IDropSource and IDataObject to create a
> > somewhat non-dotNet object to drop. One of the first things that I
> > tried was the .net DataObject that you spoke of, but that did not
> > help. =([/color]
>
> Actually what the drop target sees is COM interfaces so using DataObject or
> not should be the same.
>
> Reading you post I guess that the problem is in the data formats you
> receive. It looks like your program is looking for format that don't exist
> when you drag out from you application. Usually, programs like MSWord or
> WordPad provide very rich dataobjects in terms of data formats. Thus the
> chances that you find the format you want are big.
>
> For example when I look at what the DataObject has when I set simple text I
> get:
> - System.String - this won't be understand by non-.NET application
> - Unknown Clipboard Format
> - CF_TEXT - almost all application will understand that
>
> If you are not looking for any of the formats above you will not be able to
> accept anything dropped form .NET application.
>
> So, my suggestion is to use IDataObject-Viewer tool to check what the
> differences in the formats comming form .NET and non-.NET applications are.
> In cases that you haven't use that tool you can find it in the VS .NET
> folder
> in my computer it is located in
> C:\Program Files\Microsoft Visual Studio .NET
> 2003\Common7\Tools\Bin\dobjview.exe
>
> Just drag and drop some stuff on the tool window and it will show formats
> the data carries.
> And then you can make sure that your .NET application puts the same format
> in the DataObject.
> You said *mshtml stuff* if you are looking for HTML data format you'll find
> such data comming from MSWord or IE for example but you won't find it if you
> have string containing na HTML page and just do
> new DataObject(str);
> You should do
> new DataObject(DataFormats,Html, str);
>
> So make sure that the format(s) you are looking for comes when the drag is
> originated from your application
>
> HTH
> B\rgds
> 100
>
>
>[color=green]
> > "100" <100@100.com> wrote in message[/color]
> news:<ecPKJfg2DHA.1744@TK2MSFTNGP12.phx.gbl>...[color=green][color=darkred]
> > > Hi Dave,
> > >
> > > > I need to add the ability to drag from a Windows Form and drop into a
> > > > non dotNet application.
> > >
> > > Yes, you can do that. .NET applications use the same technology of[/color][/color]
> dragging[color=green][color=darkred]
> > > and dropping as the others non-.NET applications
> > >
> > > >For example, having a generated image in my
> > > > app that I wish to drag out into explorer as a friendly way to save
> > > > it.
> > >
> > > IMHO this is not completely possible. Objects D&D over windows explorer[/color][/color]
> or[color=green][color=darkred]
> > > the desktop may be saved in a so called *shell scrap* files. Those[/color][/color]
> *scarp*[color=green][color=darkred]
> > > files can contain embedded or linked objects, which afterwards can be[/color][/color]
> linked[color=green][color=darkred]
> > > or embedded in some container, but IMHO you cannot save the data in some
> > > native format (say if you D&D images in BMP or JPG). To have the[/color][/color]
> explorer[color=green][color=darkred]
> > > create *scrap* file from data your dragged the datao bject has to carry
> > > CF_EMBEDEDSOURCE and/or CF_LINKSOURCE data on it. But to open *scarp*[/color][/color]
> files[color=green][color=darkred]
> > > your application has to be OLE container. There are other options for
> > > *cached data formats* and *delay rendering* of course but anyways you[/color][/color]
> cannot[color=green][color=darkred]
> > > save the data in any format you want. The data will be saved in *shell
> > > scrap* files.
> > >
> > > >
> > > > I have tried creating the object that I place into the DoDragDrop() by
> > > > inheriting the COM interfaces IDropSource and IDataObject with no
> > > > luck.
> > >
> > > You don't need to create your own classes and inherit IDataObject You[/color][/color]
> can[color=green][color=darkred]
> > > use DataObject class provided by the framework. This class is all you[/color][/color]
> need[color=green][color=darkred]
> > > to make D&D and store data in the clipboard.
> > >
> > > If you want to read more for *shell scrap* files you can find some info[/color][/color]
> in[color=green][color=darkred]
> > > MSDN
> > >[/color][/color]
> ms-help://MS.MSDNQTR.2003FEB.1033/shellcc/platform/shell/programmersguide/sh[color=green][color=darkred]
> > > ell_basics/shell_basics_programming/transferring/datascenarios.htm#scrap
> > >
> > > HTH
> > > B\rgds
> > > 100[/color][/color][/color]
Closed Thread