ActiveX Controls and Applications

Creating an ActiveX Control

In this exercise, you will create an ActiveX control using Visual Basic.

* To create an ActiveX control

  1. Start Visual Basic and create a new ActiveX Control project.
  2. Rename the project, Lab8Control .
  3. Change the name of UserControl1 to ChangeDateTime .
  4. From the File menu, click Save Project .
  5. Save the project in the WA\Practice\Ch08 directory. Click No when prompted to Add this project to SourceSafe .
  6. Change the BackColor property of ChangeDateTime to Window Background .
  7. Insert a Label control and a Timer control to the ChangeDateTime as shown in the following illustration.

  8. Set the following properties:
    Control Property Value
    Timer1 Interval = 100
    Label1 Caption = ""
    Label1 Font = Arial 12 point
    Label1 BackStyle = 0 “ Transparent
    Label1 Alignment = 2 “ Center

  9. In the Timer control's Timer event, add the following code:
     Label1.Caption = Now() 
  10. Save changes to the project.
  11. From the File menu, click Make Lab8Control.ocx .

    When the Make Project dialog appears, make sure the directory is set to WA\Practice\Ch08 .



Microsoft Windows Architecture Training
Microsoft Windows Architecture for Developers Training Kit
ISBN: B00007FY9D
EAN: N/A
Year: 1998
Pages: 324

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net