Skip to content

Commit c835031

Browse files
committed
hammer: Scale map compile window and fix computing tools paths for it
1 parent cf0cf06 commit c835031

File tree

5 files changed

+48
-15
lines changed

5 files changed

+48
-15
lines changed

hammer/mapdoc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5868,7 +5868,7 @@ void CMapDoc::OnFileRunmap(void)
58685868
else if (dlgExpert.m_pActiveSequence) // clicked ok
58695869
{
58705870
// run the commands in the active sequence
5871-
RunCommands(dlgExpert.m_pActiveSequence->m_Commands, strFile);
5871+
RunCommands(dlgExpert.m_pActiveSequence->m_Commands, strFile, AfxGetApp()->GetMainWnd());
58725872
return;
58735873
}
58745874
else
@@ -5959,7 +5959,7 @@ void CMapDoc::OnFileRunmap(void)
59595959
cmds.Add(cmd);
59605960
}
59615961

5962-
RunCommands(cmds, GetPathName());
5962+
RunCommands(cmds, GetPathName(), AfxGetApp()->GetMainWnd());
59635963
}
59645964

59655965

hammer/processwnd.cpp

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ BEGIN_MESSAGE_MAP(CProcessWnd, CBaseWnd)
3535
ON_BN_CLICKED(IDC_PROCESSWND_COPYALL, OnCopyAll)
3636
ON_WM_TIMER()
3737
ON_WM_CREATE()
38+
ON_WM_DESTROY()
39+
ON_MESSAGE(WM_DPICHANGED, OnDpiChanged)
3840
ON_WM_SIZE()
3941
//}}AFX_MSG_MAP
4042
END_MESSAGE_MAP()
@@ -222,22 +224,40 @@ int CProcessWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
222224

223225
CRect rctEdit;
224226
rctEdit = rctClient;
225-
rctEdit.bottom = rctClient.bottom - 20;
227+
rctEdit.bottom = rctClient.bottom - m_dpi_behavior.ScaleOnY(20);
226228

227229
Edit.Create(WS_CHILD | WS_BORDER | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN, rctClient, this, IDC_PROCESSWND_EDIT);
228230
Edit.SetReadOnly(TRUE);
229231
Edit.SetFont(&Font);
232+
m_edit_dpi_behavior.OnCreateWindow(Edit.GetSafeHwnd());
230233

231234
CRect rctButton;
232235
rctButton = rctClient;
233-
rctButton.top = rctClient.bottom - 20;
236+
rctButton.top = rctClient.bottom - m_dpi_behavior.ScaleOnY(20);
234237

235238
m_btnCopyAll.Create("Copy to Clipboard", WS_CHILD | WS_VISIBLE, rctButton, this, IDC_PROCESSWND_COPYALL);
236239
m_btnCopyAll.SetButtonStyle(BS_PUSHBUTTON);
240+
m_edit_dpi_behavior.OnCreateWindow(m_btnCopyAll.GetSafeHwnd());
237241

238242
return 0;
239243
}
240244

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+
241261
void CProcessWnd::OnSize(UINT nType, int cx, int cy)
242262
{
243263
__super::OnSize(nType, cx, cy);
@@ -248,12 +268,12 @@ void CProcessWnd::OnSize(UINT nType, int cx, int cy)
248268

249269
CRect rctEdit;
250270
rctEdit = rctClient;
251-
rctEdit.bottom = rctClient.bottom - 20;
271+
rctEdit.bottom = rctClient.bottom - m_dpi_behavior.ScaleOnY(20);
252272
Edit.MoveWindow(rctEdit);
253273

254274
CRect rctButton;
255275
rctButton = rctClient;
256-
rctButton.top = rctClient.bottom - 20;
276+
rctButton.top = rctClient.bottom - m_dpi_behavior.ScaleOnY(20);
257277
m_btnCopyAll.MoveWindow(rctButton);
258278
}
259279

