#include <richedit.h>
...
void CreateRichText(HWND hwndParent)
{
RECT rcClient;
GetClientRect(hwndParent, &rcClient);
//-- RichEdit dll laden
LoadLibrary("riched32.dll");
//-- Steuerelement erzeugen
hEdit = CreateWindowEx(WS_EX_CLIENTEDGE,
"RichEdit",
"",
WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_MULTILINE |ES_AUTOVSCROLL|ES_NOHIDESEL|ES_READONLY,
0,
0,
rcClient.right,
rcClient.bottom,
hwndParent,
(HMENU) IDC_EDIT,
hInst,
NULL);
//-- formatieren Text einfügen
CHARFORMAT cf = {0};
cf.cbSize = sizeof(CHARFORMAT);
cf.dwMask = CFM_COLOR | CFM_FACE | CFM_SIZE | CFM_BOLD;
cf.crTextColor = RGB(255,0,0);
cf.dwEffects = 0L;
cf.yHeight = 180;
strcpy(cf.szFaceName, "Arial");
SendMessage(hEdit, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
SendMessage(hEdit, EM_REPLACESEL, (WPARAM)0, (LPARAM)"Hallo! Dies ist ein Richtext-Steuerelement"); |