各位兄弟在看到标题时,可能会火冒三丈,"你这小子,欠揍吗?"
(本文来源于图老师网站,更多请访问http://m.tulaoshi.com/bianchengyuyan/)在MessageBox的最后参数上指定MB_YESNO不就行了?
众兄弟请息怒,请再看一遍标题,我说的是显示"Yes"与"No",不是"是"与"否",以下为示例代码:本文发表于http://bianceng.cn(编程入门网)
#include windows.h
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;
}