i have created dynamic button with code below, the button caption is too long so i have to change the size of the caption to fit the button width but the wordwrap seen to be not function at all.
var
Reg: TRegistry;
lstKey, lstSubKey : TStringList;
sKeyName, sSubKeyName : string;
i, j, iSize, iSize2, iTop, iSpace, iComp : integer;
begin
lstKey := TStringList.Create;
lstSubKey := TStringList.Create;
lstBtnName := TStringList.Create;
Reg := TRegIniFile.Create;
try
Reg.OpenKeyReadOnly('registryPath');
Reg.GetKeyNames(lstSubKey); // get registry key
Reg.CloseKey;
iSize := 5;
iSize2 := 5;
iTop := 5;
iSpace := 5;
if ScrollBox1.ControlCount > 0 then begin
for j := ScrollBox1.ControlCount - 1 downto 0 do begin
with ScrollBox1.Controls[j] AS TBitBtn do begin
Free;
end;
end;
end;
for i := 0 to lstSubKey.Count - 1 do begin
with TBitBtn.Create(self) do begin // create dynamic buttons
Parent := ScrollBox1;
Height := 50;
Width := 50;
if iSize > ((Width + iSpace) * 3) then begin //2nd row, 3 btns in 1 row
Left := iSize2;
iSize2 := iSize2 + Width + iSpace;
Top := iTop + Height + iSpace;
end else begin //1st row
Left := iSize;
iSize := iSize + Width + iSpace;
Top := iTop;
end;
Caption := lstSubKey.Strings[i];
WordWrap := TRUE;
end;
end;
finally
lstKey.Free;
lstSubKey.Free;
Reg.Free;
end;
end;