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;

 

posted @ 2010-12-21 16:12  Jekhn  阅读(213)  评论(0编辑  收藏  举报