Scalabium Software

SMReport Autogenerated
Knowledge for your independence'.
Home Delphi and C++Builder tips


#167: How can I change the alignment for TButton?

As you know, by default the TButton paints the caption in the center (horizontal and vertical align)

But you may easy to change this behaviour.

For example, the next code will change the alignment to right (horizontal) and bottom (vertical):

var
  defstyle: dWord;
begin
  defstyle := GetWindowLong(yourTButton.Handle, GWL_STYLE);
  SetWindowLong(yourTButton.Handle, GWL_STYLE, defstyle or BS_BOTTOM or BS_RIGHT);
end;

Or just to use the left justify:

SetWindowLong(yourTButton.Handle, GWL_STYLE, defstyle or BS_LEFT);

Just execute this code in OnCreate event for your form (where TButton is)

The available consts declared in Windows.pas:

BS_LEFT = $100;
BS_RIGHT = $200;
BS_CENTER = 768;
BS_TOP = $400;
BS_BOTTOM = $800;
BS_VCENTER = 3072;


Published: October 11, 2005

See also
 
ABA Picture Convert
Paradox Password Recovery
Viewer for TNEF-files (winmail.dat)
ABA Database Convert
ABA Spreadsheet Convert
ABA Document Convert
Paradox to Text converter
MAPIMail
Excel Web-stream
Metafile Convert
 
 


Contact to webmaster

 

Borland Software Code Gear Scalabium Delphi tips

Copyright© 1998-2024, Scalabium Software. All rights reserved.
webmaster@scalabium.com

SMExport advertising