CodeItBetter Programming Another VB Programming Blog

How to create rounded Form

Posted on September 4, 2009

Sometimes we may need to create a form little differently like rounded form. Here is the way to set your form as rounded:

Instructions:

  • Create a new Project
  • Add a new Form to it and name it as Form1
  • Add a new command button to it and name it as Command1
  • Add a new Module to it and name it as Module1

Now, add the following code to Module1:

1
2
3
4
Option Explicit
 
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 Boolean) As Long

Add the following code to Form1:

1
2
3
4
5
6
7
8
9
Option Explicit
 
Private Sub Command1_Click()
  Unload Me
End Sub
 
Private Sub Form_Load()
  SetWindowRgn hWnd, CreateEllipticRgn(0, 0, 300, 200), True
End Sub
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

Trackbacks are disabled.