2547681771aaafcb4f81d50648eebe04e3206151
[matches/honours.git] / research / transmission_spectroscopy / TOF / Win32++ / samples / MDIFrameDemo / src / MDIChildText.cpp
1 //////////////////////////////////////////////\r
2 // MDIChildText.cpp\r
3 //  Definitions for the CMDIChildText class\r
4 \r
5 #include "stdafx.h"\r
6 #include "MDIChildText.h"\r
7 #include "resource.h"\r
8 \r
9 \r
10 CViewText::CViewText()\r
11 {\r
12         m_hRichEdit = ::LoadLibrary(_T("RICHED32.DLL"));\r
13     if (!m_hRichEdit)\r
14     {\r
15                 ::MessageBox(NULL,_T("CRichView::CRichView  Failed to load RICHED32.DLL"), _T(""), MB_ICONWARNING);\r
16     }\r
17 }\r
18 \r
19 CViewText::~CViewText()\r
20 {\r
21         // Cleanup\r
22         if (m_hRichEdit) ::FreeLibrary(m_hRichEdit);\r
23 }\r
24 \r
25 void CViewText::OnCreate()\r
26 {\r
27         //Set font\r
28         if (!m_Font)\r
29         {\r
30                 m_Font.CreateFont(16, 0, 0, 0, FW_DONTCARE, 0, 0, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS,\r
31                             CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_MODERN, _T("Courier New"));\r
32         }\r
33         \r
34         SendMessage(WM_SETFONT, (WPARAM)m_Font.GetHandle(), 0L);\r
35 }\r
36 \r
37 void CViewText::PreCreate(CREATESTRUCT &cs)\r
38 {\r
39         cs.lpszClass = _T("RichEdit");\r
40         cs.style = ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_MULTILINE | WS_CHILD | \r
41                                 WS_CLIPCHILDREN | WS_HSCROLL | WS_VISIBLE | WS_VSCROLL;\r
42 }\r
43 \r
44 \r
45 CMDIChildText::CMDIChildText()\r
46 {\r
47         HINSTANCE hResource = GetApp()->GetResourceHandle();\r
48         HMENU hChildMenu = LoadMenu(hResource, _T("MdiMenuText"));\r
49         SetHandles(hChildMenu, NULL);\r
50         SetView(m_TextView);\r
51 }\r
52 \r
53 CMDIChildText::~CMDIChildText()\r
54 {       \r
55 }\r
56 \r
57 BOOL CMDIChildText::OnCommand(WPARAM wParam, LPARAM lParam)\r
58 {\r
59         UNREFERENCED_PARAMETER(lParam);\r
60 \r
61         switch (LOWORD(wParam))\r
62         {\r
63         case IDM_EDIT_COPY:\r
64                 GetView()->SendMessage(WM_COPY, 0, 0);\r
65                 return TRUE;\r
66         case IDM_EDIT_PASTE:\r
67                 GetView()->SendMessage(WM_PASTE, 0, 0);\r
68                 return TRUE;\r
69         }\r
70 \r
71         return FALSE;\r
72 }\r
73 \r
74 \r
75 void CMDIChildText::OnCreate()\r
76 {\r
77         m_TextView.Create(this);\r
78 }\r
79 \r
80 void CMDIChildText::OnInitialUpdate()\r
81 {\r
82         SetWindowText(_T("Text Window"));\r
83         SetIconLarge(IDI_TEXT);\r
84         SetIconSmall(IDI_TEXT);\r
85 }\r
86 \r
87 LRESULT CMDIChildText::WndProc(UINT uMsg, WPARAM wParam, LPARAM lParam)\r
88 {\r
89         switch (uMsg)\r
90         {\r
91         case WM_SETFOCUS:\r
92                 m_TextView.SetFocus();\r
93                 break;\r
94         }\r
95 \r
96         // Do default processing for other messages\r
97         return WndProcDefault(uMsg, wParam, lParam);\r
98 }\r

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