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

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

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

#if   0  //简单测试
class CMyWindowRichEdit
{
public:
	HWINDOW m_hWindow;
	HELE    m_hRichEditRecv;
	HELE    m_hRichEditSend;
	CMyWindowRichEdit()
	{
		Init();
	}
	void Init()
	{
		m_hWindow = XWnd_Create(0, 0, 300, 300, L"炫彩界面库窗口", NULL, xc_window_style_default);
		XBtn_SetType(XBtn_Create(5, 3, 60, 20, L"Close", m_hWindow),button_type_close);
		//XWnd_SetImage(m_hWindow,XImage_LoadFile(L"image\\111.jpg"));

		m_hRichEditRecv=XRichEdit_Create(20, 40, 200, 200, m_hWindow);
		//XRichEdit_InsertString(m_hRichEditRecv, 0, 0, L"123456");
		XRichEdit_EnableMultiLine(m_hRichEditRecv,TRUE);
		//XSView_EnableAutoShowScrollBar(m_hRichEditRecv,FALSE);
		//XEle_SetImage(m_hRichEditRecv,XImage_LoadFile(L"image\\111.jpg"));
		XWnd_BindLayoutEle(m_hWindow,XC_LAYOUT_BODY,m_hRichEditRecv);
		//XSView_SetLineSize(m_hRichEditRecv,20,20);
		//XRichEdit_SetRowHeight(m_hRichEditRecv,20);

		XEle_SetFont(m_hRichEditRecv,XFont_Create(20));
		XRichEdit_EnableAutoWrap(m_hRichEditRecv,TRUE);

		//XSView_ShowSBarV(m_hRichEditRecv,TRUE);
		//XSView_ShowSBarH(m_hRichEditRecv,TRUE);

		XRichEdit_SetText(m_hRichEditRecv,L"123456\n一二三四五六");
		XWnd_AdjustLayout(m_hWindow);
		XWnd_ShowWindow(m_hWindow,SW_SHOW);
	}
};

int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
	XInitXCGUI();
	CMyWindowRichEdit  MyWindow;
	XRunXCGUI();
	XExitXCGUI();
	return TRUE;
}

#endif


#if   1 //富文本全面测试
class CMyWindowRichEdit
{
public:
	HWINDOW m_hWindow;
	HELE    m_hRichEditRecv; //接收框
	HELE    m_hRichEditSend; //发送框
	HELE    m_hBtnSend;  //发送按钮
	HELE    m_hBtnImage;  //插入图片
	HELE    m_hBtnGif;   //插入GIF

	//默认属性,日后增加
	//...

	//当前输入属性
	HXCGUI m_hTextBlock;
	HELE  m_hColor_Edit;        //颜色
	HELE  m_hFontName_ComboBox; //字体名称
	HELE  m_hFontSize_ComboBox; //字体大小
	HELE  m_hBold_Button;       //粗体
	HELE  m_hItalic_Button;     //斜体
	HELE  m_hUnderline_Button;  //下划线

	//设置选择属性
	HXCGUI m_hTextBlock_Sel;
	HELE  m_hColor_Edit_Sel;        //颜色
	HELE  m_hFontName_ComboBox_Sel; //字体名称
	HELE  m_hFontSize_ComboBox_Sel; //字体大小
	HELE  m_hBold_Button_Sel;       //粗体
	HELE  m_hItalic_Button_Sel;     //斜体
	HELE  m_hUnderline_Button_Sel;  //下划线

	CMyWindowRichEdit();
	void Init();
	void InitToolBar();
	void InitToolBarSel();

	void AdjustWindow(int cx, int cy);
	void AdjustWindowToolBar(int cx, int cy);
	void AdjustWindowToolBar_Sel(int cx, int cy);

	void OnFontChange();
	void OnFontChange_Sel();

	int  OnWndSize(UINT flags,SIZE *pSize,BOOL *pbHandled);
	int  OnBtnClick_Send(BOOL *pbHandled);
	int  OnBtnClick_Image(BOOL *pbHandled);
	int  OnBtnClick_Gif(BOOL *pbHandled);

