|
|
Title | Give a form a skin |
Description | This example shows how to give a form a skin in Visual Basic 6. It restricts the form to a shape and uses PictureButton and DragButton ActiveX controls to let the user minimize, close, and move the form. |
Keywords | skin, ActiveX control, button, picture |
Categories | Controls, ActiveX Controls, ActiveX |
|
|
At design time, the form's Picture property was set to a picture. PictureButton and DragButton ActiveX controls were added with appropriate pictures to allow the user to minimize, close, and move the form. See HowTo: Make ActiveX button controls that display different pictures when up or down for information about those controls.
When the form loads, the program uses the CreateEllipticRgn and SetWindowRgn API functions to restrict the form to a circle that outlines the form's picture.
|
|
Private Sub Form_Load()
Const CX As Long = 201
Const CY As Long = 195
Const R As Long = 183
Dim rgn As Long
' Create the region.
rgn = CreateEllipticRgn(CX - R, CY - R, CX + R, CY + R)
' Restrict the window to the region.
SetWindowRgn hWnd, rgn, True
End Sub
|
|
When the user clicks the minimize or close PictureButtons, the program's event handlers minimize or close the form. The DragButton lets the user drag the form automatically without any additional code.
|
|
Private Sub btnMinimize_Click()
Me.WindowState = vbMinimized
End Sub
Private Sub btnClose_Click()
Unload Me
End Sub
|
|
|
|
|
|