I just had some fun with paths and regions for clipping portions of the form.
You may try this method if you wish.
Start a new project and insert the following code in Form1.
___
[tt]
Option Explicit
Private Declare Function BeginPath Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function EndPath Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function PathToRegion Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function StrokeAndFillPath Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Private Declare Function SetWindowRgn Lib "user32" (ByVal hwnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
Private Type POINTAPI
X As Long
Y As Long
End Type
Dim Char As Long
Dim U As Long, V As Long
Private Sub Form_Load()
FillColor = &H800000 'navy
ForeColor = vbCyan
ScaleMode = vbPixels
AutoRedraw = True
FillStyle = vbSolid
Char = 33
Font = "Webdings"
FontSize = 144
Form_KeyUp 0, 0
End Sub
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyUp, vbKeyRight
Char = Char + 1
Case vbKeyDown, vbKeyLeft
Char = Char - 1
End Select
If Char = 256 Then Char = 33
If Char = 32 Then Char = 255
Cls
BeginPath hdc
Print Chr$(Char)
EndPath hdc
StrokeAndFillPath hdc
Dim P As POINTAPI
ClientToScreen hwnd, P
CurrentX = P.X - Left \ Screen.TwipsPerPixelX
CurrentY = P.Y - Top \ Screen.TwipsPerPixelY
BeginPath hdc
Print Chr$(Char)
EndPath hdc
SetWindowRgn hwnd, PathToRegion(hdc), True
Caption = Char
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
U = X: V = Y
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then _
Move Left + (X - U) * Screen.TwipsPerPixelX, _
Top + (Y - V) * Screen.TwipsPerPixelY
End Sub[/tt]
___
Now run the program. Press Up/Down keys to change the shape of the form.
Besides this, you may also try the SetLayeredWindowAttributes function. I mentioned both methods in thread222-493597. But note that this function is supported on Windows 2000 and XP only.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.