Advice on "return-when-finished" function call 
Author Message
 Advice on "return-when-finished" function call

Hey everyone,

   I wrote a very simple class that takes a
bitmap "strip" and animates it frame by frame onto the
provided device context with a speed that the caller can
specify.

   My function is: AnimateBlt (HDC, int x, int y, ...)

   How would I write it so that the function itself will
not return until the animation cycle is complete?

   Right now, the function sets a timer, and on each tick
of the timer, the frame is incremented and updated onto
the screen. It works well and the animation looks real.
Problem is, after the animation is complete,
the "permanent" image (not part of the strip) must be
rendered overtop the last frame of the animation, and as
it stands now- it does but is never seen because my
function returns prior to the last frame being rendered.

   How can I do this?

TIA- Stiffler



Sun, 20 Feb 2005 12:43:25 GMT  
 Advice on "return-when-finished" function call
If the intervals are short and the whole animation plays out quickly,
just use Sleep for delays. Otherwise, you can spin a modal message pump
based on PeekMessage to keep UI responsive, but beware reentrancy.
--
With best wishes,
    Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken


Quote:
> Hey everyone,

>    I wrote a very simple class that takes a
> bitmap "strip" and animates it frame by frame onto the
> provided device context with a speed that the caller can
> specify.

>    My function is: AnimateBlt (HDC, int x, int y, ...)

>    How would I write it so that the function itself will
> not return until the animation cycle is complete?

>    Right now, the function sets a timer, and on each tick
> of the timer, the frame is incremented and updated onto
> the screen. It works well and the animation looks real.
> Problem is, after the animation is complete,
> the "permanent" image (not part of the strip) must be
> rendered overtop the last frame of the animation, and as
> it stands now- it does but is never seen because my
> function returns prior to the last frame being rendered.

>    How can I do this?

> TIA- Stiffler



Sun, 20 Feb 2005 23:14:40 GMT  
 Advice on "return-when-finished" function call
Thanks Igor,
   THe first option should work nicely.

Quote:
>-----Original Message-----
>If the intervals are short and the whole animation plays
out quickly,
>just use Sleep for delays. Otherwise, you can spin a
modal message pump
>based on PeekMessage to keep UI responsive, but beware
reentrancy.
>--
>With best wishes,
>    Igor Tandetnik

>"For every complex problem, there is a solution that is
simple, neat,
>and wrong." H.L. Mencken



>> Hey everyone,

>>    I wrote a very simple class that takes a
>> bitmap "strip" and animates it frame by frame onto the
>> provided device context with a speed that the caller can
>> specify.

>>    My function is: AnimateBlt (HDC, int x, int y, ...)

>>    How would I write it so that the function itself will
>> not return until the animation cycle is complete?

>>    Right now, the function sets a timer, and on each
tick
>> of the timer, the frame is incremented and updated onto
>> the screen. It works well and the animation looks real.
>> Problem is, after the animation is complete,
>> the "permanent" image (not part of the strip) must be
>> rendered overtop the last frame of the animation, and as
>> it stands now- it does but is never seen because my
>> function returns prior to the last frame being rendered.

>>    How can I do this?

>> TIA- Stiffler

>.



Mon, 21 Feb 2005 02:10:15 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Q: Return-values of system("...") calls

2. Function without a "return type"?

3. lint warning "function actually returns double"

4. WinSock function "connect" returns unknown error

5. How to call the function "RasEnumEntries"

6. The mysterious "Call" function

7. function call with "pipe"

8. what is called a "hush function"?

9. "Pure Virtual Function Call"

10. Q : What is returned by "return;"

11. "Standards" advice needed

12. "Application" Type Advice

 

 
Powered by phpBB® Forum Software