在TButton中显示多行Caption
【打印文章】
procedure TForm1.Button1Click(Sender: TObject);
begin
SetCaption(button1,'第一行','第二行',form1.Color);
end;
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;
begin
SetCaption(button1,'第一行','第二行',form1.Color);
end;
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;
本栏文章均来自于互联网,版权归原作者和各发布网站所有,本站收集这些文章仅供学习参考之用。任何人都不能将这些文章用于商业或者其他目的。( Pfan.cn )
【编程爱好者论坛】