Button - 动画按钮

说明

Button 动画按钮.

示例代码

//包含炫彩界面库文件
#pragma comment(lib, "XCGUI.lib")
#include "xcgui.h"
struct my_image_info
{
HIMAGE hImage1;
HIMAGE hImage2;
HIMAGE hImage3;
HIMAGE hImage4;
HIMAGE hImage5;
HIMAGE hImage6;
};
void CreateButton(int left,int top,my_image_info *pInfo,HWINDOW hWindow)
{
HELE hButton=XBtn_Create(left,top,37,42,L"A",hWindow);
XBtn_AddAnimationFrame(hButton,pInfo->hImage1,100); //添加动画帧
XBtn_AddAnimationFrame(hButton,pInfo->hImage2,100);
XBtn_AddAnimationFrame(hButton,pInfo->hImage3,100);
XBtn_AddAnimationFrame(hButton,pInfo->hImage4,100);
XBtn_AddAnimationFrame(hButton,pInfo->hImage5,100);
XBtn_AddAnimationFrame(hButton,pInfo->hImage6,100);
XBtn_EnableAnimation(hButton,TRUE); //启动动画
}
void CreateButtonLoop(int left,int top,my_image_info *pInfo,HWINDOW hWindow)
{
HELE hButton=XBtn_Create(left,top,37,42,L"B",hWindow);
XBtn_AddAnimationFrame(hButton,pInfo->hImage1,100); //添加动画帧
XBtn_AddAnimationFrame(hButton,pInfo->hImage2,100);
XBtn_AddAnimationFrame(hButton,pInfo->hImage3,100);
XBtn_AddAnimationFrame(hButton,pInfo->hImage4,100);
XBtn_AddAnimationFrame(hButton,pInfo->hImage5,100);
XBtn_AddAnimationFrame(hButton,pInfo->hImage6,100);
XBtn_EnableAnimation(hButton,TRUE,TRUE); //启动动画,循环播放
}
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
XInitXCGUI(TRUE);
HWINDOW hWindow = XWnd_Create(0, 0, 300, 200, L"炫彩界面库窗口",NULL, window_style_default);
my_image_info info;
info.hImage1=XImage_LoadFile(L"animation\\1.png");
info.hImage2=XImage_LoadFile(L"animation\\2.png");
info.hImage3=XImage_LoadFile(L"animation\\3.png");
info.hImage4=XImage_LoadFile(L"animation\\4.png");
info.hImage5=XImage_LoadFile(L"animation\\5.png");
info.hImage6=XImage_LoadFile(L"animation\\6.png");
int left=20;
int top=50;
CreateButton(left,top,&info,hWindow); left+=50;
CreateButton(left,top,&info,hWindow); left+=50;
CreateButton(left,top,&info,hWindow); left+=50;
CreateButton(left,top,&info,hWindow); left+=50;
CreateButton(left,top,&info,hWindow); left+=50;
left=20; top=100;
CreateButtonLoop(left,top,&info,hWindow); left+=50;
CreateButtonLoop(left,top,&info,hWindow); left+=50;
CreateButtonLoop(left,top,&info,hWindow); left+=50;
CreateButtonLoop(left,top,&info,hWindow); left+=50;
CreateButtonLoop(left,top,&info,hWindow); left+=50;
XWnd_ShowWindow(hWindow,SW_SHOW);
return 0;
}
@ window_style_default
窗口样式-控制按钮: 居中 图标, 标题, 关闭按钮, 最大化按钮, 最小化按钮
Definition: XCGUI.h:398
void WINAPI XBtn_EnableAnimation(HELE hEle, BOOL bEnable, BOOL bLoopPlay)
按钮_启用动画 开始或关闭图片动画的播放.
Definition: ButtonUI.cpp:2007
HELE WINAPI XBtn_Create(int x, int y, int cx, int cy, const wchar_t *pName, HXCGUI hParent)
按钮_创建 创建按钮元素
Definition: ButtonUI.cpp:1765
void WINAPI XBtn_AddAnimationFrame(HELE hEle, HIMAGE hImage, UINT uElapse)
按钮_添加动画帧 添加动画帧.
Definition: ButtonUI.cpp:1995
HIMAGE WINAPI XImage_LoadFile(const wchar_t *pFileName)
图片_加载从文件 加载图片从文件.
Definition: ImageFrame.cpp:1014
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
HWINDOW WINAPI XWnd_Create(int x, int y, int cx, int cy, const wchar_t *pTitle, HWND hWndParent, int XCStyle)
窗口_创建 创建窗口
Definition: WindowUI.cpp:5964
BOOL WINAPI XWnd_ShowWindow(HWINDOW hWindow, int nCmdShow)
@窗口_显示扩展 显示隐藏及控制窗口最大化还原等
Definition: WindowUI.cpp:6387

程序截图