代码打包下载
http://download.youkuaiyun.com/detail/u012607841/9211489
代码如下
#include "Common.h"
class CWindow_Demo
{
public:
HWINDOW m_hWindow;
CWindow_Demo()
{
Init();
}
void Init()
{
m_hWindow = XWnd_Create(0, 0, 300, 200, L"QQ窗口",NULL, xc_window_style_default);
XBtn_SetType(XBtn_Create(5, 3, 60, 20, L"Close", m_hWindow),button_type_close);
HELE hComboBox=XComboBox_Create(20,40,120,20,m_hWindow);
XComboBox_SetItemTemplateXML(hComboBox,L"ComboBox_ListBox_Item.xml");
XRichEdit_SetText(hComboBox,L"123");
HXCGUI hAdapter=XAdapterTable_Create();
XComboBox_BindApapter(hComboBox,hAdapter);
XAdapterTable_AddColumn(hAdapter,L"name");
XAdapterTable_AddColumn(hAdapter,L"name1");
XEle_RegEventCPP(hComboBox,XE_COMBOBOX_POPUP_LIST,&CWindow_Demo::OnComboBoxPopupList);
wchar_t buf[256]={0};
for (int i=0;i<20;i++)
{
wsprintf(buf,L"name-%d-0",i);
int k = XAdapterTable_AddItemText(hAdapter,buf);
XAdapterTable_SetItemText(hAdapter,k,1,L"测试下");
}
XWnd_AdjustLayout(m_hWindow);
XWnd_ShowWindow(m_hWindow,SW_SHOW);
}
int OnComboBoxPopupList(HWINDOW hWindow,HELE hListBox,BOOL *pbHandled)
{
XEle_RegEventCPP2(hListBox,XE_LISTBOX_TEMP_CREATE_END,&CWindow_Demo::OnListBoxTemplateCreateEnd);
*pbHandled = TRUE;
return 0;
}
int OnListBoxTemplateCreateEnd(HELE hEle,HELE hEventEle,listBox_item_i* pItem,BOOL *pbHandled)
{
HELE hBtn = (HELE)XListBox_GetTemplateObject(hEventEle,pItem->index,2);
if (XC_IsHXCGUI(hBtn,XC_BUTTON))
{
BOOL bCheck = XListBox_GetItemData(hEventEle,pItem->index);
XBtn_SetCheck(hBtn,bCheck);
XEle_RegEventCPP1(hBtn,XE_BUTTON_CHECK,&CWindow_Demo::OnButtonCheck);
}
*pbHandled = TRUE;
return 0;
}
int OnButtonCheck(HELE hEventEle,BOOL bCheck,BOOL *pbHandled)
{
int ItemID = XEle_GetTemplateListItemID(hEventEle);
XListBox_SetItemData(XEle_GetParentEle(hEventEle),ItemID,bCheck);
return 0;
}
};
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
XInitXCGUI();
CWindow_Demo MyWindow;
XRunXCGUI();
XExitXCGUI();
return TRUE;
}
头文件。。。
#ifndef Common_h__
#define Common_h__
#ifndef _UNICODE
#define _UNICODE
#define UNICODE
#endif
#define _CRT_SECURE_NO_WARNINGS
#include <windows.h>
// #ifndef strcpy_s
// #define strcpy_s strcpy
// #endif
#if _MSC_VER == 1200 // MS VC++6.0 _MSC_VER=1200 vc6
#define strcpy_s strcpy
#endif
#if _MSC_VER == 1500 // MS VC++9.0 _MSC_VER=1500 vs2008
#endif
//包含炫彩界面库文件
#pragma comment(lib, "XCGUI.lib")
#include "xcgui.h"
#define XC_SY_DEFAULT xc_window_style_default
#define XC_BUTTON_TYPE_CLOSE button_type_close
#include <GdiPlus.h>
using namespace Gdiplus;
#define ULONG_PTR ULONG
#pragma comment(lib,"gdiplus.lib")
#ifndef _tWinMain
#ifdef _UNICODE
#define _tWinMain wWinMain
#else
#define _tWinMain WinMain
#endif
#endif
#ifndef _T
#define _T(x) L ## x
#endif
#ifndef wstring
#include <string>
using namespace std;
#endif
#endif // Common_h__