![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | Associating an Animation::Completed event with an object Is there an easy way to associate an EventHandler attached to the animation Completed event with the object that BeginAnimation was initially called? I need to run some cleanup code after my animation finishes. I've attached a handler to the Completed event but I can't find any useful context in the Object which is passed into the handler. The object is an Animation::AnimationClock but nowhere in the debugger can I find the Object that I called BeginAnimation from. I guess I could set up a callback on a timer to call the cleanup function but it seemed like it should be possible to hook into the Animation system to get this information. here's some psuedo code of what i'd like to do void anim_done( Object sender, EventArgs args ) { // somehow get the handle to the my_object instance here my_object.cleanup(); } void my_object::start_anim() { DoubleAnimation anim = new DoubleAnimation(); anim.From = 1; anim.To = 0; anim.Duration = 150; anim.Completed += anim_done; BeginAnimation( Opacity, anim ); } Thanks- John |
My System Specs![]() |
| | #2 (permalink) |
| Guest | Re: Associating an Animation::Completed event with an object John, Isn't it anim_done member of the my_object class? If it is the reference to the object is *this*. -- Stoitcho Goutsev (100) "John Dunn" <jhndnn@community.nospam> wrote in message news:Ot4BkSZDHHA.4024@TK2MSFTNGP04.phx.gbl... > Is there an easy way to associate an EventHandler attached to the > animation Completed event with the object that BeginAnimation was > initially called? > > I need to run some cleanup code after my animation finishes. I've attached > a handler to the Completed event but I can't find any useful context in > the Object which is passed into the handler. The object is an > Animation::AnimationClock but nowhere in the debugger can I find the > Object that I called BeginAnimation from. > > I guess I could set up a callback on a timer to call the cleanup function > but it seemed like it should be possible to hook into the Animation system > to get this information. > > here's some psuedo code of what i'd like to do > > void anim_done( Object sender, EventArgs args ) { > // somehow get the handle to the my_object instance here > my_object.cleanup(); > } > > void my_object::start_anim() { > DoubleAnimation anim = new DoubleAnimation(); > anim.From = 1; > anim.To = 0; > anim.Duration = 150; > anim.Completed += anim_done; > BeginAnimation( Opacity, anim ); > } > > Thanks- > > John > > |
My System Specs![]() |
| | #3 (permalink) |
| Guest | Re: Associating an Animation::Completed event with an object John, Isn't it anim_done member of the my_object class? If it is the reference to the object is *this*. -- Stoitcho Goutsev (100) "John Dunn" <jhndnn@community.nospam> wrote in message news:Ot4BkSZDHHA.4024@TK2MSFTNGP04.phx.gbl... > Is there an easy way to associate an EventHandler attached to the > animation Completed event with the object that BeginAnimation was > initially called? > > I need to run some cleanup code after my animation finishes. I've attached > a handler to the Completed event but I can't find any useful context in > the Object which is passed into the handler. The object is an > Animation::AnimationClock but nowhere in the debugger can I find the > Object that I called BeginAnimation from. > > I guess I could set up a callback on a timer to call the cleanup function > but it seemed like it should be possible to hook into the Animation system > to get this information. > > here's some psuedo code of what i'd like to do > > void anim_done( Object sender, EventArgs args ) { > // somehow get the handle to the my_object instance here > my_object.cleanup(); > } > > void my_object::start_anim() { > DoubleAnimation anim = new DoubleAnimation(); > anim.From = 1; > anim.To = 0; > anim.Duration = 150; > anim.Completed += anim_done; > BeginAnimation( Opacity, anim ); > } > > Thanks- > > John > > |
My System Specs![]() |
| | #4 (permalink) |
| Guest | Re: Associating an Animation::Completed event with an object Stoitcho Goutsev (100) wrote: > John, > Isn't it anim_done member of the my_object class? If it is the reference to > the object is *this*. > > My code is C++/CLI so the anim_done method is actually a static function. In that case the object is a System::Windows::Media::Animation::AnimationClock handle. Here's my C++ code- static void close_anim_done( Object^ obj, EventArgs^ args ) { // do something here } void window_t::close() { Animation: oubleAnimation^ sanim = gcnewAnimation: oubleAnimation(1,0,Duration( TimeSpan::FromMilliseconds( 150 )));sanim->Completed += gcnew EventHandler( close_anim_done ); BeginAnimation( OpacityProperty, sanim ); } |
My System Specs![]() |
| | #5 (permalink) |
| Guest | Re: Associating an Animation::Completed event with an object Stoitcho Goutsev (100) wrote: > John, > Isn't it anim_done member of the my_object class? If it is the reference to > the object is *this*. > > My code is C++/CLI so the anim_done method is actually a static function. In that case the object is a System::Windows::Media::Animation::AnimationClock handle. Here's my C++ code- static void close_anim_done( Object^ obj, EventArgs^ args ) { // do something here } void window_t::close() { Animation: oubleAnimation^ sanim = gcnewAnimation: oubleAnimation(1,0,Duration( TimeSpan::FromMilliseconds( 150 )));sanim->Completed += gcnew EventHandler( close_anim_done ); BeginAnimation( OpacityProperty, sanim ); } |
My System Specs![]() |
| | #6 (permalink) |
| Guest | Re: Associating an Animation::Completed event with an object John Dunn wrote: > Stoitcho Goutsev (100) wrote: >> John, >> Isn't it anim_done member of the my_object class? If it is the >> reference to the object is *this*. >> >> > > My code is C++/CLI so the anim_done method is actually a static > function. In that case the object is a > System::Windows::Media::Animation::AnimationClock handle. Here's my C++ > code- > > > static void close_anim_done( Object^ obj, EventArgs^ args ) { > // do something here > } > > void window_t::close() { > Animation: oubleAnimation^ sanim = gcnew> Animation: oubleAnimation(1,0,Duration( TimeSpan::FromMilliseconds( 150> ))); > sanim->Completed += gcnew EventHandler( close_anim_done ); > BeginAnimation( OpacityProperty, sanim ); > } Never mind, I just figured out if I use the other signature for the EventHandler constructor I can pass in a pointer along with a pointer to a member function. That works fine. |
My System Specs![]() |
| | #7 (permalink) |
| Guest | Re: Associating an Animation::Completed event with an object John Dunn wrote: > Stoitcho Goutsev (100) wrote: >> John, >> Isn't it anim_done member of the my_object class? If it is the >> reference to the object is *this*. >> >> > > My code is C++/CLI so the anim_done method is actually a static > function. In that case the object is a > System::Windows::Media::Animation::AnimationClock handle. Here's my C++ > code- > > > static void close_anim_done( Object^ obj, EventArgs^ args ) { > // do something here > } > > void window_t::close() { > Animation: oubleAnimation^ sanim = gcnew> Animation: oubleAnimation(1,0,Duration( TimeSpan::FromMilliseconds( 150> ))); > sanim->Completed += gcnew EventHandler( close_anim_done ); > BeginAnimation( OpacityProperty, sanim ); > } Never mind, I just figured out if I use the other signature for the EventHandler constructor I can pass in a pointer along with a pointer to a member function. That works fine. |
My System Specs![]() |
| | #8 (permalink) |
| Guest | Re: Associating an Animation::Completed event with an object Yes, this is what C# anonyimous methods does automatically for us, but if you use c++ I guess you need to do it by yourself. -- Stoitcho Goutsev (100) "John Dunn" <jhndnn@community.nospam> wrote in message news:ugY8PcmEHHA.4048@TK2MSFTNGP02.phx.gbl... > John Dunn wrote: >> Stoitcho Goutsev (100) wrote: >>> John, >>> Isn't it anim_done member of the my_object class? If it is the reference >>> to the object is *this*. >>> >>> >> >> My code is C++/CLI so the anim_done method is actually a static function. >> In that case the object is a >> System::Windows::Media::Animation::AnimationClock handle. Here's my C++ >> code- >> >> >> static void close_anim_done( Object^ obj, EventArgs^ args ) { >> // do something here >> } >> >> void window_t::close() { >> Animation: oubleAnimation^ sanim = gcnew>> Animation: oubleAnimation(1,0,Duration( TimeSpan::FromMilliseconds(>> 150 ))); >> sanim->Completed += gcnew EventHandler( close_anim_done ); >> BeginAnimation( OpacityProperty, sanim ); >> } > > Never mind, I just figured out if I use the other signature for the > EventHandler constructor I can pass in a pointer along with a pointer to a > member function. That works fine. |
My System Specs![]() |
| | #9 (permalink) |
| Guest | Re: Associating an Animation::Completed event with an object Yes, this is what C# anonyimous methods does automatically for us, but if you use c++ I guess you need to do it by yourself. -- Stoitcho Goutsev (100) "John Dunn" <jhndnn@community.nospam> wrote in message news:ugY8PcmEHHA.4048@TK2MSFTNGP02.phx.gbl... > John Dunn wrote: >> Stoitcho Goutsev (100) wrote: >>> John, >>> Isn't it anim_done member of the my_object class? If it is the reference >>> to the object is *this*. >>> >>> >> >> My code is C++/CLI so the anim_done method is actually a static function. >> In that case the object is a >> System::Windows::Media::Animation::AnimationClock handle. Here's my C++ >> code- >> >> >> static void close_anim_done( Object^ obj, EventArgs^ args ) { >> // do something here >> } >> >> void window_t::close() { >> Animation: oubleAnimation^ sanim = gcnew>> Animation: oubleAnimation(1,0,Duration( TimeSpan::FromMilliseconds(>> 150 ))); >> sanim->Completed += gcnew EventHandler( close_anim_done ); >> BeginAnimation( OpacityProperty, sanim ); >> } > > Never mind, I just figured out if I use the other signature for the > EventHandler constructor I can pass in a pointer along with a pointer to a > member function. That works fine. |
My System Specs![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Is there a SELECTION-COMPLETED event for DATAGRIDVIEWS??? | Alan Mailer | .NET General | 0 | 08-17-2008 05:00 PM |
| Object lifetime/event problem | Barry Gilbert | .NET General | 5 | 05-27-2008 09:47 AM |
| Associating WMI disk classes | Thomas Makro | PowerShell | 8 | 01-30-2008 09:05 AM |
| Adding canonical aliases for Compare-Object, Measure-Object, New-Object | Alex K. Angelopoulos [MVP] | PowerShell | 2 | 05-26-2006 07:58 AM |
| Event fired when an animation ends? | Jason Dolinger | Avalon | 3 | 01-31-2006 06:59 AM |