Results 1 to 3 of 3

Thread: Raising Events from ActiveX Control

  1. #1
    WALDO
    Guest

    Question Raising Events from ActiveX Control

    I'm going to post this in the other forum, too.

    Here's the deal...
    I have an ActiveX control that I wrote. I have custom events that I raise from code like AxInitializationComplete, and ErrorTrapped.

    When hosted on a vb form all my events raise as expected. When hosted on a web page in Internet Explorer, the only events that fire are ones in which RaiseEvent is called in an event raised by the control or its constituent controls.

    I know some of you are going, "HUH?"

    If I call RaiseEvent from any Method that I wrote, the event does not bubble up to IE. If I call RaiseEvent in say, cboInput_Click(), my events raise.

    VB Code:
    1. Option Explicit
    2.  
    3. Event ErrorTrapped()
    4. Event AxInitializationComplete()
    5. Event UserSelected()
    6. Event ControlGotFocus()
    7.  
    8. Private Sub cboInput_LostFocus()
    9.     RaiseEvent UserSelected 'OK
    10. End Sub
    11.  
    12. Private Sub UserControl_Initialize()
    13.     Call Init()
    14. End Sub
    15.  
    16. Private Function Init()
    17.     RaiseEvent AxInitializationComplete 'Does Not Work
    18. End Sub

  2. #2
    Frenzied Member MerrionComputin's Avatar
    Join Date
    Apr 2001
    Location
    Dublin, Ireland
    Posts
    1,616
    Hi,

    I don't think any event can be triggered before the control Initialize event is complete as the event sink isn't valid yet. Try putting a timer on the control and start it on the initialise event and trigger the event after, say, half a second?
    ----8<---------------------------------------
    NEW - The .NET printer queue monitor component
    ----8<---------------------------------------
    Now with Examples of use

  3. #3
    Addicted Member
    Join Date
    Apr 2000
    Location
    England
    Posts
    246
    I had a similar problem, the controls on the control is not loaded until the init event is complete, there is another event usercontrol_show that triggers once everything is done, but it re-triggers every time the control is shown.


    I can't think of any reason you would want an event to fire then anyway.
    Some Days, i just get this feeling that i'm helping to write dozens of Viruses...

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