How do I make odd shaped form like that used by IOLO Technologies System Mechanic. Please tell me if anyone know it.
Thanks.
Printable View
How do I make odd shaped form like that used by IOLO Technologies System Mechanic. Please tell me if anyone know it.
Thanks.
Try this. It creates a form with a hole inside. I based it on a form of 6300 x 6300 twips. I cheated a bit, because the POINTAPI uses pixels, and I didn't do a conversion but assumed 15 twips in a pixel. If you want to do it right, you should check the Screen.TwipsPerPixelX and Screen.TwipsPerPixelY for this.
Code:Option Explicit
Private Type POINTAPI
X As Long
Y As Long
End Type
Private hRgn As Long
Private Declare Function CreatePolygonRgn Lib "gdi32" (lpPoint As POINTAPI, ByVal nCount As Long, ByVal nPolyFillMode As Long) As Long
Private Declare Function SetWindowRgn Lib "user32" (ByVal hwnd As Long, ByVal hRgn As Long, ByVal bRedraw As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const HTCAPTION = 2
Private Const WM_NCLBUTTONDOWN = &HA1
Private Sub Form_DblClick()
Unload Me
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Call ReleaseCapture
Call SendMessage(Me.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&)
End Sub
Private Sub Form_Load()
Dim retVal As Long
Dim XY(12) As POINTAPI
'hide the form, so nobody can see the unshaped form
Me.Hide
' now fill the polygone points
XY(0).X = 10
XY(0).Y = 10
XY(1).X = 10
XY(1).Y = 210
XY(2).X = 50
XY(2).Y = 210
XY(3).X = 50
XY(3).Y = 100
XY(4).X = 370
XY(4).Y = 100
XY(5).X = 370
XY(5).Y = 320
XY(6).X = 50
XY(6).Y = 320
XY(7).X = 50
XY(7).Y = 210
XY(8).X = 10
XY(8).Y = 210
XY(9).X = 10
XY(9).Y = 410
XY(10).X = 410
XY(10).Y = 410
XY(11).X = 410
XY(11).Y = 10
XY(12).X = 10
XY(12).Y = 10
' Create the polygone range
' Pass in the address of the first point and
' the number of points.
hRgn = CreatePolygonRgn(XY(0), (UBound(XY) + 1), 2)
' set the window range to this polygone
retVal = SetWindowRgn(Me.hwnd, hRgn, True)
' now show the window
Me.Show
Me.Refresh
End Sub
Private Sub Form_Terminate()
Dim retVal As Long
' delete the polygone
retVal = DeleteObject(hRgn)
End Sub