当前位置:网站首页>在SOUI里使用真窗口时使用SOUI的滚动条
在SOUI里使用真窗口时使用SOUI的滚动条
2022-07-02 22:09:00 【搬砖道人】
在UI里合理使用真窗口一般可以充分利用现有控件,并且减少重写的麻烦,但是在DUI里融合是一个问题,而带有滚动条的控件一般有控件自带的滚动条,这种情况可能需要HOOK掉现在的控件。另一种是自己的窗口实现大小大于视图大小需要显示滚动条,本文讨论的是第二种情况。对于这种情况下要使用SOUI自带的滚动条我使用的方法是在外层再加一层这真窗口这样答到clip子窗口的效果。这里只讲关键部分不提供源码。
一 、关闭窗口透明,真窗口是不能在透明窗口当子窗口显示的。
二、外层窗口创建时添加WS_CLIPCHILDREN标志。
三、真子窗口放入一个scollview里。
四、创建真子窗口时需要创建两层,外面为clip功能一直和视图大小一样。以下是我使用创建方法
HWND CVideoHostWnd::Create(HWND hWndParent, int id)
{
HWND hWnd = SNativeWnd::Create(_T("video_host_wnd"), WS_CHILD | WS_VISIBLE/*| WS_CLIPCHILDREN*/, NULL, 0, 0, 0, 0, hWndParent, NULL);
m_hRealWnd.Create(_T("video_wnd"), WS_CHILD | WS_VISIBLE, NULL, 0, 0, 0, 0, hWnd, NULL);
SetRelWndID(id);
return hWnd;
}
在IRealWndHandler接口实现的OnRealWndCreate
CVideoHostWnd* pvideoWnd = new CVideoHostWnd();
pvideoWnd->Create(pRealWnd->GetContainer()->GetHostHwnd(),pRealWnd->GetID());
pRealWnd->SetData(pvideoWnd);
//返回成功创建后的窗口句柄
return pvideoWnd->m_hWnd;
五、在合适的时机里调整两个窗口的大小和位置
void CRealWndHelper::Init(CVideoHostWnd* pvideoWnd, SScrollView* pScoroll)
{
m_pvideoWnd = pvideoWnd;
m_pScoroll = pScoroll;
SASSERT(m_pvideoWnd && m_pScoroll);
m_pScoroll->GetEventSet()->subscribeEvent<CRealWndHelper, EventScrollViewOriginChanged>(&CRealWndHelper::OnScrollViewOriginChanged, this);
m_pScoroll->GetEventSet()->subscribeEvent<CRealWndHelper, EventScrollViewSizeChanged>(&CRealWndHelper::OnScrollViewSizeChanged, this);
}
void CRealWndHelper::SetvideoViewSize(CSize szViewSize)
{
SASSERT(m_pvideoWnd && m_pScoroll);
m_pScoroll->SetAttribute(L"viewsize", SStringT().Format(L"%dpx,%dpx", szViewSize.cx, szViewSize.cy), TRUE);
m_pScoroll->RequestRelayout();
}
bool CRealWndHelper::OnScrollViewSizeChanged(EventScrollViewSizeChanged* pEv)
{
m_pvideoWnd->SetRelWndSize(pEv->szNewViewSize);
return true;
}
bool CRealWndHelper::OnScrollViewOriginChanged(EventScrollViewOriginChanged* pEv)
{
m_pvideoWnd->SetRelWndOrg(pEv->ptNewOrigin);
return true;
}
最后效果如下:
边栏推荐
- [leetcode] most elements [169]
- 地方经销商玩转社区团购模式,百万运营分享
- Chow-Liu Tree
- MySQL queries nearby data And sort by distance
- Learning Websites commonly used by circuit designers
- Go multithreaded data search
- Go 4 modes Singleton
- mysql重置密码,忘记密码,重置root密码,重置mysql密码
- Construction of Hisilicon 3559 universal platform: rotation operation on the captured YUV image
- 分布式监控系统zabbix
猜你喜欢
世界环境日 | 周大福用心服务推动减碳环保
E-commerce system microservice architecture
Share 10 JS closure interview questions (diagrams), come in and see how many you can answer correctly
Generics and reflection, this is enough
地方经销商玩转社区团购模式,百万运营分享
AES高级加密协议的动机阐述
分享 10 个 JS 闭包面试题(图解),进来看看你能答对多少
Construction of Hisilicon 3559 universal platform: rotation operation on the captured YUV image
设置单击右键可以选择用VS Code打开文件
[npuctf2020]ezlogin XPath injection
随机推荐
用sentinel熔断比例阈值改不了,设置慢调用比例没效果
【喜欢的诗词】好了歌
stop slave卡住--事务的事件没有复制完整
AES高級加密協議的動機闡述
go 多线程数据搜索
性能优化----严苛模式
WebRTC音视频采集和播放示例及MediaStream媒体流解析
Splunk audit setting
Jerry's built-in shutdown current is 1.2ua, and then it can't be turned on by long pressing [chapter]
QT qpprogressbar details
数据标注典型案例,景联文科技如何助力企业搭建数据方案
Motivation du Protocole de chiffrement avancé AES
Go multithreaded data search
Chow-Liu Tree
数组进阶提高
世界环境日 | 周大福用心服务推动减碳环保
地方经销商玩转社区团购模式,百万运营分享
位的高阶运算
[favorite poems] OK, song
mysql重置密码,忘记密码,重置root密码,重置mysql密码