• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

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

原作者: [db:作者] 来自: [db:来源] 收藏 邀请
 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);


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Delphi7CodeEditor之几个特性(转)发布时间:2022-07-18
下一篇:
Delphi回调函数的使用发布时间:2022-07-18
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap