Ok @pv007. Thought I should write a demo and see it for myself.
I won't include this in Imagen() as Windows 7 doesn't support WS_EX_LAYERED for controls.
Code: Select all
#NoEnv
#Warn
#SingleInstance, Force
SetWorkingDir, %A_ScriptDir%
SetBatchLines, -1
; Fade in/out a picture on layered control
; This script requires Windows OS v8.0 or higher
#NoEnv
#Warn
#SingleInstance, Force
SetWorkingDir, %A_ScriptDir%
SetBatchLines -1
If ! FileExist("pkf.jpg")
UrlDownLoadToFile
, http://www.indianaturewatch.net/images/album/photo/7700105755c69b2d6e684a.jpg
, pkf.jpg
Gui, New,, Fade-in / Fade-out
Gui, Margin, 20, 20
Gui, Add, Text, w1020 h680 hwndhPic +E0x80000 ; WS_EX_LAYERED
Gui, Show,, % "Fade-in / fade-out demo " (A_PtrSize=8 ? "x64" : "x86")
Sleep 500
hBM := LoadPicture("pkf.jpg", "GDI+")
mDC := DllCall("CreateCompatibleDC", "Ptr",0, "Ptr")
DllCall("SaveDC", "Ptr",mDC)
DllCall("SelectObject", "Ptr",mDC, "Ptr",hBM)
VarSetCapacity(SIZE, 8, 0)
NumPut(1020, SIZE, "int")
NumPut(680, SIZE, 4, "int")
VarSetCapacity(BLENDFUNCTION, 4, 0)
NumPut(1, BLENDFUNCTION, 3, "UChar")
SetBatchLines 1
Loop 255
DllCall("UpdateLayeredWindow", "Ptr",hPic, "Ptr",0, "Ptr",0
, "Ptr",&SIZE, "Ptr",mDC, "Int64P",0, "Int",0
, "Ptr", NumPut(A_Index, BLENDFUNCTION, 2, "UChar") - 3
, "Int", 2)
Sleep 2000
Loop 254
DllCall("UpdateLayeredWindow", "Ptr",hPic, "Ptr",0, "Ptr",0
, "Ptr",&SIZE, "Ptr",mDC, "Int64P",0, "Int",0
, "Ptr", NumPut(255-A_Index, BLENDFUNCTION, 2, "UChar") - 3
, "Int", 2)
DllCall("RestoreDC", "Ptr",mDC, "Int",-1)
DllCall("DeleteDC", "Ptr",mDC)
Return
GuiEscape:
GuiClose:
ExitApp