Recent

Author Topic: Groupbox Colour for Text Background  (Read 1096 times)

Badger

  • Full Member
  • ***
  • Posts: 144
Groupbox Colour for Text Background
« on: May 30, 2020, 04:42:03 am »
If I change the colour of a group box in the Object Inspector, the background to the caption remains the old windows default although any label's background colour takes the parent's (groupbox) colour.

I've tried playing with canvases and brushes but can't get the caption background to change.
Badger
(A bad tempered, grumpy animal that sleeps most of the winter!)

If at first you don't succeed - you're running about average!

I'm using Windows 10 Lazarus v2.4.4  FPC 3.2.2   Win 32/64

Handoko

  • Hero Member
  • *****
  • Posts: 5130
  • My goal: build my own game engine using Lazarus
Re: Groupbox Colour for Text Background
« Reply #1 on: May 30, 2020, 05:42:19 am »
I cannot reproduce the behavior on Linux GTK2.

Perhaps you can use a TPanel. Drop a TPanel on the form, set the panel's color. Then put the group box inside the panel.

wp

  • Hero Member
  • *****
  • Posts: 11855
Re: Groupbox Colour for Text Background
« Reply #2 on: May 30, 2020, 12:10:10 pm »
As usual, colors, although they have entries in the Object Inspector, are determined by the widgetset. It depends on the widgetset whether you can change the color of the groupbox caption. That's the price you have to pay for a common appearance of your program.

The groupbox is not drawn by explicit code somewhere in the groupbox unit (stdctrls) nor in the widgetset unit (win32wsstdctrls.pp *), there are no ThemeServices to be called so that something looking like a native groupbox cannot be emulated.

For this reason, I do not see a way to add a "TGroupBoxEx" to the ExCtrls collection where I already put the extended checkboxes and radiobuttons.

If you REALLY need a colored caption you should experiment with a TPanel to which you add a TBevel and a TLabel - then you have all visual details under your control. But you must be aware that this will look different from the native groupboxes...

If you only want to highlight the groupbox caption it is maybe an idea to set Groupbox.Font.Style := [fsBold]; this works in Windows (until Microsoft will decide to disable even this). You should turn off ParentFont of the contained controls before doing this to prevent them becoming bold too.

----------------
(*) There is some text-drawing code in the GroupBoxWindowProc, but this is a workaround for the issue that the caption of a disabled groupbox is not grayed as usual - it will break once Microsoft decides to center the caption instead of left-align it.

Badger

  • Full Member
  • ***
  • Posts: 144
Re: Groupbox Colour for Text Background
« Reply #3 on: May 31, 2020, 12:43:57 am »
Quote
It depends on the widgetset whether you can change the color of the groupbox caption.

I'm not trying to change the colour of the Caption, I am changing the colour of the GroupBox but the caption remains in the default colour.
Badger
(A bad tempered, grumpy animal that sleeps most of the winter!)

If at first you don't succeed - you're running about average!

I'm using Windows 10 Lazarus v2.4.4  FPC 3.2.2   Win 32/64

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: Groupbox Colour for Text Background
« Reply #4 on: May 31, 2020, 03:04:28 am »
The caption is drawn by themes colors.. that's the issue where as the background of the group box is using the color property..

 I recently was looking at that code and almost was willing to change it ;)

 If you run your app without themes then you'll see what you are looking for..
but the again you'll not have that nice in your face MS look ;)
The only true wisdom is knowing you know nothing

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: Groupbox Colour for Text Background
« Reply #5 on: May 31, 2020, 04:40:09 am »
I have a fix for that issue... with themes on..

I just edited a bit..

I'll wait for WP to chime in on it, mean while I need insert a Brush fill because there is a box around the caption of the same size as the border line, not sure if that is the way it should be..

The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018