Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Creating ActiveX controls dynamically

Creating ActiveX controls dynamically

Scheduled Pinned Locked Moved Visual Basic
questioncomtutorial
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Min 0
    wrote on last edited by
    #1

    I know how to create an instance of activeX control using CreateObject, but this doesn't exactly display the visual control on the form. It seems like it only creates an object instance of it. How do I make it so that i can switch between activex *visual* controls dynamically on a form? thanks,

    J R 2 Replies Last reply
    0
    • M Min 0

      I know how to create an instance of activeX control using CreateObject, but this doesn't exactly display the visual control on the form. It seems like it only creates an object instance of it. How do I make it so that i can switch between activex *visual* controls dynamically on a form? thanks,

      J Offline
      J Offline
      Jafet Sanchez 0
      wrote on last edited by
      #2

      Use Load

      1 Reply Last reply
      0
      • M Min 0

        I know how to create an instance of activeX control using CreateObject, but this doesn't exactly display the visual control on the form. It seems like it only creates an object instance of it. How do I make it so that i can switch between activex *visual* controls dynamically on a form? thanks,

        R Offline
        R Offline
        Ravi S V
        wrote on last edited by
        #3

        Loading ActiveX controls on form dynamically at runtime is not that easy. One way is to declare an object variable. but you cannot handle events for the controls. Other way is to declare a variable as VBControlExtender. u can declare this variables with events. The procedure to use this VBControlExtender: 'place the code in form_load or form_initialize event Dim WithEvents MyCtrl As VBControlExtender 'declaration Licenses.Add "MyCombo.MCombo" 'Add the licence of the control class to the project 'Add the control to the form which is the parent to the control Set MyCtrl = Me.Controls.Add("MyCombo.MCombo", "MyCtrl", Me) 'Set the position of the control and make it visible With MyCtrl .Top = 100 .Width = 100 .Height = 315 .Left = 100 .Visible = True End With Click event of the control can implemented in this way: Private Sub MyCtrl_ObjectEvent(Info as EventInfo) 'This Info parameter consists of event name and the parameters of the event. If Info.Name = "Click" then 'do your code End If End Sub that's all Regards, Ravi.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups