RTF Static control

RTF Static control

This article was submitted .

This is yet another RTF based label control which understands a subset for HTML. This control interprets the subset known as mini html which are the basic text formatting tags of HTML.

The following tags are supported:

The bold text format.

Formats text in italics.

Prints underlined text.

<f x>
Change font typeface. Where x is a number from the following face name list:
  • 0 - Standard font
  • 1 - MS Sans Serif
  • 2 - Symbol
  • 3 - Arial
  • 4 - Times New Roman
<c x>
Change text colour Where x is a number from the following named color list:
  • 0 - Standard Control Text
  • 1 - Black
  • 2 - Red
  • 3 - Blue
<s x>
Change font size. Where x is the font-size.

Align left.

Align right.

Center alignment.

Of course you can add more font types and colours to your likening. Line breaks are still good old CR LF characters.

How to use it

Replace or add a RTF (RichEdit) control to the dialog. Make sure to remove the border styles in the dialog resource, and possibly to make it read-only.

Now add a member variable to your dialog implementation file...

  CSimpleHtmlCtrl m_ctrlHTML
In the OnInitDialog() event handler, add the following lines:
LRESULT OnInitDialog(UINT /*uMsg*/, 
                     WPARAM /*wParam*/, 
                     LPARAM /*lParam*/, 
                     BOOL& /*bHandled*/)
  m_ctrlHTML.SetWindowText("html stuff goes here...");

And do remember to initialise the RichEdit library properly in your application startup code.

int WINAPI _tWinMain(HINSTANCE hInstance, HIN...)
  HINSTANCE hInstRich = 
  int nRet = Run(lpstrCmdLine, nCmdShow);
  return 0;

Source Code Dependencies

Microsoft Visual C++ 6.0
Microsoft WTL 7.0 Library

See Also

A GDI based label control.

Download Files

DownloadSource Code (4 Kb)

To the top