Replace MessageBox Button's Caption
1
代码
var
hook: HHOOK;
const
K_YesNew = '&Yes-NEW'; //&:Can use short cut:Y replace for sigle click
K_NoNew = '&No-NEW';
K_OKNew = '&Ok-NEW';
K_CancelNew = '&Cancel-NEW';
function HookProc(Code: Integer; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;
begin
if (code=HCBT_ACTIVATE) then
begin
SetDlgItemText(wParam,IDYES,K_YesNew);
SetDlgItemText(wParam,IDNO,K_NoNew);
SetDlgItemText(wParam,IDOK,K_OKNew);
SetDlgItemText(wParam,IDCANCEL,K_CancelNew);
end;
Result := CallNextHookEx(hook,code,wparam,lparam);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
hook := SetWindowsHookEx(WH_CBT, @HookProc, 0, GetCurrentThreadID);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
UnhookWindowsHookEx(hook);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
MessageBox(Handle,'Hello ...','A Caption',MB_YESNOCANCEL);
end;