Sunday, November 6, 2011

Membuat Form berbentuk Oval atau shape


Buat sebuah Form baru (BorderStyle=None), lalu di bagian '(Declarations)'-nya ketikkan :

Private Declare Function CreateRoundRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long) 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

Untuk membuat Form berbentuk shape rounded rectangle, di bagian 'Form_Load' ketikkan :

Dim l As Long
l = CreateRoundRectRgn(0, 0, Me.Width / Screen.TwipsPerPixelX, Me.Height / Screen.TwipsPerPixelY, 20, 20)
SetWindowRgn Me.hwnd, l, False

Sedangkan untuk membuat Form berbentuk shape oval / lingkaran, di bagian 'Form_Load' ketikkan :

Dim l As Long
l = CreateEllipticRgn(0, 0, Me.Width / Screen.TwipsPerPixelX, Me.Height / Screen.TwipsPerPixelY)
SetWindowRgn Me.hwnd, l, False

Jika anda bingung untuk cara menggerakan form yang sengaja tidak di border maka simak lah artikel saya di sini
Menggerakan Form tanpa Border

2 comments:

  1. salah gan code Declarations, yan benar begini :

    Private Declare Function CreateRoundRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long) 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

    Begitu, thank gan :)

    ReplyDelete
    Replies
    1. makasi gan komentarnya, tapi itu coding saya sudah benar ko & work..
      terima akasih sudah berunjung

      Delete