Results 1 to 8 of 8

Thread: ObjectEvent not firing, please help!

  1. #1

    Thread Starter
    Lively Member Elvenstone's Avatar
    Join Date
    Feb 2008
    Location
    Rotterdam (Netherlands)
    Posts
    122

    Question ObjectEvent not firing, please help!

    Hi all!

    I built a usercontrol (JaNee), which fires an event called "Changed" when the optionbutton it contains is clicked.

    The control is added to a parent usercontrol at runtime using Controls.add, like this:

    Code:
    Private WithEvents m_Ctl As VBControlExtender
    ...
    Set m_Ctl = Controls.Add("MyControls.JaNee", "jnValue")
            m_Ctl.Visible = True
    I use the following to catch the event:

    Code:
    Private Sub m_Ctl_ObjectEvent(Info As EventInfo)
        If Info.Name = "Changed" Then
            MsgBox "Hello World!"
        End If
    End Sub
    This works fine for other usercontrols I've built, but for some particular reason, the ObjectEvent is not fired for this usercontrol.

    Any ideas guys? There has to be a logical explanation.
    Please be kind enough to RATE a helpful post.

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: ObjectEvent not firing, please help!

    This is going to sound like a couple of stupid questions.
    1. Are sure the control loaded? Have you checked with a statement similar to:
    If m_Ctl Is Nothing Then MsgBox "Failed to load JaNee"

    2. Are you sure the option button is firing the event? Is there any code in the option button's click event that is being tested and doesn't fire the event for some cases?

    3. Is the parent usercontrol & the JaNee controls enabled?

    If you simply do a Debug.Print Info.Name, do you get other events from the dynamically loaded usercontrol?
    Last edited by LaVolpe; Feb 7th, 2009 at 06:56 PM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    Lively Member Elvenstone's Avatar
    Join Date
    Feb 2008
    Location
    Rotterdam (Netherlands)
    Posts
    122

    Re: ObjectEvent not firing, please help!

    I do not regard your questions stupid, so here's the answers:

    1. Are sure the control loaded?
    Yes, the control is visible.
    2. Are you sure the option button is firing the event?
    Yes, stepping through the code it executes the RaiseEvent statement, but the Changed event is not captured by the ObjectEvent handler.
    3. Is the parent usercontrol & the JaNee controls enabled?
    Yes, all enabled properties are set to True.
    4. If you simply do a Debug.Print Info.Name, do you get other events from the dynamically loaded usercontrol?
    No, the "Changed" event is the only one event it fires.

    Thanks for thinking along. Any more suggestions?
    Please be kind enough to RATE a helpful post.

  4. #4

    Thread Starter
    Lively Member Elvenstone's Avatar
    Join Date
    Feb 2008
    Location
    Rotterdam (Netherlands)
    Posts
    122

    Angry Re: ObjectEvent not firing, please help!

    I added a new usercontrol which raises "Changed" when clicked.
    And as before the event is raised, but not handled by it's parent.

    I compared the usercontrol's properties to one that does work, but they are an exact match. Therefor, I am beginning to think it has something to do with the project properties. Alas, no differences found there either.

    As an old Hobbit would say: Confusticate and bebother VB!
    Please be kind enough to RATE a helpful post.

  5. #5
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: ObjectEvent not firing, please help!

    I tried to play along. I created a uc (uc#1) that had a couple of option buttons that raised a change event & compiled it. In IDE, I added a new usercontrol (uc#2) that dynamically loaded uc#1, using Controls.Add(...). When the option button was clicked, I did get the event in uc#2. Last dumb question: SP6 installed? I am running out of dumb questions & good ideas.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  6. #6

    Thread Starter
    Lively Member Elvenstone's Avatar
    Join Date
    Feb 2008
    Location
    Rotterdam (Netherlands)
    Posts
    122

    Lightbulb Re: ObjectEvent not firing, please help!

    SP6 is installed allright.

    I added the usercontrol that fires the event to the parent control's project and it works fine now.

    But off course, this not a fancy solution. Maybe if I reach the brilliant zone in the future, which I doubt, I will add the solution to this thread. Unless anyone else figures this thing out.

    Thanks for your help. I'll add one to your rep.
    Please be kind enough to RATE a helpful post.

  7. #7
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: ObjectEvent not firing, please help!

    If I understand you correctly the parent.child relationship looks like this:
    FormX.UserCtrl1.JaNee

    UserCtrl1 does get JaNee's events? If so, you want JaNee to send the event directly to the form? I don't think that is doable. JaNee would trigger events to UserCtrl1 and UserCtrl1 may need to forward/propogate those events to FormX

    The child parent relationship described above is what I used to try to replicate the problem. I may not have replicated the scenario correctly?
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  8. #8

    Thread Starter
    Lively Member Elvenstone's Avatar
    Join Date
    Feb 2008
    Location
    Rotterdam (Netherlands)
    Posts
    122

    Re: ObjectEvent not firing, please help!

    Nope. Just plain and simple UserCtrl1 handles JaNee's events.
    The JaNee is loaded runtime.
    Please be kind enough to RATE a helpful post.

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