473,581 Members | 2,444 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Drag and Drop like Windows Explorer

I am trying to implement the user feedback provided by
Windows Explorer when draggng a filename from one place to
another.
I have the drag and drop action worked out but have had no
luck in finding how to capture the piece of the screen
into a bitmap to simulate the movement. I know this could
be done with the Windows API but can't find any way to do
it with .Net functions.

Any help is appreciated.

Clyde

Nov 15 '05 #1
5 4946
Clyde, what do you mean by 'capture the piece of screen'? It might be
easiest if you could outline how you would do this with the Win API. From
there we can tell you whether you should use P/Invoke or if there are
managed classes to accomplish your task.

--
Greg Ewing [MVP]
http://www.citidc.com/
"Clyde" <cl******@devco r.com> wrote in message
news:0a******** *************** *****@phx.gbl.. .
I am trying to implement the user feedback provided by
Windows Explorer when draggng a filename from one place to
another.
I have the drag and drop action worked out but have had no
luck in finding how to capture the piece of the screen
into a bitmap to simulate the movement. I know this could
be done with the Windows API but can't find any way to do
it with .Net functions.

Any help is appreciated.

Clyde

Nov 15 '05 #2
My terminology may be wrong. When you start to drag a
file in Explorer, the cursor changed and a muted image of
the selected file is dragged with the mouse. Some
controls, like CTreeGrid have a function,Create DragImage
which returns the image to use. This is what I want to
implement for the DataGrid in .Net.

Clyde
-----Original Message-----
Clyde, what do you mean by 'capture the piece of screen'? It might beeasiest if you could outline how you would do this with the Win API. Fromthere we can tell you whether you should use P/Invoke or if there aremanaged classes to accomplish your task.

--
Greg Ewing [MVP]
http://www.citidc.com/
"Clyde" <cl******@devco r.com> wrote in message
news:0a******* *************** ******@phx.gbl. ..
I am trying to implement the user feedback provided by
Windows Explorer when draggng a filename from one place to another.
I have the drag and drop action worked out but have had no luck in finding how to capture the piece of the screen
into a bitmap to simulate the movement. I know this could be done with the Windows API but can't find any way to do it with .Net functions.

Any help is appreciated.

Clyde

.

Nov 15 '05 #3

Hi Clyde,

I think you should refer to the DataGrid's DragEnter, DragDrop, DragOver
event which are inherited from Control's DragEnter, DragDrop, DragOver
event.
You can change the cursor display by changing the DragEventArgs with
DragDropEffects enumerate.
You also can use e.Data.GetDataP resent method to determine the source
data's format.
You can find many small samples of these events in MSDN.

For your datagrid dragdrop, if you want to add this source data into the
datagrid, I think you should add this source data into the dataset, then
the datagrid will reflect the change. Then if you want to update the
database, you should use SqlDataAdapter' s Update method.

If you still have anyting unclear, please feel free to let me know.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| Content-Class: urn:content-classes:message
| From: <an*******@disc ussions.microso ft.com>
| Sender: <an*******@disc ussions.microso ft.com>
| References: <0a************ *************** *@phx.gbl>
<ev************ **@tk2msftngp13 .phx.gbl>
| Subject: Re: Drag and Drop like Windows Explorer
| Date: Wed, 29 Oct 2003 15:09:30 -0800
| Lines: 46
| Message-ID: <0c************ *************** *@phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcOecbVE+iYSE3C sRVCgGO60YFwwLw ==
| Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
| Path: cpmsftngxa06.ph x.gbl
| Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:1952 25
| NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.csharp
|
| My terminology may be wrong. When you start to drag a
| file in Explorer, the cursor changed and a muted image of
| the selected file is dragged with the mouse. Some
| controls, like CTreeGrid have a function,Create DragImage
| which returns the image to use. This is what I want to
| implement for the DataGrid in .Net.
|
| Clyde
|
| >-----Original Message-----
| >Clyde, what do you mean by 'capture the piece of
| screen'? It might be
| >easiest if you could outline how you would do this with
| the Win API. From
| >there we can tell you whether you should use P/Invoke or
| if there are
| >managed classes to accomplish your task.
| >
| >--
| >Greg Ewing [MVP]
| >http://www.citidc.com/
| >
| >
| >"Clyde" <cl******@devco r.com> wrote in message
| >news:0a******* *************** ******@phx.gbl. ..
| >> I am trying to implement the user feedback provided by
| >> Windows Explorer when draggng a filename from one place
| to
| >> another.
| >> I have the drag and drop action worked out but have had
| no
| >> luck in finding how to capture the piece of the screen
| >> into a bitmap to simulate the movement. I know this
| could
| >> be done with the Windows API but can't find any way to
| do
| >> it with .Net functions.
| >>
| >> Any help is appreciated.
| >>
| >> Clyde
| >>
| >
| >
| >.
| >
|

Nov 15 '05 #4
I don't have a problem with the drag and drop action. I
am using the DataGrid DragDrop, DragEnter, and DragOver
events.
When I start a drag, the cursor converts to an arrow with
two small boxes along the tail of the arrow. I know I can
change the cursor. What I would like to do is add the
small bitmap along with the cursor like Windows Explorer
does when you start to drag a file.

I don't know if the Explorer effect is a cursor only or a
cursor plus bitmap. If it is a cursor only, can you
provide some help in creating cursors on-the-fly of
arbitrary size? If it is a bitmap, how is the bitmap
generated on-the-fly?
-----Original Message-----

Hi Clyde,

I think you should refer to the DataGrid's DragEnter, DragDrop, DragOverevent which are inherited from Control's DragEnter, DragDrop, DragOverevent.
You can change the cursor display by changing the DragEventArgs withDragDropEffect s enumerate.
You also can use e.Data.GetDataP resent method to determine the sourcedata's format.
You can find many small samples of these events in MSDN.

