Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi TButton align to left (https://www.delphipraxis.net/84493-tbutton-align-left.html)

mr_fahrrad 17. Jan 2007 15:57


TButton align to left
 
How i make to align to left a text in the Button component?

Idont find solution for this, anybody can helpme?

MrKnogge 17. Jan 2007 16:08

Re: TButton align to left
 
Moin mr_fahrrad,

du musst dir eine eigene Komponente vom Typ TButton ableiten und die Eigenschaft Align selbst hinzufügen.
Welche Delphi-Version hast du ?

Gruß

DGL-luke 17. Jan 2007 16:12

Re: TButton align to left
 
Maybe TSpeedButton or TBitButton have a text-align property...

If you have to draw the text yourself (e.g. following MrKnogge's suggestion), you might want to draw the text yourself: MSDN-Library durchsuchenDrawText.

On the other Hand, you should be able to tell the WinAPI to align the text... but I don't know how.

marabu 17. Jan 2007 16:39

Re: TButton align to left
 
Hi Lukas,

Zitat:

Zitat von DGL-luke
... On the other Hand, you should be able to tell the WinAPI to align the text... but I don't know how.

it is a matter of style:

Delphi-Quellcode:
procedure TDemoForm.ButtonClick(Sender: TObject);
var
  dwStyle: LongWord;
begin
  with Sender as TButton do
  begin
    dwStyle := GetWindowLong(Handle, GWL_STYLE);
    dwStyle := dwStyle and not BS_CENTER or BS_LEFT;
    SetWindowLong(Handle, GWL_STYLE, dwStyle);
    Invalidate;
  end;
end;
Regards


Alle Zeitangaben in WEZ +1. Es ist jetzt 08:38 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz