// Test.cpp : 定义应用程序的入口点。
//

#include "stdafx.h"
#include "Test.h"

//包含炫彩界面库文件
#include "xcgui.h"
#pragma comment(lib,"XCGUI.lib")


class CMyWindowDemo
{
public:
	HWINDOW m_hWindow;
	HELE    m_hButton;
	CMyWindowDemo()
	{
		Init();
	}
	void Init()
	{
		m_hWindow = XWnd_Create(0, 0, 400, 300, L"炫彩界面库窗口",NULL, xc_window_style_default);
		XBtn_SetType(XBtn_Create(20, 50, 60, 25,L"close",m_hWindow),button_type_close);

		m_hButton = XBtn_Create(100, 50, 160, 100,L"Button", m_hWindow);
		XEle_RegEventCPP(m_hButton,XE_BNCLICK,&CMyWindowDemo::OnBtnClick);

		XWnd_ShowWindow(m_hWindow,SW_SHOW);
	}
	int OnBtnClick(BOOL *pbHandled)
	{
		MessageBox(XWnd_GetHWND(m_hWindow),L"你点击了按钮",L"提示",MB_OK);
		return 0;
	}
};

int APIENTRY _tWinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPTSTR    lpCmdLine,
                     int       nCmdShow)
{
	XInitXCGUI();
	CMyWindowDemo  MyWindow;
	XRunXCGUI();
	XExitXCGUI();
	return 0;
}

/*

class CMyWindowDemo
{
public:
	HWINDOW m_hWindow;
	HELE    m_hButton;
	CMyWindowDemo()
	{
		Init();
	}
	void Init()
	{
		m_hWindow = XWnd_Create(0, 0, 400, 300, L"炫彩界面库窗口",NULL, xc_window_style_default);
		XBtn_SetType(XBtn_Create(20, 50, 60, 25,L"close",m_hWindow),button_type_close);

		m_hButton = XBtn_Create(100, 50, 160, 100,L"Button", m_hWindow);
		XEle_RegEventCPP(m_hButton,XE_PAINT, &CMyWindowDemo::OnDrawButton);
		XEle_RegEventCPP(m_hButton,XE_BNCLICK,&CMyWindowDemo::OnBtnClick);

		XWnd_ShowWindow(m_hWindow,SW_SHOW);
	}
	int OnBtnClick(BOOL *pbHandled)
	{
		MessageBox(XWnd_GetHWND(m_hWindow),L"你点击了按钮",L"提示",MB_OK);
		return 0;
	}
	int  OnDrawButton(HDRAW hDraw, BOOL *pbHandled)
	{
		*pbHandled=TRUE;
		int state=XBtn_GetState(m_hButton);
		RECT rect;
		XEle_GetClientRect(m_hButton,&rect);
		if(STATE_LEAVE==state)
		{
			XDraw_FillRectColor(hDraw,&rect,RGB(100,0,0),255);
		}else
		{
			XDraw_FillRectColor(hDraw,&rect,RGB(200,0,0),255);
		}
		return 0;
	}
};

int APIENTRY _tWinMain(HINSTANCE hInstance,
					   HINSTANCE hPrevInstance,
					   LPTSTR    lpCmdLine,
					   int       nCmdShow)
{
	XInitXCGUI();
	CMyWindowDemo  MyWindow;
	XRunXCGUI();
	XExitXCGUI();
	return 0;
}

*/