The following tags are supported:
<B>...</B>
The bold text format.
<I>...</I>
Formats text in italics.
<U>...</U>
Prints underlined text.
<f x>
Change font typeface. Where x is a number from the following face name list:
Change text colour Where x is a number from the following named color list:
Change font size. Where x is the font-size.
<al>
Align left.
<ar>
Align right.
<ac>
Center alignment.
The bold text format.
<I>...</I>
Formats text in italics.
<U>...</U>
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
Change text colour Where x is a number from the following named color list:
- 0 - Standard Control Text
- 1 - Black
- 2 - Red
- 3 - Blue
Change font size. Where x is the font-size.
<al>
Align left.
<ar>
Align right.
<ac>
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.SubclassWindow(GetDlgItem(IDC_RICHEDIT1));
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...)
{
...
::InitCommonControls();
HINSTANCE hInstRich =
::LoadLibrary(CRichEditCtrl::GetLibraryName());
...
int nRet = Run(lpstrCmdLine, nCmdShow);
...
::FreeLibrary(hInstRich);
...
return 0;
}
Source Code Dependencies
Microsoft Visual C++ 6.0Microsoft WTL 7.0 Library
See Also
A GDI based label control.Download Files
![]() | Source Code (4 Kb) |