CStatus类更新状态条上的现实内容 访问冲突 问题
来源:互联网 发布:热点wifi软件下载 编辑:程序博客网 时间:2024/06/05 19:49
一直想使用状态条动态显示文字。程序采用SDI不带Doc/View支持的架构。m_wndStatusBar可以访问,而且我就在MainFrm.cpp内使用。但是,我在使用GetPaneText()或者SetPaneText()总是出现访问冲突错误,其他相关的方法也是如此。一直觉得奇怪,这些方法都是属于CStatusBar类的,怎么就不能用了,不能用的话,什么方法用来达到同样的目的?
终于找到有关的资料,提到CStatusBar类创建后,面板的默认值是禁用的。真觉得vc++怎么故意在制造障碍。搜到相关的描述如下:
By default, a CStatusBar pane is notenabled when the pane is created. To activate a pane, you must call theON_UPDATE_COMMAND_UI() macro for each pane on the status bar and updatethe panes. Because panes do not send WM_COMMAND messages, you cannotuse ClassWizard to activate panes; you must type the code manually. Forexample, suppose one pane has ID_INDICATOR_PAGE as its identifier andthat it contains the current page number in a document. To make theID_INDICATOR_PAGE pane display text, add the following to a header file(probably the MAINFRM.H file):
afx_msg void OnUpdatePage(CCmdUI *pCmdUI);
//Add the following to the application message map:
ON_UPDATE_COMMAND_UI(ID_INDICATOR_PAGE, OnUpdatePage)
//Add the following to a source code file (probably MAINFRM.CPP):
void CMainFrame::OnUpdatePage(CCmdUI *pCmdUI)
{
pCmdUI->Enable();
}
Todisplay text in the panes, either call SetPaneText() or callCCmdUI::SetText() in the OnUpdate() function. For example, you mightwant to set up an integer variable m_nPage that contains the currentpage number. Then, the OnUpdatePage() function might read as follows:
void CMainFrame::OnUpdatePage(CCmdUI *pCmdUI)
{
pCmdUI->Enable();
char szPage[16];
wsprintf((LPSTR)szPage, "Page %d", m_nPage);
pCmdUI->SetText((LPSTR)szPage);
}
Thistechnique causes the page number to appear in the pane during idleprocessing in the same manner that the application updates otherindicators.
照着上面的描述,算是把问题解决了。状态栏内自已定义的面板可以动态显示文本了。不过还是觉得VC++跟VB比较起来,做同样的事情,代码书写繁琐多了,而且代码的错误提示让人坠入迷雾,如果不去搜索引擎,很难找到问题的根本原因!
- CStatus类更新状态条上的现实内容 访问冲突 问题
- flex 同时访问数据的冲突问题
- CMFCToolBar上按钮的状态更新
- WEB STANDARDS和现实项目的冲突
- 关于Windows更新窗口内容的问题
- 关于Tabhost里面的内容更新问题
- eclipse提交svn,解决内容冲突的问题
- 如何设置微软拼音状态条上的图标
- c语言中关于“访问冲突”的问题
- 解决线程同步带来的访问冲突问题
- cstatus bar
- Qt-GUI如何更新状态条
- 关于JAVAFX定时更新ui界面上的控件内容
- UIScrollview 和其view上的事件冲突问题
- 理念高大上的智慧社区,要落地还得俯下身解决四个现实问题
- 视图内容显示不全,没有垂直滚动条的问题
- 没有滚动条,页面内容显示不全问题的解决方法
- mysql 插入更新多条数据的效率问题
- 数据字典 sql
- android环境搭建
- 匈牙利算法
- 传智播客Hibernate视频教程学习笔记41
- JS调试技巧汇总(待补充)
- CStatus类更新状态条上的现实内容 访问冲突 问题
- 一个SqlDataReader的用法,dr.IsDBNull(2)用来判断第几列是否为null
- How to install live555 in the MSYS?
- 在vc中实现DIB图像镜像转换的两个方法
- J2EE 加载Spring的applicationContext.xml文件的两种方式
- 无线上网常见的十二大故障解决方法
- iframe 的onload事伯
- iPhone开发step by step
- ActiveX 控件测试容器 (tstcon32.exe)