duilib虚拟窗口使用

 方便每一个TabLayout的界面都可以用一个类去处理;避免将所有的消息写到同一个主窗口类中;方便维护;

主窗口代码:

构造函数中添加

CEtcdMainWnd::CEtcdMainWnd()
{
	AddVirtualWnd(_T("PatManage"),&m_PatManagePage);         //加载“病例管理”界面   PatManage与xml配置必须相同
	m_PatManagePage.Init(&m_PaintManager,NULL);
}

xml配置

<HorizontalLayout virtualwnd="PatManage">
	<Include source="PatManagePage.xml" />
</HorizontalLayout>

类中添加消息处理类的成员变量

CPatManagePage m_PatManagePage; 

消息处理类的声明与定义

.h文件

#ifndef _ETCD_PATMANAGE_PAGE_H__
#define	 _ETCD_PATMANAGE_PAGE_H__

#include "stdafx.h"
class CPatManagePage : public DuiLib::CNotifyPump
{
public:
	CPatManagePage();
	~CPatManagePage();

    void Init(CPaintManagerUI *pPaint, HWND hWnd);

public:
	DUI_DECLARE_MESSAGE_MAP() //定义消息
	virtual void OnClick(TNotifyUI& msg);
	virtual void OnSelectChange(TNotifyUI &msg); //定义消息

private:
	CPaintManagerUI *m_PaintManager;
	HWND m_hWnd;
};


#endif

.cpp文件

#include "stdafx.h"
#include "EtcdPatManagePage.h"

DUI_BEGIN_MESSAGE_MAP(CPatManagePage, CNotifyPump)//定义消息
DUI_ON_MSGTYPE(DUI_MSGTYPE_CLICK,OnClick)
DUI_ON_MSGTYPE(DUI_MSGTYPE_SELECTCHANGED,OnSelectChange)
DUI_END_MESSAGE_MAP()//定义消息
CPatManagePage::CPatManagePage(){}CPatManagePage::~CPatManagePage(){}void CPatManagePage::Init(CPaintManagerUI *pPaint, HWND hWnd){m_hWnd = hWnd;m_PaintManager = pPaint; //这个是为了能够在此类中找到相关控件}void CPatManagePage::OnClick(TNotifyUI& msg) //消息处理函数{ }void CPatManagePage::OnSelectChange(TNotifyUI &msg)//消息处理函数{} 
 

猜你喜欢

转载自blog.csdn.net/qwerdf10010/article/details/79389540