I have no practice with windows programming at all, but now I have a problem I want to fix in some program. I need to place an image to windows clipboard and I have raw pointer to valid DIB
(device independent bitmap)(in my experiments the dib header version is 3). The program uses the model with delayed clipboard rendering, which means that at first we use SetClipboardData(CF_DIB, NULL)
and then on WM_RENDERFORMAT
message the program place the actual data to clipboard with SetClipboardData(format, dibDataPointer)
.
When I open clipbrd.exe
(on windows xp) and I choose the DIB
view, I can see an Image without any problem. But in msdn
is written that the system can render automatically from CF_DIB
to CF_BITMAP
format. I think that's why when I look in clipbrd.exe
I see 2 formats: DIB
and BITMAP
. When I select in clipbrd.exe
the bitmap
format I got an error. At first when I looked at the code I saw that there is no case for CF_BITMAP
in system message handler function, so when system asks to render CF_BITMAP
nothing valid is placed to clipboard, so I added something like this:
switch(format){
case CF_DIB:
case CF_BITMAP: //new code
if(format == CF_BITMAP)//new cOde
format = CF_DIB;// new code
....
SetClipboardData(format, dibDataPointer);
....
and hope (actually, I knew that won't gonna work, but gave this way a try) that the system will recognize that I'm going to give as a response for CF_BITMAP
a DIB
data and the system will convert in automatically.
So how can I place proper data for WM_RENDERFORMAT
message with CF_BITMAP
format from the system if I have a DIB
data (generally it would be better if I could use the system ability to convert DIB
to BITMAP
rather then create BITMAP
from DIB
manually)?