Articles 3D Audio Custom Controls General RB Graphics Hacks Mac OS X Menus Novelty Printing REALbasic 2005 REALbasic 2006 Registration Resources Reviews Serial Speech Sockets XML Video Resource Links News Current News February 2006 January 2006 December 2005 November 2005 October 2005 September 2005 August 2005 July 2005 June 2005 May 2005 April 2005 March 2005 ![]() REALbasic for Dummies by Erick Tejkowski ![]() Learning REALbasic through Applications REALbasic for Macintosh REALbasic Cross-Platform Application Development
Older files are in Stuffit 5 or greater format. Newer files are ".Zip". Download StuffIt Expander |
|
I cooked up an example project for someone using a slider and a button to fade in and out a window for a certain lenth of time. I morphed that into this project which automatically fades in and out a window when it is shown or hidden. I don't think you should use this for ever application or even many, but in the chance where you have one where a window needs to fade in (like a global floating window for a background task) here is how you can do it.
Setup First, add a new class called FadeWindow (a Window subclass) and then add a constant kFadeLength = 0.06 as a number. Next add a Close event definition, and then follow the steps below.
Fading In There's a Carbon function called SetWindowAlpha which sets the translucency of a window with a value from 0 (transparent) to 100 (opaque). So all our window fading has to do is loop for a certain length of time (under 0.1 seconds is good) and linearly change the value from 0 to 100 to fade in. We do that like so:
FadeIn is called from the Show method after calling the superclass's show method so the window actually shows up first.
Similarly, we call FadeOut from the Close event (not the method since it calls CancelClose and does some other things).
And then the fade out code is the same as fade in, but there's a "1.0 - " in front of the alpha parameter to flip the value from going from 0 to 100 to 100 down to 0.
Finished That's all there is to it. There's . Download the project.
|
||||
|
||||||||||||||||||||||||||||||||
Maintained by the Staff of ResExcellence. This entire site ©1997-2006 ResExcellence
Privacy Statement? Sure we gotta Privacy Statement.
[an error occurred while processing this directive]