![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
| |
| | #1 (permalink) |
| | 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) |
| | 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) |
| | 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![]() |
| | #4 (permalink) |
| | 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![]() |
| | #5 (permalink) |
| | 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 | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Associating MDB to MS Access | Microsoft Office | |||
| Is there a SELECTION-COMPLETED event for DATAGRIDVIEWS??? | .NET General | |||
| Object lifetime/event problem | .NET General | |||
| Adding canonical aliases for Compare-Object, Measure-Object, New-Object | PowerShell | |||