设置:
AutoSHcroll False
AutoVHcroll True
Multiline True
VerticleSrcol True
即可

解决方案 »

  1.   


    void CAutoScrollEditDlg::OnAuto() 
    {
    // TODO: Add your control notification handler code here
    static BOOL done=FALSE;
    CRect rcWin;
    m_Edit.GetWindowRect(&rcWin);
    ScreenToClient(&rcWin);
    //
    CFont *pfont=m_Edit.GetFont();
    //
    DWORD Style=GetWindowLong(m_Edit.m_hWnd,GWL_STYLE);
    long id=m_Edit.GetDlgCtrlID();
    CString txt;
    m_Edit.GetWindowText(txt);
    //
    done = !done;
    if(done)
    Style |=(ES_AUTOHSCROLL|WS_HSCROLL);
    else
    Style &=~(ES_AUTOHSCROLL|WS_HSCROLL);
    CEdit edit;
    edit.Create(Style,rcWin,this,id);
    edit.SetFont(pfont);
    edit.SetWindowText(txt); m_Edit.DestroyWindow();
    m_Edit.Attach(edit.Detach());
    m_Edit.MoveWindow(rcWin);
    }需要重新创建edit ,这个风格一旦设置就不能再改回来了.
      

  2.   

    Because ES_AUTOHSCROLL style can not be modified after an edit control has been created, We have to create a new edit control and destroy the old one! The ES_AUTOHSCROLL actually controls the wrap on/off of the edit. By the way,without the WS_HSCROOL style, you also can scroll the edit by pressing the left or right key.
      

  3.   

    即: m_Edit.SetWindowText("Because ES_AUTOHSCROLL style can not be modified"
     " after an edit control has been created, We have to"
     " create a new edit control and destroy the old one!"
     " The ES_AUTOHSCROLL actually controls the wrap on/off of the edit."
     " By the way,without the WS_HSCROOL style, you also can scroll the edit"
     " by pressing the left or right key.");没有 CRLF !
      

  4.   

    这些我都试了,根本不行。
    网上的都是这样说的:
    AutoVHcroll True //自动滚屏而已
    Multiline True        //只是支持多行,如果文本中有回车是可以的。如果文本中没有回车,还是一样的不行。
    VerticleSrcol True//滚动条而已。
      

  5.   

    这个仍然不行,标红的字体,意思是自动水平滚动条控制的是edit的外框,如果没有这个属性,你仍然可以用左右方向键滚动edit控件。和自动换行,没有一点关系。。
      

  6.   

    怎么 不明白 ?
    “只是自动滚屏,显示了横向滚动条”  不要自动滚屏,没有横向滚动条 才是  “Word break”
    即 ;
    Style &=~(ES_AUTOHSCROLL|WS_HSCROLL);
      

  7.   

    明白了关键是这一句:
    Because ES_AUTOHSCROLL style can not be modified after an edit control has been created, We have to create a new edit control and destroy the old one! 
    看来我的MSDN里面太老了,没有这个说明
    把我给郁闷的。要疯了
      

  8.   

    你看到 #5楼的 edit 初始化了 没有 ?
    这是我 写 的 !这些 字符串 间是 没有 CRLF 的 ,如果有  ES_AUTOHSCROLL , 就有 滚动条, 他们会 变成 一行 !没有 ES_AUTOHSCROLL 时他们 会 ”自动换行“ 。
      

  9.   

    VS 2010的确实可以。我用的VC6确实不行。
    要通过 @schlafenhamster 的方法才行。
      

  10.   

    还有一点想问你的。这段文字的来源是哪里?
    Because ES_AUTOHSCROLL style can not be modified after an edit control has been created, We have to create a new edit control and destroy the old one! The ES_AUTOHSCROLL actually controls the wrap on/off of the edit. By the way,without the WS_HSCROOL style, you also can scroll the edit by pressing the left or right key.
      

  11.   


    强大。
    你给的代码,原来的3D风格给没了,当然可以通过别的方法找回来。但是过程比较崎岖不是太好
    根据你的经验和提示,我自己改了一下,实现了,不用销毁原来的,也不用新建一个新的,而且保留原来的3D风格。
    代码又短的实现方法。
    起作用的就两行就代码:
    再次多谢您的经验,给我的帮助void CEditScreenDlg::OnButton1() 
    {
    // TODO: Add your control notification handler code here
    CString str = "1234567890一二三四五六七八九十1234567890一二三四五六七八九十1234567890一二三四五六七八九十1234567890一二三四五六七八九十1234567890一二三四五六七八九十1234567890";
    DWORD Style = GetWindowLong(m_edt1.m_hWnd,GWL_STYLE);
    SetWindowLong(m_edt1.m_hWnd, GWL_STYLE, Style);
    m_edt1.SetWindowText(str);
    }
      

  12.   


    再进一步:
    子类化一下CEdit类,更改一下OnCreate函数:int CColorEdit::OnCreate(LPCREATESTRUCT lpCreateStruct) 
    {
    if (CEdit::OnCreate(lpCreateStruct) == -1)
    return -1;

    // TODO: Add your specialized creation code here
    DWORD Style = GetWindowLong(CEdit::m_hWnd, GWL_STYLE);
    SetWindowLong(CEdit::m_hWnd, GWL_STYLE, Style);
    return 0;
    }
    这样就可以,在属性面板里面设这好属性就可以了,类似VS2010了。
      

  13.   

    直接使用lisctrl控件,把风格改一下就可以了
      

  14.   

    这是 vc6 上 的 代码, 2010 没用过, 兴许 “不用销毁原来的,也不用新建一个新的”。
    “原来的3D风格给没了” 应该 不会, 因为 原来的 style 是 读出 后 改变的 。 有时间 看看。
      

  15.   

    listctrl是个好方法,能否说一下改哪些属性呢?
      

  16.   

    我新改的代码就是在VC6验证过的。是可以的。
    你给的代码3D风格确实没了,在VC6上验证过的。
      

  17.   

    "3D风格确实没了"  
    3D 是 exstyle , 忘了考虑。
    读出 exStyle。
    Create  要 改成  CreatEx(exSytle,。
    谢谢 
      

  18.   

    这么想自动换行,直接使用richeditbox,把Multiline True
    (VerticleSrcol True可以不要)  要想回车换行 Want Return  True
      

  19.   

    这么想自动换行,直接使用richeditbox,把Multiline True
    (VerticleSrcol True可以不要)  要想回车换行 Want Return  True
    应当是VS的都可以。我用的VC6不行。
      

  20.   

    这些我都试了,根本不行。
    网上的都是这样说的:
    AutoVHcroll True //自动滚屏而已
    Multiline True        //只是支持多行,如果文本中有回车是可以的。如果文本中没有回车,还是一样的不行。
    VerticleSrcol True//滚动条而已。那我就不知道了,我用的可以的,给你截个图吧
      

  21.   

    这些我都试了,根本不行。
    网上的都是这样说的:
    AutoVHcroll True //自动滚屏而已
    Multiline True        //只是支持多行,如果文本中有回车是可以的。如果文本中没有回车,还是一样的不行。
    VerticleSrcol True//滚动条而已。那我就不知道了,我用的可以的,给你截个图吧
    我试验过了,VS确实可以,但VC6就是不行。确实太老了。
      

  22.   

    这些我都试了,根本不行。
    网上的都是这样说的:
    AutoVHcroll True //自动滚屏而已
    Multiline True        //只是支持多行,如果文本中有回车是可以的。如果文本中没有回车,还是一样的不行。
    VerticleSrcol True//滚动条而已。那我就不知道了,我用的可以的,给你截个图吧
    我试验过了,VS确实可以,但VC6就是不行。确实太老了。用S吧,VC6V过时了
      

  23.   

    这些我都试了,根本不行。
    网上的都是这样说的:
    AutoVHcroll True //自动滚屏而已
    Multiline True        //只是支持多行,如果文本中有回车是可以的。如果文本中没有回车,还是一样的不行。
    VerticleSrcol True//滚动条而已。那我就不知道了,我用的可以的,给你截个图吧
    我试验过了,VS确实可以,但VC6就是不行。确实太老了。用S吧,VC6V过时了
    唉,是的。