Commit before breaking everything
[matches/honours.git] / research / transmission_spectroscopy / TOF / Win32++ / samples / Notepad / src / RichView.cpp
diff --git a/research/transmission_spectroscopy/TOF/Win32++/samples/Notepad/src/RichView.cpp b/research/transmission_spectroscopy/TOF/Win32++/samples/Notepad/src/RichView.cpp
new file mode 100644 (file)
index 0000000..7054e9e
--- /dev/null
@@ -0,0 +1,71 @@
+/////////////////////////////////////////////\r
+// RichView.cpp\r
+\r
+#include "stdafx.h"\r
+#include "richview.h"\r
+#include <richedit.h>\r
+\r
+\r
+CRichView::CRichView(void) : m_hInstRichEdit(NULL)\r
+{\r
+       // Changed from RichEdit v1.0 to RichEdit v2.0 for Unicode support!\r
+\r
+       m_hInstRichEdit = ::LoadLibrary(_T("Riched20.dll")); // RichEdit ver 2.0\r
+    if (!m_hInstRichEdit)\r
+    {\r
+               ::MessageBox(NULL,_T("CRichView::CRichView  Failed to load Riched20.dll"), _T(""), MB_ICONWARNING);\r
+    }\r
+}\r
+\r
+CRichView::~CRichView(void)\r
+{\r
+       // Destroy the window before freeing the DLL\r
+       Destroy();\r
+\r
+       // Now do remaining clean up\r
+       if (m_hInstRichEdit)\r
+               ::FreeLibrary(m_hInstRichEdit);\r
+}\r
+\r
+void CRichView::PreCreate(CREATESTRUCT &cs)\r
+{\r
+       cs.style = ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_MULTILINE | WS_CHILD |\r
+                               WS_CLIPCHILDREN | WS_HSCROLL | WS_VISIBLE | WS_VSCROLL;\r
+\r
+       cs.dwExStyle = WS_EX_CLIENTEDGE | WS_EX_ACCEPTFILES;\r
+       cs.lpszClass = RICHEDIT_CLASS; // RichEdit ver 2.0\r
+}\r
+\r
+void CRichView::OnInitialUpdate(void)\r
+{\r
+       //Before EM_LIMITTEXT is called, the default limit for the amount\r
+       //of text a user can enter in an edit control is 32,767 characters\r
+       //increase the text limit of the rich edit window\r
+       SendMessage(EM_LIMITTEXT, (WPARAM)1.0e9, 0);\r
+\r
+       //Determine which messages will be passed to the parent\r
+       UINT uMask = ENM_KEYEVENTS | ENM_DROPFILES ;\r
+       SendMessage(EM_SETEVENTMASK, 0, uMask);\r
+\r
+       SetFontDefaults();\r
+}\r
+\r
+void CRichView::SetFontDefaults()\r
+{\r
+       //Set font\r
+       if (!m_Font.GetHandle())\r
+               m_Font.CreateFont(16, 0, 0, 0, FW_NORMAL, 0, 0, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS,\r
+                           CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_MODERN, _T("Courier New"));\r
+       SetFont(&m_Font, FALSE);\r
+\r
+// Required for Dev-C++\r
+#ifndef IMF_AUTOFONT\r
+  #define IMF_AUTOFONT                 0x0002\r
+#endif\r
+\r
+       // Prevent Unicode characters from changing the font\r
+       LRESULT lres = SendMessage(EM_GETLANGOPTIONS, 0, 0);\r
+       lres &= ~IMF_AUTOFONT;\r
+       SendMessage(EM_SETLANGOPTIONS, 0, lres);\r
+}\r
+\r

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