1. Setting a button image - Help Please
- Posted by Tony Steward <figjam at nlc.net.au> Jul 30, 2001
- 450 views
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.
2. Re: Setting a button image - Help Please
- Posted by mtsreborn_again at yahoo.com Jul 30, 2001
- 418 views
Doing what you say is quite tricky. What you can do as a better alternative is simple. Instead of creating a PushButton, create a bitmap! When it's clicked, you will know, and you can even change it's image to a 'down state' or something. Mike The Spike --- Tony Steward <figjam at nlc.net.au> 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. > > > > > > > > > > >
3. Re: Setting a button image - Help Please
- Posted by Derek Parnell <ddparnell at bigpond.com> Jul 30, 2001
- 433 views
Win32lib already supports most of this. Here is a reworking of Brian's code... ----------------- -- bmp_btn.exw -- ----------------- include win32lib.ew ----------------------- atom hBmp1, hBmp2, btn_state hBmp1 = loadBitmapFromFile( "btn1.bmp" ) hBmp2 = loadBitmapFromFile( "btn2.bmp" ) btn_state = hBmp1 constant Win = create( Window, "Simple Window", 0, Default, Default, 200, 200, 0 ), Btn = create( PictureButton, "", Win, 20, 20, 40, 40, hBmp1 ) ------------------------------ procedure onClick_Btn() atom result if btn_state = hBmp1 then btn_state = hBmp2 else btn_state = hBmp1 end if result = sendMessage( Btn, BM_SETIMAGE, IMAGE_BITMAP, btn_state ) end procedure onClick[Btn] = routine_id( "onClick_Btn" ) ------------------------------ WinMain( Win, Normal ) ------------------------------ I'll add the this ability in an enhancement to the library. Maybe something along the lines of ... Btn = create( PictureButton, "", Win, 20, 20, 40, 40, {"btn1.bmp","btn2.bmp"} ) and have it do the up-down image swapping. > 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. > > > > > > > > > >
4. Re: Setting a button image - Help Please
- Posted by martin.stachon at worldonline.cz Jul 31, 2001
- 412 views
> > 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 Hi, Tony use this code : sendMessange(control_id, BM_SETIMAGE, 0, handle) where handle can be for example atom handle -- load the bitmap handle= loadBitmapFromFile( "graphic.bmp" ) Regards, Martin