Virtual Developer Workshop: Containerized Development with Docker

Environment: VC6 SP4, 2000.

Follow these 10 easy steps to build the OutLookRichEdit control:

  1. Insert a rich edit control into the dialog.
  2. Call AfxInitRichEdit() in the InitInstance of the App class or in InitDialog.
  3. If it does not exist, copy OutLookRichEdit.cpp and OutLookRichEdit.h to the project directory.
  4. Click the menu choice Project-Add to Project-Files and select the above-copied files to add the wrapper class to your project.
  5. Import the hand cursor into the resource and rename it "IDC_LINK".
  6. Use Classwizard to add a member variable of the rich edit control (CRichEditCtrl).
  7. Include the OutLookRichEdit.h file in the dialog's header file and change the declaration of rich edit member variable, as in
  8. CRichEditCtrl    m_ctrlText1;
    COutLookRichEdit m_ctrlText1;
  9. In InitDialog(), add the following code.
  10. m_ctrlText1.SetRawHyperText(_T("Click <%$here$#100#%>
                                    to see the about box."));

    At this level, if you build the project and run it, you can see the rich edit control with linked text, but nothing would happen if you clicked on the link.

    To Show a dialog while the link is clicked, you have to add some more code in the dialog class. Before that, have a closer look at the preceding code and hypertext syntax. The link text is enclosed between the "$" symbols and the corresponding dialog's resource value 100 (About Box), enclosed in "#" symbols.

    You can find the #define values of dialogs in the resource.h file.

  11. Use ClassWizard to map OnNotify of the dialog and write the corresponding implementation code in .cpp file, like:
  12. BOOL CDEMODlg::OnNotify(WPARAM wParam,
                            LPARAM lParam,
                            LRESULT* pResult)
      NMHDR* pNmHdr = (NMHDR*) lParam;
      if(IDC_RICHEDIT1 == pNmHdr->idFrom){
          case IDD_ABOUTBOX:
            CAboutDlg oDlg;
            oDlg.DoModal ();
      return CDialog::OnNotify(wParam, lParam, pResult);
  13. Now, build and run the project. It is recommended that you set the read-only attribute to the rich edit control.


Download demo project - 23 Kb
Download source - 6 Kb


  • how can i add a new line like chatting line scrolling..

    Posted by Legacy on 07/28/2003 07:00am

    Originally posted by: min_hoae_kim

    Could you please tell me how can I add a new line(like chatting) using SetRawHyperText function?

  • How to keep the link destnation when I change the text?

    Posted by Legacy on 06/06/2003 07:00am

    Originally posted by: Woolf Yang

    Thank you for your work.But,if I change the text ,for example insert some other text before the linked text,then the mouse can't click on the linked text .
    Whold you like to give me an advice or fix it ?

  • Solution to support chinese character

    Posted by Legacy on 04/25/2003 07:00am

    Originally posted by: yiweihua

    Madhu B Nair's work is very much appriciated. Thank him.

    I found a very easy way to support Chinese character.
    To change the RTF_SKELTON definition:

    //#define RTF_SKELTON _T("{\\rtf1\\ansi\\deff0\\deftab720{\\fonttbl{\\f0\\fswiss MS Sans Serif;}{\\f1\\froman\\fcharset2 Symbol;}{\\f2\\froman Times New Roman;}{\\f3\\fswiss Arial;}}{\\colortbl\\red0\\green0\\blue0;\\red0\\green0\\blue255;}\\deflang1033\\pard\\plain\\f2\\fs20 <@RAW@>}");

    modify font define
    change f2\\froman Times New Roman to f2\\f<font supports character shown>
    such as (in china) f2\\f宋体. it's ok

    #define RTF_SKELTON _T("{\\rtf1\\unicode\\deff0\\deftab720{\\fonttbl{\\f0\\fswiss MS Sans Serif;}{\\f1\\froman\\fcharset2 Symbol;}{\\f2\\f宋体;}{\\f3\\fswiss Arial;}}{\\colortbl\\red0\\green0\\blue0;\\red0\\green0\\blue255;}\\deflang1033\\pard\\plain\\f2\\fs20 <@RAW@>}");

    Good luck!
    Thank you all!

  • Re - Scroll Fix

    Posted by Legacy on 04/14/2003 07:00am

    Originally posted by: Madhu B Nair

    Thank you Reptile, Thank you so much.

  • Scroll Fix

    Posted by Legacy on 04/13/2003 07:00am

    Originally posted by: Reptile

    There are small bugs in OnLButtonDown and OnMouseMove, which cause incorrect hyperlink detection, when rich edit window is scrolled. We should mention current scroll position, for example, in this way:

    Instead of



    CSize sOffset(GetScrollPos(SB_HORZ),

    if(IsPointInsideALink(point + sOffset,linkInfo))

  • CFM_LINK flag

    Posted by Legacy on 02/10/2003 08:00am

    Originally posted by: object

    There is CFM_LINK flag in CHARFORMAT2.
    If clicked, you receive EN_LINK notify.

  • wow great!!!

    Posted by Legacy on 01/30/2003 08:00am

    Originally posted by: sanjay siva

    it's really great to know that richedit is having such flexibility and i appreciate mr Madhu B Nair on his work.
    I have one doubt that is it possible to merge the functionality of a richedit and tree control? plz answer me.

  • Re-How to add a new line ...

    Posted by Legacy on 01/19/2003 08:00am

    Originally posted by: Madhu B Nair

    Dear Kien ,
    It is as simple as adding \n in printf. What you have to do is simply add
    \par just after the last word of line. The \par is a rtf directive for new
    line. The SetRawHyperText function allows you to add such rich edit magic to
    format the text content of COutLookRichEdit. For more information please
    visit " CAutoRichEditCtrl - automate rich edit formatting and RTF handling -
    Jeremy Iverson "

    Let us see how to add new line to following text -
    "Click here to continue
    and Click here to exit"

    "Click <%$here$#100#%> to continue\\par and Click <%$here$#101#%> to exit"

    I think this will help you. Feel free to contact me whenever you stuck with

  • How to add new line?

    Posted by Legacy on 01/14/2003 08:00am

    Originally posted by: Kien Bui


    Very interesting!!!
    Could you please tell me how can I add a new line using SetRawHyperText function?

    -Kien Bui

  • Good work, but you can use a CHtmlView

    Posted by Legacy on 12/30/2002 08:00am

    Originally posted by: JEFF ZHANG

    Since the main purpose is to highlight and redirect, a CHtmlView implented inside a dialog will be better. Besides RichEdit and HtmlView are all memory glutton.

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date