Derek: function subClassBitmap
Derek, I looked at the function subClassControl, and used it to create the
function subClassBitmap. This function takes a bitmap-handle and wraps it into a
Win32Lib Pixmap.
--/topic Events
--/func subClassBitmap(atom bitmap)
--/desc Used to access Windows created bitmaps as if they were win32lib pixmaps.
--/return INTEGER: A win32lib control id. ZERO if it fails.
-- /i bitmap is the Windows Handle to the bitmap.
--
--Example
--/code
-- newid = subClassBitmap( bitmap_handle )
--/endcode
global function subClassBitmap(atom bitmap)
integer lNewId
if bitmap = 0 then
return 0
end if
lNewId = NewControl(Pixmap, 0)
-- Set up data for child control
window_handle[lNewId] = bitmap
window_handle_type[lNewId] = kht_Bitmap
return lNewId
end function
You could put it just after the function subClassControl in win32lib.ew.
To wrap a Win32Dib-bitmap into a Win32Lib-pixmap (with the purpose of drawing
directly to it):
object myDib
atom myPixmap
myDib = newDib(300, 200) -- create a 300x200 bitmap
if atom(myDib) then abort(0) end if
myPixmap = subClassBitmap(myDib[DibHandle])
-- start drawing:
clearDib(myDib, {255, 255, 255}) -- clear the bitmap
setFont(myPixmap, "Verdana", 8, Bold)
setTextColor(myPixmap, Black)
wPuts({myPixmap, 0, 0}, "Testing Pixmap-wrapper...")
If you wrap a bitmap in a Pixmap with this method, everything you draw on the
Pixmap using the Win32Lib-routines will be drawn on the bitmap: you don't have to
create a separate Pixmap, and you don't have to blit from the new Pixmap to the
Win32Dib-bitmap.
--
tommy online: http://users.pandora.be/tommycarlier
|
Not Categorized, Please Help
|
|