Jeg har funnet en løsning.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
hWinHook: HWND;
hHookDLL: HMODULE;
SetWindowOpacy: procedure (Handle: HWND; Opacy: Byte);
EnumWindowsProc: function (Handle: HWND; lParam: LPARAM): Boolean;
ShellProc: TFNHookProc;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
hHookDLL := LoadLibrary('hook.dll');
@SetWindowOpacy := GetProcAddress(hHookDLL, 'SetWindowOpacy');
@EnumWindowsProc := GetProcAddress(hHookDLL, 'EnumWindowsProc');
@ShellProc := GetProcAddress(hHookDLL, 'ShellProc');
EnumWindows(@EnumWindowsProc, 0); // gjør alle vinduer gjennomsiktige med valgt opacy verdi i DLL filen
hWinHook := SetWindowsHookEx(WH_SHELL, @ShellProc, hHookDLL, 0);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
if hWinHook > 0 then
UnhookWindowsHook(WH_SHELL, @ShellProc);
if hHookDLL > 0 then
FreeLibrary(hHookDLL);
end;
end.
DLL filen:
library hook;
uses
SysUtils,
Classes,
Windows;
const
WindowOpacyValue = 200;
{$R *.res}
procedure SetWindowOpacy(Handle: HWND; Opacy: Byte); stdcall;
begin
SetWindowLong(Handle, GWL_EXSTYLE, GetWindowLong(Handle, GWL_EXSTYLE) + WS_EX_LAYERED);
SetLayeredWindowAttributes(Handle, 0, Opacy, LWA_ALPHA);
end;
function EnumWindowsProc(Handle: HWND; lParam: LPARAM): Boolean; stdcall;
begin
Result := True;
if (Handle <> FindWindow('Progman', 'Program Manager'))
and (Handle <> FindWindow('Shell_TrayWnd', nil)) { Taskbar } then
SetWindowOpacy(Handle, WindowOpacyValue);
end;
function ShellProc(nCode: Integer; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;
begin
Result := 0;
if nCode < 0 then
begin
CallNextHookEx(WH_SHELL, nCode, wParam, lParam);
Exit;
end;
if nCode = HSHELL_WINDOWCREATED then
SetWindowOpacy(wParam, WindowOpacyValue);
end;
exports
SetWindowOpacy,
EnumWindowsProc,
ShellProc;
begin
end.
Mvh
DiZpel