Mega Code Archive

 
Categories / Delphi / Ide Indy
 

TSpeedButton Left Align Caption Left Justify Delphis TSpeedButton Caption Text

Title: TSpeedButton Left Align Caption - Left Justify Delphi's TSpeedButton Caption Text Delphi provides three "standard" button types for your applications : TButton, TBitButton and TSpeedButton. The TButton is a wrapper for the standard Windows push button control. TBitBtn (bitmap button) which provides properties that specify the bitmap images, along with their appearance and placement on the button. TSpeedButton introduces properties that allow speed buttons to work together as a group. TSpeedButton Glyph and Caption and Layout In general, when you need graphics on a button you'll use a TBitBtn. When you are building a toolbar you'll use a TSpeedButton. The Glyph property of a TSpeedButton let's you select a bitmap image to be displayed in a button to represent different button states (selected, unselected, disabled and so on). The Layout property determines where the image or text appears on the speed button. The image can be placed left to the button caption, right, above or below. TSpeedButton Caption Alignment When you have a group of speed buttons one after another in vertical "line", with Layout set to blGlyphLeft the buttons do not look so nice. What you might start looking for is the "Caption Layout" property to let you set the alignment of the button caption. Sadly, you'll find no such property :( Or, would you? TSpeedButton and the Margin property The TSpeedButton's Margin property specifies the number of pixels between the edge of the button and the image or caption drawn on its surface. When Margin is –1, the default value, the image or text is centered on the button. If you want the caption to be aligned left you need to specify the indentation of the image specified by the Glyph property or the text specified by the Caption property. The edges that Margin separates depends on the Layout property. When Layout is blGlyphLeft, the margin appears between the left edge of the image or caption and the left edge of the button. When Layout is blGlyphRight, the margin separates the right edges. When Layout is blGlyphTop, the margin separates the top edges. When Layout is blGlyphBottom, the margin separates the bottom edges. Therefore when a speed button has a Glyph with Layout set to blGlyphLeft and you want the Caption also to align left - just specify Margin to a positive value. Yes, that simple.