这样就OK了.<br><br>unit Unit1;<br>interface<br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br> ExtCtrls, StdCtrls;<br><br>type<br> TForm1 = class(TForm)<br> Button1: TButton;<br> Panel1: TPanel;<br> Button2: TButton;<br> procedure FormDestroy(Sender: TObject);<br> procedure FormCreate(Sender: TObject);<br> procedure Button1Click(Sender: TObject);<br> procedure Button2Click(Sender: TObject);<br> procedure FormResize(Sender: TObject);<br> private<br> { Private declarations }<br> procedure DoVisible;<br> procedure DoInvisible;<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br> FullRgn, ClientRgn, CtlRgn : THandle;<br><br>implementation<br><br>{$R *.DFM}<br><br>procedure TForm1.DoInvisible;<br>var<br> AControl : TControl;<br> A, Margin, X, Y, CtlX, CtlY : Integer;<br>begin<br> Margin := ( Width - ClientWidth ) div 2;<br> FullRgn := CreateRectRgn(0, 0, Width, Height);<br> X := Margin;<br> Y := Height - ClientHeight - Margin;<br> ClientRgn := CreateRectRgn( X, Y, X + ClientWidth, Y + ClientHeight );<br><br> CombineRgn( FullRgn, FullRgn, ClientRgn, RGN_DIFF );<br><br> for A := 0 to ControlCount - 1 do begin<br> AControl := Controls[A];<br> if ( AControl is TWinControl ) or ( AControl is TGraphicControl )<br> then with AControl do begin<br> if Visible then begin<br> CtlX := X + Left;<br> CtlY := Y + Top;<br> CtlRgn := CreateRectRgn( CtlX, CtlY, CtlX + Width, CtlY + Height );<br> CombineRgn( FullRgn, FullRgn, CtlRgn, RGN_OR );<br> end;<br> end;<br> end;<br><br> SetWindowRgn(Handle, FullRgn, TRUE);<br>end;<br><br>procedure TForm1.FormDestroy(Sender: TObject);<br>begin<br><br> DeleteObject(ClientRgn);<br> DeleteObject(FullRgn);<br> DeleteObject(CtlRgn);<br>end;<br><br>procedure TForm1.DoVisible;<br>begin<br> FullRgn := CreateRectRgn(0, 0, Width, Height);<br> CombineRgn(FullRgn, FullRgn, FullRgn, RGN_COPY);<br> SetWindowRgn(Handle, FullRgn, TRUE);<br>end;<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br> DoInvisible;<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br> if Button1.Caption = 'Show Form' then begin<br> DoVisible;<br> Button1.Caption := '隐藏窗口';<br> end<br> else begin<br> DoInvisible;<br> Button1.Caption := '显示窗口';<br> end;<br>end;<br><br>procedure TForm1.Button2Click(Sender: TObject);<br>begin<br> Application.Terminate;<br>end;<br><br>procedure TForm1.FormResize(Sender: TObject);<br>begin<br> if Button1.Caption = '显示窗口' then<br> DoInvisible<br> else<br> DoVisible;<br>end;<br>end.<br><br>呵 呵.兄弟加分啊.我没分了.不好意思.快啊.<br>