VB 怎样实现圆角窗体?

蓉蓉284
2013-10-12 · TA获得超过4703个赞
知道小有建树答主
回答量:1023
采纳率:0%
帮助的人:2422万
展开全部
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) Private Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long Private Declare Function CreateRoundRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long) As Long Private Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long Private Const RGN_AND = 1 Private MyRgn1 As Long Private MyRgn2 As Long Private MyRgn As Long Private Sub Form_Load() Dim w As Long, h As Long w = ScaleX(Me.Width, vbTwips, vbPixels) h = ScaleY(Me.Height, vbTwips, vbPixels) MyRgn = CreateRoundRectRgn(30, 30, w - 30, h - 30, 16, 16) '在此可改变参数以调整圆角大小 Call SetWindowRgn(Me.hWnd, MyRgn, True) '改变窗口的区域为"MyRgn" Dim w As Long, h As Long w = ScaleX(Me.Width, vbTwips, vbPixels) h = ScaleY(Me.Height, vbTwips, vbPixels) MyRgn = CreateRoundRectRgn(0, 0, w - 0, h - 0, 16, 16) '在此可改变参数以调整圆角大小 Call SetWindowRgn(Me.hWnd, MyRgn, True) '改变窗口的区域为"MyRgn"
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式