Re: how to make an image draggable? by JohnSmith
JohnSmith
Fri Apr 07 08:27:02 CDT 2006
Another way is to use the rtf data of the image and drag that.
Here's what to do...Open Word Pad. Drag and Drop your image into Word Pad
(and nothing but the image). Save the document as rtf. Close it and open
the document in Notepad. Notepad will display all the rtf data. Copy all the
rtf data and then, for your drag drop, do:
string rtfcode = @"rtfcode goes here";
object rtfDropData = new DataObject(DataFormats.Rtf, rtfcode);
YourControl.DoDragDrop(rtfDropData, DragDropEffects.Copy);
Now when you drag and drop the rtf data into word, your image will appear
"Lloyd Dupont" wrote:
> Thanks Michael..
>
> "Michael Phillips, Jr." <mphillips53@nospam.jun0.c0m> wrote in message
> news:%23O$GJ5NKGHA.532@TK2MSFTNGP15.phx.gbl...
> > The .Net clipboard format "DeviceIndependentBitmap" expects a stream
> > consisting of a packed DIB.
> >
> > The packed DIB's layout is as follows:
> > BITMAPINFOHEADER
> > ColorTable or Bitfields, if necessary
> > Bitmap's bits
> >
> > When you open a bitmap as a stream, the stream consists of
> > a BITMAPFILEHEADER plus the packed DIB structure
> > outlined above.
> >
> > All you need to do is create a MemoryStream representing the packed DIB
> > and read the bytes after the BITMAPFILEHEADER into your new stream.
> >
> >
> > "Lloyd Dupont" <net.galador@ld> wrote in message
> > news:OV%23W%23IIKGHA.2040@TK2MSFTNGP14.phx.gbl...
> >>I try to implement Drag & Drop in my application.
> >> It works rather well except I'm not able to drag in other application
> >> like, say, word.
> >>
> >> I tryed to look at what IE does and when I drag animage from IE it has
> >> the follwoing formats:
> >> [0]: "UntrustedDragDrop"
> >> [1]: "FileDrop"
> >> [2]: "FileNameW"
> >> [3]: "FileName"
> >> [4]: "DeviceIndependentBitmap"
> >> [5]: "HTML Format"
> >>
> >> In my code I created my 'drag value' as follow:
> >>
> >> byte[] imageData = ....;
> >> Bitmap bmp = new Bimtap(new MemoryStream(imageData));
> >>
> >>
> >> DataObject dao = new DataObject();
> >> dao.SetData(DataFormats.Bitmap, bmp);
> >> dao.SetData("DeviceIndependentBitmap", imageData);
> >>
> >> But that doesn't work....
> >> Beside when I drag from IE the form DeviceIndependantBitmap is a stream,
> >> whereas with my code I generetae either a byte[] or a proxy
> >>
> >> what could I do?
> >> I would like to drag image from my application without having to save
> >> them to a file....
> >>
> >
> >
>
>
>