BBC BASIC for Windows
Programming >> User Interface >> Tool Button States
http://bb4w.conforums.com/index.cgi?board=ui&action=display&num=1413126271

Tool Button States
Post by Matt on Oct 12th, 2014, 3:04pm

Hi,

In the BB4W help some of the the tool button states are listed as:

0 Disabled
4 Enabled
6 Pressed
8 Hidden

The bottom three are from a combination of the Window's constants:

TBSTATE_ENABLED = 4
TBSTATE_PRESSED = 2
TBSTATE_HIDDEN = 8

But neither the MSDN or WINCONSTANT suggests what the constant label is for 'Disabled'. I've tried various combination of words (e.g. TBSTATE_DISABLED), but apart from adding to my own contant table TBSTATE_DISABLED = 0, I can't figure out if there's supposed to be a Window's constant for it. Any ideas?

Matt
Re: Tool Button States
Post by rtr2 on Oct 12th, 2014, 5:30pm

on Oct 12th, 2014, 3:04pm, Matt wrote:
I can't figure out if there's supposed to be a Windows constant for it.

No, there isn't - 'disabled' is simply 'not enabled'.

Richard.

Re: Tool Button States
Post by Matt on Oct 12th, 2014, 6:50pm

on Oct 12th, 2014, 5:30pm, g4bau wrote:
No, there isn't - 'disabled' is simply 'not enabled'.

OK. That's interesting.

Would the normal routine, then, be to get the state first (e.g.):

SYS "SendMessage", HTool%, TB_GETSTATE, Butt%, 0 TO state%
SYS "SendMessage", HTool%, TB_SETSTATE, Butt%, state% AND NOT TBSTATE_ENABLED

rather than arbitrarily setting the state? (e.g.):

SYS "SendMessage", HTool%, TB_SETSTATE, Butt%, TBSTATE_ENABLED

Matt
Re: Tool Button States
Post by rtr2 on Oct 12th, 2014, 8:23pm

on Oct 12th, 2014, 6:50pm, Matt wrote:
Would the normal routine, then, be to get the state first ... rather than arbitrarily setting the state?

I've no idea what is "normal" since I've not studied other people's code. I can only say what is obviously the case: the only time one would need to use the read-modify-write procedure is if it is necessary to change the state of one (or more) bits whilst preserving the remaining bits in an unchanged - but unknown - state.

To me that sounds like an uncommon requirement. In a typical application most of the state bits will be pre-defined and remain unchanged. For example you would be very unlikely to want to change the TBSTATE_ELLIPSIS or TBSTATE_WRAP bits dynamically, so going to the trouble of reading the state first just to ensure those bits are unaltered is extra work, you might just as well set the required bits every time.

But in a situation when you do need to preserve the state of a bit that you don't know (for example disable a button without altering its 'pressed' state) then the procedure you describe is the way to do it.

Richard.