Hi everybody;
How can I change the forms shape to regullar shapes like circles or ellipse or into irregular shapes like rounded corners and undefined edges.:confused:
Printable View
Hi everybody;
How can I change the forms shape to regullar shapes like circles or ellipse or into irregular shapes like rounded corners and undefined edges.:confused:
The following code will show you how to create various kind of window shape :)
regards,VB Code:
Option Explicit '// WIN32API Function 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 CreatePolygonRgn Lib "gdi32" (lpPoint As POINTAPI, ByVal nCount As Long, ByVal nPolyFillMode 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 '// WIN32API Structure Private Type POINTAPI x As Long y As Long End Type '// WIN32API Constant Private Const WINDING = 2 Private Sub Form_Load() Load frmSample frmSample.Show End Sub Private Sub Form_Unload(Cancel As Integer) Unload frmSample End Sub Private Sub CmdAction_Click(Index As Integer) Dim hRgn As Long Dim pt(4) As POINTAPI Select Case Index Case 0 '// Ellipse hRgn = CreateEllipticRgn(0, 0, 200, 400) Case 1 '// Triangle pt(0).x = 200 pt(0).y = 0 pt(1).x = 400 pt(1).y = 500 pt(2).x = 0 pt(2).y = 500 pt(3).x = 200 pt(3).y = 0 hRgn = CreatePolygonRgn(pt(0), 4, WINDING) Case 2 '// Round Rect hRgn = CreateRoundRectRgn(0, 0, 400, 400, 50, 50) Case 3 '// Circle hRgn = CreateEllipticRgn(0, 0, 300, 300) End Select SetWindowRgn frmSample.hWnd, hRgn, True End Sub