设置Region属性:
站在用户的角度思考问题,与客户深入沟通,找到枣强网站设计与枣强网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:网站建设、做网站、企业官网、英文网站、手机端网站、网站推广、主机域名、虚拟主机、企业邮箱。业务覆盖枣强地区。
Dim path As New System.Drawing.Drawing2D.GraphicsPath
path.AddEllipse(0, 0, 400, 300)
Region = New Region(path)
如下所示:
Private Sub Type(ByVal sender As Control, ByVal p_1 As Integer, ByVal p_2 As Double)
Dim oPath As New Drawing2D.GraphicsPath()
oPath.AddClosedCurve(New Point() {New Point(0, sender.Height / p_1), New Point(sender.Width / p_1, 0), New Point(sender.Width - sender.Width / p_1, 0), New Point(sender.Width, sender.Height / p_1), New Point(sender.Width, sender.Height - sender.Height / p_1), New Point(sender.Width - sender.Width / p_1, sender.Height), _
New Point(sender.Width / p_1, sender.Height), New Point(0, sender.Height - sender.Height / p_1)}, CSng(p_2))
sender.Region = New Region(oPath)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Type(Me, 20, 0.1)
End Sub
VB.net
示例:
1.
窗体设置
边框模式
2.代码
Declare
Function
CreateRoundRectRgn
Lib
"gdi32"
Alias
"CreateRoundRectRgn"
(ByVal
X1
As
Int32,
ByVal
Y1
As
Int32,
ByVal
X2
As
Int32,
ByVal
Y2
As
Int32,
ByVal
X3
As
Int32,
ByVal
Y3
As
Int32)
As
Int32
Declare
Function
SetWindowRgn
Lib
"user32"
Alias
"SetWindowRgn"
(ByVal
hWnd
As
Int32,
ByVal
hRgn
As
Int32,
ByVal
bRedraw
As
Boolean)
As
Int32
‘GDI重绘API
Private
Sub
Form1_Load(ByVal
sender
As
Object,
ByVal
e
As
System.EventArgs)
Handles
MyBase.Load
Dim
r
As
Integer
=
CreateRoundRectRgn(0,
0,
Me.Width,
Me.Height,
20,
20)
'CreateRoundRectRgn参数([窗体左],[窗体顶],[窗体宽],[窗体高],[向左偏移
],[向
偏移
])
SetWindowRgn(Me.Handle,
r,
True)
End
Sub