1. SEQUENCES and BITMAPS
Hi,
I'm Renzo from Belgium , and i'm working on a graphical IDE program.
I'm stuck right now.
I need some things to finish the proggie.
I use Win32Lib.(0.50)
1. Why can't I use SetIcon(A,B) to a PictureButton or TogglePicture
It doesnt work (Docs say it should work)only Bitmaps
is there a way to load an icon as Bitmap
or is there a Euphoria file to convert BMP to Icon and Icon to BMP ??
2.moveWindow() with an Icon resizes the icon,moveWindow()
With a Bitmap , the bitmap does not resize ?? How can I resize this ??
3 Is there a way to rotate BMP's and then display ?
4 Can Win32lib display (Animated)Gif's ??
5 Is there a way to save Sequences of sequences to a file
and then read them from the file
example : SEQ= {{1},{hello},1,{TEXT},NUMBER}
printf to file doesnt work (only atoms in sequence allowed)
6 Is there a way to know if a static Icon or Bitmap were clicked ??
If you know an answer to 1 of the questions above please,please let me know!
Thanks in advance (I hope anyone responds )
Renzo Beggia
2. Re: SEQUENCES and BITMAPS
> 1. Why can't I use SetIcon(A,B) to a PictureButton or TogglePicture
> It doesnt work (Docs say it should work)only Bitmaps
>
> is there a way to load an icon as Bitmap
> or is there a Euphoria file to convert BMP to Icon and Icon to BMP ??
look a little bit in the archives or in win32lib for this one!
> 2.moveWindow() with an Icon resizes the icon,moveWindow()
> With a Bitmap , the bitmap does not resize ?? How can I resize this ??
You can stretch bitmaps to any size with this routine, which is not declared
in Win32Lib:
iStretchBlt = define_c_func(gdi32,"StretchBlt",{ C_LONG
NG)
--draws bitmap and stretches it to fit to wid and hei arguments
---------------------------------------------------------------------------
global procedure TSDrawWin_DrawBitmapHi (atom hdc, atom hBitmap ,
integer xStart, integer yStart ,integer wid,integer
hei)
-- Draw a bitmap onto the requested device
-- The bitmap is (currently) expected to be passed as a handle
atom hdcMem,bm, fName, ptSize, ptOrg
-- NEW! 0.15b changed allocate to allocate_struct
bm = allocate_struct( SIZEOF_BITMAP )
ptSize = allocate_struct( SIZEOF_POINT )
ptOrg = allocate_struct( SIZEOF_POINT )
-- create a memory device context
hdcMem = c_func( iCreateCompatibleDC, {hdc} )
if hdcMem = NULL then
warnErr( "drawBitmap:CreateCompatibleDC failed." )
end if
-- select the bitmap into it
if not c_func( iSelectObject, {hdcMem, hBitmap} ) then
warnErr( "drawBitmap:SelectObject failed." )
end if
-- set mapping mode to same as window
if not c_func( iSetMapMode, {hdcMem, c_func( iGetMapMode, {hdc} ) } )
then
warnErr( "drawBitmap:SetMapMode failed." )
end if
-- get the dimensions of the bitmap
if not c_func( iGetObject, {hBitmap, SIZEOF_BITMAP, bm} ) then
warnErr( "drawBitmap:GetObject failed." )
end if
-- move the size into the point structure ptSize
store( ptSize, {0,-3}, fetch( bm, {4,-3} ) )
store( ptSize, {4,-3}, fetch( bm, {8,-3} ) )
-- convert the point to logical coordinates
if not c_func( iDPtoLP, {hdc, ptSize, 1} ) then
warnErr( "drawBitmap:DPtoLP failed." )
end if
-- get the origin of the bitmap
store( ptOrg, {0,Long}, 0 )
store( ptOrg,{4,Long}, 0 )
-- convert to logical coordinates
if not c_func( iDPtoLP, {hdc, ptOrg, 1} ) then
warnErr( "drawBitmap:DPtoLP failed." )
end if
-- copy bitmap to device context
if not c_func( iStretchBlt,
hdc, xStart, yStart,
wid,hei,
hdcMem,
fetch( ptOrg, {0,Long} ), fetch( ptOrg, {4,Long }),
fetch( ptSize, {0,Long} ), fetch( ptSize, {4,Long} ),
SRCCOPY} ) then
warnErr( "drawBitmap:BitBlt failed." )
end if
-- release the device context
if not c_func( iDeleteDC, {hdcMem} ) then
warnErr( "drawBitmap:DeleteDC failed." )
end if
-- release structures
free( bm )
free( ptSize )
free( ptOrg )
end procedure
> 3 Is there a way to rotate BMP's and then display ?
sure, but i don't know how :)
> 4 Can Win32lib display (Animated)Gif's ??
sure?
> 5 Is there a way to save Sequences of sequences to a file
>
> and then read them from the file
do it with EDS, Euphoria database system by RDS, download it from the
contribution site.
it's simplest with this library to do this kinds of things
> 6 Is there a way to know if a static Icon or Bitmap were clicked ??
you remember where in window you drew bitmap and when mouse is clicked in
that window check if mouse click is within that bitmap's rectangle.
use this function:
--includes borders, if point lies on borders of rect or within returns true
global function IsPointInRectIncS(sequence point,
sequence rect)
if point[1]<rect[1] or point[1]>rect[3]
or point[2]<rect[2] or point[2]>rect[4] then return false
else return true end if
end function