phillip Posted October 12, 2004 Posted October 12, 2004 Guys I am receiving an Object position changed event from another application. when i handle the event i move another object in the application. I need to stop the event getting handled a second time when i move the object as it crashes the applicaion. How can i switch the event handler off while i move the object? Thanks Quote phillip Restall
mocella Posted October 12, 2004 Posted October 12, 2004 In C# it looks something like this: this.btnTest.Click -= new System.EventHandler(this.btnTest_Click); That will turn off the click event handler for "btnTest", and to turn it back on, you'd do this (notice any similarities to the first code?): this.btnTest.Click += new System.EventHandler(this.btnTest_Click); Quote
phillip Posted October 12, 2004 Author Posted October 12, 2004 In C# it looks something like this: this.btnTest.Click -= new System.EventHandler(this.btnTest_Click); That will turn off the click event handler for "btnTest", and to turn it back on, you'd do this (notice any similarities to the first code?): this.btnTest.Click += new System.EventHandler(this.btnTest_Click); Thanks for the Reply, I'm using Visual basic Quote phillip Restall
Leaders Iceplug Posted October 12, 2004 Leaders Posted October 12, 2004 If you are using Handles, then you cannot turn it off and your best bet would be to wrap all of the inside code in an If block. If you used AddHandler, then you can use RemoveHandler to remove the handler (equivalent to the example above). :) Quote Iceplug, USN One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(
phillip Posted October 12, 2004 Author Posted October 12, 2004 If you are using Handles, then you cannot turn it off and your best bet would be to wrap all of the inside code in an If block. If you used AddHandler, then you can use RemoveHandler to remove the handler (equivalent to the example above). :) I'll have to try the Addhandler method. how would i make that work? here is what i'm currently doing Private sub blahblah() handles appx.position_change_event appx.move("shape1",x,y) end sub Quote phillip Restall
phillip Posted October 12, 2004 Author Posted October 12, 2004 I got the add event handler woking but it did not help The problem seems to be the other application. It seems to crash when firing the second event when it has not recived the first one back (excuse my terminoligy lol) I need to end the routine and then do the oject move. I tried setting up a timer to run after the routine finishes that then moves the oject but the timer does not seem to work from my event (timer1.enabled=true) Can anyone think of a way round this? Quote phillip Restall
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.