Как отловить появление MessageBox
Оформил: DeeCo
function CenterProc(nCode: Integer;
wParam: WPARAM;
lParam: LPARAM): LRESULT; stdcall;
begin
Result := CallNextHookEx(hHook, nCode, wParam, lParam);
if nCode = HCBT_ACTIVATE then
begin
// CenterDialog(wParam);
UnhookWindowsHookEx(hHook)
end
end;
function MessageBoxCenter(hWnd: HWND; lpText, lpCaption: PChar; uType: UINT):
Integer;
var
hHook: THandle = 0;
begin
hHook := SetWindowsHookEx(WH_CBT, @CenterProc, hInstance, GetCurrentThreadID);
Result := MessageBox(hWnd, lpText, lpCaption, uType);
end;
|