今天Leader说我升级过的一个东东出了个错误窗口,图如下:
我记得我没有把BOX的caption设置成错误的习惯,所以一口咬定不是自己写的。
结果最后自己查出果然是自己写的。(哎,话不能说太满啊。。。。。)
出现上面的对话框是因为调用了user32.dll导出的系统API
int MessageBox(
HWND hWnd, LPCTSTR lpText, LPCTSTR lpCaption, UINT uType );
第三个参数
lpCaption
[in] Pointer to a null-terminated string that contains the dialog box title. If this parameter is NULL, the default title
Error is used.
我的代码居然是MessageBox(0,NULL,NULL,MB_OK);
平常在从CWND集成出来的类调用的是CWnd::MessageBox
int CWnd::MessageBox(LPCTSTR lpszText, LPCTSTR lpszCaption, UINT nType)
{
if (lpszCaption == NULL)
lpszCaption = AfxGetAppName();
int nResult = ::AfxCtxMessageBox(GetSafeHwnd(), lpszText, lpszCaption, nType);
return nResult;
}
第三个参数如果为NULL,它会获取当前模块状态的实例名称
AfxGetModuleState()->m_lpszCurrentAppName
// Human-redable name of the application. Normally set in
// constructor or retreived from AFX_IDS_APP_TITLE.
是类CWinApp的成员变量
LPCTSTR m_pszAppName;
当然它最后还是调用了上面所说的系统API函数。
调用MFC的CWnd::MessageBox效果如下:
![](https://p-blog.csdn.net/images/p_blog_csdn_net/king011a/EntryImages/20090927/b2.jpg)
我也许认为对一些经常使用的东西很熟悉,但是却发现自己并没有真正去了解过它。