[求助]求一画圆的代码!
小弟才开始学VB ,故向各位大哥大姐求助如何用VB写一个画圆的函数,圆的圆心可以控制,大小一定,谢谢了先
我再提供一个画窗体圆或者椭圆的程序. 通过API函数实现:
椭圆:
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
Dim hrgn As Long
Dim lres As Long
Private Sub form_Click()
Dim hrgn As Long
Dim lres As Long
hrgn = CreateEllipticRgn(30, 30, 300, 200)
lres = SetWindowRgn(Me.hWnd, hrgn, True)
End Sub
圆:
只要将hrgn = CreateEllipticRgn(30, 30, 300, 200)
这条命令改一下:比如改为:
hrgn = CreateEllipticRgn(30, 30, 200, 200)
API函数setwindowrgn是一个很好用的函数