	int  OnRichEditChangeColor(BOOL *pbHandled);
	int  OnComboBoxSelect_FontName(int iItem,BOOL *pbHandled);
	int  OnComboBoxSelect_FontSize(int iItem,BOOL *pbHandled);
	int  OnBtnClick_Bold(BOOL *pbHandled);
	int  OnBtnClick_Italic(BOOL *pbHandled);
	int  OnBtnClick_Underline(BOOL *pbHandled);

	int  OnRichEditChangeColor_Sel(BOOL *pbHandled);
	int  OnComboBoxSelect_FontName_Sel(int iItem,BOOL *pbHandled);
	int  OnComboBoxSelect_FontSize_Sel(int iItem,BOOL *pbHandled);
	int  OnBtnClick_Bold_Sel(BOOL *pbHandled);
	int  OnBtnClick_Italic_Sel(BOOL *pbHandled);
	int  OnBtnClick_Underline_Sel(BOOL *pbHandled);
};

CMyWindowRichEdit::CMyWindowRichEdit()
{
	m_hRichEditRecv=NULL;
	m_hRichEditSend=NULL;
	m_hBtnSend=NULL;
	m_hBtnImage=NULL;
	m_hBtnGif=NULL;
	Init();
}

void CMyWindowRichEdit::Init()
{
	m_hWindow = XWnd_Create(0, 0, 550, 400, L"炫彩界面库窗口", NULL, xc_window_style_default);
	HELE hClose=XBtn_Create(5, 3, 60, 20, L"Close", m_hWindow);
	XBtn_SetType(hClose,button_type_close);

	m_hRichEditRecv=XRichEdit_Create(0, 0, 100, 100, m_hWindow);
	XRichEdit_EnableAutoWrap(m_hRichEditRecv,TRUE);

	m_hRichEditSend=XRichEdit_Create(20, 40, 100, 100, m_hWindow);
	XRichEdit_SetRowHeight(m_hRichEditSend,14);
	//XRichEdit_EnableMultiLine(m_hRichEditSend,TRUE);
	//XSView_ShowSBarV(m_hRichEditSend,TRUE);
	//XSView_ShowSBarH(m_hRichEditSend,TRUE);
	//XSView_EnableAutoShowScrollBar(m_hRichEditSend,TRUE);
	XRichEdit_EnableAutoWrap(m_hRichEditSend,TRUE);
	//XRichEdit_EnablePassword(m_hRichEditSend,TRUE);

	HFONTX hFontX=XFont_Create2(L"宋体",20);
	XEle_SetFont(m_hRichEditSend,hFontX);
	//XEle_SetTextColor(m_hRichEditSend,RGB(0,0,160));
	XRichEdit_InsertStringEx(m_hRichEditSend, 0, 0, L"123456\n一二三四五六",NULL);

	m_hBtnSend=XBtn_Create(0,0,60,20,L"发 送",m_hWindow);

	m_hBtnImage=XBtn_Create(0,0,60,20,L"图片",m_hWindow);
	m_hBtnGif=XBtn_Create(0,0,60,20,L"GIF",m_hWindow);

	InitToolBar();
	InitToolBarSel();

	AdjustWindow(550,400);

	XWnd_RegEventCPP(m_hWindow,WM_SIZE,&CMyWindowRichEdit::OnWndSize);
	XEle_RegEventCPP(m_hBtnSend,XE_BNCLICK,&CMyWindowRichEdit::OnBtnClick_Send);
	XEle_RegEventCPP(m_hBtnImage,XE_BNCLICK,&CMyWindowRichEdit::OnBtnClick_Image);
	XEle_RegEventCPP(m_hBtnGif,XE_BNCLICK,&CMyWindowRichEdit::OnBtnClick_Gif);

	XWnd_AdjustLayout(m_hWindow);
	XWnd_ShowWindow(m_hWindow,SW_SHOW);
	XWnd_SetFocusEle(m_hWindow,m_hRichEditRecv);
}

