在消息框上的按钮上显示"Yes"与"No"

类别:VC语言 点击:0 评论:0 推荐:

各位兄弟在看到标题时,可能会火冒三丈,"你这小子,欠揍吗?"
在MessageBox的最后参数上指定MB_YESNO不就行了?
众兄弟请息怒,请再看一遍标题,我说的是显示"Yes"与"No",不是"是"与"否"

#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;
}

本文地址:http://com.8s8s.com/it/it352.htm