码迷,mamicode.com
首页 > Windows程序 > 详细

Delphi 代码实现窗口透明+圆角边框

时间:2017-08-25 12:34:51      阅读:249      评论:0      收藏:0      [点我收藏+]

标签:remote   pre   窗口   integer   cli   ble   控件   win   bsp   

 1 procedure TfrmRemoteData.DoInvisible;  //透明
 2 var
 3   control: TControl;
 4   index, margin, X, Y, ctlX, ctlY, i: Integer;
 5   fullRgn, clientRgn, ctlRgn: THandle;
 6 begin
 7   margin := (Width - ClientWidth) div 2;
 8   fullRgn := CreateRectRgn(0, 0, Width, Height); //创建总裁剪区域
 9   X := margin;
10   Y := Height - ClientHeight - margin;
11   clientRgn := CreateRectRgn(X, Y, X + ClientWidth, Y + ClientHeight);
12   CombineRgn(fullRgn, fullRgn, clientRgn, RGN_DIFF); //合并区域,RGN_DIFF差集
13 
14   for index := 0 to ControlCount - 1 do   //遍历控件
15   begin
16     control := Controls[index];
17     if (control is TWinControl) or (control is TGraphicControl) then
18       with control do
19       begin
20         if Visible then
21         begin
22           ctlX := X + Left;
23           ctlY := Y + Top;
24 //          ctlRgn := CreateRectRgn(CtlX, CtlY, CtlX + Width, CtlY + Height);
25           ctlRgn := CreateRoundRectRgn(ctlX, ctlY, ctlX+ Width, ctlY + Height, Height, Height);
26           CombineRgn(fullRgn, fullRgn, ctlRgn, RGN_OR);  //RGN_OR并集
27 
28         end;
29       end;
30   end;
31   SetWindowRgn(Handle, fullRgn, True);    //设置重绘窗口
32 end;

 说明:CreateRoundRectRgn(R.Left, R.Top, R.Right, R.Bottom, arc1, arc2);

Delphi 代码实现窗口透明+圆角边框

标签:remote   pre   窗口   integer   cli   ble   控件   win   bsp   

原文地址:http://www.cnblogs.com/ADAN1024225605/p/7427012.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!