7 inline VOID
GenericInsertText(LPCWSTR lpszText
, LONG InsertedTextLen
, DWORD dwEffects
)
10 LONG Len
= GetTextLen();
13 SetText
.flags
= ST_SELECTION
;
14 SetText
.codepage
= 1200;
16 SendMessageW(EM_SETTEXTEX
, (WPARAM
) &SetText
, (LPARAM
) lpszText
);
18 SetRangeFormatting(Len
, Len
+ InsertedTextLen
,
19 (dwEffects
== CFM_LINK
) ? (PathIsURLW(lpszText
) ? dwEffects
: 0) : dwEffects
);
23 VOID
SetRangeFormatting(LONG Start
, LONG End
, DWORD dwEffects
)
25 CHARFORMAT2W CharFormat
;
27 SendMessageW(EM_SETSEL
, Start
, End
);
29 ZeroMemory(&CharFormat
, sizeof(CharFormat
));
31 CharFormat
.cbSize
= sizeof(CharFormat
);
32 CharFormat
.dwMask
= dwEffects
;
33 CharFormat
.dwEffects
= dwEffects
;
35 SendMessageW(EM_SETCHARFORMAT
, SCF_WORD
| SCF_SELECTION
, (LPARAM
) &CharFormat
);
37 SendMessageW(EM_SETSEL
, End
, End
+ 1);
42 GETTEXTLENGTHEX TxtLenStruct
;
44 TxtLenStruct
.flags
= GTL_NUMCHARS
;
45 TxtLenStruct
.codepage
= 1200;
47 return (LONG
) SendMessageW(EM_GETTEXTLENGTHEX
, (WPARAM
) &TxtLenStruct
, 0);
51 * Insert text (without cleaning old text)
58 VOID
InsertText(LPCWSTR lpszText
, DWORD dwEffects
)
60 GenericInsertText(lpszText
, wcslen(lpszText
), dwEffects
);
63 VOID
InsertText(const ATL::CStringW
& szText
, DWORD dwEffects
)
65 GenericInsertText(szText
.GetString(), szText
.GetLength(), dwEffects
);
68 * Clear old text and add new
70 VOID
SetText(LPCWSTR lpszText
, DWORD dwEffects
)
73 InsertText(lpszText
, dwEffects
);
76 VOID
SetText(const ATL::CStringW
& szText
, DWORD dwEffects
)
78 SetText(szText
.GetString(), dwEffects
);
81 HWND
Create(HWND hwndParent
)
83 // TODO: FreeLibrary when the window is destroyed
84 LoadedLibrary
= LoadLibraryW(L
"riched20.dll");
86 m_hWnd
= CreateWindowExW(0,
89 WS_CHILD
| WS_VISIBLE
| ES_MULTILINE
|
90 ES_LEFT
| ES_READONLY
,
94 _AtlBaseModule
.GetModuleInstance(),
99 SendMessageW(EM_SETBKGNDCOLOR
, 0, GetSysColor(COLOR_BTNFACE
));
100 SendMessageW(WM_SETFONT
, (WPARAM
) GetStockObject(DEFAULT_GUI_FONT
), 0);
101 SendMessageW(EM_SETEVENTMASK
, 0, ENM_LINK
| ENM_MOUSEEVENTS
);
102 SendMessageW(EM_SHOWSCROLLBAR
, SB_VERT
, TRUE
);
108 virtual VOID
OnLink(ENLINK
*Link
)
114 FreeLibrary(LoadedLibrary
);