当前位置:网站首页>在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;
}最后效果如下
:
边栏推荐
- MySQL查询附近的数据.并按距离进行排序.
- Mask R-CNN
- Jerry's built-in shutdown current is 1.2ua, and then it can't be turned on by long pressing [chapter]
- 创新实力再获认可!腾讯安全MSS获2022年度云原生安全守护先锋
- Go语言sqlx库操作SQLite3数据库增删改查
- QT qpprogressbar details
- Kubernetes uses the host name to allocate the pod on the specified node
- To myself who is about to work
- 2016. 增量元素之间的最大差值
- Webrtc audio and video capture and playback examples and mediastream media stream analysis
猜你喜欢

boot actuator - prometheus使用

Lambda expression: an article takes you through

分享 10 个 JS 闭包面试题(图解),进来看看你能答对多少

STM32之ADC

Methods to solve the tampering of Chrome browser and edeg browser homepage

Share 10 JS closure interview questions (diagrams), come in and see how many you can answer correctly

全面解析分享购商业模式逻辑?分享购是如何赋能企业

MySQL查询附近的数据.并按距离进行排序.

數據分析學習記錄--用EXCEL完成簡單的單因素方差分析
![加油站[问题分析->问题转换->贪心]](/img/15/5313f900abedb46ce82d8ab81af1d7.png)
加油站[问题分析->问题转换->贪心]
随机推荐
odoo13搭建医院HRP环境(详细步骤)
mysql重置密码,忘记密码,重置root密码,重置mysql密码
Innovation strength is recognized again! Tencent security MSS was the pioneer of cloud native security guard in 2022
从2022年Q1财报看携程的韧性和远景
电路设计者常用的学习网站
高并发介绍及应对
ServletContext learning diary 1
MySQL查询附近的数据.并按距离进行排序.
Golang interview finishing three resumes how to write
20220527_数据库过程_语句留档
go 多线程数据搜索
【板栗糖GIS】arcmap—如何批量修改注记要素的字体,颜色,大小等
Golang面试整理 三 简历如何书写
[Solved] Splunk: Cannot get username when all users are selected“
[leetcode] number of palindromes [9]
移动端 1px 像素兼容性问题,实现1px 边框
P7072 [CSP-J2020] 直播获奖
最小生成树 Minimum Spanning Tree
Splunk audit setting
[羊城杯2020]easyphp