当前位置:网站首页>在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;
}最后效果如下
:
边栏推荐
- LC173. 二叉搜索树迭代器
- Zhong Xuegao responded that the product will not melt for 1 hour: it contains solid components and cannot melt into water
- Comprehensively analyze the logic of the shared purchase business model? How sharing purchase empowers Enterprises
- Jerry's charge unplugged, unable to touch the boot [chapter]
- [leetcode] reverse the word III in the string [557]
- [NPUCTF2020]ezlogin xPATH注入
- How does Jerry test the wrong touch rate of keys [chapter]
- 电路设计者常用的学习网站
- 静态文件显示问题
- Innovation strength is recognized again! Tencent security MSS was the pioneer of cloud native security guard in 2022
猜你喜欢

Lambda表达式:一篇文章带你通透

QT qpprogressbar details

Odoo13 build a hospital HRP environment (detailed steps)

Mask R-CNN
![[hardware] origin of standard resistance value](/img/d1/b9184c508d363eb0fa018ea6a57a10.png)
[hardware] origin of standard resistance value

严守工期,确保质量,这家AI数据标注公司做到了!
![[Yangcheng cup 2020] easyphp](/img/12/da28f738e50e625b0a66a94af3703d.png)
[Yangcheng cup 2020] easyphp

ServletContext learning diary 1

mysql重置密码,忘记密码,重置root密码,重置mysql密码
![[npuctf2020]ezlogin XPath injection](/img/6e/dac4dfa0970829775084bada740542.png)
[npuctf2020]ezlogin XPath injection
随机推荐
Chow-Liu Tree
[favorite poems] OK, song
Odoo13 build a hospital HRP environment (detailed steps)
pytorch训练CPU占用持续增长(bug)
[chestnut sugar GIS] ArcScene - how to make elevation map with height
高并发介绍及应对
[chestnut sugar GIS] ArcMap - how to batch modify the font, color, size, etc. of annotation elements
Zhong Xuegao responded that the product will not melt for 1 hour: it contains solid components and cannot melt into water
The kth largest element in the [leetcode] array [215]
泛型与反射,看这篇就够了
Hanging mirror security won four global infosec awards on rsac2022
【硬件】标准阻值的由来
[Luogu p1541] tortoise chess [DP]
剑指 Offer II 099. 最小路径之和-双百代码
海思3559万能平台搭建:在截获的YUV图像上旋转操作
悬镜安全在RSAC2022上斩获Global InfoSec Awards四项大奖
Construction of Hisilicon 3559 universal platform: rotation operation on the captured YUV image
创新实力再获认可!腾讯安全MSS获2022年度云原生安全守护先锋
Jerry's prototype will trigger shutdown after multiple touches [chapter]
Boot actuator - Prometheus use