1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| function HookPaintProc(Code: Integer; RemoveOrNot: WPARAM; MSG: LPARAM): LRESULT; stdcall;
var
DC: HDC;
TextString: ShortString;
begin
Result := 0;
with TMsg(Pointer(MSG)^) do
begin
if message = WM_PAINT then
begin
DC := GetDC(hwnd);
if DC > 0 then
begin
SendMessage(hwnd, message, wParam, lParam); // ne provoque pas de HookPaintProc ... j'aurais cru que ...
TextString := '';
GetClassName(hwnd, @TextString[1], 255);
TextOut(DC, 0, 0, @TextString[1], StrLen(@TextString[1]));
message := WM_NULL;
end;
end;
end;
end;
function StartPaintHook(): HHOOK; stdcall;
begin
Result := SetWindowsHookEx(WH_GETMESSAGE, HookPaintProc, HInstance, 0);
end;
procedure StopPaintHook(HookPaintHandle: HHook); stdcall;
begin
if HookPaintHandle <> 0 then
UnhookWindowsHookEx(HookPaintHandle);
end; |
Partager