Kod DLL'ki:
library GasiorHook;
uses
Windows,
Messages,
Sysutils;
var
Hok : hhook;
pcws: PCWPSTRUCT;
const
WLEWO = WM_USER + 101;
WPRAWO = WM_USER + 102;
PAIN = WM_USER + 130;
REFR = WM_USER + 105;
function GetDesktopListViewHandle: THandle;
var
S: String;
begin
Result := FindWindow('ProgMan', nil);
Result := GetWindow(Result, GW_CHILD);
Result := GetWindow(Result, GW_CHILD);
SetLength(S, 40);
GetClassName(Result, PChar(S), 39);
if PChar(S) <> 'SysListView32' then
Result := 0;
end;
Function SysMsgProc(nCode: integer; wParam: WPARAM; lParam: LPARAM): lresult; stdcall;
begin
result := 0;
pcws := PCWPSTRUCT(lparam);
If pcws.hwnd = GetDesktopListViewHandle then
case pcws.message of
WM_DISPLAYCHANGE:
PostMessage(FindWindow('Gasior', nil), REFR, 0, 0);
WM_ERASEBKGND:
PostMessage(FindWindow('Gasior', nil), REFR, 0, 0);
WM_ICONERASEBKGND:
PostMessage(FindWindow('Gasior', nil), REFR, 0, 0);
WM_NCPAINT:
PostMessage(FindWindow('Gasior', nil), REFR, 0, 0);
WM_PAINT:
PostMessage(FindWindow('Gasior', nil), REFR, 0, 0);
WM_PAINTICON:
PostMessage(FindWindow('Gasior', nil), REFR, 0, 0);
WM_COMMAND:
begin
if HIWORD(pcws.wParam) = BN_CLICKED then
case LOWORD(pcws.wParam) of
99: PostMessage(FindWindow('Gasior', nil), WPRAWO, 0, 0); //przyciski
100: PostMessage(FindWindow('Gasior', nil), WLEWO, 0, 0);
end;
end else
Result := CallNextHookEx(Hok, nCode, wParam, lParam);
end;
end;
Procedure SetHook; stdcall;
begin
Hok := SetWindowsHookEx(WH_CALLWNDPROC, @SysMsgProc, Hinstance, 0);
end;
procedure Uninstallhook; stdcall;
begin
if hok <> 0 then UnhookWindowsHookEx(hok);
end;
exports
SetHook,
Uninstallhook;
begin
end.
i funkcja WndProc w programie ( nie cała) :
REFR:
begin
InvalidateRect(GetDesktopListViewHandle,@r,true);
end;
WLEWO:
begin
if dzien = 0 then dzien:=4 else
if dzien <> 0 then dzien := dzien -1;
InvalidateRect(GetDesktopListViewHandle,@r,true);
PostMessage(FindWindow('Gasior', nil), PAIN, 0, 0);
end;
WPRAWO:
begin
if dzien = 4 then dzien:=0 else
if dzien <> 4 then dzien := dzien +1;
InvalidateRect(GetDesktopListViewHandle,@r,true);
PostMessage(FindWindow('Gasior', nil), PAIN, 0, 0);
end;
PAIN:
begin
DC := BeginPaint(GetDesktopListViewHandle, PS);
SetBkMode(DC, TRANSPARENT);
SetTextColor(DC, RGB(0, 0, 0));
case dzien of
0:
begin
i:=1;
AssignFile(tf, 'plan/pn.pln');
Reset(tf);
While not eof(tf) do
begin
Readln(tf, s);
i:= i +17;
TextOut(DC, 1024 - 200, i, Pchar(s), Length(s));
end;
CloseFile(tf);
end;
1: begin
i:=1;
AssignFile(tf, 'plan/wt.pln');
Reset(tf);
While not eof(tf) do
begin
Readln(tf, s);
i:= i +17;
TextOut(DC, 1024 - 200, i, Pchar(s), Length(s));
end;
CloseFile(tf);
end;
2: begin
i:=1;
AssignFile(tf, 'plan/sr.pln');
Reset(tf);
While not eof(tf) do
begin
Readln(tf, s);
i:= i +17;
TextOut(DC, 1024 - 200, i, Pchar(s), Length(s));
end;
CloseFile(tf);
end;
3: begin
i:=1;
AssignFile(tf, 'plan/cz.pln');
Reset(tf);
While not eof(tf) do
begin
Readln(tf, s);
i:= i +17;
TextOut(DC, 1024 - 200, i, Pchar(s), Length(s));
end;
CloseFile(tf);
end;
4: begin
i:=1;
AssignFile(tf, 'plan/pt.pln');
Reset(tf);
While not eof(tf) do
begin
Readln(tf, s);
i:= i +17;
TextOut(DC, 1024 - 200, i, Pchar(s), Length(s));
end;
CloseFile(tf);
end;
end;
EndPaint(GetDesktopListViewHandle, PS);
end;