用CRichEditCtrl,
pRichEdit->Create(WS_CHILD|WS_VISIBLE|ES_MULTILINE|ES_WANTRETURN ,
rect, const_cast<CDiagramEditor *>(this), uID);
在没有ES_AUTOVSCROLL得情况下,输入内容到了底部,按回车 在下面插入看不见得一行;
有ES_AUTOVSCROLL得情况下,输入内容到了底部,按回车 在下面插入一行,同时整体内容上移。难道就没有什么风格 输入内容满了后,就输入不进得??失望
难道只能 自己计算 文字高度是否超过 CRect得高度???前面刚处理了一个 CRichEditCtrl打印得问题,自己用DRAWTEXT来计算行高及行间距。因为我得打印是在75%显示状态下打印100%得效果,而CRichEditCtrl自己封装得打印死板得所见既所得。真麻烦。。

解决方案 »

  1.   

    CRichEdit有个外框,内容满了 希望 不能再换行 我得程序是个图文报告
      

  2.   

    GetWindowText(OldString);
    OldLineTotal = GetLineCount();
        CRichEditCtrl::OnChar(nChar, nRepCnt, nFlags);  
    int CurLineTotal =GetLineCount();
    //int CreatPosition = GetSel();
    if( CurLineTotal > OldLineTotal )
    {
    CString CurString;
    GetWindowText(CurString);
    CWindowDC DC (this);
    //CFont *pFont = GetFont();
            //CFont *pFontDC = DC.SelectObject (pFont);
            CSize Size = DC.GetTextExtent (CurString);
    // Get client rect
    CRect Rect, ParentRect;
    GetClientRect (&Rect);
    GetParent()->GetClientRect (&ParentRect); // Transform rect to parent coordinates
    ClientToScreen (&Rect);
    GetParent()->ScreenToClient (&Rect);
    //temprect.top +=round(static_cast<LONG>((float)lineheight*linespace));
    int TextHeight = (float)Size.cy;
    int TotalHeight;
                TotalHeight=static_cast<LONG>((((float)TextHeight*m_linespace)+(float)TextHeight)*CurLineTotal)-(float)((float)TextHeight*m_linespace*2+TextHeight)*1.5;
    if (TotalHeight > Rect.Height())
    {
                SetWindowText(OldString);
    int temp = OldString.GetLength();
    SetSel(temp,temp);
    } }