Text to a Rich Edit Box

Discussion in 'MFC' started by zapper222, Feb 13, 2008.

  1. zapper222

    zapper222 New Member

    Joined:
    Apr 30, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Trying to print color in a rich edit box using following code:

    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 = 1200;
       SetTextEx.flags = ST_SELECTION;
    
       m_Richer.SetSel(-1,-1);
       m_Richer.SendMessage(EM_SETTEXTEX,(WPARAM)&SetTextEx, (LPARAM) &text);
    }
    Unfortunatly that only prints garbage.....anyone know what I am doing wrong ??
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice