plain RTF inside CRichEditCtrl - Programmer

This is a discussion on plain RTF inside CRichEditCtrl - Programmer ; I have a buffer with some text in it which is in RTF format and what I'd like to do is to have a CRichEditCtrl display that data in its RAW form, meaning, to actually display the tags of the ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: plain RTF inside CRichEditCtrl

  1. plain RTF inside CRichEditCtrl

    I have a buffer with some text in it which is in RTF format and what
    I'd like to do is to have a CRichEditCtrl display that data in its RAW
    form, meaning, to actually display the tags of the RTF. moreover, that
    being displayed I'd like to have the ability to change the color and
    font of the data displayed.
    I've tried the normal SetWindowText and it parsed the RTF and
    displayed it with its own formatting and without the tags, I also
    tried using InStream and the result was very odd and not so well
    defined.
    can anyone help me?

  2. Re: plain RTF inside CRichEditCtrl

    give you one example
    // read RTF file
    void CDocView::readText(CString fileName, CString fileExt)
    {
    CWaitCursor waitCursor;
    CFile file(fileName,CFile::modeRead);
    editStream.dwCookie = (DWORD)&file;
    editStream.pfnCallback = readFunc;

    int format = fileExt.CompareNoCase(_T("rtf"))==0
    ? SF_RTF : SF_TEXT;
    m_editCtrl.StreamIn(format,editStream);

    }

    // change color
    void CDocView::OnChooseColor()
    {
    CHARFORMAT cf;
    m_editCtrl.GetSelectionCharFormat(cf);
    CColorDialog dlg(cf.crTextColor);
    m_editCtrl.HideSelection(FALSE,TRUE);

    if( dlg.DoModal()==IDOK )
    {
    cf.crTextColor = dlg.GetColor();
    cf.dwMask = CFM_COLOR;
    cf.dwEffects = 0; // Make sure CFE_AUTOCOLOR isn't on
    m_editCtrl.SetSelectionCharFormat(cf);
    }

    m_editCtrl.SetFocus();
    }

    // change font
    void CDocView::OnChooseFont()
    {
    CHARFORMAT cf;
    m_editCtrl.GetSelectionCharFormat(cf);
    CFontDialog dlg(cf);
    m_editCtrl.HideSelection(FALSE,TRUE);

    if( dlg.DoModal()==IDOK )
    {
    dlg.GetCharFormat(cf);
    m_editCtrl.SetSelectionCharFormat(cf);
    }

    m_editCtrl.SetFocus();
    }

    ???
    news:81b96c54.0404230524.69097150@posting.google.c om ???...
    > I have a buffer with some text in it which is in RTF format and what
    > I'd like to do is to have a CRichEditCtrl display that data in its RAW
    > form, meaning, to actually display the tags of the RTF. moreover, that
    > being displayed I'd like to have the ability to change the color and
    > font of the data displayed.
    > I've tried the normal SetWindowText and it parsed the RTF and
    > displayed it with its own formatting and without the tags, I also
    > tried using InStream and the result was very odd and not so well
    > defined.
    > can anyone help me?




  3. Re: plain RTF inside CRichEditCtrl

    thank but no thanks. that is exactly the oposite of what I wanted to do.
    I wanted to put the RTF text AS IT IS! with the TAGS showing in the edit
    control.


    "eric" wrote in message
    news:3MQic.96$1f2.19@newsfe1-win...
    > give you one example
    > // read RTF file
    > void CDocView::readText(CString fileName, CString fileExt)
    > {
    > CWaitCursor waitCursor;
    > CFile file(fileName,CFile::modeRead);
    > editStream.dwCookie = (DWORD)&file;
    > editStream.pfnCallback = readFunc;
    >
    > int format = fileExt.CompareNoCase(_T("rtf"))==0
    > ? SF_RTF : SF_TEXT;
    > m_editCtrl.StreamIn(format,editStream);
    >
    > }
    >
    > // change color
    > void CDocView::OnChooseColor()
    > {
    > CHARFORMAT cf;
    > m_editCtrl.GetSelectionCharFormat(cf);
    > CColorDialog dlg(cf.crTextColor);
    > m_editCtrl.HideSelection(FALSE,TRUE);
    >
    > if( dlg.DoModal()==IDOK )
    > {
    > cf.crTextColor = dlg.GetColor();
    > cf.dwMask = CFM_COLOR;
    > cf.dwEffects = 0; // Make sure CFE_AUTOCOLOR isn't on
    > m_editCtrl.SetSelectionCharFormat(cf);
    > }
    >
    > m_editCtrl.SetFocus();
    > }
    >
    > // change font
    > void CDocView::OnChooseFont()
    > {
    > CHARFORMAT cf;
    > m_editCtrl.GetSelectionCharFormat(cf);
    > CFontDialog dlg(cf);
    > m_editCtrl.HideSelection(FALSE,TRUE);
    >
    > if( dlg.DoModal()==IDOK )
    > {
    > dlg.GetCharFormat(cf);
    > m_editCtrl.SetSelectionCharFormat(cf);
    > }
    >
    > m_editCtrl.SetFocus();
    > }
    >
    > ???
    > news:81b96c54.0404230524.69097150@posting.google.c om ???...
    > > I have a buffer with some text in it which is in RTF format and what
    > > I'd like to do is to have a CRichEditCtrl display that data in its RAW
    > > form, meaning, to actually display the tags of the RTF. moreover, that
    > > being displayed I'd like to have the ability to change the color and
    > > font of the data displayed.
    > > I've tried the normal SetWindowText and it parsed the RTF and
    > > displayed it with its own formatting and without the tags, I also
    > > tried using InStream and the result was very odd and not so well
    > > defined.
    > > can anyone help me?

    >
    >




+ Reply to Thread