Merge branch 'master' of git.ucc.asn.au:/matches/honours
[matches/honours.git] / research / transmission_spectroscopy / TOF / Win32++ / samples / Notepad / src / RichView.cpp
1 /////////////////////////////////////////////\r
2 // RichView.cpp\r
3 \r
4 #include "stdafx.h"\r
5 #include "richview.h"\r
6 #include <richedit.h>\r
7 \r
8 \r
9 CRichView::CRichView(void) : m_hInstRichEdit(NULL)\r
10 {\r
11         // Changed from RichEdit v1.0 to RichEdit v2.0 for Unicode support!\r
12 \r
13         m_hInstRichEdit = ::LoadLibrary(_T("Riched20.dll")); // RichEdit ver 2.0\r
14     if (!m_hInstRichEdit)\r
15     {\r
16                 ::MessageBox(NULL,_T("CRichView::CRichView  Failed to load Riched20.dll"), _T(""), MB_ICONWARNING);\r
17     }\r
18 }\r
19 \r
20 CRichView::~CRichView(void)\r
21 {\r
22         // Destroy the window before freeing the DLL\r
23         Destroy();\r
24 \r
25         // Now do remaining clean up\r
26         if (m_hInstRichEdit)\r
27                 ::FreeLibrary(m_hInstRichEdit);\r
28 }\r
29 \r
30 void CRichView::PreCreate(CREATESTRUCT &cs)\r
31 {\r
32         cs.style = ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_MULTILINE | WS_CHILD |\r
33                                 WS_CLIPCHILDREN | WS_HSCROLL | WS_VISIBLE | WS_VSCROLL;\r
34 \r
35         cs.dwExStyle = WS_EX_CLIENTEDGE | WS_EX_ACCEPTFILES;\r
36         cs.lpszClass = RICHEDIT_CLASS; // RichEdit ver 2.0\r
37 }\r
38 \r
39 void CRichView::OnInitialUpdate(void)\r
40 {\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
45 \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
49 \r
50         SetFontDefaults();\r
51 }\r
52 \r
53 void CRichView::SetFontDefaults()\r
54 {\r
55         //Set font\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
60 \r
61 // Required for Dev-C++\r
62 #ifndef IMF_AUTOFONT\r
63   #define IMF_AUTOFONT                  0x0002\r
64 #endif\r
65 \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
70 }\r
71 \r

UCC git Repository :: git.ucc.asn.au