By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 1,128 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

Drag and Drop like Windows Explorer

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a
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******@devcor.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

P: n/a
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,CreateDragImage
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******@devcor.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

P: n/a

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.GetDataPresent 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*******@discussions.microsoft.com>
| Sender: <an*******@discussions.microsoft.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+iYSE3CsRVCgGO60YFwwLw==
| Newsgroups: microsoft.public.dotnet.languages.csharp
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:195225
| NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| X-Tomcat-NG: microsoft.public.dotnet.languages.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,CreateDragImage
| 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******@devcor.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

P: n/a
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 withDragDropEffects enumerate.
You also can use e.Data.GetDataPresent 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

P: n/a

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******@devcor.com>
| Sender: "Clyde LeFevre" <cl******@devcor.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: AcOfDaVB98soo0s9QLetkj/am2zrBg==
| Newsgroups: microsoft.public.dotnet.languages.csharp
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:195469
| NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
| X-Tomcat-NG: microsoft.public.dotnet.languages.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
| >DragDropEffects enumerate.
| >You also can use e.Data.GetDataPresent 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 discussion thread is closed

Replies have been disabled for this discussion.