BitBtn WordWrap özelliği True yapıldığında, XE sürümü içinde bulunan temalardan birini seçtiğim de Btn üzrerinde yazan ismin Sola Hizalı olduğunu farkettim. Normal temada olduğu gibi ortalama yapabilirmiyiz?
Teşekkürler.

Kod: Tümünü seç
MultiLine_Yap( self );
Kod: Tümünü seç
procedure MultiLine_Yap( Form: TForm );
Var
i : Integer;
iSay, iMax : Integer;
Liste : TStringList;
strBaslik : String;
begin
Liste := TStringList.Create;
for I := 0 to Form1.ComponentCount-1 do
begin
if Form.Components[i] is TBitBtn then
begin
Liste.Clear;
strBaslik := StringReplace( TBitBtn(Form.Components[i]).Caption, #10, '|', [rfReplaceAll]) + '|';
while Pos('|', strBaslik) > 0 do
begin
Liste.Add( Trim( Copy(strBaslik, 1, Pos('|', strBaslik)-1) ) );
System.Delete(strBaslik, 1, Pos('|', strBaslik));
end;
if Assigned( TStyleManager.ActiveStyle )
and ( TStyleManager.ActiveStyle.Name <> 'Windows' ) then
begin // Style varsa caption ortalama sorunu vardır, biz çözelim...
iMax := 0;
for iSay := 0 to Liste.Count-1 // En büyük satır uzunluğunu buluyoruz.
do if Length(Liste[iSay]) >= iMax
then iMax := Length( Liste[iSay] );
for iSay := 0 to Liste.Count-1 // Başına yeteri kadar boşluk ekliyoruz...
do Liste[iSay] := StringOfChar(' ', (iMax-Length(Liste[iSay])) div 2) + Liste[iSay];
end;
strBaslik := '';
for iSay := 0 to Liste.Count-1 do
if strBaslik = '' then strBaslik := Liste[iSay]
else strBaslik := strBaslik + #10 + Liste[iSay];
TBitBtn(Form.Components[i]).Caption := strBaslik;
end;
end;
Liste.Free;
end;