资料收集站

SDL

Wednesday
Dec 03rd
Text size
  • Increase font size
  • Default font size
  • Decrease font size

每次绘制列表框都要重绘某项,通过消息WM_CTLCOLOR从父窗口获得DC颜色.因此每欠列表框的滚动你都可以用WM_CTLCOLOR来检验是否滚动.

HBRUSH CParentDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)


   // is the control _the_ list box we're interested in?

   if( nCtlColor == CTLCOLOR_LISTBOX &&

      pWnd->GetDlgCtrlID() == IDC_LIST )

   {

      // if the top index changed, the list box has been scrolled

      int iTop = ((CListBox*)pWnd)->GetTopIndex();

      if( iTop != m_iTopOld )

      {

         // keeps tracking of the top index changes

         m_iTopOld = iTop;

         // process scrolling

         ...

      }

   }

   HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

   return hbr;


使用这种方法可以不必为了实现这个功能而去产生一个继承类. 
Comments (0)Add Comment

Write comment

busy
 

Google 搜索

在线用户

We have 50 guests online