@@ -35,6 +35,8 @@ BEGIN_MESSAGE_MAP(CProcessWnd, CBaseWnd)
35
35
ON_BN_CLICKED(IDC_PROCESSWND_COPYALL, OnCopyAll)
36
36
ON_WM_TIMER()
37
37
ON_WM_CREATE()
38
+ ON_WM_DESTROY()
39
+ ON_MESSAGE(WM_DPICHANGED, OnDpiChanged)
38
40
ON_WM_SIZE()
39
41
// }}AFX_MSG_MAP
40
42
END_MESSAGE_MAP()
@@ -222,22 +224,40 @@ int CProcessWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
222
224
223
225
CRect rctEdit;
224
226
rctEdit = rctClient;
225
- rctEdit.bottom = rctClient.bottom - 20 ;
227
+ rctEdit.bottom = rctClient.bottom - m_dpi_behavior. ScaleOnY ( 20 ) ;
226
228
227
229
Edit.Create (WS_CHILD | WS_BORDER | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN, rctClient, this , IDC_PROCESSWND_EDIT);
228
230
Edit.SetReadOnly (TRUE );
229
231
Edit.SetFont (&Font);
232
+ m_edit_dpi_behavior.OnCreateWindow (Edit.GetSafeHwnd ());
230
233
231
234
CRect rctButton;
232
235
rctButton = rctClient;
233
- rctButton.top = rctClient.bottom - 20 ;
236
+ rctButton.top = rctClient.bottom - m_dpi_behavior. ScaleOnY ( 20 ) ;
234
237
235
238
m_btnCopyAll.Create (" Copy to Clipboard" , WS_CHILD | WS_VISIBLE, rctButton, this , IDC_PROCESSWND_COPYALL);
236
239
m_btnCopyAll.SetButtonStyle (BS_PUSHBUTTON);
240
+ m_edit_dpi_behavior.OnCreateWindow (m_btnCopyAll.GetSafeHwnd ());
237
241
238
242
return 0 ;
239
243
}
240
244
245
+ void CProcessWnd::OnDestroy ()
246
+ {
247
+ m_copy_all_dpi_behavior.OnDestroyWindow ();
248
+ m_edit_dpi_behavior.OnDestroyWindow ();
249
+
250
+ __super::OnDestroy ();
251
+ }
252
+
253
+ LRESULT CProcessWnd::OnDpiChanged (WPARAM wParam, LPARAM lParam)
254
+ {
255
+ m_edit_dpi_behavior.OnWindowDpiChanged (wParam, lParam);
256
+ m_copy_all_dpi_behavior.OnWindowDpiChanged (wParam, lParam);
257
+
258
+ return __super::OnDpiChanged (wParam, lParam);
259
+ }
260
+
241
261
void CProcessWnd::OnSize (UINT nType, int cx, int cy)
242
262
{
243
263
__super::OnSize (nType, cx, cy);
@@ -248,12 +268,12 @@ void CProcessWnd::OnSize(UINT nType, int cx, int cy)
248
268
249
269
CRect rctEdit;
250
270
rctEdit = rctClient;
251
- rctEdit.bottom = rctClient.bottom - 20 ;
271
+ rctEdit.bottom = rctClient.bottom - m_dpi_behavior. ScaleOnY ( 20 ) ;
252
272
Edit.MoveWindow (rctEdit);
253
273
254
274
CRect rctButton;
255
275
rctButton = rctClient;
256
- rctButton.top = rctClient.bottom - 20 ;
276
+ rctButton.top = rctClient.bottom - m_dpi_behavior. ScaleOnY ( 20 ) ;
257
277
m_btnCopyAll.MoveWindow (rctButton);
258
278
}
259
279
@@ -262,15 +282,23 @@ void CProcessWnd::OnSize(UINT nType, int cx, int cy)
262
282
// Purpose: Prepare the process window for display. If it has not been created
263
283
// yet, register the class and create it.
264
284
// -----------------------------------------------------------------------------
265
- void CProcessWnd::GetReady (LPCTSTR pszDocName)
285
+ void CProcessWnd::GetReady (LPCTSTR pszDocName, CWnd *parent )
266
286
{
267
287
if (!IsWindow (m_hWnd))
268
288
{
269
289
CString strClass = AfxRegisterWndClass (0 , AfxGetApp ()->LoadStandardCursor (IDC_ARROW), HBRUSH (GetStockObject (WHITE_BRUSH)));
270
290
CString title;
271
291
// dimhotepus: Add compiling map name to title.
272
292
title.Format (" Compile - [%s]" , pszDocName);
273
- CreateEx (0 , strClass, title.GetString (), WS_OVERLAPPEDWINDOW, 50 , 50 , 600 , 400 , AfxGetMainWnd ()->GetSafeHwnd (), nullptr );
293
+
294
+ unsigned newDpi = ::GetDpiForWindow (parent->GetSafeHwnd ());
295
+
296
+ CreateEx (0 , strClass, title.GetString (), WS_OVERLAPPEDWINDOW,
297
+ se::windows::ui::CDpiWindowBehavior::ScaleByDpi (USER_DEFAULT_SCREEN_DPI, 50 , newDpi),
298
+ se::windows::ui::CDpiWindowBehavior::ScaleByDpi (USER_DEFAULT_SCREEN_DPI, 50 , newDpi),
299
+ se::windows::ui::CDpiWindowBehavior::ScaleByDpi (USER_DEFAULT_SCREEN_DPI, 800 , newDpi),
300
+ se::windows::ui::CDpiWindowBehavior::ScaleByDpi (USER_DEFAULT_SCREEN_DPI, 600 , newDpi),
301
+ AfxGetMainWnd ()->GetSafeHwnd (), nullptr );
274
302
}
275
303
276
304
ShowWindow (SW_SHOW);
0 commit comments