Results 1 to 6 of 6

Thread: ActiveX Control

  1. #1

    Thread Starter
    Frenzied Member vbgladiator's Avatar
    Join Date
    May 2001
    Posts
    1,950

    ActiveX Control

    I created an Activex Control.

    In my application I did not added it to the toolbox. I'm creating it dynamically. This is the code I use:

    VB Code:
    1. Dim WithEvents objExt As VBControlExtender ' Declare VBControlExtender variable
    2.  
    3. Private Sub LoadControl()
    4.    Licenses.Add "MyControl.Control"
    5.    Set objExt = Controls.Add("MyControl.Control", "myCtl")
    6. End Sub
    7.  
    8. Private Sub extObj_ObjectEvent(Info As EventInfo)
    9.    ' Program the events of the control using Select Case.
    10.    Select Case Info.Name
    11.    Case "Click"
    12.       ' Handle Click event here.
    13.    ' Other cases now shown
    14.    Case Else ' Unknown Event
    15.       ' Handle unknown events here.
    16.    End Select
    17. End Sub
    18.  
    19.  
    20. Private Sub Command1_Click()
    21.     Call LoadControl
    22. End Sub

    I can handle the events. However, does anyone know how I can access the methods and properties I created for the control when adding the control dynamically to the form?

    I can use access them fine when I add it to the toolbox.

  2. #2

    Thread Starter
    Frenzied Member vbgladiator's Avatar
    Join Date
    May 2001
    Posts
    1,950
    Got it.

    VB Code:
    1. Dim WithEvents objExt As VBControlExtender ' Declare VBControlExtender variable
    2.  
    3. Private Sub LoadControl()
    4.    Licenses.Add "MyControl.Control"
    5.    Set objExt = Controls.Add("MyControl.Control", "myCtl")
    6.  
    7.    'To call a method
    8.    objExt.Object.MethodName(parameteres)
    9.    'Cool
    10. End Sub
    11.  
    12. Private Sub extObj_ObjectEvent(Info As EventInfo)
    13.    ' Program the events of the control using Select Case.
    14.    Select Case Info.Name
    15.    Case "Click"
    16.       ' Handle Click event here.
    17.    ' Other cases now shown
    18.    Case Else ' Unknown Event
    19.       ' Handle unknown events here.
    20.    End Select
    21. End Sub
    22.  
    23.  
    24. Private Sub Command1_Click()
    25.     Call LoadControl
    26. End Sub

  3. #3

    Thread Starter
    Frenzied Member vbgladiator's Avatar
    Join Date
    May 2001
    Posts
    1,950
    Damn, I knew it was too easy.

    I'm probably missing something easy but here it goes:

    I am able to access properties and methods.

    However, I have public enumerations. Does anyone know how I can access those?

    Thanks to those who reply.

  4. #4
    Hyperactive Member
    Join Date
    Jan 2002
    Location
    The Netherlands
    Posts
    425
    HAHA! Thank you very much for your solution. had the same problem... Thx...

    unfortunately I don't know the answhere to your second question, but I'll probably know when a reply is posted here

    Thx
    "Experience is something you don't get until just after you need it."

  5. #5
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Originally posted by BShadow
    HAHA! Thank you very much for your solution. had the same problem... Thx...

    unfortunately I don't know the answhere to your second question, but I'll probably know when a reply is posted here

    Thx
    Uhm... I think 2 years is enough time for him to have solved this problem or gotten over it.

  6. #6
    Hyperactive Member
    Join Date
    Jan 2002
    Location
    The Netherlands
    Posts
    425
    Originally posted by mendhak
    Uhm... I think 2 years is enough time for him to have solved this problem or gotten over it.
    LOL, Yes I've noticed the date after i've posted the reply
    "Experience is something you don't get until just after you need it."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width