void CMyWindowRichEdit::InitToolBar()
{
	m_hTextBlock=XShapeText_Create(0,0,20,20,L"当前属性:",m_hWindow);

	m_hColor_Edit=XRichEditColor_Create(0,0,20,20,m_hWindow);
	XRichEditColor_SetColor(m_hColor_Edit,RGB(0,0,160));

	m_hFontName_ComboBox=XComboBox_Create(0,0,20,20,m_hWindow);
	XComboBox_EnableEdit(m_hFontName_ComboBox,FALSE);
	XComboBox_SetItemTemplateXML(m_hFontName_ComboBox,L"xml-template\\ComboBox_ListBox_Item.xml");
	HXCGUI hAdapter=XAdTable_Create();
	XComboBox_BindApapter(m_hFontName_ComboBox,hAdapter);
	XAdTable_AddColumn(hAdapter,XC_NAME);
	XAdTable_AddItemText(hAdapter,L"宋体");
	XAdTable_AddItemText(hAdapter,L"隶书");
	XAdTable_AddItemText(hAdapter,L"方正舒体");
	XAdTable_AddItemText(hAdapter,L"华文彩云");
	XComboBox_SetSelItem(m_hFontName_ComboBox,0);

	m_hFontSize_ComboBox=XComboBox_Create(0,0,20,20,m_hWindow);
	XComboBox_EnableEdit(m_hFontSize_ComboBox,FALSE);
	XComboBox_SetItemTemplateXML(m_hFontSize_ComboBox,L"xml-template\\ComboBox_ListBox_Item.xml");
	hAdapter=XAdTable_Create();
	XComboBox_BindApapter(m_hFontSize_ComboBox,hAdapter);
	XAdTable_AddColumn(hAdapter,XC_NAME);
	XAdTable_AddItemText(hAdapter,L"12");
	XAdTable_AddItemText(hAdapter,L"14");
	XAdTable_AddItemText(hAdapter,L"16");
	XAdTable_AddItemText(hAdapter,L"18");
	XAdTable_AddItemText(hAdapter,L"20");
	XComboBox_SetSelItem(m_hFontSize_ComboBox,4);

	m_hBold_Button=XBtn_Create(0,0,20,20,L"粗体",m_hWindow);
	m_hItalic_Button=XBtn_Create(0,0,20,20,L"斜体",m_hWindow);
	m_hUnderline_Button=XBtn_Create(0,0,20,20,L"下划线",m_hWindow);
	XBtn_SetType(m_hBold_Button,button_type_check);
	XBtn_SetType(m_hItalic_Button,button_type_check);
	XBtn_SetType(m_hUnderline_Button,button_type_check);

	XRichEdit_EnableEvent_XE_RICHEDIT_CHANGE(m_hColor_Edit,TRUE);
	XEle_RegEventCPP(m_hColor_Edit,XE_RICHEDIT_CHANGE,&CMyWindowRichEdit::OnRichEditChangeColor);
	XEle_RegEventCPP(m_hFontName_ComboBox,XE_COMBOBOX_SELECT,&CMyWindowRichEdit::OnComboBoxSelect_FontName);
	XEle_RegEventCPP(m_hFontSize_ComboBox,XE_COMBOBOX_SELECT,&CMyWindowRichEdit::OnComboBoxSelect_FontSize);
	XEle_RegEventCPP(m_hBold_Button,XE_BNCLICK,&CMyWindowRichEdit::OnBtnClick_Bold);
	XEle_RegEventCPP(m_hItalic_Button,XE_BNCLICK,&CMyWindowRichEdit::OnBtnClick_Italic);
	XEle_RegEventCPP(m_hUnderline_Button,XE_BNCLICK,&CMyWindowRichEdit::OnBtnClick_Underline);
}

