Title | Create an elliptical form |
Keywords | form, shape, region, SetWindowRgn, shaped form, ellipse, elliptical |
Categories | Tips and Tricks, Graphics |
|
Private Sub Form_Resize()
Dim rgn As Long
Dim wid As Single
Dim hgt As Single
If WindowState = vbMinimized Then Exit Sub
' Create the elliptical region.
wid = ScaleX(Width, vbTwips, vbPixels)
hgt = ScaleY(Height, vbTwips, vbPixels)
rgn = CreateEllipticRgn(0, 0, wid, hgt)
' Restrict the window to the region.
SetWindowRgn hWnd, rgn, True
DeleteObject rgn
Command1.Move _
(ScaleWidth - Command1.Width) / 2, _
(ScaleHeight - Command1.Height) / 2
End Sub
|