我想在点击按钮后,按钮变成椭圆形,这是一段VB的代码,请给看看,为什么不成功呢

yannankai 2003-05-15 11:20:10
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 GetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long) As Long
Private Declare Function GetRgnBox Lib "gdi32" (ByVal hRgn As Long, lpRect As RECT) As Long
Private Declare Function CreateEllipticRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 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 Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long

Private Sub Command1_Click()
Dim WindowRect As RECT
Dim WindowRgn As Long
WindowRgn = CreateRectRgn(0, 0, 0, 0)
GetWindowRgn Command1.hWnd, WindowRgn
Debug.Print WindowRgn

GetRgnBox WindowRgn, WindowRect
Debug.Print WindowRect.Left

CreateEllipticRgn WindowRect.Left, WindowRect.Top, WindowRect.Right, WindowRect.Bottom
SetWindowRgn Command1.hWnd, WindowRgn, True
DeleteObject WindowRgn
End Sub
...全文
29 点赞 收藏 2
写回复
2 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
ClassicWuHao 2003-05-15
Option Explicit
Private Declare Function CreateEllipticRgn Lib "gdi32.dll" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function SetWindowRgn Lib "user32.dll" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
Dim hRgn As Long

Private Sub Command1_Click()
With Command1
hRgn = CreateEllipticRgn(0&, 0&, .Width / 15, .Height / 15)
If hRgn = 0 Then Exit Sub
SetWindowRgn .hWnd, hRgn, True
End With
End Sub
回复
yannankai 2003-05-15
有帮忙的兄弟吗
回复
相关推荐
发帖
VB基础类
创建于2007-09-28

7492

社区成员

VB 基础类
申请成为版主
帖子事件
创建了帖子
2003-05-15 11:20
社区公告
暂无公告