Autor Beitrag
hathor
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Do 08.02.07 15:15 
Ich möchte den Text rechtsbündig oder linksbündig, statt zentriert - ich bin sicher, so eine Lösung kürzlich gelesen zu haben...finde es nicht mehr.

Habe BDS2006.

Habe in der Zwischenzeit weitergesucht:


//---------------------------------------------------------------------------
// Horizontale Ausrichtung der Caption des TButtons ändern:
//---------------------------------------------------------------------------

DWORD dwStyle = GetWindowLong(Button1->Handle, GWL_STYLE);
dwStyle = dwStyle | BS_RIGHT; //(oder BS_LEFT, oder BS_CENTER)
SetWindowLong(Button1->Handle, GWL_STYLE, dwStyle);
Button1->Invalidate();

..und das in Delphi (und gleich mehrzeilig):

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
function SetMultiLineCaption(const p_Button : TButton;const p_sCaption : String;const p_fAutoAdjust : Boolean = false) : Boolean;
begin
  Result := false;
  if SetWindowLong(p_Button.Handle, GWL_STYLE, GetWindowLong(p_Button.Handle, GWL_STYLE) or BS_MULTILINE)> 0 then
  begin
    p_Button.Caption := p_sCaption;
    Result := true;
  end;
end;
function TextAlignCaption(const p_Button : TButton;const p_sCaption : String;const p_fAutoAdjust : Boolean = false) : Boolean;
//var dwStyle : Dword;
begin
  Result := false;
//  BS_LEFT BS_RIGHT oder BS_CENTER
  if SetWindowLong(p_Button.Handle, GWL_STYLE, GetWindowLong(p_Button.Handle, GWL_STYLE) or BS_LEFT)> 0 then
  begin
    p_Button.Caption := p_sCaption;
    Result := true;
  end;

end;

procedure TForm1.Button12Click(Sender: TObject);
begin
  SetMultiLineCaption(self.Button12,'Und noch'#13#10'mehr Zeilen',true);
  TextAlignCaption(self.Button12,'Und noch'#13#10'mehr Zeilen',true);
end;