?? utransparent.pas
字號:
//unit UTransparent: Transparent the Windows;
unit UTransparent;
interface
uses Windows;
function TransparentWind(const Handle: THandle; Level: Byte; Toggle: Boolean): Boolean;
function LoadWin2k: Boolean;
function UnLoadWin2k: Boolean;
function WinVer: Integer;
function GetTrans(Int: Integer): Byte;
var
TransLoaded: Boolean;
const
OS_WINNT = 1; { WINDOWS NT}
OS_WIN32 = 0; { WINDOWS 95 OR 98}
OS_WINS = 2; { WIN32 UNDER WIN3.1}
OS_WINNT4 = 3; { NT 4 }
OS_WIN2k = 4; { Win2k - duh! }
implementation
var
LayerFunc: Function(Handle: HWND; crKey: DWord; bAlpha: Byte; dwFlags: DWORD): Bool; stdcall;
hDLL: HWND;
const
WS_EX_LAYERED = $00080000;
LWA_COLORKEY = $00000001;
LWA_ALPHA = $00000002;
ULW_COLORKEY = $00000001;
ULW_ALPHA = $00000002;
ULW_OPAQUE = $00000004;
function GetTrans(Int: Integer): Byte;
begin
case Int of
0: result := 0;
1: result := 40;
2: result := 80;
3: result := 120;
4: result := 160;
5: result := 200;
6: result := 240
else
result := 0;
end;
end;
function WinVer: Integer;
var
OSVerInfo: TOSVersionInfo;
begin
try
OSVerInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
GetVersionEx(OSVerInfo);
result := OSVerInfo.dwMajorVersion;
case OSVerInfo.dwPlatformID of
VER_PLATFORM_WIN32s: Result := OS_WINS;
VER_PLATFORM_WIN32_WINDOWS: result := OS_WIN32;
VER_PLATFORM_WIN32_NT: begin
case OSVerInfo.dwMajorVersion of
1: result := OS_WINNT;
2: result := OS_WINNT;
3: result := OS_WINNT;
4: result := OS_WINNT4;
5: result := OS_WIN2k;
end;
end
else
result := OSVerInfo.dwPlatformID;
end;
except
result := -1;
end;
end;
function LoadTransDLL: Boolean;
begin
try
hDLL := LoadLibrary('user32.dll');
if hDLL <> 0 then
@LayerFunc := GetProcAddress(hDLL, 'SetLayeredWindowAttributes');
result := true;
except
result := false;
end;
end;
function LoadWin2k: Boolean;
begin
if WinVer = OS_WIN2k then
begin
try
if LoadTransDll then
begin
Result := True;
TransLoaded := True;
end
else
begin
result := false;
TransLoaded := false;
end;
except
TransLoaded := false;
result := false;
end;
end
else
result := false;
end;
function UnLoadWin2k: Boolean;
begin
if WinVer = OS_WIN2k then
begin
try
@LayerFunc := Nil;
FreeLibrary(HDLL);
result := true;
except
result := false;
end;
end
else
result := False;
end;
function TransparentWind(const Handle: THandle; Level: Byte; Toggle: Boolean): Boolean;
var
dwLong,
nAlpha: DWORD;
begin
if WinVer = OS_WIN2k then
begin
if Toggle = true then
begin // turn it on
try
if Level < 10 then Level := 10 // anything lower is blank
else
if Level > 240 then Level := 240; // anything higher is blank
dwLong := GetWindowLong(Handle, GWL_EXSTYLE);
nAlpha := Level;
SetWindowLong(Handle, GWL_EXSTYLE, dwLong or WS_EX_LAYERED);
LayerFunc(Handle, RGB(0,0,0), nAlpha, LWA_ALPHA);
result := true;
except
result := false;
end;
end
else
begin // turn it off
try
dwLong := GetWindowLong(Handle, GWL_EXSTYLE);
SetWindowLong(Handle, GWL_EXSTYLE, dwLong and (NOT WS_EX_LAYERED));
result := true;
except
result := false;
end;
end;
end
else
result := false; // oops- this isn't win2k
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -