Make Circular Controls/Forms

'Add a module to your project (In the menu choose Project -> Add Module, Then click Open)
'Add 1 Command Button to your Form.
'Insert this code to the module :

Declare Function CreateEllipticRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As _
Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal _
hRgn As Long, ByVal bRedraw As Long) As Long

'Insert the following code to your form:

Function CircleIt(Contrl As Control)
Dim hr&, dl&
Dim usew&, useh&
hwndDest = Contrl.hWnd
usew& = Contrl.Width / Screen.TwipsPerPixelX
useh& = Contrl.Height / Screen.TwipsPerPixelY
hr& = CreateEllipticRgn(0, 0, usew&, useh&)
dl& = SetWindowRgn(hwndDest, hr, True)
End Function

Private Sub Command1_Click()
'Replace 'Command1' with the name of the control or form you want to round.
CircleIt Command1
End Sub

Go Back