myamanda

博客园 首页 新随笔 联系 订阅 管理
{ 在窗体中添加 button,然后加入以下代码:} 

procedure TForm1.FormCreate(Sender: TObject); 
var 
  FullRgn, ClientRgn, ButtonRgn: THandle; 
  Margin, X, Y: Integer; 
begin 
  Margin := (Width - ClientWidth) div 2; 
  FullRgn := CreateRectRgn(0, 0, Width, Height); 
  X := Margin; 
  Y := Height - ClientHeight - Margin; 
  ClientRgn := CreateRectRgn(X, Y, X + ClientWidth, Y + ClientHeight); 
  CombineRgn(FullRgn, FullRgn, ClientRgn, RGN_DIFF); 
  X := X + Button1.Left; 
  Y := Y + Button1.Top; 
  ButtonRgn := CreateRectRgn(X, Y, X + Button1.Width, Y + Button1.Height); 
  CombineRgn(FullRgn, FullRgn, ButtonRgn, RGN_OR); 
  SetWindowRgn(Handle, FullRgn, True); 
end;
posted on 2009-08-05 11:35  myamanda  阅读(207)  评论(0)    收藏  举报