Ecco un po 'di codice che ho scritto, si potrebbe desiderare di usarlo nota per nota.
function SetHook(Code : Integer; wparam : Integer; LParam : Integer) : Longint; stdcall;
function HookWndProc(wnd : HWND ;uMsg : UINT; wParam : WPARAM; lParam : LPARAM) : LRESULT; stdcall;
var
CaptHook : HHOOK;
GHookProc : TFNWndProc;
GOldHookProc : TFNWndProc;
implementation
uses Messages, Types, Graphics;
function SetHook(Code : Integer; wparam : Integer; LParam : Integer) : Longint; stdcall;
var
pwp : CWPSTRUCT;
begin
if Code = HC_ACTION then
begin
pwp := CWPStruct(Pointer(LParam)^);
if pwp.message = WM_INITDIALOG then
begin
GOldHookProc := TFnWndProc(SetWindowLong(pwp.hwnd, GWL_WNDPROC, LongInt(GHookProc)));
end;
end;
result := CallNextHookEx(CaptHook, Code, wparam, lparam);
end;
function HookWndProc(wnd : HWND ;uMsg : UINT; wParam : WPARAM; lParam : LPARAM) : LRESULT;
var
DC : HDC;
WndRect : Trect;
BR: HBRUSH;
WndText : array[1..20] of char;
begin
result := CallWindowProc(GOldHookProc, wnd, uMsg, wParam, lParam);
if uMsg = WM_ERASEBKGND then
begin
GetWindowText(wnd, @wndText, 20);
//do stuff here (I colored the button red)
DC := GetDC(wnd);
WndRect := Rect(0, 0, 200,200);
BR := CreateSolidBrush(clRed);
FillRect(dc, WndRect, BR);
DeleteObject(BR);
ReleaseDC(wnd, dc);
end;
end;
...
mettere questo nel vostro modulo Crea in cui si desidera effettuare le finestre di messaggio funky
uses windows;
...
CaptHook := SetWindowsHookEx(WH_CALLWNDPROC, @SetHook, 0, GetCurrentThreadId);
GHookProc := @HookWndProc;
Quindi, ciò che questo fa agganciare le funzioni di finestra di dialogo di Windows e puoi ottenere il contesto per la finestra di dialogo e disegnare su di esso.
fonte
2011-10-13 13:27:19
+1 Questo sembra corrispondere meglio a quello che Shirish sta cercando –
@aldo grazie per l'idea – Shirish11
Non ho mai saputo dell'esistenza di 'FindComponent'. +1! –