Sizing a TRadioGroup at runtime lazarus / 10-Designer ---------------------------------------------------------------------- Bart · 2007-03-12 13:48 Hi, For a new component I'm designing, I create a TRadioGroup at runtime and place it on a panel. Now the radiogroup holds two items in two columns. The item "captions"  are resource strings as is the RadioGroup's caption. These then may be altered by translations. Now I want to "sculpt" the RadioGroup so that is is as small as possible (widht, height), whilst ensuring that all captions are still readable. So, I thougth: I need to know the width and height of each item, including the radiobutton, the height of the radiogroup.caption etc, all OS independent. This is where I get stuck. TRadioGroup AFAIK provides no info about that. Anybody got some suggestions as on how to approach this? Bart ---------------------------------------------------------------------- antonio · 2007-03-30 01:06 Your idea is interesting... You have Canvas.TextHeight and Canvas.TextWidth to measure the strings. ---------------------------------------------------------------------- Bart · 2007-04-15 15:35 But TRadioGroup has no canvas... I decided to use 2 radiobuttons and a bevel instead. This works fine for me right now. Bart ---------------------------------------------------------------------- antonio · 2007-04-22 12:09 Maybe the ancestor has Canvas property protected.   type     trg = class(tcustomradiogroup)   end; var   rg:trg; implementation procedure TForm1.FormCreate(Sender: TObject); var   i :integer; begin   rg := trg.create(self);   rg.align := alleft;   rg.parent := form1;   rg.caption := 'custom_radio_group';   rg.items.add('one');   rg.items.add('two');   rg.items.add('threeeeeeeeeeeeeeeeeee');   rg.items.add('four');   rg.items.add('five');   rg.items.add('six');   rg.items.add('seven');   rg.width := 40 + rg.canvas.textwidth(rg.items[0]);   for i := 1 to rg.items.count -1 do       if (40 + rg.canvas.textwidth(rg.items) > rg.width) then          rg.width := 40 + rg.canvas.textwidth(rg.items); end; procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); begin   rg.free; end;