473,327 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

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

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
Nov 15 '05 #1
4 3019
100
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 dragging
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 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.

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 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
Nov 15 '05 #2
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" <10*@100.com> wrote in message news:<ec**************@TK2MSFTNGP12.phx.gbl>...
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 dragging
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 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.

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 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

Nov 15 '05 #3
100
Hi Dave,
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

Yes, this is the same article I was talking about.
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. =(
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
"100" <10*@100.com> wrote in message

news:<ec**************@TK2MSFTNGP12.phx.gbl>...
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 dragging 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 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.

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 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

Nov 15 '05 #4
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" <10*@100.com> wrote in message news:<eJ**************@TK2MSFTNGP09.phx.gbl>...
Hi Dave,
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

Yes, this is the same article I was talking about.
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. =(


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
"100" <10*@100.com> wrote in message

news:<ec**************@TK2MSFTNGP12.phx.gbl>...
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 dragging 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 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.

>
> 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 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

Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Lauren Quantrell | last post by:
I'm trying to drop a file from Windows Explorer (or desktop, etc.) onto a field in Access2K and capture the full file path. I found an posting below that says this is possible but I cannot...
4
by: zav | last post by:
Hi all i`m having a small problem with windows forms, i`m attempting to provide the following functionality to a form. Ability to drag and drop another form onto a form and then to dock this...
0
by: Oberon | last post by:
How do I navigate through records using drag 'n' drop controls? I have an example in C# for Windows forms that relies on BindingContext but this is not available for ASP.NET. How do I solve that...
5
by: Brian Henry | last post by:
I haven't worked much with drag/drop but I am trying to make a form that accepts files to drug onto it from explorer and droped and have the form know the full path and file name of the files...
1
by: Terry Olsen | last post by:
My first time using TreeViews. I have TreeView1 set up to display my directory structure just like Windows Explorer. I can drag & drop files and folders over to TreeView2. I can re-arrange the...
3
by: VB Programmer | last post by:
In VB.NET 2005 (winform) any sample code to drag & drop items between 2 listboxes? Thanks!
2
by: ViRi | last post by:
I am wringing a small and lite Media Player to fit my custom needs for usage while programming. I had written some drag and drop functionality like i do with other programs, but hey, the ActiveX...
2
by: Robert Zahm | last post by:
I have created a C# user control which display certain filesystem information, and allows the user to drag an drop files into and out of the control. I then placed this user form in IE using an...
16
by: John | last post by:
I am looking for VBA code that will work with Access 2003 to enable dragging and dropping a file/folder name from Windows XP Explorer into an Access form's text box. This is a common functionality...
2
by: deccio | last post by:
I have create an activex Control with Visual studio 2005 and framework 2.0 in c# to add drag & drop functionality to upload multi file. When I use it in a windows form it work fine. Infact if I...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.