CodeItBetter Programming Another VB Programming Blog

How to create Circular Controls

Posted on January 5, 2009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
'Controls - How to create Circular Controls

Option Explicit
 
'Add a Command Button to your Form.

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
 
Function CircleIt(Contrl As Control)
    Dim hr&, dl&, 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
 
'How can I call this function:
Private Sub Command1_Click()
    'To Create Circulare Command Button
    Call CircleIt(Command1)
End Sub
Filed under: Controls Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.