ReactOS 0.4.15-dev-7681-g776c3a3
crichedit.h
Go to the documentation of this file.
1#pragma once
2#include <ui/rosctrls.h>
3
4class CRichEdit : public CWindow
5{
7
8 VOID
9 GenericInsertText(LPCWSTR lpszText, SIZE_T InsertedTextLen, DWORD dwEffects)
10 {
13
14 if (InsertedTextLen)
15 {
16 /* Insert new text */
17 SetText.flags = ST_SELECTION;
18 SetText.codepage = 1200;
19
21
22 if ((dwEffects == CFM_LINK) && !PathIsURLW(lpszText))
23 {
24 // if text is not an URL, no styling is used
25 SetRangeFormatting(Len, Len + InsertedTextLen, 0);
26 }
27 else
28 {
29 SetRangeFormatting(Len, Len + InsertedTextLen, dwEffects);
30 }
31 }
32 }
33
34 public:
36 {
37 }
38
39 VOID
41 {
42 CHARFORMAT2W CharFormat;
43
45
46 ZeroMemory(&CharFormat, sizeof(CharFormat));
47
48 CharFormat.cbSize = sizeof(CharFormat);
49 CharFormat.dwMask = dwEffects;
50 CharFormat.dwEffects = dwEffects;
51
53
54 SendMessageW(EM_SETSEL, End, End + 1);
55 }
56
57 LONG
59 {
60 GETTEXTLENGTHEX TxtLenStruct;
61
62 TxtLenStruct.flags = GTL_NUMCHARS;
63 TxtLenStruct.codepage = 1200;
64
65 return (LONG)SendMessageW(EM_GETTEXTLENGTHEX, (WPARAM)&TxtLenStruct, 0);
66 }
67
68 /*
69 * Insert text (without cleaning old text)
70 * Supported effects:
71 * - CFM_BOLD
72 * - CFM_ITALIC
73 * - CFM_UNDERLINE
74 * - CFM_LINK
75 */
76 VOID
77 InsertText(LPCWSTR lpszText, DWORD dwEffects)
78 {
79 GenericInsertText(lpszText, wcslen(lpszText), dwEffects);
80 }
81
82 VOID
83 InsertText(const CStringW &szText, DWORD dwEffects)
84 {
85 GenericInsertText(szText.GetString(), szText.GetLength(), dwEffects);
86 }
87 /*
88 * Clear old text and add new
89 */
90 VOID
91 SetText(LPCWSTR lpszText, DWORD dwEffects)
92 {
94 InsertText(lpszText, dwEffects);
95 }
96
97 VOID
98 SetText(const CStringW &szText, DWORD dwEffects)
99 {
100 SetText(szText.GetString(), dwEffects);
101 }
102
103 HWND
105 {
106 m_LoadedLibrary = LoadLibraryW(L"riched20.dll");
107
108 m_hWnd = CreateWindowExW(
109 0, L"RichEdit20W", NULL, WS_CHILD | WS_VISIBLE | ES_MULTILINE | ES_LEFT | ES_READONLY, 205, 28, 465, 100,
110 hwndParent, NULL, _AtlBaseModule.GetModuleInstance(), NULL);
111
112 if (m_hWnd)
113 {
118 }
119
120 return m_hWnd;
121 }
122
123 virtual VOID
125 {
126 }
127
129 {
130 if (m_LoadedLibrary)
131 {
133 }
134 }
135};
LONG GetTextLen()
Definition: crichedit.h:58
CRichEdit()
Definition: crichedit.h:35
virtual VOID OnLink(ENLINK *Link)
Definition: crichedit.h:124
VOID SetText(const CStringW &szText, DWORD dwEffects)
Definition: crichedit.h:98
HWND Create(HWND hwndParent)
Definition: crichedit.h:104
~CRichEdit()
Definition: crichedit.h:128
VOID GenericInsertText(LPCWSTR lpszText, SIZE_T InsertedTextLen, DWORD dwEffects)
Definition: crichedit.h:9
VOID InsertText(const CStringW &szText, DWORD dwEffects)
Definition: crichedit.h:83
VOID InsertText(LPCWSTR lpszText, DWORD dwEffects)
Definition: crichedit.h:77
HMODULE m_LoadedLibrary
Definition: crichedit.h:6
VOID SetText(LPCWSTR lpszText, DWORD dwEffects)
Definition: crichedit.h:91
VOID SetRangeFormatting(SIZE_T Start, SIZE_T End, DWORD dwEffects)
Definition: crichedit.h:40
static HWND hwndParent
Definition: cryptui.c:300
#define Len
Definition: deflate.h:82
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FreeLibrary(x)
Definition: compat.h:748
#define LoadLibraryW(x)
Definition: compat.h:747
BOOL WINAPI PathIsURLW(LPCWSTR lpstrPath)
Definition: url.c:2432
unsigned long DWORD
Definition: ntddk_ex.h:95
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define L(x)
Definition: ntvdm.h:50
#define WS_CHILD
Definition: pedump.c:617
#define ES_READONLY
Definition: pedump.c:675
#define WS_VISIBLE
Definition: pedump.c:620
long LONG
Definition: pedump.c:60
#define ES_LEFT
Definition: pedump.c:664
#define ES_MULTILINE
Definition: pedump.c:667
#define SCF_WORD
Definition: richedit.h:236
#define ENM_LINK
Definition: richedit.h:485
#define ST_SELECTION
Definition: richedit.h:1072
#define EM_SETEVENTMASK
Definition: richedit.h:102
#define SCF_SELECTION
Definition: richedit.h:235
#define EM_SETBKGNDCOLOR
Definition: richedit.h:100
#define EM_SETTEXTEX
Definition: richedit.h:131
#define GTL_NUMCHARS
Definition: richedit.h:1058
#define EM_SETCHARFORMAT
Definition: richedit.h:101
#define EM_SHOWSCROLLBAR
Definition: richedit.h:130
#define CFM_LINK
Definition: richedit.h:337
#define EM_GETTEXTLENGTHEX
Definition: richedit.h:129
#define ENM_MOUSEEVENTS
Definition: richedit.h:476
DWORD dwMask
Definition: richedit.h:306
DWORD dwEffects
Definition: richedit.h:307
ULONG_PTR SIZE_T
Definition: typedefs.h:80
@ Start
Definition: partlist.h:33
static int Link(const char **args)
Definition: vfdcmd.c:2414
#define ZeroMemory
Definition: winbase.h:1712
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define DEFAULT_GUI_FONT
Definition: wingdi.h:909
DWORD WINAPI GetSysColor(_In_ int)
#define SB_VERT
Definition: winuser.h:553
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
#define WM_SETFONT
Definition: winuser.h:1649
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define EM_SETSEL
Definition: winuser.h:2017
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define COLOR_BTNFACE
Definition: winuser.h:927
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185