Pascal
Tue Jan 04 12:49:05 CST 2005
Hello,
i have just tried it and this works, but only if the i put the code in the
event handlerss of the form. The Event handlers of the Control (a PictureBox
in my case) are never called when draging a file from the desktop.
Is this a normal behaviour?
thanks,
Pascal
"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> a écrit dans le message
de news: Ogt26rd8EHA.2012@TK2MSFTNGP15.phx.gbl...
> You don't need remoting. You need to handle the DragEnter and DragDrop
> event from the control and decide whether the clipboard contains a format
> of data you can handle.
>
> In DragEnter, check the clipboard data for formats such as bitmaps or
> paths to image files. if the test is positive then allow the drop. When
> the drop happens use the data in whatever way your application needs.
>
> For example, this code enables file dropping...
>
> protected override void OnDragEnter(DragEventArgs e)
>
> {
>
> if (e.Data.GetDataPresent(DataFormats.Text))
>
> {
>
> string path =(string) e.Data.GetData("Text");
>
> if(File.Exists(path))
>
> {
>
> e.Effect = DragDropEffects.Copy;
>
> }
>
> else
>
> {
>
> e.Effect=DragDropEffects.None;
>
> }
>
> }
>
> else
>
> {
>
> e.Effect = DragDropEffects.None;
>
> }
>
> base.OnDragEnter(e);
>
> }
>
> This should get you started on thedrop.
>
> protected override void OnDragDrop(DragEventArgs e)
> {
>
> if(e.Data.GetDataPresent("Text"))
> {
> string path=(string)e.Data.GetData("Text");
> //load an image from a file??
> }
> Invalidate();
>
> base.OnDragDrop(e);
>
> }
>
> --
> Bob Powell [MVP]
> Visual C#, System.Drawing
>
> Find great Windows Forms articles in Windows Forms Tips and Tricks
>
http://www.bobpowell.net/tipstricks.htm
>
> Answer those GDI+ questions with the GDI+ FAQ
>
http://www.bobpowell.net/faqmain.htm
>
> All new articles provide code in C# and VB.NET.
> Subscribe to the RSS feeds provided and never miss a new article.
>
>
>
>
>
> <ravisingh11@gmail.com> wrote in message
> news:1104784983.292277.154190@f14g2000cwb.googlegroups.com...
>> Hello all
>>
>> I have a C# application, with two pictureBox 's I can successfully load
>> an image in one of the box drag and drop to the other box.
>>
>> I want to expand this concept so I can drag and drop images from
>> folders, and other applications. I think I have to use .NET remoting
>> for this. Any ideas, pointers as to how to do this, would be greatly
>> appreciated.
>>
>> Thanks
>>
>> Ravi Singh
>> (UCSD)
>>
>
>