Monday, May 28, 2012

Membuat Form Yang Berbentuk Lingkaran

Bagaimanakah cara membuat form yang berbentuk lingkaran? simaklah kodenya di bawah ini:
Option Explicit 

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

Function
CutCirCle(frm As Form, Left, Top, Fat, Tall)
With frm
.Width = (Fat + 10) * 15
.Height = (Tall + 10) * 15
End With
SetWindowRgn frm.hWnd, CreateEllipticRgn(Left, Top, Fat, Tall), True
End Function
Contoh penggunaan kode di atas:
Private Sub Command1_Click() 
Call CutCirCle(Me, 0, 0, 600, 600)
End Sub

Private Sub
Form_Resize()
Command1.Left = ((610 * 15) / 2) - (Command1.Width / 2)
End Sub