Results 1 to 6 of 6

Thread: Events in ActiveX controls

  1. #1

    Thread Starter
    Hyperactive Member brenaaro's Avatar
    Join Date
    Sep 2001
    Location
    Montreal, Canada
    Posts
    391

    Events in ActiveX controls

    Will an ActiveX control wait for any code in an event handler to finish executing before processing the code after the RaiseEvent call?

    Example:
    VB Code:
    1. 'In the ActiveX control...
    2.    MsgBox "1"
    3.    RaiseEvent Call("2")
    4.    MsgBox "3"
    5.    '...rest of code
    6.  
    7. 'In the calling application
    8. Public Sub MyControl_Call(Msg As String)
    9.    MsgBox Msg
    10. End Sub

    Will I get 1,2,3?
    And I, for one, welcome our new insect overlords. I'd like to remind them as a trusted TV personality, I can be helpful in rounding up others to toil in their underground sugar caves.

  2. #2
    Frenzied Member vbgladiator's Avatar
    Join Date
    May 2001
    Posts
    1,950
    Run it and see. I don't think it will stop and wait.
    Don't anthropomorphize computers -- they hate it

  3. #3

    Thread Starter
    Hyperactive Member brenaaro's Avatar
    Join Date
    Sep 2001
    Location
    Montreal, Canada
    Posts
    391

    Wink

    *throws his hands in the air*
    Awwww!!! Do I have to do EVERYTHING myself?!?!

    I decided to just move the code after that RaiseEvent to a public method, and let the user decide if that code should be executed or not by calling the method..makes it easier on me
    And I, for one, welcome our new insect overlords. I'd like to remind them as a trusted TV personality, I can be helpful in rounding up others to toil in their underground sugar caves.

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    I believe it does wait. In other ActiveX objects it does (dll/exe). Because you can get a return value from the event and can decide what to do from there. That is kind of how the Cancel parameter works for things like the Unload Event of a form.

    VB Code:
    1. 'in axtivex
    2. Public Event Closing(Cancel As Boolean)
    3.  
    4. dim bCancel as boolean
    5. RaiseEvent Closing(bCancel)
    6. If bCancel=True then Exit Sub
    7. 'user didn't cancel in the event so continue
    8.  
    9. 'in the event
    10. Public Sub Obj_Closing(Cancel As Boolean)
    11.   'this gets returned to the object
    12.   Cancel=True
    13. End Sub

  5. #5
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    it should wait on a message box at least since it will display modally to the control...

  6. #6

    Thread Starter
    Hyperactive Member brenaaro's Avatar
    Join Date
    Sep 2001
    Location
    Montreal, Canada
    Posts
    391
    Ah yes the Unload and QueryUnload events..that makes sense now that I think of it.

    I was pretty sure if I had a message box displaying it would wait, but it was highly unlikely we would have a message box in the event handler in question.

    Anyways, thanks for the feedback as always.
    And I, for one, welcome our new insect overlords. I'd like to remind them as a trusted TV personality, I can be helpful in rounding up others to toil in their underground sugar caves.

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