1) Standard.exe | Position a Tree View List named treeview1 on the frmMain form. Add a Frame which will become the container for the user controls. Name the frame - framContainer | Name the project: projUserControls |
2) Add Project ActiveX Control | Name the project: CALC_OCX | |
3) Create 3 user controls |
userCalculator Simple Calculator userCalendar Simple Calendar userMultimedia Plays an Avi file |
Add Functionality for each of the user controls |
04-05>On the Project Menu. click Properties. Select the General Tab, check Require License Key, then click ok.From the User Application Perspective the License Key is passed the VB runtime dll. From the developer perspective the license ey will need to be put in the registery before it can be used in development. 06> Controls.Add (ProgID, name, container). ProgrID defines the UserControl Project.Name Name identifies a unique container identification Container identifies a container in which the user control will become active. |
Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node) Dim objCalc As Object 01> Call RemoveApplication("Application1") 02> Call RemoveApplication("Application2") 03> Call RemoveApplication("Application3") If Node.Text = "Calculator" Then 04> If CheckLicense("CALC_OCX.userCalculator") = False Then 05> Licenses.Add "CALC_OCX.userCalculator" End If 06> Set objCalc = Me.Controls.Add("CALC_OCX.userCalculator", "Application1", framContainer) objCalc.Visible = True framContainer.Width = objCalc.Width framContainer.Height = objCalc.Height ElseIf Node.Text = "Calendar" Then If CheckLicense("CALC_OCX.userCalendar") = False Then Licenses.Add "CALC_OCX.userCalendar" End If Set objCalc = Me.Controls.Add("CALC_OCX.userCalendar", "Application2", framContainer) objCalc.Visible = True framContainer.Width = objCalc.Width framContainer.Height = objCalc.Height ElseIf Node.Text = "Multimedia" Then If CheckLicense("CALC_OCX.usermultimedia") = False Then Licenses.Add "CALC_OCX.usermultimedia" End If Set objCalc = Me.Controls.Add("CALC_OCX.usermultimedia", "Application3", framContainer) objCalc.Visible = True framContainer.Width = objCalc.Width framContainer.Height = objCalc.Height End If end sub Private Function CheckLicense(sProgID As String) As Boolean Dim objLicense As LicenseInfo For Each objLicense In Licenses If objLicense.ProgID = sProgID Then CheckLicense = True Exit Function End If Next CheckLicense = False End Function Private Sub RemoveApplication(sApplication As String) Dim objControl As Control For Each objControl In Me.Controls If objControl.Name = sApplication Then Me.Controls.Remove sApplication End If Next End Sub