@@ -262,15 +282,23 @@ void CProcessWnd::OnSize(UINT nType, int cx, int cy)
262282
// Purpose: Prepare the process window for display. If it has not been created
263283
// yet, register the class and create it.
264284
//-----------------------------------------------------------------------------
265-
void CProcessWnd::GetReady(LPCTSTR pszDocName)
285+
void CProcessWnd::GetReady(LPCTSTR pszDocName, CWnd *parent)
266286
{
267287
if (!IsWindow(m_hWnd))
268288
{
269289
CString strClass = AfxRegisterWndClass(0, AfxGetApp()->LoadStandardCursor(IDC_ARROW), HBRUSH(GetStockObject(WHITE_BRUSH)));
270290
CString title;
271291
// dimhotepus: Add compiling map name to title.
272292
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);
274302
}
275303

276304
ShowWindow(SW_SHOW);

hammer/processwnd.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ class CProcessWnd : public CBaseWnd
3434

3535
void Clear();
3636
void Append(CString str);
37-
void GetReady();
38-
void GetReady(LPCTSTR pszDocName);
37+
void GetReady(LPCTSTR pszDocName, CWnd *parent);
3938

4039
// Overrides
4140
// ClassWizard generated virtual function overrides
@@ -53,10 +52,16 @@ class CProcessWnd : public CBaseWnd
5352

5453
CString m_EditText;
5554
CButton m_btnCopyAll;
55+
56+
// Need additional one as controls created dynamically after DPI is applied.
57+
se::windows::ui::CDpiWindowBehavior m_edit_dpi_behavior{false};
58+
se::windows::ui::CDpiWindowBehavior m_copy_all_dpi_behavior{false};
5659

5760
//{{AFX_MSG(CProcessWnd)
5861
afx_msg void OnTimer(UINT_PTR nIDEvent);
5962
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
63+
afx_msg void OnDestroy();
64+
afx_msg LRESULT OnDpiChanged(WPARAM wParam, LPARAM lParam);
6065
afx_msg void OnSize(UINT nType, int cx, int cy);
6166
afx_msg void OnCopyAll();
6267
//}}AFX_MSG

hammer/runcommands.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ void SplitFileNameFromPath(char* szDocLongPath,
242242
}
243243
}
244244

245-
bool RunCommands(CCommandArray& Commands, LPCTSTR pszOrigDocName)
245+
bool RunCommands(CCommandArray& Commands, LPCTSTR pszOrigDocName, CWnd *parent)
246246
{
247247
s_bRunsCommands = true;
248248

@@ -254,7 +254,7 @@ bool RunCommands(CCommandArray& Commands, LPCTSTR pszOrigDocName)
254254
std::generic_category().message(errno).c_str() );
255255
}
256256

257-
procWnd.GetReady(pszOrigDocName);
257+
procWnd.GetReady(pszOrigDocName, parent);
258258

259259
// cut up document name into file and extension components.
260260
// create two sets of buffers - one set with the long filename

hammer/runcommands.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ typedef struct
4242
typedef CArray<CCOMMAND, CCOMMAND&> CCommandArray;
4343

4444
// run a list of commands:
45-
bool RunCommands(CCommandArray& Commands, LPCTSTR pszDocName);
46-
void FixGameVars(char *pszSrc, OUT_Z_CAP(dstSize) char *pszDst, intp dstSize, BOOL bUseQuotes = TRUE);
45+
bool RunCommands(CCommandArray& Commands, LPCTSTR pszDocName, CWnd *parent);
46+
void FixGameVars(char *pszSrc, OUT_Z_CAP(dstSize) char *pszDst, intp dstSize, BOOL bUseQuotes /*= TRUE*/);
4747
template<intp dstSize>
48-
void FixGameVars(char* pszSrc, OUT_Z_ARRAY char (&pszDst)[dstSize], BOOL bUseQuotes = TRUE)
48+
void FixGameVars(char* pszSrc, OUT_Z_ARRAY char (&pszDst)[dstSize], BOOL bUseQuotes)
4949
{
5050
FixGameVars(pszSrc, pszDst, dstSize, bUseQuotes);
5151
}

0 commit comments

Comments
 (0)