MCPcopy Create free account
hub / github.com/Apress/design-patterns-in-modern-cpp / OnPaint

Method OnPaint

Structural/AdapterVisual/AdapterVisualDlg.cpp:225–258  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

223// this is automatically done for you by the framework.
224
225void CAdapterVisualDlg::OnPaint()
226{
227 CPaintDC dc(this); // device context for painting
228
229 if (IsIconic())
230 {
231 SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
232
233 // Center icon in client rectangle
234 int cxIcon = GetSystemMetrics(SM_CXICON);
235 int cyIcon = GetSystemMetrics(SM_CYICON);
236 CRect rect;
237 GetClientRect(&rect);
238 int x = (rect.Width() - cxIcon + 1) / 2;
239 int y = (rect.Height() - cyIcon + 1) / 2;
240
241 // Draw the icon
242 dc.DrawIcon(x, y, m_hIcon);
243 }
244 else
245 {
246 for (auto& o : vectorObjects)
247 {
248 for (auto& l : *o)
249 {
250 LineToPointCachingAdapter lpo{ l };
251 DrawPoints(dc, lpo.begin(), lpo.end());
252 }
253 }
254
255 CDialogEx::OnPaint();
256 }
257
258}
259
260// The system calls this function to obtain the cursor to display while the user drags
261// the minimized window.

Callers

nothing calls this directly

Calls 2

beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected