需求:能够实现让窗口的内容向上(或者向下)一行(或n行)。我的想法是用一个回车的函数(还不知道有没这种函数)定位在top(或者是bottom),在需要的时候在进行调用。敬请赐教!

解决方案 »

  1.   

    SendMessage(WM_VSCROLL,SB_TOP);//到TOP
    SendMessage(WM_VSCROLL,SB_BOTTOM);SendMessage(WM_VSCROLL,SB_LINEDOWN);//向下一行
    SendMessage(WM_VSCROLL,SB_LINEUP);SendMessage(WM_VSCROLL,SB_PAGEDOWN);//向下一页
    SendMessage(WM_VSCROLL,SB_PAGEUP);
      

  2.   

    index: WM_VSCROLL
    The WM_VSCROLL message is sent to a window when a scroll event occurs in the window's standard vertical scroll bar. This message is also sent to the owner of a vertical scroll bar control when a scroll event occurs in the control. 
      

  3.   

    重载一下WM_VSROLL吧
    在MSDN里有很详细的帮助
      

  4.   

    SendMessage(WM_VSCROLL,SB_TOP);//到TOP
    SendMessage(WM_VSCROLL,SB_BOTTOM);SendMessage(WM_VSCROLL,SB_LINEDOWN);//向下一行
    SendMessage(WM_VSCROLL,SB_LINEUP);SendMessage(WM_VSCROLL,SB_PAGEDOWN);//向下一页
    SendMessage(WM_VSCROLL,SB_PAGEUP);////////////////////////////////////////////
    参见:《windows程序设计》第5版
      

  5.   

    呵呵,上面andy_lau(天行键,君子当自强不息!) 兄拷贝我的答复已经有很多次了。
        本人书读得少,不知《windows程序设计》第5版中是否真的有与我上面写的一样的一段话?
      

  6.   

    嘿嘿!我找了一下,但是找不到,望告知页码,,本人是菜鸟一只,还真没用过这个方法所以想找个参照一下!我的想法是在CEditView里实现一个 文本框,其实我不希望是通过滚动条产生消息来滚动,我是希望我里面的内容在我的控制下实现滚动,,望各位大侠指点。
      

  7.   

    不是很明白你的意思,不过窗口的滚动免不了使用ScrollWindow(...);函数。
      

  8.   

    我认为SendMessage的消息处理函数就是当前的窗口函数windowproc, 这个在mfc里应该是被封装了吧。
      

  9.   

    void ScrollWindow ( 
    int xAmount, 
    int yAmount, 
    LPCRECT lpRect = NULL, 
    LPCRECT lpClipRect = NULL ); 
    validateRect(CRect);
    MFC windows 程序设计 P146有详细讲解
      

  10.   

    先调用 ScrollWindow(Ex) 将当前窗口显示整体上移(超出的部分自动被 DC 剪切), 然后计算上移后未覆盖的 rect,调用: 
    InvalidateRect(hWnd, &rect, TRUE);
    UpdateWindow(hWnd);
      

  11.   

    CWnd::ScrollWindow
    void ScrollWindow( int xAmount, int yAmount, LPCRECT lpRect = NULL, LPCRECT lpClipRect = NULL );ParametersxAmountSpecifies the amount, in device units, of horizontal scrolling. This parameter must be a negative value to scroll to the left.yAmountSpecifies the amount, in device units, of vertical scrolling. This parameter must be a negative value to scroll up.lpRectPoints to a CRect object or RECT structure that specifies the portion of the client area to be scrolled. If lpRect is NULL, the entire client area is scrolled. The caret is repositioned if the cursor rectangle intersects the scroll rectangle.lpClipRectPoints to a CRect object or RECT structure that specifies the clipping rectangle to scroll. Only bits inside this rectangle are scrolled. Bits outside this rectangle are not affected even if they are in the lpRect rectangle. If lpClipRect is NULL, no clipping is performed on the scroll rectangle.ResScrolls the contents of the client area of the current CWnd object.