This is the operative code for my splash screen generator:
COMMON /SPLASH/ ICTRL
COMMON /Spl_Hnd/ iSplash_Wnd, jSplash_Wnd, NoInc
! various things in between
ICTRL = 1
NoInc = 255
Delta_Time = 2.0D0/255.0D0
IB=WINIO@('%ww[no_border,no_caption,no_maxminbox,topmost,'// &
& 'toolwindow,no_frame]&')
IB=WINIO@('%^bm[SPLASHBMP]&','EXIT')
IB=WINIO@('%lc%hw&', iSplash_Wnd, jSplash_Wnd)
IB=WINIO@('%dl%lw',Delta_Time,KOUNTER,ictrl)
RETURN
END
KOUNTER is an INTEGER FUNCTION that counts down changing the splash opacity so it fades away:
INTEGER FUNCTION KOUNTER()
C --------------------------
COMMON /SPLASH/ ICTRL
COMMON /Spl_Hnd/ iSplash_Wnd, jSplash_Wnd, NoInc
LOGICAL IA, SetWindowOpacity
IF (NoInc .GE. 1) THEN
IA=SetWindowOpacity(jSplash_Wnd, NoInc)
NoInc = NoInc-1
KOUNTER=1
ELSE
ICTRL = 0
KOUNTER=0
ENDIF
RETURN
END
and because this predates the incorporation of transparency in Clearwin+, it employs the code posted by another contributor (modified a tiny bit by me):
logical function SetWindowOpacity(hWnd, alpha)
C ----------------------------------------------
! Set opacity level for a window (call after window creation) -
! automatically sets appropriate extended style and sets opacity
! from 0 (transparent) to 255 (no transparency).
use mswin
integer, parameter:: WS_EX_LAYERED = Z'00080000'
integer, parameter:: LWA_COLORKEY = Z'00000001'
integer, parameter:: LWA_ALPHA = Z'00000002'
STDCALL SetLayeredWindowAttributes 'SetLayeredWindowAttributes'
& (VAL, VAL, VAL, VAL) : LOGICAL*4
integer, intent(in):: hWnd
integer, intent(in):: alpha
integer:: attrib, i
! Get current window attributes to ensure WS_EX_LAYERED extended style is set
attrib = GetWindowLong(hWnd, GWL_EXSTYLE)
if (IAND(attrib,WS_EX_LAYERED) /= WS_EX_LAYERED) then
i = SetWindowLong(hWnd, GWL_EXSTYLE, IOR(attrib,WS_EX_LAYERED))
end if
! Set layered window alpha value
SetWindowOpacity = SetLayeredWindowAttributes
& (hWnd, 0, CORE1(LOC(alpha)), LWA_ALPHA)
end function SetWindowOpacity
The persistence of vision effect makes dark splashes appear to be visible some time after they have actually disappeared.
It is also useful to kill off the splash if the main application window has fully loaded, especially if it loads with a pre-existing 'document', which is done by setting the window handle (ictrl in this case) to zero.
Eddie