void CMyWindowRichEdit::InitToolBarSel()
{
	m_hColor_Edit_Sel=XRichEditColor_Create(0,0,20,20,m_hWindow);

	m_hTextBlock_Sel=XShapeText_Create(0,0,20,20,L"选择属性:",m_hWindow);

	m_hFontName_ComboBox_Sel=XComboBox_Create(0,0,20,20,m_hWindow);
	XComboBox_EnableEdit(m_hFontName_ComboBox_Sel,FALSE);
	XComboBox_SetItemTemplateXML(m_hFontName_ComboBox_Sel,L"xml-template\\ComboBox_ListBox_Item.xml");
	HXCGUI hAdapter=XAdTable_Create();
	XComboBox_BindApapter(m_hFontName_ComboBox_Sel,hAdapter);
	XAdTable_AddColumn(hAdapter,XC_NAME);
	XAdTable_AddItemText(hAdapter,L"宋体");
	XAdTable_AddItemText(hAdapter,L"隶书");
	XAdTable_AddItemText(hAdapter,L"方正舒体");
	XAdTable_AddItemText(hAdapter,L"华文彩云");
	XComboBox_SetSelItem(m_hFontName_ComboBox_Sel,0);

	m_hFontSize_ComboBox_Sel=XComboBox_Create(0,0,20,20,m_hWindow);
	XComboBox_EnableEdit(m_hFontSize_ComboBox_Sel,FALSE);
	XComboBox_SetItemTemplateXML(m_hFontSize_ComboBox_Sel,L"xml-template\\ComboBox_ListBox_Item.xml");
	hAdapter=XAdTable_Create();
	XComboBox_BindApapter(m_hFontSize_ComboBox_Sel,hAdapter);
	XAdTable_AddColumn(hAdapter,XC_NAME);
	XAdTable_AddItemText(hAdapter,L"12");
	XAdTable_AddItemText(hAdapter,L"14");
	XAdTable_AddItemText(hAdapter,L"16");
	XAdTable_AddItemText(hAdapter,L"18");
	XAdTable_AddItemText(hAdapter,L"20");
	XComboBox_SetSelItem(m_hFontSize_ComboBox_Sel,4);

	m_hBold_Button_Sel=XBtn_Create(0,0,20,20,L"粗体",m_hWindow);
	m_hItalic_Button_Sel=XBtn_Create(0,0,20,20,L"斜体",m_hWindow);
	m_hUnderline_Button_Sel=XBtn_Create(0,0,20,20,L"下划线",m_hWindow);
	XBtn_SetType(m_hBold_Button_Sel,button_type_check);
	XBtn_SetType(m_hItalic_Button_Sel,button_type_check);
	XBtn_SetType(m_hUnderline_Button_Sel,button_type_check);

	XRichEdit_EnableEvent_XE_RICHEDIT_CHANGE(m_hColor_Edit_Sel,TRUE);
	XEle_RegEventCPP(m_hColor_Edit_Sel,XE_RICHEDIT_CHANGE,&CMyWindowRichEdit::OnRichEditChangeColor_Sel);
	XEle_RegEventCPP(m_hFontName_ComboBox_Sel,XE_COMBOBOX_SELECT,&CMyWindowRichEdit::OnComboBoxSelect_FontName_Sel);
	XEle_RegEventCPP(m_hFontSize_ComboBox_Sel,XE_COMBOBOX_SELECT,&CMyWindowRichEdit::OnComboBoxSelect_FontSize_Sel);
	XEle_RegEventCPP(m_hBold_Button_Sel,XE_BNCLICK,&CMyWindowRichEdit::OnBtnClick_Bold_Sel);
	XEle_RegEventCPP(m_hItalic_Button_Sel,XE_BNCLICK,&CMyWindowRichEdit::OnBtnClick_Italic_Sel);
	XEle_RegEventCPP(m_hUnderline_Button_Sel,XE_BNCLICK,&CMyWindowRichEdit::OnBtnClick_Underline_Sel);
}

