背景管理器-按钮设置背景

按钮设置背景示例

//创建按钮
HELE hButton = XBtn_Create(100, 50, 160, 100,L"Button", m_hWindow);
XEle_EnableFocus(hButton,FALSE);
HIMAGE hImage=XImage_LoadFile(L"image\\icon.png");
HBKM hBkInfoM=XEle_GetBkManager(hButton); //获取背景管理器
//XBkM_Clear(hBkInfoM); //清除先前的背景内容, 默认没有背景内容所以不需要清除
//设置鼠标离开状态背景
XBkM_AddFill(hBkInfoM,button_state_flag_leave,COLORREF_MAKE(100,100,100,255)); //添加背景填充色
XBkM_AddBorder(hBkInfoM,button_state_flag_leave,COLORREF_MAKE(200,0,0,255),1); //添加边框
XBkM_AddImage(hBkInfoM,button_state_flag_leave,hImage); //添加图片
//设置鼠标停留状态背景
XBkM_AddFill(hBkInfoM,button_state_flag_stay,COLORREF_MAKE(120,120,120,255);
XBkM_AddBorder(hBkInfoM,button_state_flag_stay,COLORREF_MAKE(200,0,0,255),1);
//设置鼠标按下状态背景
XBkM_AddFill(hBkInfoM,button_state_flag_down,COLORREF_MAKE(150,150,150,255));
XBkM_AddBorder(hBkInfoM,button_state_flag_down,COLORREF_MAKE(200,0,0,255),1);
void WINAPI XBkM_AddFill(HBKM hBkInfoM, int nState, COLORREF color, int id)
背景_添加填充 添加背景内容填充.
Definition: BkObjectMgr.cpp:472
void WINAPI XBkM_AddImage(HBKM hBkInfoM, int nState, HIMAGE hImage, int id)
背景_添加图片 添加背景内容图片.
Definition: BkObjectMgr.cpp:483
void WINAPI XBkM_AddBorder(HBKM hBkInfoM, int nState, COLORREF color, int width, int id)
背景_添加边框 添加背景内容边框.
Definition: BkObjectMgr.cpp:461
@ button_state_flag_down
鼠标按下
Definition: XCGUI.h:2130
@ button_state_flag_stay
鼠标停留
Definition: XCGUI.h:2128
@ button_state_flag_leave
鼠标离开
Definition: XCGUI.h:2126
HELE WINAPI XBtn_Create(int x, int y, int cx, int cy, const wchar_t *pName, HXCGUI hParent)
按钮_创建 创建按钮元素
Definition: ButtonUI.cpp:1765
void WINAPI XEle_EnableFocus(HELE hEle, BOOL bEnable)
元素_启用焦点 启用焦点.
Definition: EleUI.cpp:4033
HBKM WINAPI XEle_GetBkManager(HELE hEle)
元素_取背景管理器 获取元素背景管理器.
Definition: EleUI.cpp:4502
HIMAGE WINAPI XImage_LoadFile(const wchar_t *pFileName)
图片_加载从文件 加载图片从文件.
Definition: ImageFrame.cpp:1014

程序截图