Adding a permanent margin to a Memo
or RichEdit
Windows
allows the formatting of the visible and editable area of an Edit or RichEdit control by using the EM_SETRECT message. SImply send the edit control this message, specifying the
formatting rectangle as the long parameter (LParam).
The main pitfall here is that the EM_SETRECT message only works if the Memo or RichEdit is already visible. As such, sending the
message in the functions such as CreateWnd() method won't work. What you want to do is set the
gutter the first time the Memo or RichEdit is
painted, and in response to the CreateWnd() method (since the handle has changed). The CreateWnd()
method response is necessary since the handle of the Memo or RichEdit is destroyed then recreated when certain
Properties are changed. The example below demonstrates creating a RichEdit component with a left offset.
KEYWORDS: EM_GETRECT, EM_SETRECT, CreateWnd
|