怪事,,真怪!!TextOut问题(10分)

  • 主题发起人 主题发起人 abencat
  • 开始时间 开始时间
A

abencat

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>&nbsp; TextOut(image1.Canvas.Handle,1,1,'qw',2);<br>end;<br>procedure TForm1.Button2Click(Sender: TObject);<br>begin<br>&nbsp; &nbsp;TextOut(image1.Canvas.Handle,10,10,'qw',2);<br>end;<br>先执行哪个都可以,第一个可以在Image1上显示,第2个却不能在Image1上显示??????<br>(要用API函数处理)
 
为什么不这样:<br>&nbsp;image1.Canvas.TextOut(10,10,'qw');<br>&nbsp;image2.Canvas.TextOut(10,10,'qw');<br><br>用你的方法也可以呀,我用的是 Delphi5+Win2k server + sp2<br>
 
没刷新的缘故...这样看看..<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>&nbsp; TextOut(image1.Canvas.Handle,1,1,'qw',2);<br>&nbsp; &nbsp;Image1.Refresh;<br><br>end;<br><br>procedure TForm1.Button2Click(Sender: TObject);<br>begin<br>&nbsp; &nbsp;TextOut(image1.Canvas.Handle,10,10,'qw',2);<br>&nbsp; &nbsp;Image1.Refresh;<br>end;<br>
 
//为什么这样都不行呀????<br>var<br>&nbsp; Form1: TForm1;<br>&nbsp; iHDC :HDC;<br>implementation<br>{$R *.dfm}<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>&nbsp; iHDC :=Image1.Canvas.Handle ;<br>&nbsp; Textout(ihdc,1,1,'dd',2);<br>&nbsp; Image1.Refresh;<br>end;<br>procedure TForm1.Button2Click(Sender: TObject);<br>begin<br>&nbsp; &nbsp;Textout(ihdc,10,10,'dd',2);<br>&nbsp; &nbsp;Image1.Refresh;<br>end;<br><br>end.<br>
 
//这样也不可以的<br>&nbsp; iHDC :integer;<br>implementation<br>{$R *.dfm}<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>&nbsp; Textout(iHDC,1,1,'dd',2);<br>&nbsp; Image1.Refresh;<br>end;<br>procedure TForm1.Button2Click(Sender: TObject);<br>begin<br>&nbsp; &nbsp;Image1.Refresh;<br>&nbsp; &nbsp;Textout(iHDC,10,10,'dffffdff',10);<br>&nbsp; &nbsp;Image1.Refresh;<br>end;<br><br>procedure TForm1.FormShow(Sender: TObject);<br>begin<br>&nbsp; &nbsp; iHDC :=Image1.Canvas.Handle;<br>end;<br><br>
 
procedure TForm1.Button2Click(Sender: TObject);//上一问<br>begin<br>&nbsp; &nbsp;iHDC :=Image1.Canvas.Handle ;//加上这句<br>&nbsp; &nbsp;Textout(ihdc,10,10,'dd',2);<br>&nbsp; &nbsp;Image1.Refresh;<br>end;<br><br>设断点可以看到,每点击一次,Image1.Canvas.Handle的值都会改变。<br><br>追加:<br>在FormShow事件中加上image1.Canvas.Lock;
 
后退
顶部