XRichEdit
XRichEdit is a sample MFC control derived from CRichEditCtrl that shows how to implement a gutter with line numbers:

XRichEdit API
Here are the CXRichEdit methods:
void SetGutterBackgroundColor(COLORREF cr)
void SetGutterTextColor(COLORREF cr)
void SetGutterWidth(int nWidth)
void SetMargins(UINT nLeft, UINT nRight)
How To Use
To integrate XRichEdit into your app, you first need to add following files to your project:
- XRichEdit.cpp
- XRichEdit.h
- MemDC.cpp
Then use the resource editor to add a rich edit control to your dialog, and use Class Wizard to attach a member variable to that control.
Next, include the header file XRichEdit.h in
the dialog's header file. Then replace
the CRichEditCtrl definition with CXRichEdit.
Now you are ready to start using XRichEdit.
Setting the Gutter Width
You can set the gutter width directly using pixel measurement with
void SetMargins(UINT nLeft, UINT nRight)
or you can specify the width in terms of characters with
void SetGutterWidth(int nWidth)
You can use either method when setting up the rich edit control,
or you can use them afterwards, if you need to alter the gutter width.
Revision History
Version 1.0
- Initial public release.