How to toggle a button

Share your advanced PureBasic knowledge/code with the community.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Shagwana.

When you create a image or text button, it will return a handle. With this handle you can toggle it (set it into a up/down state) using;

SendMessage_(handle,#BM_SETSTATE,1,0)

and...

SendMessage_(handle,#BM_SETSTATE,0,0)

Might also be usefull on other types of gadgets. Maybe someone will find that usefull?

http://www.sublimegames.com
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by TronDoc.

I've said this before, and some folks are doing it,
but it would be nice when code is
presented to always have a way of knowing which
O.S. the code is applicable to and whether
or not an external library, .dll, API
call or whatever is required...
Joe


Edited by - TronDoc on 09 February 2002 11:47:57
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Shagwana.

Its a windows api function and works on 98,2000 and XP as far as i know!

http://www.sublimegames.com
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.
SendMessage_(handle,#BM_SETSTATE,1,0)
SendMessage_(handle,#BM_SETSTATE,0,0)
The above is good for manually toggling a button's state, but if you'd rather
have Windows do the toggling for you, just create a CheckBox (yes!) like so:

; CheckBox looks and acts like a toggle button.
cb=CheckBoxGadget(#Gadget, x, y, Width, Heigth, Text$)
SetWindowLong_(cb,#GWL_STYLE,GetWindowLong_(cb,#GWL_STYLE)|$1000)

PB - Registered PureBasic Coder

Edited by - PB on 17 February 2002 10:58:25
Post Reply