I am creating the check style menu. But I have tried many times, it always failed.
I give my program as following:
void CHandyScopeDlg::OnMeasureCh1()
{
m_nChannel = 1;
Invalidate();
}void CHandyScopeDlg::OnUpdateMeasureCh1(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(m_nChannel == 1);
}
void CHandyScopeDlg::OnUpdateMeasureCh2(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(m_nChannel == 2);
}void CHandyScopeDlg::OnMeasureCh2()
{
m_nChannel = 2;
Invalidate();
}I set the style of menu Measure->Ch1 and Measure->Ch2 to checked.
but it is not successful. Then, I omit this style, not successful either.
I don't know how to deal with it. Please give me some suggestion.
I am on aboard. so I can't type Chinese, sorry!
I give my program as following:
void CHandyScopeDlg::OnMeasureCh1()
{
m_nChannel = 1;
Invalidate();
}void CHandyScopeDlg::OnUpdateMeasureCh1(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(m_nChannel == 1);
}
void CHandyScopeDlg::OnUpdateMeasureCh2(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(m_nChannel == 2);
}void CHandyScopeDlg::OnMeasureCh2()
{
m_nChannel = 2;
Invalidate();
}I set the style of menu Measure->Ch1 and Measure->Ch2 to checked.
but it is not successful. Then, I omit this style, not successful either.
I don't know how to deal with it. Please give me some suggestion.
I am on aboard. so I can't type Chinese, sorry!
解决方案 »
- 在VS2008中运行C++源文件
- 再请教各位大鸟mfc程序在vista的英文操作系统下的安装错误
- 求一片因为文章
- 求助---我刚学MFC时遇到的几个问题
- 在VC中,如何使用和调用.dll(急)
- 怎样读写word里的数据
- 初学者问题:用define自定义的消息语句出错, 为何??
- 如何改变对话框的背景颜色?
- 用UDP发送mpg,mpeg1数据,可丢包%3左右就会死机,(接收端我用dx里的Memfile例子改的)
- MFC ODBC database
- 现在在一家网络公司做网站,主要用asp,可想多学些其它的东西,为将来所用。可不知该从哪里下手?
- 哪儿有《MFC程序设计Using Visual C++ 6.0》下载啊??
先将变量去掉,直接写pCmdUI->SetCheck(1);或pCmdUI->SetCheck(0)试试;
void CHandyScopeDlg::OnUpdateMeasureCh2(CCmdUI* pCmdUI) 下面,
如下:
static int i=0;
pCmdUI->SetCheck(i);
i = 1-i;
这样都不行。不知道是为什么。然后我把菜单和CHandyScopeApp这个类联系起来,
意思是说把OnUpdateMeasureCh2作为它的成员函数。但是结果还是失败,着实郁闷了几天。
对了,如果我是在基于单文档或者复合文档的应用程序下面实现这样的功能,使用同样的代码,是完全没有问题的。
我看到一本书上这样说的,在你Click弹出式菜单的时候,就调用了OnUpdate...这个函数。
然后实现更新,而我设置断点,发现Click弹出式菜单的时候根本就没有调用这个函数,只有点击要更新的菜单项的时候,才中断。
不知道你们有没有明白我的意思,如果父菜单式File,下面有一个子菜单New,书上说点File,就调用了File父菜单下所有子菜单的OnUpdate,而我测试的时候,只有点击New菜单项,才调用OnUpdateNew这个函数。
同样,在SDI和MDI里面测试,是和书上说的一摸一样。是否给对话框绑定菜单的时候,需要考虑很多因素,而且还有很多功能不能用呢?
望赐教!!!你们也可以建一个基于对话框的应用程序自己试一试我说的是不是事实,谢谢!