VC ++ 2010的奇怪问题 [英] Strange Issue With VC++ 2010

查看:74
本文介绍了VC ++ 2010的奇怪问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只在MDI应用程序中编写了此代码
我的工具栏按钮已被打开"按钮删除.
问题是,如果我运行并测试应用程序以删除按钮两次或三次,则下次我不需要按按钮时,工具栏按钮也会自动被删除.即使在清理并重建后,甚至在关闭项目并
重新显示工具栏按钮不会重新出现.这是什么错误或智慧?
谁能告诉我这是什么?

I have written only this code in MDI application
My toolbar button gets removed by On Button.
The issue is that If I run and test the application to remove the button two or three times , The next time I dont require to press button,toolbar button gets automatically removed.Even after clean and rebuild ,even after closing project and
Rebuiding again toolbar button does not reappear.What is this bug or intellisence
Can anyone tell me What is this ?

void CMerilisaRApp::OnButton()
{
    ((CMainFrame*)(AfxGetApp()->GetMainWnd()))->ApplyPolicy();
}







void CMainFrame::ApplyPolicy(void)
{
    m_wndToolBar.RemoveButton(4);
    
}

推荐答案

您应该首先为该按钮添加一个测试.如果您的代码被多次调用,则还应该使用按钮标识符而不是索引.您是否真的确定要删除而不是禁用它?
You should first add a test for that button existing. You should also use button identifiers rather than indices in case your code gets called multiple times. Are you really sure that you want this removed rather than disabled?


这篇关于VC ++ 2010的奇怪问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