Share this page 

Have a transparent windowTag(s): WinAPI/Registry


[Available on W2K or better] A cool effect giving a see-through window.
[local external function]
FUNCTION long GetWindowLong (ulong hWnd, int nIndex) & 
   LIBRARY "USER32.DLL"  ALIAS FOR "GetWindowLongA"
FUNCTION long SetWindowLong (ulong hWnd, int nIndex, long dwNewLong) & 
   LIBRARY "USER32.DLL" ALIAS FOR "SetWindowLongA"

//W2K or better
FUNCTION long SetLayeredWindowAttributes & 
  (long hWnd, Long crKey , char /*Byte*/ bAlpha , Long dwFlags) & 
     LIBRARY "USER32.DLL" 


[powerscript]
CONSTANT long LWA_COLORKEY = 1, LWA_ALPHA = 2
CONSTANT long GWL_EXSTYLE = - 20
CONSTANT long WS_EX_LAYERED = 524288 //2^19
long ll_Ret, ll_handle

// or-bitwise function
OleObject wsh
wsh = CREATE OleObject
wsh.ConnectToNewObject( "MSScriptControl.ScriptControl" )
wsh.language = "vbscript"

ll_handle = Handle (this)  // handle of the window
ll_Ret = GetWindowLong(ll_handle, GWL_EXSTYLE)
ll_Ret = wsh.Eval(string(ll_ret) + " or " + string(WS_EX_LAYERED))
SetWindowLong (ll_handle, GWL_EXSTYLE, ll_Ret)

// Set the opacity of the layered window to 128 (transparent)
SetLayeredWindowAttributes (ll_handle, 0, char(128),LWA_ALPHA)

// Set the opacity of the layered window to 255 (opaque)
// SetLayeredWindowAttributes (ll_handle, 0, char(255),LWA_ALPHA)