1. RE: Setting a button image - Help Please
No problem,
You provide the bitmaps for the following example. My test images were
32x32 pixels, 16 colors.
-----------------
-- bmp_btn.exw --
-----------------
include win32lib.ew
-----------------------
constant
Win = create( Window, "Simple Window", 0, Default, Default, 200, 200,
0 ),
Btn = create( PushButton, "", Win, 20, 20, 40, 40, BS_BITMAP )
atom hBmp1, hBmp2, result
integer btn_state
------------------------------
procedure onClick_Btn()
if btn_state = 1 then
result = sendMessage( Btn, BM_SETIMAGE, IMAGE_BITMAP, hBmp2 )
btn_state = 2
else
result = sendMessage( Btn, BM_SETIMAGE, IMAGE_BITMAP, hBmp1 )
btn_state = 1
end if
end procedure
onClick[Btn] = routine_id( "onClick_Btn" )
------------------------------
procedure onOpen_Win()
hBmp1 = loadBitmapFromFile( "btn1.bmp" )
hBmp2 = loadBitmapFromFile( "btn2.bmp" )
result = sendMessage( Btn, BM_SETIMAGE, IMAGE_BITMAP, hBmp1 )
btn_state = 1
end procedure
onOpen[Win] = routine_id( "onOpen_Win" )
------------------------------
WinMain( Win, Normal )
------------------------------
Tony Steward wrote:
> Hi all,
> I am using WIN32LIB and I would like to know if it is possible to
> set/change a buttons image after it has been created.
> In WIN32Help I found the following but do not understand how to use it.
>
> -- Cut WIN32Help
>
> BM_SETIMAGE
> wParam = 0; // not used, must be zero
> lParam = (LPARAM) (HANDLE) hImage; // handle of the image
>
>
> An application sends a BM_SETIMAGE message to associate a new image
> (icon
> or bitmap) with the button.
>
> Parameters
>
> hImage
>
> Value of lParam. Identifies the image to associate with the button.
>
> Return Value
>
> The return value is the handle of the image previously associated with
> the
> button, if any; otherwise, it is NULL.
>
> Regards
> Tony Steward
>
>
> Come Visit Me At www.locksdownunder.com
>
> Give your hardest tasks to the laziest workers,
> as they will find the easiest way to complete it.
>
>
>