OSDN Git Service

28038ac9d0b6c32555de8a720197844d6618b0a2
[tombo/Tombo.git] / CppUnitTestApp / CppUnitTestAppDlg.cpp
1 // CppUnitTestAppDlg.cpp : implementation file\r
2 //\r
3 \r
4 #include "stdafx.h"\r
5 #include "CppUnitTestApp.h"\r
6 #include "CppUnitTestAppDlg.h"\r
7 \r
8 #ifdef _DEBUG\r
9 #define new DEBUG_NEW\r
10 #undef THIS_FILE\r
11 static char THIS_FILE[] = __FILE__;\r
12 #endif\r
13 \r
14 /////////////////////////////////////////////////////////////////////////////\r
15 // CAboutDlg dialog used for App About\r
16 \r
17 class CAboutDlg : public CDialog\r
18 {\r
19 public:\r
20         CAboutDlg();\r
21 \r
22 // Dialog Data\r
23         //{{AFX_DATA(CAboutDlg)\r
24         enum { IDD = IDD_ABOUTBOX };\r
25         //}}AFX_DATA\r
26 \r
27         // ClassWizard generated virtual function overrides\r
28         //{{AFX_VIRTUAL(CAboutDlg)\r
29         protected:\r
30         virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\r
31         //}}AFX_VIRTUAL\r
32 \r
33 // Implementation\r
34 protected:\r
35         //{{AFX_MSG(CAboutDlg)\r
36         //}}AFX_MSG\r
37         DECLARE_MESSAGE_MAP()\r
38 };\r
39 \r
40 CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)\r
41 {\r
42         //{{AFX_DATA_INIT(CAboutDlg)\r
43         //}}AFX_DATA_INIT\r
44 }\r
45 \r
46 void CAboutDlg::DoDataExchange(CDataExchange* pDX)\r
47 {\r
48         CDialog::DoDataExchange(pDX);\r
49         //{{AFX_DATA_MAP(CAboutDlg)\r
50         //}}AFX_DATA_MAP\r
51 }\r
52 \r
53 BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)\r
54         //{{AFX_MSG_MAP(CAboutDlg)\r
55                 // No message handlers\r
56         //}}AFX_MSG_MAP\r
57 END_MESSAGE_MAP()\r
58 \r
59 /////////////////////////////////////////////////////////////////////////////\r
60 // CppUnitTestAppDlg dialog\r
61 \r
62 CppUnitTestAppDlg::CppUnitTestAppDlg(CWnd* pParent /*=NULL*/)\r
63         : CDialog(CppUnitTestAppDlg::IDD, pParent)\r
64 {\r
65         //{{AFX_DATA_INIT(CppUnitTestAppDlg)\r
66                 // NOTE: the ClassWizard will add member initialization here\r
67         //}}AFX_DATA_INIT\r
68         // Note that LoadIcon does not require a subsequent DestroyIcon in Win32\r
69         m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);\r
70 }\r
71 \r
72 void CppUnitTestAppDlg::DoDataExchange(CDataExchange* pDX)\r
73 {\r
74         CDialog::DoDataExchange(pDX);\r
75         //{{AFX_DATA_MAP(CppUnitTestAppDlg)\r
76                 // NOTE: the ClassWizard will add DDX and DDV calls here\r
77         //}}AFX_DATA_MAP\r
78 }\r
79 \r
80 BEGIN_MESSAGE_MAP(CppUnitTestAppDlg, CDialog)\r
81         //{{AFX_MSG_MAP(CppUnitTestAppDlg)\r
82         ON_WM_SYSCOMMAND()\r
83         ON_WM_PAINT()\r
84         ON_WM_QUERYDRAGICON()\r
85         //}}AFX_MSG_MAP\r
86 END_MESSAGE_MAP()\r
87 \r
88 /////////////////////////////////////////////////////////////////////////////\r
89 // CppUnitTestAppDlg message handlers\r
90 \r
91 BOOL CppUnitTestAppDlg::OnInitDialog()\r
92 {\r
93         CDialog::OnInitDialog();\r
94 \r
95         // Add "About..." menu item to system menu.\r
96 \r
97         // IDM_ABOUTBOX must be in the system command range.\r
98         ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);\r
99         ASSERT(IDM_ABOUTBOX < 0xF000);\r
100 \r
101         CMenu* pSysMenu = GetSystemMenu(FALSE);\r
102         if (pSysMenu != NULL)\r
103         {\r
104                 CString strAboutMenu;\r
105                 strAboutMenu.LoadString(IDS_ABOUTBOX);\r
106                 if (!strAboutMenu.IsEmpty())\r
107                 {\r
108                         pSysMenu->AppendMenu(MF_SEPARATOR);\r
109                         pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);\r
110                 }\r
111         }\r
112 \r
113         // Set the icon for this dialog.  The framework does this automatically\r
114         //  when the application's main window is not a dialog\r
115         SetIcon(m_hIcon, TRUE);                 // Set big icon\r
116         SetIcon(m_hIcon, FALSE);                // Set small icon\r
117         \r
118         // TODO: Add extra initialization here\r
119         \r
120         return TRUE;  // return TRUE  unless you set the focus to a control\r
121 }\r
122 \r
123 void CppUnitTestAppDlg::OnSysCommand(UINT nID, LPARAM lParam)\r
124 {\r
125         if ((nID & 0xFFF0) == IDM_ABOUTBOX)\r
126         {\r
127                 CAboutDlg dlgAbout;\r
128                 dlgAbout.DoModal();\r
129         }\r
130         else\r
131         {\r
132                 CDialog::OnSysCommand(nID, lParam);\r
133         }\r
134 }\r
135 \r
136 // If you add a minimize button to your dialog, you will need the code below\r
137 //  to draw the icon.  For MFC applications using the document/view model,\r
138 //  this is automatically done for you by the framework.\r
139 \r
140 void CppUnitTestAppDlg::OnPaint() \r
141 {\r
142         if (IsIconic())\r
143         {\r
144                 CPaintDC dc(this); // device context for painting\r
145 \r
146                 SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);\r
147 \r
148                 // Center icon in client rectangle\r
149                 int cxIcon = GetSystemMetrics(SM_CXICON);\r
150                 int cyIcon = GetSystemMetrics(SM_CYICON);\r
151                 CRect rect;\r
152                 GetClientRect(&rect);\r
153                 int x = (rect.Width() - cxIcon + 1) / 2;\r
154                 int y = (rect.Height() - cyIcon + 1) / 2;\r
155 \r
156                 // Draw the icon\r
157                 dc.DrawIcon(x, y, m_hIcon);\r
158         }\r
159         else\r
160         {\r
161                 CDialog::OnPaint();\r
162         }\r
163 }\r
164 \r
165 // The system calls this to obtain the cursor to display while the user drags\r
166 //  the minimized window.\r
167 HCURSOR CppUnitTestAppDlg::OnQueryDragIcon()\r
168 {\r
169         return (HCURSOR) m_hIcon;\r
170 }\r