[Win32] OLE IDataObject interface (SetData)

Got questions? Got answers? Go here for both.

Moderator: MaxCoderz Staff

Post Reply
Spencer
Extreme Poster
Posts: 346
Joined: Mon 17 Jan, 2005 8:56 am
Location: Indiana

[Win32] OLE IDataObject interface (SetData)

Post by Spencer »

I figure Cobb or Ben might have some insight into this.

A Windows interface called IDragSourceHelper can draw transparent images during drag and drop. It's what's responsible for transparent icons when you drag column headings or files around in Windows 2000 and up. To get started, it only requires some image information and a pointer to an IDataObject you have implemented.

It uses the IDataObject you implement to store some of its data (it says it does this to be "cross-process"). In Windows, OLE data is stored in a structure called a STGMEDIUM (storage medium), which is really just a type ID and a union of corresponding pointers. IDragSourceHelper requests to store a type called HGLOBAL (which is just a buffer) and IStream, a datatype that's a bit like a FILE. This is where I get confused.

It calls IDataObject::SetData to store these. I've never seen an example SetData implemented before so I really don't know what to do. I can make a copy of the HGLOBAL, but I don't know where to begin to copy an IStream. It's easy to read from an IStream, but I don't know how to create a new one.
Spencer
Extreme Poster
Posts: 346
Joined: Mon 17 Jan, 2005 8:56 am
Location: Indiana

Post by Spencer »

I've got the solution and it's not as simple as I thought. Refer to http://msdn2.microsoft.com/en-us/library/ms997502.aspx for details.

I can't believe that result was never in the top 50 on google. The result of this, anyway, is

Image
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Post by benryves »

Congratulations on getting it working (looks good!)

I've never delved into the mysterious, shadowy world of drag and drop (least of all between multiple applications), so sorry I couldn't help earlier.
User avatar
Jim e
Calc King
Posts: 2457
Joined: Sun 26 Dec, 2004 5:27 am
Location: SXIOPO = Infinite lives for both players
Contact:

Post by Jim e »

Your mouse is ugly.
Image
User avatar
kalan_vod
Calc King
Posts: 2932
Joined: Sat 18 Dec, 2004 6:46 am
Contact:

Post by kalan_vod »

Good job spencer, I guess you just wanted to show the amazing work with the emu and zelda? ^.^
Post Reply