各位兄弟在看到標題時,可能會火冒三丈,"你這小子,欠揍嗎?"
在MessageBox的最後參數上指定MB_YESNO不就行了?
眾兄弟請息怒,請再看一遍標題,我說的是顯示"Yes"與"No",不是"是"與"否",以下為示例代碼:
HHOOK hHook;
LRESULT __stdcall CBTHookProc( long nCode,WPARAM wParam,LPARAM
lParam);
int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrevInstance,LPSTR
szCmdLine, int iCmdShow)
{
hHook=SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,hInst,NULL);
if (hHook)
{
MessageBox(NULL,"你是帥哥嗎?","SC++",MB_ICONINFORMATION|MB_YESNO);
}
else
{
MessageBox(NULL,"無法安裝HOOK" ,"SC++",MB_ICONINFORMATION|MB_YESNO);
}//if
return 1;
}
LRESULT __stdcall CBTHookProc( long nCode,WPARAM wParam,LPARAM
lParam)
{
if (nCode==HCBT_ACTIVATE)
{
SetDlgItemText((HWND)wParam,IDYES,"&Yes");
SetDlgItemText((HWND)wParam,IDNO ,"&No");
UnhookWindowsHookEx(hHook);
}
return 0;
}