-
-
Notifications
You must be signed in to change notification settings - Fork 215
/
ConvertRTFToText.cpp
56 lines (42 loc) · 1.21 KB
/
ConvertRTFToText.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "stdafx.h"
#include "ConvertRTFToText.h"
#include "Shared/TextConvert.h"
BOOL CConvertRTFToText::Create()
{
// Get the class name and create the window
CString szClassName = AfxRegisterWndClass(CS_CLASSDC | CS_SAVEBITS, LoadCursor(NULL, IDC_ARROW));
// Create the window - just don't show it yet.
if (!CWnd::CreateEx(WS_EX_NOACTIVATE, szClassName, _T(""), WS_POPUP,0, 0, 0, 0, NULL, 0, NULL))
{
return FALSE;
}
m_richEditTextConverter.Create(_T(""), _T(""), WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_NOHIDESEL | ES_AUTOHSCROLL, CRect(10, 10, 100, 200), this, 1);
return TRUE;
}
CString CConvertRTFToText::GetTextFromRTF(CStringA rtf)
{
m_richEditTextConverter.SetRTF(rtf);
auto x = m_richEditTextConverter.GetRTF();
int loops = 0;
MSG msg;
while (::PeekMessage(&msg, m_hWnd, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
loops++;
if (loops > 100)
break;
}
loops = 0;
while (::PeekMessage(&msg, m_richEditTextConverter.m_hWnd, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
loops++;
if (loops > 100)
break;
}
Sleep(50);
CString text = m_richEditTextConverter.GetText();
return text;
}