XP Window Fading in MaxGUI

BlitzMax Forums/BlitzMax Programming/XP Window Fading in MaxGUI

SebHoll(Posted 2006) [#1]
Hi Everyone,

I found out a way to apply transition-like effects while hiding and showing windows in BlitzMax. You can do alpha fading and wipe effects by changing the flag value (from 1-5) in the function below. (0: Fade!) The visibility argument specifies whether you want the window to hide (0) or show (1) as a result of the effect. Finally the time argument tells Windows the duration of the effect (in milliseconds).

Declarations
Extern

Function LoadLibraryA( dll$z )
Function GetProcAddress:Byte Ptr( libhandle,func$z )

End Extern

Global libUser32 = LoadLibraryA("user32.dll")

Global AnimateWindow(hwnd,dword1,dword2)
AnimateWindow = GetProcAddress(libUser32,"AnimateWindow")

Function
Function WindowEffect(tmpgadget:TGadget,visibility:Byte=0,flags:Byte=0,time:Int=200)

If (flags < 0) Or (flags > 5) Or (visibility < 0) Or (visibility > 1) Or (time < 0) Then
	RuntimeError "Invalid arguments passed to WindowEffect()"
EndIf

Local varEffect:Int
Local varVisible:Int
Local windowhwnd:Int = QueryGadget(tmpgadget:TGadget,1)

If windowhwnd = 0 Then RuntimeError("Invalid gadget passed to WindowEffect()")

Select flags

	Case 0;varEffect = $80000
	Case 1;varEffect = $10
	Case 2;varEffect = $1
	Case 3;varEffect = $2
	Case 4;varEffect = $4
	Case 5;varEffect = $8

EndSelect

Select visibility

	Case 0;varVisible = $10000
	Case 1;varVisible = $20000

EndSelect

Return AnimateWindow(windowhwnd,time,varVisible | varEffect)

End Function
I don't know if there are any equivalent commands in the API for Macs or Linux but I hope this is of use to someone.

Here's an example that fades a window in and out.



Let me know what you think,


Seb