jsxjd说得是对的。
Kingron (2001-4-10 15:03:12)
----------------------------------------
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
procedure SetCaption(AButton: TButton;
ACaption1,ACaption2: string;color:TColor);
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.SetCaption(AButton: TButton;
ACaption1,
ACaption2: string;color:TColor);
var
dc:Hdc;
info:tagsize;
begin
AButton.Caption:='';
dc:=GetDC(AButton.Handle);
SetBKColor(dc,Color);
//SetBkMode(dc, TRANSPARENT);
GetTextExtentPoint32(dc,pchar(ACaption1),length(ACaption1),info);
Textout(dc,AButton.Width div 2-info.cx div 2,AButton.Height div 2-info.cy,pchar(ACaption1),length(ACaption1));
GetTextExtentPoint32(dc,pchar(ACaption2),length(ACaption2),info);
TextOut(dc,AButton.width div 2-info.cx div 2,AButton.Height div 2,pchar(ACaption2),length(ACaption2));
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
SetCaption(button1,'First Line','Second Line',clred);
end;
end.