1 /////////////////////////////////////////////
\r
5 #include "richview.h"
\r
6 #include <richedit.h>
\r
9 CRichView::CRichView(void) : m_hInstRichEdit(NULL)
\r
11 // Changed from RichEdit v1.0 to RichEdit v2.0 for Unicode support!
\r
13 m_hInstRichEdit = ::LoadLibrary(_T("Riched20.dll")); // RichEdit ver 2.0
\r
14 if (!m_hInstRichEdit)
\r
16 ::MessageBox(NULL,_T("CRichView::CRichView Failed to load Riched20.dll"), _T(""), MB_ICONWARNING);
\r
20 CRichView::~CRichView(void)
\r
22 // Destroy the window before freeing the DLL
\r
25 // Now do remaining clean up
\r
26 if (m_hInstRichEdit)
\r
27 ::FreeLibrary(m_hInstRichEdit);
\r
30 void CRichView::PreCreate(CREATESTRUCT &cs)
\r
32 cs.style = ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_MULTILINE | WS_CHILD |
\r
33 WS_CLIPCHILDREN | WS_HSCROLL | WS_VISIBLE | WS_VSCROLL;
\r
35 cs.dwExStyle = WS_EX_CLIENTEDGE | WS_EX_ACCEPTFILES;
\r
36 cs.lpszClass = RICHEDIT_CLASS; // RichEdit ver 2.0
\r
39 void CRichView::OnInitialUpdate(void)
\r
41 //Before EM_LIMITTEXT is called, the default limit for the amount
\r
42 //of text a user can enter in an edit control is 32,767 characters
\r
43 //increase the text limit of the rich edit window
\r
44 SendMessage(EM_LIMITTEXT, (WPARAM)1.0e9, 0);
\r
46 //Determine which messages will be passed to the parent
\r
47 UINT uMask = ENM_KEYEVENTS | ENM_DROPFILES ;
\r
48 SendMessage(EM_SETEVENTMASK, 0, uMask);
\r
53 void CRichView::SetFontDefaults()
\r
56 if (!m_Font.GetHandle())
\r
57 m_Font.CreateFont(16, 0, 0, 0, FW_NORMAL, 0, 0, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS,
\r
58 CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_MODERN, _T("Courier New"));
\r
59 SetFont(&m_Font, FALSE);
\r
61 // Required for Dev-C++
\r
62 #ifndef IMF_AUTOFONT
\r
63 #define IMF_AUTOFONT 0x0002
\r
66 // Prevent Unicode characters from changing the font
\r
67 LRESULT lres = SendMessage(EM_GETLANGOPTIONS, 0, 0);
\r
68 lres &= ~IMF_AUTOFONT;
\r
69 SendMessage(EM_SETLANGOPTIONS, 0, lres);
\r