void CMyWindowRichEdit::AdjustWindow(int cx, int cy)
{
	RECT rect={10,40,cx-10,0};
	if(m_hRichEditRecv)
	{
		rect.bottom=cy-125-80;
		XEle_SetRect(m_hRichEditRecv,&rect);
	}

	if(m_hRichEditSend)
	{
		rect.top=cy-125;
		rect.bottom=cy-40;
		XEle_SetRect(m_hRichEditSend,&rect);
	}

	if(m_hBtnImage && m_hBtnGif)
	{
		RECT rcButton;
		rcButton.left=10;
		rcButton.right=rcButton.left+60;
		rcButton.bottom=cy-130;
		rcButton.top=rcButton.bottom-20;
		XEle_SetRect(m_hBtnImage,&rcButton);

		rcButton.left=rcButton.right+5;
		rcButton.right=rcButton.left+60;
		XEle_SetRect(m_hBtnGif,&rcButton);
	}

	if(m_hBtnSend)
	{
		RECT rcButton;
		rcButton.left=cx-100;
		rcButton.right=rcButton.left+60;
		rcButton.bottom=cy-15;
		rcButton.top=rcButton.bottom-22;
		XEle_SetRect(m_hBtnSend,&rcButton);
	}
	AdjustWindowToolBar(cx, cy);
	AdjustWindowToolBar_Sel(cx, cy);
}

void CMyWindowRichEdit::AdjustWindowToolBar(int cx, int cy)
{
	RECT rect={10,40,cx-100,0};
	rect.bottom=cy-155;
	rect.top=rect.bottom-20;

	rect.left=10;
	rect.right=rect.left+60;
	XShape_SetRect(m_hTextBlock,&rect);

	rect.left=rect.right;
	rect.right=rect.left+80;
	XEle_SetRect(m_hColor_Edit,&rect);

	rect.left=rect.right+5;
	rect.right=rect.left+80;
	XEle_SetRect(m_hFontName_ComboBox,&rect);

	rect.left=rect.right+5;
	rect.right=rect.left+50;
	XEle_SetRect(m_hFontSize_ComboBox,&rect);

	rect.left=rect.right+5;
	rect.right=rect.left+50;
	XEle_SetRect(m_hBold_Button,&rect);

	rect.left=rect.right+5;
	rect.right=rect.left+50;
	XEle_SetRect(m_hItalic_Button,&rect);

	rect.left=rect.right+5;
	rect.right=rect.left+60;
	XEle_SetRect(m_hUnderline_Button,&rect);
}

void CMyWindowRichEdit::AdjustWindowToolBar_Sel(int cx, int cy)
{
	RECT rect={10,40,cx-100,0};
	rect.bottom=cy-180;
	rect.top=rect.bottom-20;

	rect.left=10;
	rect.right=rect.left+60;
	XShape_SetRect(m_hTextBlock_Sel,&rect);

	rect.left=rect.right;
	rect.right=rect.left+80;
	XEle_SetRect(m_hColor_Edit_Sel,&rect);

	rect.left=rect.right+5;
	rect.right=rect.left+80;
	XEle_SetRect(m_hFontName_ComboBox_Sel,&rect);

	rect.left=rect.right+5;
	rect.right=rect.left+50;
	XEle_SetRect(m_hFontSize_ComboBox_Sel,&rect);

	rect.left=rect.right+5;
	rect.right=rect.left+50;
	XEle_SetRect(m_hBold_Button_Sel,&rect);

	rect.left=rect.right+5;
	rect.right=rect.left+50;
	XEle_SetRect(m_hItalic_Button_Sel,&rect);

	rect.left=rect.right+5;
	rect.right=rect.left+60;
	XEle_SetRect(m_hUnderline_Button_Sel,&rect);
}

void CMyWindowRichEdit::OnFontChange()
{
	COLORREF  color=XRichEditColor_GetColor(m_hColor_Edit);

	wchar_t FontName[MAX_PATH]={0};
	XRichEdit_GetText(m_hFontName_ComboBox,FontName,MAX_PATH);

	wchar_t FontSize[MAX_PATH]={0};
	XRichEdit_GetText(m_hFontSize_ComboBox,FontSize,MAX_PATH);

	BOOL bBold=XBtn_IsCheck(m_hBold_Button);
	BOOL bItalic=XBtn_IsCheck(m_hItalic_Button);
	BOOL bUnderline=XBtn_IsCheck(m_hUnderline_Button);

	LOGFONT  font;
	XC_InitFont(&font,FontName,_wtoi(FontSize),bBold,bItalic,bUnderline);
	HFONTX hFontX=XFont_CreateEx(&font);

	XEle_SetFont(m_hRichEditSend,hFontX);
	XEle_SetTextColor(m_hRichEditSend,color,255);
	XEle_RedrawEle(m_hRichEditSend);
}

