窗体上打个矩形的洞

step1 在窗体上打个矩形的洞{鼠标可以穿透这个窗体}
procedure MakeRectHole(Ctrl:TWinControl;Form:TForm);
var
  Rgn1, Rgn2: HRGN;
begin
  Rgn1 := CreateRectRgn(0,0, Form.Width, Form.Height);
  Rgn2 := CreateRectRgn(Ctrl.Left, Ctrl.Top,Ctrl.Left+ Ctrl.Width,Ctrl.Top+ Ctrl.Height);
  CombineRgn(Rgn1, Rgn1, Rgn2, RGN_DIFF);
  SetWindowRgn(Form.Handle, Rgn1, TRUE);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
     MakeRectHole(Panel1,Form1);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
       BorderStyle:=BsNone;
       WindowState:= wsMaximized;
end;

procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  ReleaseCapture();
  SendMessage(Panel1.Handle,WM_NCLBUTTONDOWN,HTCAPTION,0);
  MakeRectHole(Panel1,Form1);
end;





无标题 但能拖拽
procedure TForm1.FormCreate(Sender: TObject);
begin
  SetWindowLong(Handle, GWL_STYLE, GetWindowLong(Handle, GWL_STYLE) xor WS_CAPTION);
  Height := ClientHeight;
end;


    




posted @ 2014-07-29 16:45  XE2011  阅读(235)  评论(0编辑  收藏  举报