Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

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.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Avalon

Associating an Animation::Completed event with an object

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 11-21-2006   #1 (permalink)
John Dunn
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 SpecsSystem Spec
Old 11-22-2006   #2 (permalink)
Stoitcho Goutsev \(100\)
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 SpecsSystem Spec
Old 11-22-2006   #3 (permalink)
Stoitcho Goutsev \(100\)
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 SpecsSystem Spec
Old 11-27-2006   #4 (permalink)
John Dunn
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 = gcnew
Animation:oubleAnimation(1,0,Duration( TimeSpan::FromMilliseconds( 150 )));
sanim->Completed += gcnew EventHandler( close_anim_done );
BeginAnimation( OpacityProperty, sanim );
}
My System SpecsSystem Spec
Old 11-27-2006   #5 (permalink)
John Dunn
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 = gcnew
Animation:oubleAnimation(1,0,Duration( TimeSpan::FromMilliseconds( 150 )));
sanim->Completed += gcnew EventHandler( close_anim_done );
BeginAnimation( OpacityProperty, sanim );
}
My System SpecsSystem Spec
Old 11-27-2006   #6 (permalink)
John Dunn
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 SpecsSystem Spec
Old 11-27-2006   #7 (permalink)
John Dunn
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 SpecsSystem Spec
Old 12-08-2006   #8 (permalink)
Stoitcho Goutsev \(100\)
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 SpecsSystem Spec
Old 12-08-2006   #9 (permalink)
Stoitcho Goutsev \(100\)
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 SpecsSystem Spec
Closed Thread

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


Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51