void CMyWindowRichEdit::OnFontChange_Sel()
{
	COLORREF  color=XRichEditColor_GetColor(m_hColor_Edit_Sel);

	wchar_t FontName[MAX_PATH]={0};
	XRichEdit_GetText(m_hFontName_ComboBox_Sel,FontName,MAX_PATH);

	wchar_t FontSize[MAX_PATH]={0};
	XRichEdit_GetText(m_hFontSize_ComboBox_Sel,FontSize,MAX_PATH);

	BOOL bBold=XBtn_IsCheck(m_hBold_Button_Sel);
	BOOL bItalic=XBtn_IsCheck(m_hItalic_Button_Sel);
	BOOL bUnderline=XBtn_IsCheck(m_hUnderline_Button_Sel);

	Position_i   begin;
	Position_i   end;
	if(XRichEdit_GetSelectPosition(m_hRichEditSend,&begin,&end))
	{
		xc_font_info_i font_info;
		wcscpy_s(font_info.aName,L"宋体");
		font_info.nSize=_wtoi(FontSize);
		font_info.nStyle=xc_fontStyle_regular;
		if(bBold) font_info.nStyle |= xc_fontStyle_bold;
		if(bItalic) font_info.nStyle |= xc_fontStyle_italic;
		if(bUnderline) font_info.nStyle |= xc_fontStyle_underline;
		HFONTX hFont=XFont_Create3(&font_info);

		XRichEdit_SetItemFontEx(m_hRichEditSend,begin.iRow,begin.iColumn,end.iRow,end.iColumn,hFont);
		XRichEdit_SetItemColorEx(m_hRichEditSend,begin.iRow,begin.iColumn,end.iRow,end.iColumn,color); //设置颜色
		XEle_RedrawEle(m_hRichEditSend);
	}
}

int CMyWindowRichEdit::OnWndSize(UINT flags,SIZE *pSize,BOOL *pbHandled)
{
	AdjustWindow(pSize->cx,pSize->cy);
	return 0;
}

int  CMyWindowRichEdit::OnBtnClick_Send(BOOL *pbHandled)
{
	//	wchar_t buf[1024]={0};
	//	XRichEdit_GetHTMLFormat(m_hRichEditSend,buf,1024);

	SYSTEMTIME timeT;
	GetLocalTime(&timeT);

	wchar_t name[MAX_PATH];
	wsprintf(name,L"炫彩界面库(154460336) %d:%d:%d\n",timeT.wHour,timeT.wMinute,timeT.wSecond);
	XRichEdit_InsertStringEx(m_hRichEditRecv,-1,-1,name,NULL);

	void *pData=XRichEdit_GetData(m_hRichEditSend);
	XRichEdit_InsertData(m_hRichEditRecv,pData,-1,-1);
	XC_Free(pData);

	XRichEdit_InsertStringEx(m_hRichEditRecv,-1,-1,L"\n");

	XRichEdit_DeleteAll(m_hRichEditSend);
	XEle_RedrawEle(m_hRichEditRecv);
	XEle_RedrawEle(m_hRichEditSend);
	return 0;
}

int  CMyWindowRichEdit::OnBtnClick_Image(BOOL *pbHandled)
{
	HIMAGE hImage=XImage_LoadFile(L"image\\tou.jpg");
	if(hImage)
	{
		int iRow=XRichEdit_GetCurrentRow(m_hRichEditSend);
		int iColumn=XRichEdit_GetCurrentColumn(m_hRichEditSend);
		XRichEdit_InsertImageEx(m_hRichEditSend,iRow,iColumn,hImage,L"image\\tou.jpg");
		XEle_RedrawEle(m_hRichEditSend);
	}
	return 0;
}

