在VC++工具栏按钮上添加文本标签
2008-01-19 20:24:07 来源:WEB开发网UINT GetProfileInt( LPCTSTR lpszSection, LPCTSTR lpszEntry, int nDefault );
它和下面的函数CWinApp::Write rofileInt("Setting","m_bTextTips",m_bTextTips)搭配使用,
对该函数的使用,您可参考帮助文件,本文不再赘述.
2.在CMainFrame类的析构函数~CMainFrame()中加入如下代码保存文本标签的显示状态:
CMainFrame::~CMainFrame() { AfxGetApp()->WriteProfileInt("Setting","m_bTextTips",m_bTextTips);
}
3.加入相应的菜单项,用于控制文本标签的显示与否,如下:
在属性对话框中,选中Checked复选框,ID号为:ID_TOOL_TEXTTIPS.
4.用ClassWizard加入该菜单项的命令处理函数和接口更新处理函数,并加入以下代码:
void CMainFrame::OnToolTexttips()
{
m_bTextTips = !m_bTextTips; } void CMainFrame::OnUpdateToolTexttips(CCmdUI* pCmdUI) {
pCmdUI->SetCheck(m_bTextTips);
}
三、功能实现
以上完成了用户接口的编写工作,然后添加文本标签,步骤如下:
1.在CMainFrame类的实现文件开始部分假如静态数组,用于存放文本标签,如下:
#ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__;
2.用ClassWizard为CMainFrame添加一成员函数:void CMainFrame::UpdateToolBar(BOOL bRecalc = TRUE);用于更新工具条
#endif static TCHAR *TextTips[] = {"新建","打开","存盘","","剪切","复制","粘贴","","打印","","关于",""};
更多精彩
赞助商链接