#pragma comment(lib, "XCGUI.lib")
#include "xcgui.h"
class CEditRecv
{
public:
HELE m_hEdit;
USHORT m_style1;
HIMAGE m_hImageAvatar;
HIMAGE m_hImageAvatar2;
HIMAGE m_hImageBubble;
HIMAGE m_hImageBubble2;
void OnExit()
{
}
void Init(HWINDOW hWindow, int left, int top, int width, int height)
{
HFONTX hFont1 = XFont_Create2(L"微软雅黑", 9);
m_style1 =
XEdit_AddStyle(m_hEdit, hFont1, COLORREF_MAKE(0, 0, 255,255),TRUE);
}
{
{
}
static int send_left = 1;
if(send_left%2)
else
send_left++;
XEdit_AddTextEx(m_hEdit, L
"【实习】梦飞(154460336) 2019/1/23 20:30:12\n", m_style1);
AddData(data);
}
{
vector<USHORT> styleTable(data->
nStyleCount, edit_style_no);
{
{
styleTable[i] = iStyle;
{
styleTable[i] = iStyle;
{
{
styleTable[i] = iStyle;
}
{
{
{
styleTable[i] = iStyle;
}
}
}
}
}
};
class CEditSend
{
public:
HWINDOW m_hWindow;
HELE m_hEdit;
HELE m_hBtnSend;
HELE m_hBtnImg1;
HELE m_hBtnImg2;
HELE m_hBtnImg3;
HELE m_hButton;
HELE m_hBtnFont1;
HELE m_hBtnFont2;
HELE m_hBtnFont3;
HELE m_hBtnColor1;
HELE m_hBtnColor2;
HELE m_hBtnColor3;
int m_iCurStyle;
CEditRecv* m_pRecv;
void Init(HWINDOW hWindow, int left, int top, int width, int height)
{
m_hWindow = hWindow;
InitBar(left, top);
m_hBtnSend =
XBtn_Create(left + width + 10, top, 80, 30, L
"发 送", hWindow);
if (hImageGif)
{
}
int iStyle =
XEdit_AddStyleEx(m_hEdit, L
"微软雅黑",16, 0, COLORREF_MAKE(200, 0, 0,255), TRUE);
iStyle =
XEdit_AddStyleEx(m_hEdit, L
"微软雅黑", 24, 0, COLORREF_MAKE(0, 200, 0,255), TRUE);
iStyle =
XEdit_AddStyleEx(m_hEdit, L
"微软雅黑", 36, 0, COLORREF_MAKE(0, 0, 200,255), TRUE);
}
void InitBar(int left, int top)
{
int x = left;
m_hBtnImg1 =
XBtn_Create(x, top - 25, 60, 20, L
"img1", m_hWindow); x += 65;
m_hBtnImg2 =
XBtn_Create(x, top - 25, 60, 20, L
"img2", m_hWindow); x += 65;
m_hBtnImg3 =
XBtn_Create(x, top - 25, 60, 20, L
"gif", m_hWindow); x += 65;
m_hButton =
XBtn_Create(x, top - 25, 60, 20, L
"button", m_hWindow); x += 65;
m_hBtnFont1 =
XBtn_Create(x, top - 25, 60, 20, L
"字体12", m_hWindow); x += 65;
m_hBtnFont2 =
XBtn_Create(x, top - 25, 60, 20, L
"字体24", m_hWindow); x += 65;
m_hBtnFont3 =
XBtn_Create(x, top - 25, 60, 20, L
"字体36", m_hWindow); x += 65;
m_hBtnColor1 =
XBtn_Create(x, top - 25, 60, 20, L
"color1", m_hWindow); x += 65;
m_hBtnColor2 =
XBtn_Create(x, top - 25, 60, 20, L
"color2", m_hWindow); x += 65;
m_hBtnColor3 =
XBtn_Create(x, top - 25, 60, 20, L
"color3", m_hWindow); x += 65;
}
int OnBtnClick_Send(BOOL *pbHandled)
{
m_pRecv->Recv(data);
return 0;
}
int OnBtnClick_img1(BOOL *pbHandled)
{
if (hImage)
{
}
return 0;
}
int OnBtnClick_img2(BOOL *pbHandled)
{
if (hImage)
{
}
return 0;
}
int OnBtnClick_img3(BOOL *pbHandled)
{
if (hImageGif)
{
}
return 0;
}
int OnBtnClick_button(BOOL *pbHandled)
{
HELE hButton =
XBtn_Create(0, 0, 60, 20, L
"button", m_hEdit);
return 0;
}
int OnBtnClick_font1(BOOL bCheck, BOOL *pbHandled)
{
if(bCheck) FontColorChange();
return 0;
}
int OnBtnClick_font2(BOOL bCheck, BOOL *pbHandled)
{
if (bCheck) FontColorChange();
return 0;
}
int OnBtnClick_font3(BOOL bCheck, BOOL *pbHandled)
{
if (bCheck) FontColorChange();
return 0;
}
int OnBtnClick_color1(BOOL bCheck, BOOL *pbHandled)
{
if (bCheck) FontColorChange();
return 0;
}
int OnBtnClick_color2(BOOL bCheck, BOOL *pbHandled)
{
if (bCheck) FontColorChange();
return 0;
}
int OnBtnClick_color3(BOOL bCheck, BOOL *pbHandled)
{
if (bCheck) FontColorChange();
return 0;
}
void FontColorChange()
{
int fontSize = 12;
{
fontSize = 12;
{
fontSize = 24;
{
fontSize = 36;
}
COLORREF color = 0;
{
color = COLORREF_MAKE(200,0,0,255);
{
color = COLORREF_MAKE(0, 200, 0,255);
{
color = COLORREF_MAKE(0, 0, 200,255);
}
m_iCurStyle = iStyle;
}
int OnEditStyleChanged(int iStyle, BOOL *pbHandled)
{
m_iCurStyle = iStyle;
return 0;
}
int OnWndDrawWindow(HDRAW hDraw, BOOL *pbHandled)
{
*pbHandled = TRUE;
RECT rc;
{
{
{
wstring text = L"字体:";
xc_font_info_i f;
text += f.name;
text += L", ";
XDraw_TextOut(hDraw, rc.right + 10, rc.top + 50, text.c_str(), text.size());
};
{
wstring text = L"颜色:";
wchar_t buf[32] = { 0 };
buf[0] = L'#';
buf[1] = L'F';
buf[2] = L'F';
wsprintf(buf+3, L
"%02X", GetRValue(info.
color));
wsprintf(buf+5, L
"%02X", GetGValue(info.
color));
wsprintf(buf+7, L
"%02X", GetBValue(info.
color));
text += buf;
XDraw_TextOut(hDraw, rc.right + 10, rc.top + 75, text.c_str(), text.size());
}
}
}
return 0;
}
};
class CQQChat
{
public:
HWINDOW m_hWindow;
HELE m_hEdit;
CEditRecv m_edit_recv;
CEditSend m_edit_send;
CQQChat() {
Init();
}
void Init()
{
int top = 40;
m_edit_recv.Init(m_hWindow, 20, top, 600, 500); top += (500+30);
m_edit_send.Init(m_hWindow, 20, top, 600, 200);
m_edit_send.m_pRecv = &m_edit_recv;
}
void OnExit()
{
m_edit_recv.OnExit();
}
};
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
CQQChat MyWindow;
MyWindow.OnExit();
return 0;
}
#define XE_BNCLICK
按钮点击事件.
Definition: XCGUI.h:939
#define XE_BUTTON_CHECK
按钮选中事件
Definition: XCGUI.h:943
#define XE_EDIT_STYLE_CHANGED
Definition: XCGUI.h:1176
@ button_type_radio
单选按钮
Definition: XCGUI.h:295
XC_OBJECT_TYPE
Definition: XCGUI.h:129
@ XC_SHAPE_GIF
形状对象-GIF
Definition: XCGUI.h:232
@ XC_BUTTON
按钮
Definition: XCGUI.h:158
@ XC_FONT
炫彩字体
Definition: XCGUI.h:243
@ XC_ELE
基础元素
Definition: XCGUI.h:152
@ XC_SHAPE
形状对象
Definition: XCGUI.h:218
@ XC_IMAGE_FRAME
图片帧,指定图片的渲染属性
Definition: XCGUI.h:247
@ window_style_default
窗口样式-控制按钮: 居中 图标, 标题, 关闭按钮, 最大化按钮, 最小化按钮
Definition: XCGUI.h:398
void WINAPI XDraw_TextOut(HDRAW hDraw, int xStart, int yStart, const wchar_t *pString, int cbString)
@绘制_文本
Definition: DrawDC.cpp:3383
void WINAPI XDraw_SetBrushColor(HDRAW hDraw, COLORREF color)
绘制_置画刷颜色 设置画刷颜色.
Definition: DrawDC.cpp:2536
@ chat_flag_right
右侧
Definition: XCGUI.h:1833
@ chat_flag_left
左侧
Definition: XCGUI.h:1831
@ chat_flag_next_row_bubble
下一行显示气泡
Definition: XCGUI.h:1837
@ chat_flag_center
中间
Definition: XCGUI.h:1835
@ edit_type_richedit
富文本编辑框, 每行的高度可能不同
Definition: XCGUI.h:1810
@ edit_type_chat
聊天气泡, 每行的高度可能不同, 功能继承富文本编辑框
Definition: XCGUI.h:1812
@ edit_style_type_font_color
字体
Definition: XCGUI.h:1820
int WINAPI XEdit_AddObject(HELE hEle, HXCGUI hObj)
@编辑框_添加对象 例如: 字体, 图片, UI对象
Definition: EditUI.cpp:7024
void WINAPI XEdit_AddTextEx(HELE hEle, const wchar_t *pString, int iStyle)
@编辑框_添加文本扩展
Definition: EditUI.cpp:7013
void WINAPI XEdit_FreeData(edit_data_copy_ *pData)
@编辑框_释放数据
Definition: EditUI.cpp:6763
void WINAPI XEdit_AddText(HELE hEle, const wchar_t *pString)
@编辑框_添加文本
Definition: EditUI.cpp:6992
void WINAPI XEdit_SetRowHeightEx(HELE hEle, int iRow, int nHeight)
@编辑框_置指定行高度 当类型为 edit_type_richedit 支持指定不同行高
Definition: EditUI.cpp:7170
void WINAPI XEdit_SetRowHeight(HELE hEle, int nHeight)
@编辑框_置默认行高
Definition: EditUI.cpp:7159
void WINAPI XEdit_EnableAutoWrap(HELE hEle, BOOL bEnable)
@编辑框_启用自动换行 启用自动换行
Definition: EditUI.cpp:6600
void WINAPI XEdit_AddData(HELE hEle, edit_data_copy_ *pData, in_buffer_ USHORT *styleTable, int nStyleCount)
@编辑框_添加数据
Definition: EditUI.cpp:6754
void WINAPI XEdit_AddChatEnd(HELE hEle)
@编辑框_添加气泡结束 当前行结束
Definition: EditUI.cpp:7562
BOOL WINAPI XEdit_AutoScroll(HELE hEle)
@编辑框_自动滚动 视图自动滚动到当前插入符位置
Definition: EditUI.cpp:7274
BOOL WINAPI XEdit_GetStyleInfo(HELE hEle, int iStyle, __out edit_style_info_ *info)
@编辑框_取样式信息
Definition: EditUI.cpp:7099
HELE WINAPI XEdit_CreateEx(int x, int y, int cx, int cy, edit_type_ type, HXCGUI hParent)
@编辑框_创建扩展 创建
Definition: EditUI.cpp:6585
void WINAPI XEdit_SetCurStyle(HELE hEle, int iStyle)
@编辑框_置当前样式
Definition: EditUI.cpp:7109
int WINAPI XEdit_AddStyleEx(HELE hEle, const wchar_t *fontName, int fontSize, int fontStyle, COLORREF color, BOOL bColor)
@编辑框_添加样式扩展
Definition: EditUI.cpp:7062
edit_data_copy_ *WINAPI XEdit_GetData(HELE hEle)
@编辑框_取数据 包含文本或非文本内容
Definition: EditUI.cpp:6742
int WINAPI XEdit_AddStyle(HELE hEle, HXCGUI hFont_image_Obj, COLORREF color, BOOL bColor)
@编辑框_添加样式
Definition: EditUI.cpp:7047
int WINAPI XEdit_GetCurRow(HELE hEle)
@编辑框_取当前行
Definition: EditUI.cpp:7233
void WINAPI XEdit_AddChatBegin(HELE hEle, HIMAGE hImageAvatar, HIMAGE hImageBubble, int nFlag)
@编辑框_添加气泡开始 当前行开始
Definition: EditUI.cpp:7553
int WINAPI XEle_GetWidth(HELE hEle)
元素_取宽度 获取元素宽度.
Definition: EleUI.cpp:3640
int WINAPI XEle_GetHeight(HELE hEle)
元素_取高度 获取元素高度.
Definition: EleUI.cpp:3649
void WINAPI XEle_EnableFocus(HELE hEle, BOOL bEnable)
元素_启用焦点 启用焦点.
Definition: EleUI.cpp:4033
void WINAPI XEle_AdjustLayout(HELE hEle, UINT nAdjustNo)
元素_调整布局 调整布局.
Definition: EleUI.cpp:4676
void WINAPI XEle_EnableKeyTab(HELE hEle, BOOL bEnable)
元素_启用接收TAB 启用接收Tab输入.
Definition: EleUI.cpp:4099
void WINAPI XEle_GetRect(HELE hEle, __out RECT *pRect)
元素_取坐标 获取元素坐标.
Definition: EleUI.cpp:3592
void WINAPI XEle_Redraw(HELE hEle, BOOL bImmediate)
元素_重绘 重绘元素.
Definition: EleUI.cpp:4179
void WINAPI XFont_GetFontInfo(HFONTX hFontX, __out font_info_ *pInfo)
字体_取信息 获取字体信息.
Definition: FontX.cpp:944
void WINAPI XImage_Release(HIMAGE hImage)
图片_释放引用计数 释放引用计数,当引用计数为0时,自动销毁.
Definition: ImageFrame.cpp:1530
int WINAPI XImage_GetHeight(HIMAGE hImage)
图片_取高度 获取图片高度.
Definition: ImageFrame.cpp:1503
HIMAGE WINAPI XImage_LoadFileAdaptive(const wchar_t *pFileName, int leftSize, int topSize, int rightSize, int bottomSize)
图片_加载从文件自适应 加载图片从文件,自适应图片.
Definition: ImageFrame.cpp:1030
HIMAGE WINAPI XImage_LoadFile(const wchar_t *pFileName)
图片_加载从文件 加载图片从文件.
Definition: ImageFrame.cpp:1014
int WINAPI XImage_GetWidth(HIMAGE hImage)
图片_取宽度 获取图片宽度.
Definition: ImageFrame.cpp:1494
BOOL WINAPI XC_IsHXCGUI(HXCGUI hXCGUI, XC_OBJECT_TYPE nType)
炫彩_是否句柄包含类型 判断句柄是否拥有该类型.
Definition: Api.cpp:307
const wchar_t *WINAPI XC_itow(int nValue)
炫彩_整数到文本W 转换函数, 返回结果最大长度 TEXT_BUFFER_SIZE = 10240, 使用共享缓存,不需要释放.
Definition: Api.cpp:86
void WINAPI XExitXCGUI()
炫彩_退出 退出界面库释放资源. 不可在dllmain()中卸载, 否则会死锁
Definition: App.cpp:572
void WINAPI XRunXCGUI()
炫彩_运行 运行消息循环,当炫彩窗口数量为0时退出.
Definition: App.cpp:564
XC_OBJECT_TYPE WINAPI XC_GetObjectType(HXCGUI hXCGUI)
炫彩_取对象类型 获取句柄类型.
Definition: Api.cpp:443
BOOL WINAPI XInitXCGUI(BOOL bD2D)
炫彩_初始化 初始化界面库.
Definition: App.cpp:557
void * HXCGUI
资源句柄
Definition: XCGUI.h:92
XC_OBJECT_TYPE WINAPI XObj_GetTypeBase(HXCGUI hXCGUI)
炫彩对象_取基础类型 获取对象的基础类型,
Definition: App.cpp:761
XWnd_RegEventCPP(hWindow, nEvent, memberFunction)
窗口_注册事件CPP 注册窗口事件,将类成员函数作为事件响应函数.函数省略参数窗口自身句柄hWindow.
XEle_RegEventCPP(hEle, nEvent, memberFunction)
元素_注册事件CPP 注册元素事件,将类成员函数作为事件响应函数.函数省略元素自身句柄hEle.
HIMAGE WINAPI XShapeGif_GetImage(HXCGUI hShape)
形状GIF_取图片 获取图片句柄.
Definition: Shape.cpp:1836
void WINAPI XShapeGif_SetImage(HXCGUI hShape, HIMAGE hImage)
形状GIF_置图片 设置GIF图片.
Definition: Shape.cpp:1825
HXCGUI WINAPI XShapeGif_Create(int x, int y, int cx, int cy, HXCGUI hParent)
形状GIF_创建 创建形状对象GIF.
Definition: Shape.cpp:1813
HWINDOW WINAPI XWnd_Create(int x, int y, int cx, int cy, const wchar_t *pTitle, HWND hWndParent, int XCStyle)
窗口_创建 创建窗口
Definition: WindowUI.cpp:5964
void WINAPI XWnd_EnableDragWindow(HWINDOW hWindow, BOOL bEnable)
窗口_启用拖动窗口 启用拖动窗口.
Definition: WindowUI.cpp:6186
void WINAPI XWnd_DrawWindow(HWINDOW hWindow, HDRAW hDraw)
窗口_绘制 在自绘事件函数中,用户手动调用绘制窗口,以便控制绘制顺序.
Definition: WindowUI.cpp:6123
BOOL WINAPI XWnd_ShowWindow(HWINDOW hWindow, int nCmdShow)
@窗口_显示扩展 显示隐藏及控制窗口最大化还原等
Definition: WindowUI.cpp:6387
void WINAPI XWnd_EnableDragBorder(HWINDOW hWindow, BOOL bEnable)
窗口_启用拖动边框 启用拖动窗口边框.
Definition: WindowUI.cpp:6177
void WINAPI XWnd_Redraw(HWINDOW hWindow, BOOL bUpdate)
窗口_重绘 重绘窗口.
Definition: WindowUI.cpp:6075
Edit 数据复制
Definition: XCGUI.h:2615
edit_data_copy_style_ * pStyle
样式数组
Definition: XCGUI.h:2621
int nStyleCount
样式数量
Definition: XCGUI.h:2619
UINT hFont_image_obj
句柄(字体,图片,UI对象), 使用UINT目的当64位时可以节约4字节内存
Definition: XCGUI.h:2605
BOOL bColor
是否使用颜色
Definition: XCGUI.h:2609
COLORREF color
颜色
Definition: XCGUI.h:2607
Edit 样式信息
Definition: XCGUI.h:2587
HXCGUI hFont_image_obj
句柄(字体,图片,UI对象)
Definition: XCGUI.h:2593
USHORT type
样式类型
Definition: XCGUI.h:2589
BOOL bColor
是否使用颜色
Definition: XCGUI.h:2597
COLORREF color
颜色
Definition: XCGUI.h:2595