![]() |
WndProc der Windows Uhr
Hallo,
hab mir den Quellcode zu ![]() Nun wollte ich das WndProc der Uhr folgendermaßen ableiten:
Delphi-Quellcode:
Leider muss ein Fehler in der "CallWndProc" Funktion vorhanden sein!?
library ClockHook;
var g_hhook: THandle; hwndTaskbar, hwndTray, g_hwndClock: hwnd; idThread: dword; g_bInitClock: boolean = false; g_oldWndProc, g_hInst: THandle; procedure RefreshRebar(myHwnd: hwnd); var hhwnd: hwnd; begin if myHwnd > 0 then begin InvalidateRect(myHwnd, nil, TRUE); hhwnd := GetWindow(myHwnd, GW_CHILD); while hhwnd > 0 do begin InvalidateRect(hhwnd, nil, TRUE); hhwnd := GetWindow(hhwnd, GW_HWNDNEXT); end; end; end; procedure RefreshTaskbar(myHwnd: hwnd); var hwndTaskbar, hwndRebar, hwndTray, hwndStartButton: hwnd; begin hwndTray := GetParent(myHwnd); hwndTaskbar := GetParent(hwndTray); hwndRebar := FindWindowEx(hwndTaskbar, 0, 'ReBarWindow32', nil); hwndStartButton := FindWindowEx(hwndTaskbar, 0, 'Button', nil); InvalidateRect(hwndStartButton, nil, TRUE); InvalidateRect(hwndTray, nil, TRUE); PostMessage(hwndTray, WM_SIZE, SIZE_RESTORED, 0); RefreshRebar(hwndRebar); PostMessage(hwndRebar, WM_SIZE, SIZE_RESTORED, 0); InvalidateRect(hwndTaskbar, nil, TRUE); PostMessage(hwndTaskbar, WM_SIZE, SIZE_RESTORED, 0); end; function WndProc(hWnd: HWND; uMsg: UINT; wParam: wParam; lParam: LParam): lresult; stdcall; begin case uMsg of WM_LBUTTONDOWN: MessageBoxA(0, 'Left mouse button', 'Test', 0); end; result := CallWindowProc(@g_oldWndProc, hWnd, uMsg, wParam, lParam); end; procedure InitClock(myHwnd: hwnd); begin if g_bInitClock then exit; g_bInitClock := true; g_oldWndProc := GetWindowLong(myHwnd, GWL_WNDPROC); SetWindowLong(myHwnd, GWL_WNDPROC, LongInt(@WndProc)); RefreshTaskbar(myHwnd); end; function CallWndProc(ncode: integer; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall; var pcwps: PCWPSTRUCT; begin pcwps := PCWPSTRUCT(lParam); if (ncode = HC_ACTION) then begin if (not g_bInitClock) and (pcwps.hwnd = g_hwndClock) then InitClock(pcwps.hwnd); end; result := CallNextHookEx(g_hhook, ncode, wParam, lParam); end; function StartHook(): boolean; stdcall; begin g_hInst := GetModuleHandle('ClockHook.dll'); hwndTaskbar := FindWindow('Shell_TrayWnd', nil); hwndTray := FindWindowEx(hwndTaskbar, 0, 'TrayNotifyWnd', nil); g_hwndClock := FindWindowEx(hwndTray, 0, 'TrayClockWClass', nil); idThread := GetWindowThreadProcessId(hwndTaskbar, nil); g_hhook := SetWindowsHookEx(WH_CALLWNDPROC, @CallWndProc, g_hInst, idThread); PostMessage(hwndTaskbar, WM_SIZE, SIZE_RESTORED, 0); result := true; end; function StopHook(): boolean; stdcall; begin SetWindowLong(killhwnd, GWL_WNDPROC, g_oldWndProc); g_oldWndProc := 0; RefreshTaskbar(killhwnd); result := UnhookWindowsHookEx(g_hhook); g_hhook := 0; end; exports StartHook, StopHook; begin end. "pcwps.hwnd = g_hwndClock" führt nicht zum Erfolg. Das Hwnd der Uhr wird nicht wieder gefunden... Wo ist mein Fehler. Habe schon einiges probiert und mir den Originalen C-Quellcode etliche male angeschaut, kann aber nichts finden :? Vielleicht findet ja einer von euch den Fehler ... mfg |
Re: WndProc der Windows Uhr
*push* Hat keiner eine Idee??? :idea:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 08:29 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz