Results 1 to 5 of 5

Thread: Unfreeze events?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,996

    Unfreeze events?

    I have low expectations to find a solution to this issue, but anyway here it goes:

    Background info:

    In a component I need to show a form and after the form is on the screen to fire some events from an UserControl were the client program must do some things that are necessary.
    If the host program is showing a form modally, I have no other way that to show my form also modally.

    The problem is, that it woks fine when both programs run in the IDE, also works fine when both programs are compiled, but when the component is compiled and the host program runs on the IDE, the events do not fire.
    The UserControl.EventsFrozen property returns True in that case.

    It seems to me more a bug that an intentional feature (similar to Timers not firing when there is a MsgBox displayed... bust just in the IDE because compiled they fire).

    I spent some hours investigating, and found this old article from MSDN that is about VB4 but VB6 must be similar.

    Quoting the article:
    FreezeEvents(TRUE) is called on all controls before a modal dialog or message
    box is put up. FreezeEvents(FALSE) is called after that dialog or messagebox
    is destroyed.
    That's not how VB6 works in all cases because it freezes the events only when the component is compiled and the host programs runs in the IDE.

    I've been investigating how to unfreeze the events, and found these pages:
    IOleControl::FreezeEvents method
    Event Freezing

    I tried to use the IOleControl interface that has the FreezeEvents method with argument 0, here is the sample:

    FreezeEvents.zip
    (It needs OLEGuids.tlb)

    But it didn't work.

    I found a vbAccelerator article describing a test project that replaces the VTable of FreezeEvents, tried that in the following test project (it uses VBAccelerator's original code):

    FreezeEvents_RepVTable.zip

    That didn't work either.

    Reading again one of the articles that I posted above, the one Event Freezing, it says:

    A container can notify a control that it is not ready to respond to events by calling IOleControl::FreezeEvents with TRUE.
    It seems to me that the calls to FreezeEvents is only to notify a dependant object of an state, not to set the state (to freeze or unfreeze events).
    It seems that VB6 decides not to send the events and just notify to the control via FreezeEvents.

    Do you have any idea about how to solve this?

  2. #2
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,375

    Re: Unfreeze events?

    In which place on the UserControl you make "RaiseEvent"?
    Sometimes it's maybe better to use PostMessage and process the Msg.

  3. #3
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,120

    Re: Unfreeze events?

    Setting freeze on the events is signalled to all user-controls instantiated by raising AmbientChanged event for the "UIDead" property.

    Basicly the IDE notifies that it has shown a modal dialog of some kind -- Help->About or Add to Watch dialog or Error dialog w/ "Variable not defined".

    Not sure if events are frozen upon MsgBox and/or modal forms as these come from the run-time not the IDE.

    cheers,
    </wqw>

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,996

    Re: Unfreeze events?

    Quote Originally Posted by Krool View Post
    In which place on the UserControl you make "RaiseEvent"?
    Sometimes it's maybe better to use PostMessage and process the Msg.
    It receives the event from a helper class module.
    But it is the same if you call a method on the usercontrol to raise the event, when a form in the ActiveX Control project is displayed modally, the events of the usercontrols are frozen.
    It is not in a particular state (other than that).
    I cannot hide the form to raise the event, it must be done while the form is shown.

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,996

    Re: Unfreeze events?

    Quote Originally Posted by wqweto View Post
    Setting freeze on the events is signalled to all user-controls instantiated by raising AmbientChanged event for the "UIDead" property.

    Basicly the IDE notifies that it has shown a modal dialog of some kind -- Help->About or Add to Watch dialog or Error dialog w/ "Variable not defined".

    Not sure if events are frozen upon MsgBox and/or modal forms as these come from the run-time not the IDE.

    cheers,
    </wqw>
    I'm forced to show the form modal when the host program is showing a form modal. Still I need to fire the events and the host program need to respond (that's not optional).

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