1. Bitmaps and the clipboard
I've created 2 routines in my Win32Dib-library: 1 for copying a bitmap to
the clipboard and 1 for getting a bitmap from the clipboard. The procedure
to copy a bitmap to the clipboard works like it should. The function to
get a bitmap from the clipboard doesn't quite work like it should: if I
draw something in MSPaint and copy it to the clipboard, I can get the
bitmap with my function. If I close the Euphoria/Win32Lib-program that
gets the bitmap, and I open it again, I can't get the bitmap from the
clipboard anymore. When I keep trying, I even get a Win32Lib-error
(GetObject-error).
Here's the code:
global function getDibFromClipboard()
-- Gets a bitmap from the clipboard and returns it.
-- Returns 0 if no bitmap could be copied from the clipboard.
atom handle
object dib
sequence size
dib = 0
if w32Func(xIsClipboardFormatAvailable, {CF_BITMAP}) then
if not w32Func(xOpenClipboard, {getHandle(getActiveWindow())}) then
return 0 end if
handle = w32Func(xGetClipboardData, {CF_BITMAP})
size = getCtlSize(handle)
dib = newDib(size[1], size[2])
if sequence(dib) then copyToDib(dib, handle, 0, 0, 0, 0, size[1] - 1,
size[2] - 1) end if
w32Proc(xCloseClipboard, {})
end if
return dib
end function
--
Tommy Carlier
tommy online: http://users.pandora.be/tommycarlier