在mfc对话框前添加起始对话框的问题
来源:互联网 发布:淘宝更改登录名 编辑:程序博客网 时间:2024/05/19 16:48
前提:首先添加UIcontrol.cpp和UIcontrol.h两个文件。
#pragma onceenum {UI_INDEX_MAIN=0,//主窗口界面//UI_INDEX_SECOND,//第二个界面
//上面的界面对应自己的每一个界面};class CUIcontrol{public:CUIcontrol(void);~CUIcontrol(void);int get_current_index(){return m_current;};CDialog * get_current_ui();void showUI(int index);private:int m_current;CDialog*m_lpUI;};
#include "StdAfx.h"#include "UIcontrol.h"//此处添加每一个对应界面类的头文件
CUIcontrol::CUIcontrol(void){m_lpUI = NULL;m_current = -1;}CUIcontrol::~CUIcontrol(void){if(m_lpUI){delete m_lpUI;}}void CUIcontrol::showUI(int index){if(index == m_current){return;}CDialog *lp = NULL;switch(index){case UI_INDEX_MAIN:lp = (CDialog*)new CMainDlg();//对应界面的类break;case UI_INDEX_SECOND:lp = (CDialog*)new CSecond();//自己建立的类break;default:return;}if(lp){if(m_lpUI){m_lpUI->SendMessage(WM_CLOSE,0,0);}m_current = index;m_lpUI = lp;m_lpUI->DoModal();}}CDialog* CUIcontrol::get_current_ui(){return m_lpUI;}
然后添加一个对话框,创建类。添加的类对应上面的Second类。
然后在工程文件的APP类的InitInstance()中添加如下语句:
#include "UIcontrol.h"CUIcontrol UIcontrol; #include "Second.h"以上是定义UI成员变量。
void welcome::OnButton1() {UIcontrol.showUI(UI_INDEX_SECOND);//此处是第一个对话框上面的按钮事件,作用是调用第二个界面}
Enable3dControlsStatic();// Call this when linking to MFC statically#endif//UIControl.showUI(UI_INDEX_MAIN);//主界面UIControl.showUI(UI_INDEX_SECOND);//第二个界面
/*CCD_MetroDlg dlg;m_pMainWnd = &dlg;int nResponse = dlg.DoModal();if (nResponse == IDOK){// TODO: Place code here to handle when the dialog is// dismissed with OK}else if (nResponse == IDCANCEL){// TODO: Place code here to handle when the dialog is// dismissed with Cancel}*/// Since the dialog has been closed, return FALSE so that we exit the// application, rather than start the application's message pump.return FALSE;
}
然后运行就是。不明白的可以联系我。以上说的已经很清楚了。
- 在mfc对话框前添加起始对话框的问题
- VS2008 MFC对话框工程中,在对话框中添加ActiveX控件生成类的问题
- 在基于对话框MFC中动态的添加对话框
- MFC对话框窗口始终在最前
- 在MFC对话框中添加背景图片中遇到的问题之解决
- 在MFC中怎样添加一个非模态的对话框
- 在MFC工程中添加一个有列表的对话框
- 在mfc对话框中添加一个显示网页的窗口
- MFC 对话框中添加ACTIVEX后失败的问题
- 如何在MFC对话框中添加背景图片
- 在MFC对话框中添加状态栏
- MFC 在对话框中添加WM_ERASEBKGND响应函数
- 在MFC对话框中添加状态栏
- 在MFC对话框中添加状态栏
- MFC在对话框添加右键菜单
- 在MFC对话框中添加菜单
- MFC 在对话框中添加工具条
- 在MFC(VS2013)对话框中添加菜单
- gQuery : 简化 DOM 操作,兼容 jQuery
- s3c2440存储控制器和地址以及启动的理解
- mysql 中关于select into outfile 提示权限不足的问题
- 使用 copy 命令备份windows dhcp数据
- Measure Application Launch time?
- 在mfc对话框前添加起始对话框的问题
- C# usb Hid 访问上位机USB通讯实例 实现设备在线或者离线和发送接收数据通讯功能
- linux定时任务计划
- IE加载Flex时,报$2032错误的解决方法
- VC++2010环境下基于MFC框架的OpenGL的编程环境的配置
- BZOJ 1030([JSOI2007]文本生成器-AC自动机endmark)
- Spring property 设置属性的属性
- 【实验二】进程的创建与可执行程序的加载
- qt中的句柄类,实体类