当设置CEdit的内容的时候需要让他自动滚动.在CSND里找找,发现可以这么用:
假设CEdit是 m_EditResult
m_EditResult.SetSel(HIWORD(m_EditResult.GetSel())  , -1);有一下两点不理解,请高手指点!1.查找MSDN发现第二的参数是 是否通知滚动条 为bool型.但是我发现在这里必须设置成-1,设置成TRUE,也就是1是不行的.2.第一个参数为什么要HIWORD一下呢.奉送100分.
请高人指点,先谢谢大家了!

解决方案 »

  1.   

    首先GetSel()返回一个DWORD,在低位WORD保存选择部分的开始位置,高位WORD保存所选中的字符的后面字符的第一个字符的开始位置,比如
    abcdef,选中了cd,则高位为2,低位为4
    SetSel(DWORD dwSelection, BOOL bNoScroll)详细见MSDN吧,你这里由于第一个参数HIWORD返回WORD,所以相当于调用了下面的形式,第三个参数虽然你没写,相当于是FALSE了:
    void SetSel(
       int nStartChar,
       int nEndChar,
       BOOL bNoScroll = FALSE 
    );
    这样你可以试一下,把3个参数都填好,结果跟MSDN里一样的!
      

  2.   

    SetSel是选择字符,你想要怎么滚动?
      

  3.   

    CEdit::GetSel 
    DWORD GetSel( ) const;void GetSel( int& nStartChar, int& nEndChar ) const;Return ValueThe version that returns a DWORD returns a value that contains the starting position in the low-order word and the position of the first nonselected character after the end of the selection in the high-order word.CEdit::SetSel 
    void SetSel( DWORD dwSelection, BOOL bNoScroll = FALSE );void SetSel( int nStartChar, int nEndChar, BOOL bNoScroll = FALSE ); //第三个默认为FALSEExample// The pointer to my edit.
    extern CEdit* pmyEdit;// Set the selection to be all characters after the current selection.
    DWORD dwSel = pmyEdit->GetSel();
    pmyEdit->SetSel(HIWORD(dwSel), -1);
      

  4.   

    CEdit::SetSel
      void SetSel(DWORD dwSelection, BOOL bNoScroll = FALSE);
      void SetSel(int nStartChar, int nEndChar, BOOL bNoScroll = False);
      参数: dwSelection 低位字指定起始位置,高位字为结束位置。如果低位为0,高位为-1,则编辑控件中的全部文本被选中;如果低位字为-1,则任何当前选定内容被去掉选定状态。 
      bNoScroll 指示是否显示脱字符是滚动可见的。如果值为FALSE,则显示,TRUE不显示。 
      nStartChar 指出当前选中部分的开始位置。如果nStartChar=0且nEndChar=-1,则编辑控件的文本被全选;如果nStartChar=-1,则任何当前选定内容被去掉选定状态。 
      nEndChar 指出结束位置。 
      

  5.   

    1 你看花眼了
    2 看看GetSel()的返回值是什么