Programming Components with Microsoft Visual Basic 6.0
Creating
ActiveX Controls
- Close the UserControl designer.
- Now place the new control on Form1.
- In the Project window, double-click UserControl1 to reopen the UserControl designer.
- Double-click the UserControl designer to open the Code window.
- Code the following event procedures. You can use the Procedure box to select the event procedures and then add the message box code (shown in bold).
Private Sub UserControl_Initialize()
MsgBox "Initialize"
End Sub
Private Sub UserControl_InitProperties()
MsgBox "InitProperties"
End Sub
Private Sub UserControl_ReadProperties(PropBag As _
PropertyBag)
MsgBox "ReadProperties"
End Sub
Private Sub UserControl_WriteProperties(PropBag As _
PropertyBag)
MsgBox "WriteProperties"
End Sub
Private Sub UserControl_Terminate()
MsgBox "Terminate"
End Sub
Private Sub UserControl_Resize()
MsgBox "Resize " & ScaleWidth & ", " & ScaleHeight
End Sub
Private Sub UserControl_Show()
MsgBox "Show"
End Sub
- Close the Code window, and then close the UserControl designer. Note that the control’s icon in the toolbox has become enabled. This indicates that the control has been placed in run mode.
Note that the message boxes appear in the following order:
Initialize
Resize 1524, 1284
ReadProperties
Show
(Your resize values will reflect the size of your control.)
next page....
|
|