ScrollView-滚动视图元素

ScrollView 滚动视图元素

滚动视图元素,具有水平滚动条和垂直滚动条,可以左右上下滚动视图.

步骤:

  1. XSView_Create()创建滚动视图元素.
  2. XSView_SetTotalSize()设置视图内容大小,也就是可以滚动的最大区域.

示例代码:

#pragma comment(lib, "XCGUI.lib")
#include "xcgui.h"
class CMyWindowScrollView
{
public:
HWINDOW m_hWindow;
HELE m_hScrollView;
CMyWindowScrollView()
{
Init();
}
void Init()
{
m_hWindow = XWnd_Create(0, 0, 300, 300, L"炫彩界面库窗口", NULL, window_style_default);
m_hScrollView=XSView_Create(20,50,200,200,m_hWindow);
XSView_SetTotalSize(m_hScrollView,300,300);
XBtn_Create(10,10,100,20,L"Button1",m_hScrollView);
XBtn_Create(10,40,100,20,L"Button2",m_hScrollView);
XBtn_Create(10,70,100,20,L"Button3",m_hScrollView);
XEle_RegEventCPP(m_hScrollView,XE_SCROLLVIEW_SCROLL_H,&CMyWindowScrollView::OnScrollViewScrollH);
XEle_RegEventCPP(m_hScrollView,XE_SCROLLVIEW_SCROLL_V,&CMyWindowScrollView::OnScrollViewScrollV);
XWnd_ShowWindow(m_hWindow,SW_SHOW);
}
int OnScrollViewScrollH(int pos,BOOL *pbHandled)
{
XTRACE("XE_SCROLLVIEW_SCROLL_H %d \n",pos);
return 0;
}
int OnScrollViewScrollV(int pos,BOOL *pbHandled)
{
XTRACE("XE_SCROLLVIEW_SCROLL_V %d \n",pos);
return 0;
}
};
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
XInitXCGUI(TRUE);
CMyWindowScrollView MyWindow;
return TRUE;
}
#define XE_SCROLLVIEW_SCROLL_H
滚动视图元素水平滚动事件,滚动视图触发.
Definition: XCGUI.h:948
#define XE_SCROLLVIEW_SCROLL_V
滚动视图元素垂直滚动事件,滚动视图触发.
Definition: XCGUI.h:953
@ window_style_default
窗口样式-控制按钮: 居中 图标, 标题, 关闭按钮, 最大化按钮, 最小化按钮
Definition: XCGUI.h:398
HELE WINAPI XBtn_Create(int x, int y, int cx, int cy, const wchar_t *pName, HXCGUI hParent)
按钮_创建 创建按钮元素
Definition: ButtonUI.cpp:1765
BOOL WINAPI XSView_SetTotalSize(HELE hEle, int cx, int cy)
滚动视_置视图大小 设置内容大小.
Definition: ScrollViewUI.cpp:673
HELE WINAPI XSView_Create(int x, int y, int cx, int cy, HXCGUI hParent)
滚动视_创建 创建滚动视图元素.
Definition: ScrollViewUI.cpp:659
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
XEle_RegEventCPP(hEle, nEvent, memberFunction)
元素_注册事件CPP 注册元素事件,将类成员函数作为事件响应函数.函数省略元素自身句柄hEle.
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

截图: