您的位置:首页 > 博客中心 > 电脑问题 >

Delphi 把Form界面设置有弧度的矩形

时间:2022-03-18 14:51

 1 unit Unit1;
 2 
 3 interface
 4 
 5 uses
 6   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
 7   Dialogs, ExtCtrls, StdCtrls;
 8 
 9 type
10   TForm1 = class(TForm)
11     Panel1: TPanel;
12     Edit1: TEdit;
13     procedure FormShow(Sender: TObject);
14   private
15     { Private declarations }
16   public
17     { Public declarations }
18   end;
19 
20 var
21   Form1: TForm1;
22 
23 implementation
24 
25 {$R *.dfm}
26 
27 procedure TForm1.FormShow(Sender: TObject);
28 var
29   Rgn: HRGN;
30 begin
31   //参数:Handle的左上角left top  右下角right bottom   弧度0-->255
32   Rgn := CreateRoundRectRgn(0,0, width,height,50,50);
33   SetWindowRgn(handle, Rgn, True);
34 
35   //若是Panel1设置弧度:BorderStyle 最好设成 bsNone
36   //若是Panel1设置弧度:BevelInner和BevelOuter 最好设成 bvNone
37 end;
38 
39 end.

技术图片

 

 技术图片

 

热门排行

今日推荐

热门手游