如何设置一个按钮用有多行Caption?
procedure TForm1 . Button1Click ( Sender : TObject );
var
i : Integer ;
begin
i := GetWindowLong ( Button1 . Handle , GWL_STYLE );
SetWindowLong ( Button1 . Handle , GWL_STYLE , i or BS_MULTILINE );
Button1 . Caption := 'Line1' + #13#10 + 'Line2' ;
end ;
改成CheckBox等一样可以。
---------------------------------------
免代码的设置:
Title: Word wrapped TButton
Author: Tomas Rutkauskas
Product: Delphi 2.x (or higher)
Post Date: 08/24/2002
Problem/Question/Abstract:
Word wrapped TButton
Answer:
If you want to have your TButton objects displayed with wrapped caption, you will notice that this is not possible - not possible without a little trick.
Of course, you could search the web for some third-party component, but there's an easier way to accomplish this. Just follow these steps:
(idea from Richard B. Winston:) Select the button and then "Component|Create Component Template". After you choose a name and palette page for the template, you will be able to select the button with embedded label from the component palette and use it just like any other component.
//(before step 4)
object Button1: TButton Left = 176 Top = 184 Width = 75 Height = 25 Caption = '' TabOrder = 2endobject Label1: TLabel Left = 200 Top = 168 Width = 32 Height = 13 Caption = 'My long caption' WordWrap = Trueend
// (after step 4)
object Button1: TButton Left = 176 Top = 184 Width = 75 Height = 25 Caption = '' TabOrder = 2 object Label1: TLabel Left = 2 Top = 2 Width = 32 Height = 13 Caption = 'My long caption' WordWrap = True endend