vb.net圆角窗体 winform窗体
VB 怎样实现圆角窗体?
VB.net
创新互联专业为企业提供嘉祥网站建设、嘉祥做网站、嘉祥网站设计、嘉祥网站制作等企业网站建设、网页设计与制作、嘉祥企业网站模板建站服务,10年嘉祥做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。
示例:
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
VB.Net怎么做圆形窗体
设置Region属性:
Dim path As New System.Drawing.Drawing2D.GraphicsPath
path.AddEllipse(0, 0, 400, 300)
Region = New Region(path)
如何在vb.net中创建圆角窗体
如下所示:
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圆角窗体 winform窗体
文章地址:http://ybzwz.com/article/hjosej.html