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. ActiveX with VB

ActiveX with VB

Scheduled Pinned Locked Moved Visual Basic
helpcomtutorialquestion
2 Posts 2 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.
  • J Offline
    J Offline
    Jerome Conus
    wrote on last edited by
    #1

    Hi ! I'm building an App using Visual Basic 6, where I would like to display many ActiveX controls. The number and types of ActiveX to display is not hard-coded in the App, but rather put in a text file that would be read during initialization of the App, thus allowing me to add/remove ActiveX controls without recompiling my App. My problem is I don't know how to use an ActiveX control in VB without registering it (Project->Component) and putting it into a form. I would like to register it during code execution and placing it into my form dynamically. Anyone knows how to do that ? Thank you for your help ! Jerome

    J 1 Reply Last reply
    0
    • J Jerome Conus

      Hi ! I'm building an App using Visual Basic 6, where I would like to display many ActiveX controls. The number and types of ActiveX to display is not hard-coded in the App, but rather put in a text file that would be read during initialization of the App, thus allowing me to add/remove ActiveX controls without recompiling my App. My problem is I don't know how to use an ActiveX control in VB without registering it (Project->Component) and putting it into a form. I would like to register it during code execution and placing it into my form dynamically. Anyone knows how to do that ? Thank you for your help ! Jerome

      J Offline
      J Offline
      Jeremy Falcon
      wrote on last edited by
      #2

      To simply put it, it's a whole heck of a lot easier to reference all the ActiveX controls (Project/Components...) you'll need and create them as needed. Also, if you use the package and desployment wizard it'll make sure the OCXs are included in your installation. I am not sure what it is exactly you are looking to do, but if you do reference the controls, you can use a control array along with the Load statement to create new indices at runtime. You don't have to use a control array. Reference the rich edit control in your project, Uncheck "Remove information about unused ActiveX Controls" from Project Properties/Make. And run the following code...

      Dim MyControl As Control

      Private Sub Form_Load()

      Set MyControl = Me.Controls.Add("RICHTEXT.RichTextCtrl.1", _
      "RichText1", Me)

      MyControl.Text = "I'm Dynamic!"
      MyControl.Font.Bold = True
      MyControl.Font.Italic = True
      MyControl.Visible = True

      End Sub

      Private Sub Form_Resize()

      If IsObject(MyControl) Then _
      MyControl.Move 0, 0, Me.ScaleWidth, Me.ScaleHeight

      End Sub

      Private Sub Form_Unload(Cancel As Integer)

      If IsObject(MyControl) Then Set MyControl = Nothing

      End Sub

      However, in doing this you'll need to know the ProgID for the ActiveX control. I generally, place the control on the form, save it, use the .frm file to get the class name, run it, and get an error message giving me the ProgID. You can also get it from the registry, but I'm lazy. :) If you don't register the control in the project you may have to deal with licensing info in your code. Most MS ActiveX controls require a license to be used. You could create one manually, but this becomes more of a pain than it's worth. Good luck... Jeremy L. Falcon "The One Who Said, 'The One Who Said...'"

      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