|
-
Sep 27th, 2002, 08:30 AM
#1
Thread Starter
New Member
non traditional windows application
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?
-
Sep 27th, 2002, 08:44 AM
#2
Frenzied Member
There is an API call, SetWindowRgn that can crop a window to any shape imaginable.
-
Sep 27th, 2002, 09:40 AM
#3
Software Eng.
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.
-
Sep 27th, 2002, 09:49 AM
#4
Do these help?
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|