CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2007
    Posts
    162

    Text turns to mush

    I am using this code to print color text to a rich edit box:
    Code:
    void CRichEditDlg::OnBnClickedButton1()
    {
    	// TODO: Add your control notification handler code here
    	CHARFORMAT Cfm;
    
    	m_Richer.GetSelectionCharFormat(Cfm);
    
    	Cfm.cbSize = sizeof(CHARFORMAT);
    	Cfm.dwMask = CFM_COLOR|CFM_BOLD;
    	Cfm.dwEffects = CFE_BOLD; 
    	Cfm.crTextColor = RGB(0,0,255);
    
    	m_Richer.SetSelectionCharFormat(Cfm); 
    
    	CString text = "Now is the time for all good men to come to the aid of the party";
    
       SETTEXTEX SetTextEx;
       SetTextEx.codepage = CP_ACP;
       SetTextEx.flags = ST_SELECTION;
    
       m_Richer.SetSel(-1,-1);
       m_Richer.SendMessage(EM_SETTEXTEX,(WPARAM)&SetTextEx, (LPARAM) (LPCTSTR)text);
    }
    Everything works well, the text prints to the box and the colors are correct, but when I scroll up or down using the thumb, all the text gets distorted. Any ideas?

    Thanks
    Zapper222
    Last edited by zapper222; February 24th, 2008 at 10:47 PM.

  2. #2
    Join Date
    Apr 2007
    Posts
    162

    Re: Text turns to mush

    I think I have tracked this down to the WinXP bug that distorts text when smooth scrolling is enabled. So I tried to handle the Vertical Scroll for the rich text edit box.
    Right click on the rich text edit, select Add Event Handler...Select my class and Message type as EN_VSCROLL select Add and Edit then add this code:

    Code:
    void CMyScanDlg::OnEnVscrollRicher()
    {
    	// TODO: Add your control notification handler code here
    	Invalidate();   
            UpdateWindow();
    }
    and.......... it doesn't work
    The text still "melts" when you use the vertical scroll.
    Any help appreciated.

    Zapper

  3. #3
    Join Date
    Aug 2008
    Posts
    8

    Re: Text turns to mush

    Did you ever fix this? I'm trying to draw rectangles that seem to "melt" upon scrolling in either direction. Also, the rectangles are completely redrawn when I minimize then restore the window but apparently the origin moves.

    My code to draw the rectangles is

    CRect TempRect = pDoc->GetNode(i); // The points for the rectangle
    OnPrepareDC(pDC);
    pDC->DPtoLP(&TempRect);
    pDC->Rectangle(TempRect);

    I have tried a variety of fixes in OnPrepareDC included setting the mapping mode to MM_LOENGLISH and setting the origin at 0, 0 but nothing works.

    Any help?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured