From d83c8597b65587aa4c2f8850405a151f4eacfa56 Mon Sep 17 00:00:00 2001 From: oddMLan Date: Thu, 18 Apr 2019 14:10:04 -0700 Subject: [PATCH] [Debugger] Make Debugger DPI-Aware Thanks @Shygoo for the class code --- .../UserInterface/Debugger/DebugDialog.h | 20 +++++++++++++++++++ .../Debugger/Debugger-CPULogView.cpp | 2 +- .../Debugger/Debugger-CPULogView.h | 4 ++-- .../Debugger/Debugger-Commands.cpp | 2 +- .../Debugger/Debugger-Commands.h | 2 +- .../Debugger/Debugger-DMALogView.h | 2 +- .../Debugger/Debugger-MemorySearch.cpp | 4 ++-- .../Debugger/Debugger-MemorySearch.h | 6 +++--- .../UserInterface/Debugger/Debugger-Scripts.h | 2 +- .../Debugger/Debugger-StackTrace.h | 2 +- .../Debugger/Debugger-StackView.h | 2 +- .../UserInterface/Debugger/Debugger-Symbols.h | 2 +- 12 files changed, 35 insertions(+), 15 deletions(-) diff --git a/Source/Project64/UserInterface/Debugger/DebugDialog.h b/Source/Project64/UserInterface/Debugger/DebugDialog.h index 5e3e327b0..f766bbd86 100644 --- a/Source/Project64/UserInterface/Debugger/DebugDialog.h +++ b/Source/Project64/UserInterface/Debugger/DebugDialog.h @@ -123,3 +123,23 @@ private: LONG m_SaveWndTop; LONG m_SaveWndLeft; }; + +class CListViewCtrlVarDPI : public CListViewCtrl +{ +private: + float m_ScaleX; + +public: + CListViewCtrlVarDPI() : + CListViewCtrl() + { + HDC screen = ::GetDC(0); + m_ScaleX = GetDeviceCaps(screen, LOGPIXELSX) / 96.0f; + ::ReleaseDC(0, screen); + } + + BOOL SetColumnWidth(int nColumn, int nWidth) + { + return CListViewCtrl::SetColumnWidth(nColumn, nWidth * m_ScaleX); + } +}; \ No newline at end of file diff --git a/Source/Project64/UserInterface/Debugger/Debugger-CPULogView.cpp b/Source/Project64/UserInterface/Debugger/Debugger-CPULogView.cpp index 0d68c149c..7ca6bd94f 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-CPULogView.cpp +++ b/Source/Project64/UserInterface/Debugger/Debugger-CPULogView.cpp @@ -412,7 +412,7 @@ void CDebugCPULogView::Export(void) // util -int CDebugCPULogView::GetNumVisibleRows(CListViewCtrl& list) +int CDebugCPULogView::GetNumVisibleRows(CListViewCtrlVarDPI& list) { CHeaderCtrl header = list.GetHeader(); CRect listRect, headRect; diff --git a/Source/Project64/UserInterface/Debugger/Debugger-CPULogView.h b/Source/Project64/UserInterface/Debugger/Debugger-CPULogView.h index f54d449ae..e1a0767aa 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-CPULogView.h +++ b/Source/Project64/UserInterface/Debugger/Debugger-CPULogView.h @@ -22,7 +22,7 @@ private: int m_RowHeight; int m_LogStartIndex; - CListViewCtrl m_CPUListView; + CListViewCtrlVarDPI m_CPUListView; CEdit m_StateInfoEdit; CEditNumber32 m_BuffSizeEdit; CButton m_EnabledChk; @@ -50,7 +50,7 @@ private: void ShowRegStates(size_t stateIndex); void Export(void); - int GetNumVisibleRows(CListViewCtrl& list); + int GetNumVisibleRows(CListViewCtrlVarDPI& list); bool MouseHovering(WORD ctrlId, int xMargin = 0, int yMargin = 0); BEGIN_MSG_MAP_EX(CDebugCPULogView) diff --git a/Source/Project64/UserInterface/Debugger/Debugger-Commands.cpp b/Source/Project64/UserInterface/Debugger/Debugger-Commands.cpp index 33db63dcc..92fef2526 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-Commands.cpp +++ b/Source/Project64/UserInterface/Debugger/Debugger-Commands.cpp @@ -21,7 +21,7 @@ void CCommandList::Attach(HWND hWndNew) { - CListViewCtrl::Attach(hWndNew); + CListViewCtrlVarDPI::Attach(hWndNew); ModifyStyle(LVS_OWNERDRAWFIXED, 0, 0); SetExtendedListViewStyle(LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_LABELTIP); diff --git a/Source/Project64/UserInterface/Debugger/Debugger-Commands.h b/Source/Project64/UserInterface/Debugger/Debugger-Commands.h index 0841a5e35..ed2550ce8 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-Commands.h +++ b/Source/Project64/UserInterface/Debugger/Debugger-Commands.h @@ -18,7 +18,7 @@ #include class CCommandList : - public CWindowImpl + public CWindowImpl { public: enum diff --git a/Source/Project64/UserInterface/Debugger/Debugger-DMALogView.h b/Source/Project64/UserInterface/Debugger/Debugger-DMALogView.h index d3a07a817..07f3e56ad 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-DMALogView.h +++ b/Source/Project64/UserInterface/Debugger/Debugger-DMALogView.h @@ -44,7 +44,7 @@ private: // Return true if entry meets requirements bool FilterEntry(int dmaLogIndex); - CListViewCtrl m_DMAList; + CListViewCtrlVarDPI m_DMAList; CEdit m_DMARamEdit; CEdit m_DMARomEdit; CStatic m_BlockInfo; diff --git a/Source/Project64/UserInterface/Debugger/Debugger-MemorySearch.cpp b/Source/Project64/UserInterface/Debugger/Debugger-MemorySearch.cpp index fc35096c1..033da7bf5 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-MemorySearch.cpp +++ b/Source/Project64/UserInterface/Debugger/Debugger-MemorySearch.cpp @@ -1487,7 +1487,7 @@ void CDebugMemorySearch::SeparatorMoveCtrl(WORD ctrlId, int yChange, bool bResiz ::InvalidateRect(hControl, NULL, true); } -int CDebugMemorySearch::GetNumVisibleRows(CListViewCtrl& list) +int CDebugMemorySearch::GetNumVisibleRows(CListViewCtrlVarDPI& list) { CHeaderCtrl header = list.GetHeader(); CRect listRect, headRect; @@ -2139,7 +2139,7 @@ void CDebugMemorySearch::LoadWatchList(void) } -void CDebugMemorySearch::FixListHeader(CListViewCtrl& listCtrl) +void CDebugMemorySearch::FixListHeader(CListViewCtrlVarDPI& listCtrl) { CRect listRect, headRect; CHeaderCtrl listHead = listCtrl.GetHeader(); diff --git a/Source/Project64/UserInterface/Debugger/Debugger-MemorySearch.h b/Source/Project64/UserInterface/Debugger/Debugger-MemorySearch.h index 035f32e64..61b38efe9 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-MemorySearch.h +++ b/Source/Project64/UserInterface/Debugger/Debugger-MemorySearch.h @@ -241,10 +241,10 @@ private: CPath GetWatchListPath(void); /* generic ui util */ - void FixListHeader(CListViewCtrl& listCtrl); + void FixListHeader(CListViewCtrlVarDPI& listCtrl); void SetComboBoxSelByData(CComboBox& cb, DWORD_PTR data); bool MouseHovering(WORD ctrlId, int hMargin = 0, int vMargin = 0); - int GetNumVisibleRows(CListViewCtrl& list); + int GetNumVisibleRows(CListViewCtrlVarDPI& list); /*******************/ bool m_bJalSelected; @@ -261,7 +261,7 @@ private: CEditMixed m_SearchValue; CEditNumber32 m_AddrStart, m_AddrEnd; CComboBox m_SearchTypeOptions, m_ValueTypeOptions; - CListViewCtrl m_ResultsListCtrl, m_WatchListCtrl; + CListViewCtrlVarDPI m_ResultsListCtrl, m_WatchListCtrl; CScrollBar m_ResultsScrollbar, m_WatchListScrollbar; CButton m_PhysicalCheckbox, m_HexCheckbox; CButton m_UnsignedCheckbox, m_IgnoreCaseCheckbox, m_UnkEncodingCheckbox; diff --git a/Source/Project64/UserInterface/Debugger/Debugger-Scripts.h b/Source/Project64/UserInterface/Debugger/Debugger-Scripts.h index c65d343b5..4377a65bd 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-Scripts.h +++ b/Source/Project64/UserInterface/Debugger/Debugger-Scripts.h @@ -13,7 +13,7 @@ #include "DebuggerUI.h" #include "ScriptSystem.h" -class CScriptList : public CListViewCtrl +class CScriptList : public CListViewCtrlVarDPI { public: BEGIN_MSG_MAP_EX(CScriptList) diff --git a/Source/Project64/UserInterface/Debugger/Debugger-StackTrace.h b/Source/Project64/UserInterface/Debugger/Debugger-StackTrace.h index a7f3f5681..dea72b697 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-StackTrace.h +++ b/Source/Project64/UserInterface/Debugger/Debugger-StackTrace.h @@ -44,7 +44,7 @@ private: HANDLE m_AutoRefreshThread; static DWORD WINAPI AutoRefreshProc(void* _this); - CListViewCtrl m_List; + CListViewCtrlVarDPI m_List; LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); LRESULT OnActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); diff --git a/Source/Project64/UserInterface/Debugger/Debugger-StackView.h b/Source/Project64/UserInterface/Debugger/Debugger-StackView.h index f1b1fe3f9..479fe634a 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-StackView.h +++ b/Source/Project64/UserInterface/Debugger/Debugger-StackView.h @@ -24,7 +24,7 @@ public: void Refresh(); private: - CListViewCtrl m_StackList; + CListViewCtrlVarDPI m_StackList; CStatic m_SPStatic; LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); diff --git a/Source/Project64/UserInterface/Debugger/Debugger-Symbols.h b/Source/Project64/UserInterface/Debugger/Debugger-Symbols.h index 06ccb71e5..bfbc90176 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-Symbols.h +++ b/Source/Project64/UserInterface/Debugger/Debugger-Symbols.h @@ -20,7 +20,7 @@ class CDebugSymbols : public CDialogResize { private: - CListViewCtrl m_SymbolsListView; + CListViewCtrlVarDPI m_SymbolsListView; CAddSymbolDlg m_AddSymbolDlg; HANDLE m_AutoRefreshThread;