发信人: bird_lee() 
整理人: catmail(2000-12-05 19:04:37), 站内信件
 | 
 
 
Windows API可以给我们的程序带来许多的方便,现在我们便来讨论一个使用
 PaintDeskop。
   PaintDesktop是一个在WindowsNT中可以用的Api.
   我们首先做一个简单的例子。
 procedure TForm1.Button1Click(Sender:TObject);
 begin
    PaintDesktop(Canvas.handle);
 end;
 
 点击一下button1,你可以发现你的应用程序的背景是桌面的一部分。
 但是如果你的程序中有TLabel,TImage等东西,你会发现它们都消失了,这是
 因为你还没有对它们进行重绘。如果我们要对所有的TLabel进行重画。可以用
 下面的过程。
 procedure PaintWithDesktop(AForm:TForm);
 var
   i: integer;
 begin
   with AForm do 
   begin
     PaintDeskTop(Canvas.handle);
     for i:=0 to ControlCount-1 do
       if Controls[i] is TGraphicControl then
         Controls[i].perform(WM_PAINT, TLabel(Controls[i]).canvas.handl e, 0);
   end; 
 end;
 
 如果我们要使程序自动的重画,只要在WM_MOVE,WM_Paint,写下以下代码。
 
 procedure TForm1.WMMove(var Message: TWMMove);
 begin
   inherited;
   PaintWithDesktop(self);
 end;
 
 procedure TForm1.WMPaint(var Message: TWMPaint);
 begin
   inherited;
   PaintWithDesktop(self);
 end;
  -- Delphi Fans
 http://delfan.yeah.net
 Delphi Fans,技巧集(太多了),控件,源码
  ※ 来源:.月光软件站 http://www.moon-soft.com.[FROM: 202.101.113.205]
  | 
 
 
 |