Bug: Forecolor of GroupBox text is ignored

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Bug: Forecolor of GroupBox text is ignored

Richard
I tried to find the cause, but my lack of Win32 knowledge stumps me.

Reproduction:
    Start on a fresh Dolphin 5.03 image.
    Start View Composer
    Create a new ShellView
    Add a GroupBox
        Set text to e.g.: "Baffled"
        Set forecolor to e.g.: Green

Error:
    The text of the GroupBox remains in the default color.

This error occurs in the same way outside the View Composer
when running a ShellView.

To find out if the bug was in the ViewComposer or the GroupBox
class, I overloaded the method 'forecolor' in GroupBox to
set a breakpoint before calling forecolor in the super class.

Tracing along I see that the correct, modified color is returned (Green),
and this color is used when ultimately calling the method:
    GDILibrary>>setTextColor:crColor.

There's no special handling of text / color in the GroupBox class.
All is done with standard Win32 handling.

Then I tried it in C# with VS.NET 2003B2. That worked OK :-).
So what's going on with Dolphin here?

Thanks,
Richard


Reply | Threaded
Open this post in threaded view
|

Re: Forecolor of GroupBox text is ignored

Blair McGlashan
"Richard" <[hidden email]> wrote in message
news:3e6aa500$0$49109$[hidden email]...

> I tried to find the cause, but my lack of Win32 knowledge stumps me.
>
> Reproduction:
>     Start on a fresh Dolphin 5.03 image.
>     Start View Composer
>     Create a new ShellView
>     Add a GroupBox
>         Set text to e.g.: "Baffled"
>         Set forecolor to e.g.: Green
>
> Error:
>     The text of the GroupBox remains in the default color.

This is a limitation of the Windows BUTTON control (yes GroupBox's are
buttons for some inexplicable reason). From MSDN on WM_CTLCOLORBTN:

"Buttons with the BS_PUSHBUTTON, BS_DEFPUSHBUTTON, or BS_PUSHLIKE styles do
not use the returned brush. Buttons with these styles are always drawn with
the default system colors. Drawing push buttons requires several different
brushes-face, highlight and shadow-but the WM_CTLCOLORBTN message allows
only one brush to be returned. To provide a custom appearance for push
buttons, use an owner-drawn button."

This help isn't quite correct, because the same is also true of BS_GROUPBOX,
as you've discovered. As you can see MS don't regard this as a bug, because
they use a single message to request a correctly set up DC, yet require more
than one message (and DC) to do the job properly!

> ...
> Then I tried it in C# with VS.NET 2003B2. That worked OK :-).
> So what's going on with Dolphin here?

Dolphin is using the standard Windows control. I'd guess that the .Net
framework either does not, or implements the button using owner draw (i.e.
it may really be emulating the widget).

Regards

Blair


Reply | Threaded
Open this post in threaded view
|

Re: Forecolor of GroupBox text is ignored

Richard
"Blair McGlashan" <[hidden email]> wrote in message
news:b4hnom$2047ml$[hidden email]...
> "Richard" <[hidden email]> wrote in message
> news:3e6aa500$0$49109$[hidden email]...
> > I tried to find the cause, but my lack of Win32 knowledge stumps me.
> > <Reproduction snipped>
> > Error:
> >     The text of the GroupBox remains in the default color.
>
> This is a limitation of the Windows BUTTON control (yes GroupBox's are
> buttons for some inexplicable reason).

Yep, I saw your funny code comment :-)

> From MSDN on WM_CTLCOLORBTN:
> "Buttons with the BS_PUSHBUTTON, BS_DEFPUSHBUTTON, or BS_PUSHLIKE styles
do
> not use the returned brush. <etc, etc>.

OK. I suspected something like this. The Dolphin code looked clean.

Life's too short to grapple with this Win32 weirdness. I just put a static
text control in place of the groupbox text. This gives the desired visual
result.

Thanks for the explanation,
Richard