当前位置:网站首页>在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;
}最后效果如下
:
边栏推荐
- Qt QScrollArea
- go 4種單例模式
- 大一学习分享
- Motivation du Protocole de chiffrement avancé AES
- 创新实力再获认可!腾讯安全MSS获2022年度云原生安全守护先锋
- LeetCode 968. 监控二叉树
- Dahua cloud native load balancing article - the passenger flow of small restaurants has increased
- 泛型与反射,看这篇就够了
- Gas station [problem analysis - > problem conversion - > greed]
- 用sentinel熔断比例阈值改不了,设置慢调用比例没效果
猜你喜欢

数组进阶提高

Go language sqlx library operation SQLite3 database addition, deletion, modification and query

从2022年Q1财报看携程的韧性和远景

数据分析学习记录(二)---响应曲面法及Design-Expert的简单使用
![[chestnut sugar GIS] ArcMap - how to batch modify the font, color, size, etc. of annotation elements](/img/b1/1fae909fb6a9231096a93d741d6426.png)
[chestnut sugar GIS] ArcMap - how to batch modify the font, color, size, etc. of annotation elements

The first batch of Tencent cloud completed the first cloud native security maturity assessment in China

World Environment Day | Chow Tai Fook serves wholeheartedly to promote carbon reduction and environmental protection
![[hardware] origin of standard resistance value](/img/d1/b9184c508d363eb0fa018ea6a57a10.png)
[hardware] origin of standard resistance value

Share 10 JS closure interview questions (diagrams), come in and see how many you can answer correctly
![[chestnut sugar GIS] how does global mapper batch produce ground contour lines through DSM](/img/5d/c23ec16df6ce8d78207b635f59dc20.png)
[chestnut sugar GIS] how does global mapper batch produce ground contour lines through DSM
随机推荐
[leetcode] number of palindromes [9]
Jerry's prototype has no touch, and the reinstallation becomes normal after dismantling [chapter]
P7072 [csp-j2020] live broadcast Award
E-commerce system microservice architecture
Jerry's fast touch does not respond [chapter]
【板栗糖GIS】arcscene—如何做出有高度的高程图
Rails 3 activerecord: sort by association count - rails 3 activerecord: order by count on Association
PMP project integration management
编辑卡顿
Xshell configuration xforward forwarding Firefox browser
Golang interview finishing three resumes how to write
情感对话识别与生成简述
Higher order operation of bits
[Yangcheng cup 2020] easyphp
go 4種單例模式
Stop slave is stuck -- the event of the transaction is not copied completely
Qt QProgressBar详解
全面解析分享购商业模式逻辑?分享购是如何赋能企业
电路设计者常用的学习网站
Innovation strength is recognized again! Tencent security MSS was the pioneer of cloud native security guard in 2022