我想在点击按钮后,按钮变成椭圆形,这是一段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
...全文
68 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
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
  • 打赏
  • 举报
回复
有帮忙的兄弟吗

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