From: Robert M. <rob...@us...> - 2007-04-25 01:06:09
|
Glenn Linderman wrote: >>> -remstyle => BS_AUTOCHECKBOX, >>> -addstyle => BS_CHECKBOX, > > Is there a better way to do this operation? There are no 'options' to do this, if that's what you mean. > Not only does it require > BS_ constants, the order matters... the code shown works in the test > program, but not in my "real" program which runs the parameters through > a hash, which reorders the parameters :( Causing the checkboxes to > actually come out as buttons! The button's 'type' is the bottom 4 bits of the style (see BS_TYPEMASK). A Win32::GUI::Checkbox is type BS_AUTOCHECKBOX (=3) and you want BS_CHECKBOX (=2). (3 & ~3) | 2 = 2 (BS_CHECKBOX) but (3 | 2) & ~3 = 0 (0 = BS_PUSHBUTTON) -remstyle => 1 should do what you want: 3 & ~1 = 2 but it'll need a good comment to make it maintainable :-( As an alternative you might be able to use a button, and add BS_CHECKBOX, and then re-bless the resulting object into the checkbox class. Something like this (untested): my $cb = $mw->AddButton( -addstyle => BS_CHECKBOX, ... ); bless $cb, "Win32::GUI::Checkbox"; The bless may be unnecessary, depending on which class methods you need to be able to call. Regards, Rob. |