If it is suitable, you can change the name of your application (set by default to the name of the project) by editing a resource string named AFX_IDS_APP_TITLE. This string seems to be used by AfxMessageBox as the caption.
MFC--如何修改AfxMessageBox的title
需求原因:代码中有很多提示信息,都是用的AfxMessageBox弹出,默认title会显示工程名,现在需要修改成指定的名称。
解决方案一:(已测试可行)
对你的App重写DoMessageBox()函数
- // disable windows for modal dialog
- EnableModeless(FALSE);
- HWND hWndTop;
- HWND hWnd = CWnd::GetSafeOwner_(NULL, &hWndTop);
- // determine icon based on type specified
- if ((nType & MB_ICONMASK) == 0)
- {
- switch (nType & MB_TYPEMASK)
- {
- case MB_OK:
- case MB_OKCANCEL:
- nType |= MB_ICONEXCLAMATION;
- break;
- case MB_YESNO:
- case MB_YESNOCANCEL:
- nType |= MB_ICONEXCLAMATION;
- break;
- case MB_ABORTRETRYIGNORE:
- case MB_RETRYCANCEL:
- break;
- }
- }
- LPCTSTR pszCaption = _T("PANDA"); //此处修改title
- int nResult = ::MessageBox(hWnd, lpszPrompt, pszCaption, nType);
- // re-enable windows
- if (hWndTop != NULL)
- ::EnableWindow(hWndTop, TRUE);
- EnableModeless(TRUE);
- return nResult;
-
- //return CWinApp::DoMessageBox(lpszPrompt, nType, nIDPrompt);
参考自: http://forums.codeguru.com/showthread.php?396053-AfxMessageBox()-title
推荐阅读