⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 index119.htm

📁 一本不错的VC编程的参考书
💻 HTM
字号:
<html>
<style type="text/css"><!--
.p9 {  font-family: "宋体"; font-size: 9pt}a        {text-transform: none; text-decoration: none;}
a:hover {text-decoration: underline; color: #FF0000;}
--></style>
<body background="../di2001.jpg">
<h3 align="center"><font COLOR="#AOAO99"></font></h3>
<table width="100%" border="1" cellspacing="1">
<tr><td><p align="center"><font color="#FF0000">如何知道CListBox什么时候滚动了?</font></td></tr>
<tr><td><p>
</Br>
每次绘制列表框都要重绘某项,通过消息WM_CTLCOLOR从父窗口获得DC颜色.因此每欠列表框的滚动你都可以用WM_CTLCOLOR来检验是否滚动.<Br>
</Br>
HBRUSH CParentDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)<Br>
{<Br>
&nbsp;&nbsp;&nbsp;// is the control _the_ list box we're interested in?<Br>
&nbsp;&nbsp;&nbsp;if( nCtlColor == CTLCOLOR_LISTBOX &&<Br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pWnd->GetDlgCtrlID() == IDC_LIST )<Br>
&nbsp;&nbsp;&nbsp;{<Br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// if the top index changed, the list box has been scrolled<Br>
</Br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int iTop = ((CListBox*)pWnd)->GetTopIndex();<Br>
</Br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if( iTop != m_iTopOld )<Br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<Br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// keeps tracking of the top index changes<Br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_iTopOld = iTop;<Br>
</Br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// process scrolling<Br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...<Br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<Br>
&nbsp;&nbsp;&nbsp;}<Br>
</Br>
&nbsp;&nbsp;&nbsp;HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);<Br>
&nbsp;&nbsp;&nbsp;return hbr;<Br>
}<Br>
使用这种方法可以不必为了实现这个功能而去产生一个继承类.<Br>
</Br>
</p></td></tr>
</table>
</body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -