is anyone knows how to change the window appearance of the application.
as far as i know, i only knew how to make square or rectangle windows. How could i change its dimesions as circle or anything. . .?
is vb capable of it?
Printable View
is anyone knows how to change the window appearance of the application.
as far as i know, i only knew how to make square or rectangle windows. How could i change its dimesions as circle or anything. . .?
is vb capable of it?
There is an API call, SetWindowRgn that can crop a window to any shape imaginable.
To create the regions for use with SetWindowRgn, use CreateEllipticRgn, CreateRoundRectRgn, CreateRectRgn, CreatePolyRgn and a few more.
You can combine regions via the CombineRgn function.
I suggest reading up on "Regions" in MSDN. It'll give you the basics for working with Regions.
VB Code:
'round form 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 SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long Private Declare Function DeleteObject Lib "gdi32.dll" (ByVal hObject As Long) As Long Private Sub Form_Load() Dim fwidth As Long, fheight As Long Dim rval As Long, nhwnd As Long fwidth = Me.Width / Screen.TwipsPerPixelX fheight = Me.Height / Screen.TwipsPerPixelY 'Create Round Rectangular Region nhwnd = CreateRoundRectRgn(0, 0, fwidth - 25, fheight - 25, fwidth - 50, fheight - 50) 'Create Elliptic Region 'nhwnd = CreateRoundRectRgn(0, 0, fwidth - 50, fheight - 50, fwidth - 50, fheight - 50) 'Set Round Rectangular Region on form rval = SetWindowRgn(Me.hWnd, nhwnd, True) rval = DeleteObject(nhwnd) End Sub 'create a form in the shape of a star Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long Private Declare Function CreatePolygonRgn Lib "gdi32" (lpPoint As POINTAPI, ByVal nCount As Long, ByVal nPolyFillMode As Long) As Long Private Type POINTAPI X As Long Y As Long End Type Private Function CreatePointStruct(lX As Long, lY As Long) As POINTAPI ' Create a point structure With CreatePointStruct .X = lX .Y = lY End With End Function Private Sub Form_Load() Dim ArrBorder(0 To 9) As POINTAPI ' Set all points ArrBorder(0) = CreatePointStruct(97, 0) ArrBorder(1) = CreatePointStruct(120, 65) ArrBorder(2) = CreatePointStruct(193, 65) ArrBorder(3) = CreatePointStruct(134, 106) ArrBorder(4) = CreatePointStruct(156, 171) ArrBorder(5) = CreatePointStruct(97, 131) ArrBorder(6) = CreatePointStruct(37, 171) ArrBorder(7) = CreatePointStruct(59, 106) ArrBorder(8) = CreatePointStruct(0, 65) ArrBorder(9) = CreatePointStruct(74, 65) SetWindowRgn hWnd, CreatePolygonRgn(ArrBorder(0), 10, 1), True End Sub