[RAPPS] Incorrect "C" symbol replaced in the rest of the files
[reactos.git] / reactos / base / applications / rapps / crichedit.h
1 #pragma once
2
3 class CRichEdit :
4 public CWindow
5 {
6 HMODULE LoadedLibrary;
7 inline VOID GenericInsertText(LPCWSTR lpszText, LONG InsertedTextLen, DWORD dwEffects)
8 {
9 SETTEXTEX SetText;
10 LONG Len = GetTextLen();
11
12 if (InsertedTextLen)
13 {
14 /* Insert new text */
15 SetText.flags = ST_SELECTION;
16 SetText.codepage = 1200;
17
18 SendMessageW(EM_SETTEXTEX, (WPARAM) &SetText, (LPARAM) lpszText);
19
20 SetRangeFormatting(Len, Len + InsertedTextLen,
21 (dwEffects == CFM_LINK) ? (PathIsURLW(lpszText) ? dwEffects : 0) : dwEffects);
22 }
23 }
24
25 public:
26 VOID SetRangeFormatting(LONG Start, LONG End, DWORD dwEffects)
27 {
28 CHARFORMAT2W CharFormat;
29
30 SendMessageW(EM_SETSEL, Start, End);
31
32 ZeroMemory(&CharFormat, sizeof(CharFormat));
33
34 CharFormat.cbSize = sizeof(CharFormat);
35 CharFormat.dwMask = dwEffects;
36 CharFormat.dwEffects = dwEffects;
37
38 SendMessageW(EM_SETCHARFORMAT, SCF_WORD | SCF_SELECTION, (LPARAM) &CharFormat);
39
40 SendMessageW(EM_SETSEL, End, End + 1);
41 }
42
43 LONG GetTextLen(VOID)
44 {
45 GETTEXTLENGTHEX TxtLenStruct;
46
47 TxtLenStruct.flags = GTL_NUMCHARS;
48 TxtLenStruct.codepage = 1200;
49
50 return (LONG) SendMessageW(EM_GETTEXTLENGTHEX, (WPARAM) &TxtLenStruct, 0);
51 }
52
53 /*
54 * Insert text (without cleaning old text)
55 * Supported effects:
56 * - CFM_BOLD
57 * - CFM_ITALIC
58 * - CFM_UNDERLINE
59 * - CFM_LINK
60 */
61 VOID InsertText(LPCWSTR lpszText, DWORD dwEffects)
62 {
63 GenericInsertText(lpszText, wcslen(lpszText), dwEffects);
64 }
65
66 VOID InsertText(const ATL::CStringW& szText, DWORD dwEffects)
67 {
68 GenericInsertText(szText.GetString(), szText.GetLength(), dwEffects);
69 }
70 /*
71 * Clear old text and add new
72 */
73 VOID SetText(LPCWSTR lpszText, DWORD dwEffects)
74 {
75 SetWindowTextW(L"");
76 InsertText(lpszText, dwEffects);
77 }
78
79 VOID SetText(const ATL::CStringW& szText, DWORD dwEffects)
80 {
81 SetText(szText.GetString(), dwEffects);
82 }
83
84 HWND Create(HWND hwndParent)
85 {
86 LoadedLibrary = LoadLibraryW(L"riched20.dll");
87
88 m_hWnd = CreateWindowExW(0,
89 L"RichEdit20W",
90 NULL,
91 WS_CHILD | WS_VISIBLE | ES_MULTILINE |
92 ES_LEFT | ES_READONLY,
93 205, 28, 465, 100,
94 hwndParent,
95 NULL,
96 _AtlBaseModule.GetModuleInstance(),
97 NULL);
98
99 if (m_hWnd)
100 {
101 SendMessageW(EM_SETBKGNDCOLOR, 0, GetSysColor(COLOR_BTNFACE));
102 SendMessageW(WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
103 SendMessageW(EM_SETEVENTMASK, 0, ENM_LINK | ENM_MOUSEEVENTS);
104 SendMessageW(EM_SHOWSCROLLBAR, SB_VERT, TRUE);
105 }
106
107 return m_hWnd;
108 }
109
110 virtual VOID OnLink(ENLINK *Link)
111 {
112 }
113
114 ~CRichEdit()
115 {
116 FreeLibrary(LoadedLibrary);
117 }
118
119 };