DuiLib : 在CListUI中得到滚动条滚动通知
来源:互联网 发布:图纸绘制软件 编辑:程序博客网 时间:2024/06/07 17:36
需求: 建立好能用的CListUI, 填入超过一页的内容后,将鼠标落到CListUI上, 滚动鼠标中键,CListUI可以一行行滚动。
但是得不到滚动条的Notify.
去研究了一下DuiLib滚动通知的实现,改了3句代码,搞定~
工程下载点 : srcGetListUiScrollNotify_2014_1023_2206.rar
效果:
void CMainDlg::Notify(TNotifyUI & msg){ std::wstring strTemp = L""; SIZE szScrollRange; SIZE szScrollPos; CListUI* pListInfo = NULL; if (msg.sType == DUI_MSGTYPE_SCROLL) { pListInfo = static_cast<CListUI *>(m_PaintManager.FindControl(L"List_info")); _ASSERT_EXPR((NULL != pListInfo), L"cant' find pListInfo"); szScrollRange = pListInfo->GetScrollRange(); szScrollPos = pListInfo->GetScrollPos(); strTemp = ns_helper::StringFormatV(L"szScrollRange(%d, %d), szScrollPos(%d, %d)\r\n", szScrollRange.cx, szScrollRange.cy, szScrollPos.cx, szScrollPos.cy); OutputDebugStringW(strTemp.c_str()); } /** run result szScrollRange(0, 94), szScrollPos(0, 20) szScrollRange(0, 94), szScrollPos(0, 40) szScrollRange(0, 94), szScrollPos(0, 60) szScrollRange(0, 94), szScrollPos(0, 80) szScrollRange(0, 94), szScrollPos(0, 94) szScrollRange(0, 94), szScrollPos(0, 94) szScrollRange(0, 94), szScrollPos(0, 94) */ __super::Notify(msg);}
原生实现是: 只有鼠标点击滚动条进行滚动时,才会触发 m_pPaintManager->SendNotify(this, DUI_MSGTYPE_SCROLL);
发现只要滚动,都会调用 CScrollBarUI::SetScrollPos
修改如下:
BOOL CScrollBarUI::DoEvent(TEventUI& event){ /// ...
if( event.Type == UIEVENT_BUTTONDOWN || event.Type == UIEVENT_DBLCLICK ){if( !IsEnabled() ) return TRUE; /// ... /// 这个片段中会调用 SetScrollPos, 下面这句挪到 SetScrollPos中判断// if( m_pPaintManager != NULL && m_pOwner == NULL ) m_pPaintManager->SendNotify(this, DUI_MSGTYPE_SCROLL);return TRUE;}
if( event.Type == UIEVENT_TIMER && event.wParam == DEFAULT_TIMERID ){ /// ... /// 这个片段中会调用 SetScrollPos, 下面这句挪到 SetScrollPos中判断// if( m_pPaintManager != NULL && m_pOwner == NULL ) m_pPaintManager->SendNotify(this, DUI_MSGTYPE_SCROLL);return TRUE;}
void CScrollBarUI::SetScrollPos(int nPos) { if( m_nScrollPos == nPos ) return; m_nScrollPos = nPos; if( m_nScrollPos < 0 ) m_nScrollPos = 0; if( m_nScrollPos > m_nRange ) m_nScrollPos = m_nRange; SetPos(m_rcItem); /// m_pOwner 不为空 if (NULL != m_pPaintManager) { m_pPaintManager->SendNotify(this, DUI_MSGTYPE_SCROLL); } }
1 0
- DuiLib : 在CListUI中得到滚动条滚动通知
- Duilib 中滚动条自动滚动到底的方法
- Duilib 中滚动条自动滚动到底的方法
- duilib问题解决:滚动条不见了
- duilib combo 滚动条不起作用
- duilib中的V和H布局中滚动条问题
- duilib中的V和H布局中滚动条问题
- DuiLib界面库滚动条拖动注意事项
- duilib 滚动条不能拖动 问题处理
- 如何在MSFLEXGRID中使滚动条随着指针滚动
- 在JFrame中设置滚动条跟随内容滚动
- C# 在滚动窗口中绘图(滚动条原理)
- Android中为通知栏添加滚动条
- 在iframe中隐藏横向滚动条。
- 在CVIEW视图中添加滚动条
- 在树状控件中添加滚动条
- 在SDK中如何控制滚动条
- 在css中定义滚动条样式
- C7_结构体
- 求平均数的简单方法
- [原]Java web学习系列之 Java web开发中的Spring整合Hibernate
- 获取IRP缓冲区的长度
- java基础教程-多线程编程
- DuiLib : 在CListUI中得到滚动条滚动通知
- hdu 4249 A Famous Equation (dp 细节)
- 教程:使用 MongoDB、WCF、OData 和 PowerBI 构建 Azure 上的商业智能解决方案
- K均值聚类算法
- Material Design入门
- 1093. Air Express
- STL--map用法详解
- ListItemType
- Xcode6模拟器iOS8键盘出不来问题