473,385 Members | 1,311 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,385 software developers and data experts.

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

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

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
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...
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: 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...
0
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. ...
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...
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...
1
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: ...
2
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): ...
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...
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...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.