我在模拟列表控件的滚动条消息时给列表控件发WM_VSCROLL消息。其它CODE都正常,但是SB_TRUMBTRACK和SB_TRUMBPOSITION不起作用。通过Spy++跟踪内部滚动条发的消息,记录发消息序列,我再一一重复也不行。
没有办法,只有向各位大侠求助了!

解决方案 »

  1.   

    有个HTVSCROLL,你试下发送:
    ::SendMessage(m_list.m_hWnd,WM_VSCROLL,HTVSCROLL,(LPARAM)100);
      

  2.   

    我怀疑你的消息参数有问题:
    SB_THUMBPOSITION-The user has dragged the scroll box (thumb) and released the mouse button. The high-order word indicates the position of the scroll box at the end of the drag operation. 
    SB_THUMBTRACK-The user is dragging the scroll box. This message is sent repeatedly until the user releases the mouse button. The high-order word indicates the position that the scroll box has been dragged to. 
      

  3.   

    void CScrollDlg::OnButton3() 
    {
    m_ctrlListCtrl.SetFocus();
    m_ctrlListCtrl.SetCapture();
    m_ctrlListCtrl.SendMessage(WM_SYSCOMMAND,SC_VSCROLL,0);
    m_ctrlListCtrl.SendMessage(WM_VSCROLL,MAKELONG(SB_THUMBTRACK,10),0);
    m_ctrlListCtrl.SendMessage(WM_VSCROLL,MAKELONG(SB_ENDSCROLL,0),0);
    ReleaseCapture();
    }
    上面是我的测试代码。
      

  4.   

    直接用GetScrollBarCtrl()进行操作不行吗?
      

  5.   

    我是想通过在外面模拟滚动条消息来滚动窗口。所在不能用GetScrollBarCtrl()
      

  6.   

    外部也可以啊HWND hwnd = FindWindow(...);
    if( hwnd )
    {
       CScrollBar* pBar = CWnd::FromHandle(hwnd);
    }
      

  7.   

    HWND hwnd = FindWindow(...);
    if( hwnd )
    {
       CScrollBar* pBar = (CScrollBar*)CWnd::FromHandle(hwnd);
    }
      

  8.   

    问题已经解决。
    只是用的方法是修改ListCtrl。