vb: how to create irregular, custom shaped form?
This site provides users with the information about vb, visual basic, vb6, create irregular form, how to create custom shaped form, example, and more.
If you think that this site is helpful, please recommend your friends to visit our site.
How to create irregular form, custom shaped in vb?
The following is the example and steps to create irregular form, custom shaped in vb:
1. Add the following code in declare section:
2. Add the following code in form resize section:
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
Private Declare Function DeleteObject Lib "gdi32" _
(ByVal hObject As Long) As Long
Dim r_handler As Long
Dim width As Long
Dim height As Long
width = ScaleX(Me.width, Me.ScaleMode, vbPixels) - 1
height = ScaleY(Me.height, Me.ScaleMode, vbPixels) - 1
'width = 250
'height = 250
'change the parameters to change the shape
r_handler = CreateEllipticRgn(0, 0, width, height)
Call SetWindowRgn(Me.hWnd, r_handler, True)