莫名其妙的错误窗口

今天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效果如下:
我也许认为对一些经常使用的东西很熟悉,但是却发现自己并没有真正去了解过它。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值