使用CEdit的成员函数SetWindowText()设置文本框的内容时,滚动条都会跳回到原点,有没有什么办法能让滚动条不跳回原点,而保持在上一次的位置,使用LineScroll函数只能控制行,不能控制列,效果不太好,有什么高人指点指点!谢谢

解决方案 »

  1.   

    添加内容前通过GetScrollInfo,获取滚动条位置,
    SetWindowText()后,通过SetScrollInfo重新设置滚动条的位置GetScrollInfo Function--------------------------------------------------------------------------------The GetScrollInfo function retrieves the parameters of a scroll bar, including the minimum and maximum scrolling positions, the page size, and the position of the scroll box (thumb).SyntaxBOOL GetScrollInfo(          HWND hwnd,
        int fnBar,
        LPSCROLLINFO lpsi
    );
    Parametershwnd
    [in] Handle to a scroll bar control or a window with a standard scroll bar, depending on the value of the fnBar parameter. 
    fnBar
    [in] Specifies the type of scroll bar for which to retrieve parameters. This parameter can be one of the following values. 
    SB_CTL
    Retrieves the parameters for a scroll bar control. The hwnd parameter must be the handle to the scroll bar control. 
    SB_HORZ
    Retrieves the parameters for the window's standard horizontal scroll bar. 
    SB_VERT
    Retrieves the parameters for the window's standard vertical scroll bar. 
    lpsi
    [in, out] Pointer to a SCROLLINFO structure. Before calling GetScrollInfo, set the cbSize member to sizeof(SCROLLINFO), and set the fMask member to specify the scroll bar parameters to retrieve. Before returning, the function copies the specified parameters to the appropriate members of the structure.
    The fMask member can be one or more of the following values.SIF_PAGE
    Copies the scroll page to the nPage member of the SCROLLINFO structure pointed to by lpsi.
    SIF_POS
    Copies the scroll position to the nPos member of the SCROLLINFO structure pointed to by lpsi.
    SIF_RANGE
    Copies the scroll range to the nMin and nMax members of the SCROLLINFO structure pointed to by lpsi.
    SIF_TRACKPOS
    Copies the current scroll box tracking position to the nTrackPos member of the SCROLLINFO structure pointed to by lpsi.
    Return ValueIf the function retrieved any values, the return value is nonzero.If the function does not retrieve any values, the return value is zero. To get extended error information, call GetLastError.
      

  2.   

    可以使用GetFirstVisibleLine 和LineScroll两个成员函数进行滚动并使用SetRedraw函数减少屏幕的闪烁,谢谢各位的支持
      

  3.   

    LineScroll只能到文本最后一行,怎么办?
      

  4.   

    LineScroll只能到文本最后一行,怎么办?