Question

I need a small example on Delphi 5 on how the text of the items present in a radiogroup to wrap text if needed.

I resolved it in Delphi 2006 by accessing buttons property, but in D5 this property does not exist.

LE: is there any solution except than SetWindowLong ?

Was it helpful?

Solution 2

done.

procedure TForm1.Button1Click(Sender: TObject);
var
 i: Integer;
 rbs: DWORD;
 rb: TRadioButton;
begin
 with RadioGroup1 do
 begin
  for i := 0 to ControlCount-1 do
   begin
    rb := radiogroup1.controls[i] as TRadioButton;
    rbs := GetWindowLong(rb.Handle, GWL_STYLE);
    rbs := rbs or BS_MULTILINE or BS_TOP;
    SetWindowLong(rb.Handle, GWL_STYLE, rbs);
   end ;
   Invalidate;
 end ;
end;

OTHER TIPS

You can get the buttons easily enough in Delphi 5 by iterating over the Controls property of the radio group. But then what are you going to do to make them wrap? The Delphi 5 radio button does not have a WordWrap property.

If I were you I would add a bunch of radio buttons to a group box rather than use a radio group. This gives you control over exactly what class of radio button you create. Then derive your own radio button class and implement the WordWrap property. To do this you need to add the BS_MULTILINE style in CreateParams, just as modern Delphi versions do.

Of course, the method outlined in your answer would work too!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top