Suggested bug fix for TGlyphButton
Borland's Object Windows Library for the modern age
Brought to you by:
jogybl,
sebas_ledesma
Hello,
I'm suggesting a bug fix for glyphbtn.cpp.
The setting of the flag 'biDefault' in 'TGlyphButton::SetupWindow' to make the button a default button does not function properly.
The problem is that the complete style (32 bit) is taken for analysis. The better way is to mask the lower part of the style before, like in the functions 'TGlyphButton::BmSetStyle' and 'BButtonProc' in the same file.
original:
void TGlyphButton::SetupWindow()
{
TButton::SetupWindow();
// Update state flags based on current style
//
uint32 style = GetStyle();
if (style & BS_DEFPUSHBUTTON)
Set(biDefault);
if (style & WS_DISABLED)
Set(biDisabled);
...
fix:
void TGlyphButton::SetupWindow()
{
TButton::SetupWindow();
// Update state flags based on current style
//
uint32 style = GetStyle();
uint16 btnStyle = uint16(LoUint16(style) & BUTTONSTYLE_MASK);
if (btnStyle == BS_DEFPUSHBUTTON)
Set(biDefault);
if (style & WS_DISABLED)
Set(biDisabled);
...
Thanks
Jörg
Hello,
you're right, the button styles are defined as
define BS_PUSHBUTTON 0x00000000L
define BS_DEFPUSHBUTTON 0x00000001L
define BS_CHECKBOX 0x00000002L
define BS_AUTOCHECKBOX 0x00000003L
define BS_RADIOBUTTON 0x00000004L
define BS_3STATE 0x00000005L
define BS_AUTO3STATE 0x00000006L
define BS_GROUPBOX 0x00000007L
define BS_USERBUTTON 0x00000008L
define BS_AUTORADIOBUTTON 0x00000009L
...
which means that the test
style & BS_DEFPUSHBUTTON
will be positive for BS_AUTOCHECKBOX and some others ...