#include "StdAfx.h"
#include "MyChartWnd.h"

#include "CChart\Chart.h"
using namespace NsCChart;
#pragma comment(lib,"CChart/CChartu.lib")
 
namespace SOUI
{
	CSouiRealWndHandler::CSouiRealWndHandler(void)
	{

	}
 
	CSouiRealWndHandler::~CSouiRealWndHandler(void)
	{
	}
 
	HWND CSouiRealWndHandler::OnRealWndCreate( SRealWnd *pRealWnd )
	{
		const SRealWndParam &param=pRealWnd->GetRealWndParam();
		if(param.m_strClassName==_T("MyChartWnd"))
		{
			static HWND hWnd = CreateSubChartWnd(pRealWnd->GetContainer()->GetHostHwnd(), kTypeXY);
			int len = 100;
			for(int i=0; i<=len; i++)
			{
				GetChart(hWnd)->AddPoint2D(i, i*i/(double)len/len);
			}
			GetChart(hWnd)->SetTitle(_T("SoUI中的CChart"));
			pRealWnd->SetData(&hWnd);
			//返回成功创建后的窗口句柄

			pRealWnd->SetFocus();
			return hWnd;
		}else
		{
			return 0;
		}
	}
 
	void CSouiRealWndHandler::OnRealWndDestroy( SRealWnd *pRealWnd )
	{
		const SRealWndParam &param=pRealWnd->GetRealWndParam();
		if(param.m_strClassName==_T("MyChartWnd"))
		{//销毁真窗口，释放窗口占用的内存
			HWND *phWnd = (HWND *)pRealWnd->GetData();
			if(phWnd)
			{
				DestroyWindow(*phWnd);
			}
		}
	}

	//不处理，返回FALSE
	BOOL CSouiRealWndHandler::OnRealWndSize( SRealWnd *pRealWnd )
	{
		return FALSE;
	}
 
	//不处理，返回FALSE
	BOOL CSouiRealWndHandler::OnRealWndInit( SRealWnd *pRealWnd )
	{
		return FALSE;
	}
}