Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can you temporarily disable and then reenable event processing

Status
Not open for further replies.

WantsToLearn

Programmer
Feb 15, 2003
147
0
0
US
Hello all,

I have a process that causes a whole bunch of events to fire. If I could temporarily disable event processing that would be very helpful. In Excel VBA you can do this, but I wasn't sure in VB6. Thanks for your help!
 
It would get messy but a dirty hack would be to use a global variable as a sort of flag.

gBusyFlag = True
Call MyProcess()
gBusyFlag = False

...

Private Sub ThisObject_SomeEvent()
If gBusyFlag Then Exit Sub

'... rest of event handler goes here ...
End Sub


Of course this would cause the events to be dropped altogether. You could hook the app message queue to intercept all external events but I'm not sure if that would catch your internal ones and if it ignores external events for more than a few seconds then Windows will decide to mark it Not Responding.
 
Sorry, I didn't communicate very clearly after programming most of the night before to fix a bug. I have a form with a new button which clears all of the form controls. What I would like to be able to do is stop other control events while I am processing the new code (eg no GotFocus, LostFocus events for other controls). Thanks!
 
There's no built-in way to do this. The way to do it would be to use a "busy" flag like Sheco says.

In the future, you might want to move all your code from the event methods to their own methods (in a module or another class). That way you'll be able to call the methods to get the desired functionality working, but without all the messy events firing.

This is called a model-view-controller architecture. The form is your view, the model is the data shown in the form, and the controller is the code that operates on the form, as well as performing actions that the form requests.

Chip H.


____________________________________________________________________
Click here to learn Ways to help with Tsunami Relief
If you want to get the best response to a question, please read FAQ222-2244 first
 
Thanks, Chip! Do you have any links or resources that show some examples?

Have a great day!

j2consulting@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top