当前位置:网站首页>在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;
}最后效果如下
:
边栏推荐
猜你喜欢

首批 | 腾讯云完成国内首个云原生安全成熟度评估

Uniapp wechat login returns user name and Avatar

海思3559万能平台搭建:在截获的YUV图像上画框

Splunk audit 的设定

QT qsplitter splitter

Odoo13 build a hospital HRP environment (detailed steps)

Learning records of data analysis (II) -- simple use of response surface method and design expert

Webrtc audio and video capture and playback examples and mediastream media stream analysis

【硬件】标准阻值的由来
![[Solved] Splunk: Cannot get username when all users are selected“](/img/13/1e824c8005701e21fc5b4e73308d53.png)
[Solved] Splunk: Cannot get username when all users are selected“
随机推荐
AES高级加密协议的动机阐述
mysql重置密码,忘记密码,重置root密码,重置mysql密码
Addition, deletion, modification and query of handwritten ORM (object relationship mapping)
P7072 [CSP-J2020] 直播获奖
MySQL查询附近的数据.并按距离进行排序.
Go four singleton modes
严守工期,确保质量,这家AI数据标注公司做到了!
移动端 1px 像素兼容性问题,实现1px 边框
Qt QProgressBar详解
PMP project integration management
2016. 增量元素之间的最大差值
【板栗糖GIS】arcmap—如何批量修改注记要素的字体,颜色,大小等
The threshold value of fusing proportion cannot be changed with sentinel, and setting the slow call proportion has no effect
手写ORM(对象关系映射)增删改查
WebRTC音视频采集和播放示例及MediaStream媒体流解析
To myself who is about to work
LC173. 二叉搜索树迭代器
AES高級加密協議的動機闡述
DTM distributed transaction manager PHP collaboration client V0.1 beta release!!!
悬镜安全在RSAC2022上斩获Global InfoSec Awards四项大奖