window-窗口自绘

示例代码:

class CWindow_Demo
{
public:
HWINDOW m_hWindow;
CWindow_Demo()
{
Init();
}
void Init()
{
m_hWindow = XWnd_Create(0, 0, 300, 200, L"炫彩界面库窗口",NULL, window_style_default);
XWnd_EnableDragWindow(m_hWindow, TRUE);
//XWnd_EnableDragBorder(m_hWindow, FALSE);
XWnd_RegEventCPP(m_hWindow,WM_PAINT,&CWindow_Demo::OnWndDrawWindow);
XWnd_AdjustLayout(m_hWindow);
XWnd_ShowWindow(m_hWindow,SW_SHOW);
}
int OnWndDrawWindow(HDRAW hDraw, BOOL *pbHandled)
{
*pbHandled = TRUE;
RECT rect;
XWnd_GetClientRect(m_hWindow, &rect);
XDraw_SetBrushColor(hDraw, COLORREF_MAKE(200, 200, 200, 255));
XDraw_FillRect(hDraw, &rect);
XDraw_SetBrushColor(hDraw, COLORREF_MAKE(20, 20, 20, 255));
rect.left += 20;
rect.top += 50;
rect.right -= 20;
rect.bottom -= 20;
XDraw_FrameRect(hDraw, &rect);
wstring text = L"窗口自绘示例";
XDraw_DrawText(hDraw, text.c_str(), text.size(), &rect);
return 0;
}
};
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
XInitXCGUI(TRUE);
CWindow_Demo MyWindow;
return TRUE;
}
@ textAlignFlag_vcenter
垂直居中
Definition: XCGUI.h:1707
@ textAlignFlag_center
水平居中
Definition: XCGUI.h:1703
@ window_style_default
窗口样式-控制按钮: 居中 图标, 标题, 关闭按钮, 最大化按钮, 最小化按钮
Definition: XCGUI.h:398
void WINAPI XDraw_FillRect(HDRAW hDraw, RECT *pRect)
@绘制_填充矩形
Definition: DrawDC.cpp:2633
void WINAPI XDraw_DrawText(HDRAW hDraw, const wchar_t *pString, int nCount, RECT *pRect)
@绘制_文本指定矩形
Definition: DrawDC.cpp:3331
void WINAPI XDraw_SetTextAlign(HDRAW hDraw, int nFlags)
绘制_置文本对齐 设置文本对齐.
Definition: DrawDC.cpp:2556
void WINAPI XDraw_SetBrushColor(HDRAW hDraw, COLORREF color)
绘制_置画刷颜色 设置画刷颜色.
Definition: DrawDC.cpp:2536
void WINAPI XExitXCGUI()
炫彩_退出 退出界面库释放资源. 不可在dllmain()中卸载, 否则会死锁
Definition: App.cpp:572
void WINAPI XRunXCGUI()
炫彩_运行 运行消息循环,当炫彩窗口数量为0时退出.
Definition: App.cpp:564
BOOL WINAPI XInitXCGUI(BOOL bD2D)
炫彩_初始化 初始化界面库.
Definition: App.cpp:557
XWnd_RegEventCPP(hWindow, nEvent, memberFunction)
窗口_注册事件CPP 注册窗口事件,将类成员函数作为事件响应函数.函数省略参数窗口自身句柄hWindow.
BOOL WINAPI XWnd_GetClientRect(HWINDOW hWindow, __out RECT *pRect)
窗口_取客户区坐标 获取窗口客户区坐标;如果是阴影窗口,那么不包含阴影部分.
Definition: WindowUI.cpp:6830
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_AdjustLayout(HWINDOW hWindow)
窗口_调整布局 调整窗口布局, 当窗口显示状态才有效.
Definition: WindowUI.cpp:6718
BOOL WINAPI XWnd_ShowWindow(HWINDOW hWindow, int nCmdShow)
@窗口_显示扩展 显示隐藏及控制窗口最大化还原等
Definition: WindowUI.cpp:6387

截图: