The AnimateWindow function allows four types of special effects when showing or hiding windows: roll, slide, expand, and fade. The call is made to #user32, passing the handle of the window (handle), the duration of animation in milliseconds (dwTime), and the desired effects (dwFlags).
Function AnimateWindow(handle, dwTime, dwFlags)
CallDLL #user32, "AnimateWindow", _
handle asuLong, _
dwTime asLong, _
dwFlags asLong, _
result asBooleanEndFunction
The functions returns a zero if the function fails, or a non-zero if the function is successful.
Specifying the Animation Types
AW_SLIDE Uses slide animation, the default is AW_ROLL AW_HOR_POSITIVE Animates the window from left to right, used with AW_SLIDE, or the default AW_ROLL AW_HOR_NEGATIVE Animates the window from right to left, used with AW_SLIDE, or the default AW_ROLL AW_VER_POSITIVE Animates the window from top to bottom, used with AW_SLIDE, or the default AW_ROLL AW_VER_NEGATIVE Animates the window from bottom to top, used with AW_SLIDE, or the default AW_ROLL AW_CENTER Expands the window from centerpoint outward when opening, negates any other direction flags AW_BLEND Uses a fade in effect when opening, or a fade out effect when closing, ignored if AW_CENTER is also assigned AW_ACTIVATE Activates the window, should not be used with AW_HIDE AW_HIDE Hides the window, the default is a visible window
Defining the Animation Values
Liberty BASIC recognizes many of the Windows constants. These animated window constants are not recognized. The values will need to be defined within the code.
If these values need to be seen within several subs or functions, it may be best to declare them Global in the beginning of your program.
Global AW.SLIDEGlobal AW.HOR.POSITIVE, AW.HOR.NEGATIVEGlobal AW.VER.POSITIVE, AW.VER.NEGATIVEGlobal AW.CENTERGlobal AW.ACTIVATE, AW.HIDEGlobal AW.BLEND
Showing and Hiding Windows
To show a window opening using an animation, that window must first be in AW_HIDE mode. Assign the stylebits_WS_VISIBLE in the removebits position before opening the window.
Stylebits #a, 0, _WS_VISIBLE, 0, 0
The Demo
The following demo uses various combinations of the AW values. Some effects are more pleasing than others. Not all combinations work with all types of windows. MSDN suggests 200 milliseconds as the value for dwTime. This demo uses a greater dwTime value for illustrative purposes. Adjust the value according to the needs of your program.
Animation while opening the window is easy to achieve. Just be sure the window is in the Hide state first. It hasn't been easy to find the code to close the window using animation. MSDN states
To take effect when hiding a window, use AW_HIDE and a logical OR operator with the appropriate flags.
AW_BLEND worked well. I was unable to find the correct combination that would show a window closing in either AW_CENTER or AW_SLIDE animation.
Opening and Closing Windows with Animation
The AnimateWindow function allows four types of special effects when showing or hiding windows: roll, slide, expand, and fade. The call is made to #user32, passing the handle of the window (handle), the duration of animation in milliseconds (dwTime), and the desired effects (dwFlags).
The functions returns a zero if the function fails, or a non-zero if the function is successful.
Specifying the Animation Types
AW_SLIDE Uses slide animation, the default is AW_ROLLAW_HOR_POSITIVE Animates the window from left to right, used with AW_SLIDE, or the default AW_ROLL
AW_HOR_NEGATIVE Animates the window from right to left, used with AW_SLIDE, or the default AW_ROLL
AW_VER_POSITIVE Animates the window from top to bottom, used with AW_SLIDE, or the default AW_ROLL
AW_VER_NEGATIVE Animates the window from bottom to top, used with AW_SLIDE, or the default AW_ROLL
AW_CENTER Expands the window from centerpoint outward when opening, negates any other direction flags
AW_BLEND Uses a fade in effect when opening, or a fade out effect when closing, ignored if AW_CENTER is also assigned
AW_ACTIVATE Activates the window, should not be used with AW_HIDE
AW_HIDE Hides the window, the default is a visible window
Defining the Animation Values
Liberty BASIC recognizes many of the Windows constants. These animated window constants are not recognized. The values will need to be defined within the code.If these values need to be seen within several subs or functions, it may be best to declare them Global in the beginning of your program.
Showing and Hiding Windows
To show a window opening using an animation, that window must first be in AW_HIDE mode. Assign the stylebits _WS_VISIBLE in the removebits position before opening the window.The Demo
The following demo uses various combinations of the AW values. Some effects are more pleasing than others. Not all combinations work with all types of windows. MSDN suggests 200 milliseconds as the value for dwTime. This demo uses a greater dwTime value for illustrative purposes. Adjust the value according to the needs of your program.Demo Limitations
Animation while opening the window is easy to achieve. Just be sure the window is in the Hide state first. It hasn't been easy to find the code to close the window using animation. MSDN states- To take effect when hiding a window, use AW_HIDE and a logical OR operator with the appropriate flags.
AW_BLEND worked well. I was unable to find the correct combination that would show a window closing in either AW_CENTER or AW_SLIDE animation.