新建一个窗口:
w_test
外部函数调用:
Function ulong SetLayeredWindowAttributes(ulong hWnd , long crKey , Character bAlpha ,long dwFlags) library"user32.dll"
FUNCTION ulong SetWindowulong(ulong hwnd,ulong nIndex,ulong dwNewLong) LIBRARY "user32.dll" ALIAS FOR "SetWindowLongA"
窗口实例变量:
ulong GWL_WNDPROC = -4
ulong GWL_HINSTANCE = -6
ulong GWL_STYLE = -16
ulong GWL_EXSTYLE = -20
ulong GWL_USERDATA = -21
ulong GWL_ID = -12
ulong DWL_MSGRESULT = 0
ulong DWL_DLGPROC = 4
ulong DWL_USER = 8
ulong WS_EX_LAYERED = 524288
long LWA_COLORKEY = 1
long LWA_ALPHA = 2
open事件脚本:
//设置窗口新的扩展属性
SetWindowulong(Handle(This), GWL_EXSTYLE, WS_EX_LAYERED)
//设置透明度
SetLayeredWindowAttributes(Handle(This), 0, Char(200), LWA_ALPHA)
注:
Private Declare Function SetLayeredWindowAttributes Lib _
"user32" (ByVal hWnd As Long, ByVal crKey As Long, ByVal _
bAlpha As Byte, ByVal dwFlags As Long) As Long
hwnd是透明窗体的句柄
crKey为颜色值,
bAlpha是透明度,取值范围是[0,255],
dwFlags是透明方式,可以取两个值:
当取值为LWA_ALPHA时,crKey参数无效,bAlpha参数有效;
当取值为LWA_COLORKEY时,Alpha参数有效而窗体中的所有颜色为crKey的地方将变为透明。
LWA_ALPHA = 0x2
LWA_COLORKEY=0x1
也可以取两个值的组合:LWA_ALPHA Or LWA_COLORKEY。这样crKey的地方将变为全透明,而其它地方根据bAlpha参数确定透明度。