| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 592 人关注过本帖
标题:关于状态栏的Create函数
只看楼主 加入收藏
shn521
Rank: 2
等 级:论坛游民
威 望:1
帖 子:56
专家分:52
注 册:2010-6-18
结帖率:73.33%
收藏
已结贴  问题点数:20 回复次数:2 
关于状态栏的Create函数
BOOL CStatusBarDemoDlg::OnInitDialog()
{
    CDialog::OnInitDialog();

    // Set the icon for this dialog.  The framework does this automatically
    //  when the application's main window is not a dialog
    SetIcon(m_hIcon, TRUE);            // Set big icon
    SetIcon(m_hIcon, FALSE);        // Set small icon
     
    // TODO: Add extra initialization here
    //创建状态栏,并新建2个子窗格
    m_status.Create(this);
    UINT nID[] = {ID_SEPARATOR, 100};
    m_status.SetIndicators(nID, 2);
    //移动状态栏到合适的位置
    RECT rect = {0};
    GetClientRect(&rect);
    m_status.MoveWindow(0, rect.bottom - 20, rect.right - 10, 20, TRUE);
    //将第二个格子的宽度设置为80
    m_status.SetPaneInfo(0, 0, 0, rect.right - 10 - 80);
    m_status.SetPaneInfo(1, 100, 0, 80);
   
    return TRUE;  // return TRUE  unless you set the focus to a control
}
为什么把this换成GetParent()编译就出现Debug Assertion Failed,为什么不能替换呢,还有什么情况会出现Debug Assertion Failed
搜索更多相关主题的帖子: 状态 函数 Create 
2010-08-03 14:03
东海一鱼
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:贵宾
威 望:48
帖 子:757
专家分:4760
注 册:2009-8-10
收藏
得分:20 
m_status.Create(this);这个参数传递的是一个CWnd*对象指针,就是m_status的父对象。this指针就是CStatusBarDemoDlg这个实例,当然没有问题。
换成GetParent实际上就是在调用this->GetParent获得CStatusBarDemoDlg的父对象。结果就为NULL了。所以断言失败。

还有什么情况会出现Debug Assertion Failed?

传递NULL指针,或无效对象都会引发Debug Assertion Failed。


举世而誉之而不加劝,举世而非之而不加沮,定乎内外之分,辩乎荣辱之境,斯已矣。彼其于世未数数然也。
2010-08-03 14:58
shn521
Rank: 2
等 级:论坛游民
威 望:1
帖 子:56
专家分:52
注 册:2010-6-18
收藏
得分:0 
回复 2楼 东海一鱼
感谢
2010-08-04 16:42
快速回复:关于状态栏的Create函数
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015148 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved