当前位置:网站首页>在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;
}
最后效果如下:
边栏推荐
- Hanging mirror security won four global infosec awards on rsac2022
- 手写ORM(对象关系映射)增删改查
- PMP project integration management
- P7072 [CSP-J2020] 直播获奖
- E-commerce system microservice architecture
- 容器化技术在嵌入式领域的应用
- Distributed monitoring system ZABBIX
- [hardware] origin of standard resistance value
- 数据分析学习记录(二)---响应曲面法及Design-Expert的简单使用
- Lambda expression: an article takes you through
猜你喜欢
加油站[问题分析->问题转换->贪心]
Share 10 JS closure interview questions (diagrams), come in and see how many you can answer correctly
[羊城杯2020]easyphp
从2022年Q1财报看携程的韧性和远景
[favorite poems] OK, song
Hanging mirror security won four global infosec awards on rsac2022
[chestnut sugar GIS] how does global mapper batch produce ground contour lines through DSM
Qt QProgressBar详解
Higher order operation of bits
[hardware] origin of standard resistance value
随机推荐
用sentinel熔断比例阈值改不了,设置慢调用比例没效果
归并排序详解及应用
P1007 独木桥
Jerry's built-in shutdown current is 1.2ua, and then it can't be turned on by long pressing [chapter]
Xiaopeng P7 had an accident and the airbag did not pop up. Is this normal?
China Academy of information technology, Tsinghua University, Tencent security, cloud native security, industry university research and use strong alliance!
antd组件upload上传xlsx文件,并读取文件内容
[chestnut sugar GIS] ArcMap - how to batch modify the font, color, size, etc. of annotation elements
数据分析学习记录(二)---响应曲面法及Design-Expert的简单使用
QT qsplitter splitter
20220527_数据库过程_语句留档
[npuctf2020]ezlogin XPath injection
easyclick,ec权朗网络验证源码
P1007 single log bridge
情感对话识别与生成简述
Go four singleton modes
STM32串口DAM接收253字节就死机原因排查
AES高級加密協議的動機闡述
go 条件变量
Boot actuator - Prometheus use