1. Home
  2. Computing & Technology
  3. Delphi Programming

TButton with multiline Caption

By Zarko Gajic, About.com

The next procedure sets Captions on all TButton Controls on a given Parent to be multi-lined...

~~~~~~~~~~~~~~~~~~~~~~~~~
procedure SetMultiLineButton(AParent: TWinControl) ;
var j : integer;
     ah : THandle;
begin
for j := 0 to AParent.ControlCount - 1 do
  if (AParent.Controls[j] is TButton) then
  begin
    ah := (AParent.Controls[j] as TButton).Handle;
    SetWindowLong(ah, GWL_STYLE,
      GetWindowLong(ah, GWL_STYLE) OR
BS_MULTILINE) ;
  end;
end;

{
usage: suppose there is a
Button1 and Button2 on Form1,
Button3 and Button4 on Panel1 on Form1
by calling the next line

SetMultiLineButton(Panel1)

only Button3 and Button4 will have
multi-lined caption.
}
~~~~~~~~~~~~~~~~~~~~~~~~~

Delphi tips navigator:
» Set File Date (created)
« Is Point in Polygon?

Zarko Gajic
Guide since 1998

Zarko Gajic
Delphi Programming Guide

Explore Delphi Programming
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Coding Delphi Applications
  5. Delphi Tips and Tricks
  6. 2001 Delphi Tips
  7. TButton with multiline Caption

©2009 About.com, a part of The New York Times Company.

All rights reserved.