int  CMyWindowRichEdit::OnBtnClick_Gif(BOOL *pbHandled)
{
	HIMAGE hImage=XImage_LoadFile(L"image\\gif.gif");
	if(hImage)
	{
		int iRow=XRichEdit_GetCurrentRow(m_hRichEditSend);
		int iColumn=XRichEdit_GetCurrentColumn(m_hRichEditSend);
		XRichEdit_InsertGifEx(m_hRichEditSend,iRow,iColumn,hImage,L"image\\gif.gif");
		XEle_RedrawEle(m_hRichEditSend);
	}
	return 0;
}

int CMyWindowRichEdit::OnComboBoxSelect_FontName(int iItem,BOOL *pbHandled)
{
	*pbHandled=TRUE;
	XComboBox_SetSelItem(m_hFontName_ComboBox,iItem);
	OnFontChange();
	return 0;
}

int CMyWindowRichEdit::OnRichEditChangeColor(BOOL *pbHandled)
{
	OnFontChange();
	return 0;
}

int CMyWindowRichEdit::OnComboBoxSelect_FontSize(int iItem,BOOL *pbHandled)
{
	*pbHandled=TRUE;
	XComboBox_SetSelItem(m_hFontSize_ComboBox,iItem);
	OnFontChange();
	return 0;
}

int  CMyWindowRichEdit::OnBtnClick_Bold(BOOL *pbHandled)
{
	*pbHandled=TRUE;
	XBtn_SetCheck(m_hBold_Button,!XBtn_IsCheck(m_hBold_Button));
	OnFontChange();
	return 0;
}

int  CMyWindowRichEdit::OnBtnClick_Italic(BOOL *pbHandled)
{
	*pbHandled=TRUE;
	XBtn_SetCheck(m_hItalic_Button,!XBtn_IsCheck(m_hItalic_Button));
	OnFontChange();
	return 0;
}

int  CMyWindowRichEdit::OnBtnClick_Underline(BOOL *pbHandled)
{
	*pbHandled=TRUE;
	XBtn_SetCheck(m_hUnderline_Button,!XBtn_IsCheck(m_hUnderline_Button));
	OnFontChange();
	return 0;
}

int  CMyWindowRichEdit::OnRichEditChangeColor_Sel(BOOL *pbHandled)
{
	OnFontChange_Sel();
	return 0;
}

int CMyWindowRichEdit::OnComboBoxSelect_FontName_Sel(int iItem,BOOL *pbHandled)
{
	*pbHandled=TRUE;
	XComboBox_SetSelItem(m_hFontName_ComboBox_Sel,iItem);
	OnFontChange_Sel();
	return 0;
}

int CMyWindowRichEdit::OnComboBoxSelect_FontSize_Sel(int iItem,BOOL *pbHandled)
{
	*pbHandled=TRUE;
	XComboBox_SetSelItem(m_hFontSize_ComboBox_Sel,iItem);
	OnFontChange_Sel();
	return 0;
}

int  CMyWindowRichEdit::OnBtnClick_Bold_Sel(BOOL *pbHandled)
{
	*pbHandled=TRUE;
	XBtn_SetCheck(m_hBold_Button_Sel,!XBtn_IsCheck(m_hBold_Button_Sel));
	OnFontChange_Sel();
	return 0;
}

int  CMyWindowRichEdit::OnBtnClick_Italic_Sel(BOOL *pbHandled)
{
	*pbHandled=TRUE;
	XBtn_SetCheck(m_hItalic_Button_Sel,!XBtn_IsCheck(m_hItalic_Button_Sel));
	OnFontChange_Sel();
	return 0;
}

int  CMyWindowRichEdit::OnBtnClick_Underline_Sel(BOOL *pbHandled)
{
	*pbHandled=TRUE;
	XBtn_SetCheck(m_hUnderline_Button_Sel,!XBtn_IsCheck(m_hUnderline_Button_Sel));
	OnFontChange_Sel();
	return 0;
}

int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
	XInitXCGUI();
	CMyWindowRichEdit  MyWindow;
	XRunXCGUI();
	XExitXCGUI();
	return TRUE;
}

#endif
