建立个单元,放个按钮,然后用下面的替换掉那个unit单元即可<br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, StdCtrls;<br><br>type<br> TForm1 = class(TForm)<br> Button1: TButton;<br> procedure FormCreate(Sender: TObject);<br> procedure Button1Click(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.dfm}<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br> canvas.Brush.Style:=bsSolid;<br> canvas.Brush.Color:=clwhite;<br> canvas.FillRect(canvas.cliprect);<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var R:Trect;<br> s:string;<br>begin<br> s:='this is delphi''s drawtext programe';<br> canvas.Font.Size:=12;<br> R:=Rect(10,10,80,100);<br> canvas.Rectangle(r.Left-2,r.Top-2,r.Right+2,r.Bottom+2);<br> drawtext(canvas.Handle,pchar(s),-1,R,dt_wordbreak or dt_center);<br>end;<br><br>end.