For your datagrid dragdrop, if you want to add this source data into thedatagrid, I think you should add this source data into the dataset, thenthe datagrid will reflect the change. Then if you want to update thedatabase, you should use SqlDataAdapter' s Update method.

If you still have anyting unclear, please feel free to let me know.
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #5

Hi Clyde,

Thanks for you feedback.
I think I understand your meaning. I have done a lot research for you.
First you should be clear that the dragdrop effect should be handled by the
possible drop target container, but not the drag source.
When the drag entered your application area, you should determine the drag
source's data through the clipboard. However, you should only determine if
the clipboard contains you wanted data format.
Generally, the windows will not place all the data of drag source into the
clipboard, while it only places some certain information into the
clipboard(For example, only the filename, the file content's stream
pointer). So I think you should use the file information to retreive the
file icon, then you must draw the file icon with the mouse cursor. This all
can be done in the DragEnter and DragOver event.
But I think these steps are very complex, I recommand you do not do this.
As you can see, the Microsoft Outlook, MSN, and other applications all did
not implement this effect(file icon with curso). The windows explorer and
Internet Explorer implement this effect, because they have more information
than other applications.
So I really recommand you not implement this effect.

Hope this helps,

Best regards.
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| Content-Class: urn:content-classes:message
| From: "Clyde LeFevre" <cl******@devco r.com>
| Sender: "Clyde LeFevre" <cl******@devco r.com>
| References: <0a************ *************** *@phx.gbl>
<ev************ **@tk2msftngp13 .phx.gbl>
<0c************ *************** *@phx.gbl>
<B4************ **@cpmsftngxa06 .phx.gbl>
| Subject: Re: Drag and Drop like Windows Explorer
| Date: Thu, 30 Oct 2003 09:45:45 -0800
| Lines: 49
| Message-ID: <00************ *************** *@phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcOfDaVB98soo0s 9QLetkj/am2zrBg==
| Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
| Path: cpmsftngxa06.ph x.gbl
| Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:1954 69
| NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
| X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.csharp
|
| I don't have a problem with the drag and drop action. I
| am using the DataGrid DragDrop, DragEnter, and DragOver
| events.
| When I start a drag, the cursor converts to an arrow with
| two small boxes along the tail of the arrow. I know I can
| change the cursor. What I would like to do is add the
| small bitmap along with the cursor like Windows Explorer
| does when you start to drag a file.
|
| I don't know if the Explorer effect is a cursor only or a
| cursor plus bitmap. If it is a cursor only, can you
| provide some help in creating cursors on-the-fly of
| arbitrary size? If it is a bitmap, how is the bitmap
| generated on-the-fly?
| >-----Original Message-----
| >
| >Hi Clyde,
| >
| >I think you should refer to the DataGrid's DragEnter,
| DragDrop, DragOver
| >event which are inherited from Control's DragEnter,
| DragDrop, DragOver
| >event.
| >You can change the cursor display by changing the
| DragEventArgs with
| >DragDropEffect s enumerate.
| >You also can use e.Data.GetDataP resent method to
| determine the source
| >data's format.
| >You can find many small samples of these events in MSDN.
| >
| >For your datagrid dragdrop, if you want to add this
| source data into the
| >datagrid, I think you should add this source data into
| the dataset, then
| >the datagrid will reflect the change. Then if you want to
| update the
| >database, you should use SqlDataAdapter' s Update method.
| >
| >If you still have anyting unclear, please feel free to
| let me know.
| >
| >Best regards,
| >Jeffrey Tan
| >Microsoft Online Partner Support
| >Get Secure! - www.microsoft.com/security
| >This posting is provided "as is" with no warranties and
| confers no rights.
| >
|

Nov 15 '05 #6

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

Similar topics

6
2639
by: Colin Young | last post by:
I've got a owner-drawn listview control that displays images and now I'm trying to implement drag and drop so I can drag images from the control and drop them onto other applications. So far if I drop on windows explorer it works (i.e. an image file is created where I dropped the image) or the console displays the full path to the image....
0
2591
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 simutate it. Can anyone help? Thanks ************************** previous post: Message 1 in thread
4
3044
by: Dave | last post by:
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...
0
2858
by: Yavuz Bogazci | last post by:
Hi, i have build a form with a listbox and the function that he user can drag and drop files from the windows explorer in this listbox. this works for me when i start it on my localmachine. But when i put my Apps .exe file on my WebServers WWWROOT directory and call it from the internet explorer. the application starts with the...
5
10143
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 dropped onto it.. does anyone have any examples of this? thanks
2
2082
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 <object> tag. Doing this has broken the drag and drop functionality from Windows Explorer into IE (it still works fine going from IE to Windows...
1
5369
by: Sim | last post by:
Hello NG, I try to use drag and drop function between two list views. For this I found following code: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchimpdragdrop.asp It works fine, but I have another problem. I want to create functionality like a Windows Explorer. This means, if I select some...
2
5265
by: Andreas Mueller | last post by:
Hi All, I'm trying to show a context menu during a drag drop operation similar to the windows explorers right click drag and drop behavior (A full working sample is at the end of the post): void treeView1_DragDrop(object sender, DragEventArgs e) { ContextMenu mnu = new ContextMenu(); mnu.MenuItems.Add("Click me", OnCmClick);
16
11793
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 that most Windows programs have, so I'm suprised it's not easier to implement in Access/VBA. Through Google, I found two VB6 examples and one...
0
7857
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7788
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8137
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8299
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6545
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5667
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3813
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2297
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1397
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.