[Lazarus] Setting a groupbox caption bold?

Bo Berglund bo.berglund at gmail.com
Mon Apr 1 13:54:07 CEST 2019


On Mon, 1 Apr 2019 00:42:45 +0200, Werner Pamler via lazarus
<lazarus at lists.lazarus-ide.org> wrote:

>Am 01.04.2019 um 00:09 schrieb Bo Berglund via lazarus:
>> I have a configuration setting form where I have used group boxes to
>> collect properties that belong together.
>> But the groupbox border is not really well defined so I would like to
>> be able to augment the form visually by setting the caption of the
>> group boxes to bold.
>> But I find no such property for the group box...
>>
>> Is there a way or am I out of luck?
>
>I use this code for TGroupbox, TRadiogroup and TCheckGroup:
>
>procedure BoldGroup(AControl: TWinControl);
>var
>   i: Integer;
>   propinfo: PPropInfo;
>   cntrl: TControl;
>   fnt: TFont;
>begin
>   for i:=0 to AControl.ControlCount-1 do begin
>     cntrl := AControl.Controls[i];
>     propinfo := GetPropInfo(cntrl, 'ParentFont');
>     if propinfo <> nil then
>       SetOrdProp(cntrl, propinfo, Longint(false));
>     propinfo := GetPropInfo(cntrl, 'Font');
>     if propinfo <> nil then begin
>       fnt := TFont(GetObjectProp(cntrl, 'Font'));
>       fnt.Style := [];
>       SetObjectProp(cntrl, 'Font', fnt);
>     end;
>   end;
>   AControl.Font.Style := [fsBold];

I don't really understand what the loop accomplishes...
I don't want to touch the controls inside the group box, just the
group box caption itself...

Could you please show how this would be used for one of my group
boxes? Do I call it inside the form.OnCreate or form.OnShow?

Today I do stuff in OnShow to hide/show group boxes depening on ini
file content so this might be where I'd do this.
Or should it be in OnCreate?


-- 
Bo Berglund
Developer in Sweden



More information about the lazarus mailing list