#include "stdafx.h"
#include "ModelView.h"

//////////////////////////////////////////////////////////////////////////
MMImplement_ClassName(CViewModel)
DuiBegin_Message_Map(CViewModel, CDUINotifyPump)
	Dui_On_Notify_Ctrl(DuiNotify_WndManagerAttach, IDC_CtrlIDThis, OnDuiWndManagerAttach)
	Dui_On_Notify_Ctrl(DuiNotify_WndManagerDetach, IDC_CtrlIDThis, OnDuiWndManagerDetach)
DuiEnd_Message_Map()

CViewModel::CViewModel()
{
	CDUIControlBase *pControl = g_DuiGlobal->LoadDui(_T("strDuiName"));
	if (NULL == pControl) return;

	InsertChild(pControl);

	return;
}

CViewModel::~CViewModel()
{
	if (m_pWndManager)
	{
		m_pWndManager->RemoveINotify(this);
	}

	return;
}

void CViewModel::OnInitView()
{
	return;
}

void CViewModel::OnFindControl()
{
	return;
}

void CViewModel::OnDuiWndManagerAttach(const DuiNotify &Notify)
{
	OnInitView();
	OnFindControl();

	if (m_pWndManager)
	{
		m_pWndManager->AddINotify(this);
	}

	return;
}

void CViewModel::OnDuiWndManagerDetach(const DuiNotify &Notify)
{
	if (m_pWndManager)
	{
		m_pWndManager->RemoveINotify(this);
	}

	return;
}
