Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add support for per-monitor DPI awareness #422

Draft
wants to merge 34 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
873e7da
WIP: Add support for per-monitor DPI awareness (1)
sdottaka Aug 30, 2020
246ea44
WIP: Add support for per-monitor DPI awareness (2)
sdottaka Aug 31, 2020
5fa531a
WIP: Add support for per-monitor DPI awareness (3)
sdottaka Sep 1, 2020
0af5dec
WIP: Add support for per-monitor DPI awareness (4)
sdottaka Sep 2, 2020
c8bd781
WIP: Add support for per-monitor DPI awareness (5)
sdottaka Sep 3, 2020
1dd085b
WIP: Add support for per-monitor DPI awareness (6)
sdottaka Sep 7, 2020
55bc261
WIP: Add support for per-monitor DPI awareness (7)
sdottaka Sep 10, 2020
59cf6d9
WIP: Add support for per-monitor DPI awareness (8)
sdottaka Sep 11, 2020
ae46e46
memcombo.cpp: The text width was calculated using the wrong font.WIP:…
sdottaka Sep 11, 2020
a36ba45
WIP: Add support for per-monitor DPI awareness (10)
sdottaka Sep 12, 2020
6e97245
WIP: Add support for per-monitor DPI awareness (11)
sdottaka Sep 16, 2020
f3dd809
WIP: Add support for per-monitor DPI awareness (12)
sdottaka Sep 16, 2020
11ec528
WIP: Add support for per-monitor DPI awareness (13)
sdottaka Sep 18, 2020
cfc8bfb
WIP: Add support for per-monitor DPI awareness (14)
sdottaka Sep 19, 2020
aefc0dd
WIP: Add support for per-monitor DPI awareness (15)
sdottaka Sep 22, 2020
3e3929c
WIP: Add support for per-monitor DPI awareness (16)
sdottaka Sep 24, 2020
79e87fd
WIP: Add support for per-monitor DPI awareness (17)
sdottaka Sep 25, 2020
0b14123
Merge remote-tracking branch 'origin/master' into per-monitor-dpi-aware
sdottaka Sep 28, 2020
fc33371
WIP: Add support for per-monitor DPI awareness (18)
sdottaka Oct 1, 2020
fa63e4f
Merge remote-tracking branch 'origin/master' into per-monitor-dpi-aware
sdottaka Oct 2, 2020
241d706
Merge remote-tracking branch 'origin/master' into per-monitor-dpi-aware
sdottaka Oct 3, 2020
53e0714
Merge remote-tracking branch 'origin/master' into per-monitor-dpi-aware
sdottaka Oct 3, 2020
1560896
Merge remote-tracking branch 'origin/master' into per-monitor-dpi-aware
sdottaka Oct 4, 2020
79633fc
WIP: Add support for per-monitor DPI awareness (19)
sdottaka Oct 4, 2020
7768cb0
WIP: Add support for per-monitor DPI awareness (20)
sdottaka Oct 12, 2020
12b26b0
Merge remote-tracking branch 'origin/master' into per-monitor-dpi-aware
sdottaka Oct 12, 2020
01bbe73
Merge remote-tracking branch 'origin/master' into per-monitor-dpi-aware
sdottaka Oct 18, 2020
3ee6ff9
Merge remote-tracking branch 'origin/master' into per-monitor-dpi-aware
sdottaka Oct 28, 2020
61632ed
Merge branch 'master' into per-monitor-dpi-aware
sdottaka Dec 2, 2022
4bd7698
Merge remote-tracking branch 'origin/master' into per-monitor-dpi-aware
sdottaka Dec 4, 2022
c1c172e
Merge branch 'master' into per-monitor-dpi-aware
sdottaka Jun 4, 2024
d04365b
WIP
sdottaka Jun 4, 2024
d118721
WIP
sdottaka Jun 4, 2024
8bacafa
WIP
sdottaka Jun 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
WIP: Add support for per-monitor DPI awareness (15)
sdottaka committed Sep 22, 2020
commit aefc0ddad96885c3336854a15d833723eb021219
26 changes: 24 additions & 2 deletions Externals/crystaledit/Sample/ChildFrm.cpp
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
#include "Sample.h"

#include "ChildFrm.h"
#include "MainFrm.h"

#ifdef _DEBUG
#define new DEBUG_NEW
@@ -42,8 +43,21 @@ BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs

return __super::PreCreateWindow(cs);
MDITileLayout::LayoutManager& layoutManager = static_cast<CMainFrame*>(AfxGetMainWnd())->GetLayoutManager();
if (!layoutManager.GetTileLayoutEnabled())
return __super::PreCreateWindow(cs);
__super::PreCreateWindow(cs);
cs.style &= ~WS_CAPTION;
CRect rcMain;
CWnd* pWndMDIClient = AfxGetMainWnd()->FindWindowEx(AfxGetMainWnd()->m_hWnd, nullptr, _T("MDIClient"), nullptr);
pWndMDIClient->GetWindowRect(rcMain);
CRect rc = layoutManager.GetDefaultOpenPaneRect();
AdjustWindowRectEx(rc, cs.style, false, cs.dwExStyle);
cs.x = rc.left - rcMain.left;
cs.y = rc.top - rcMain.top;
cs.cx = rc.Width();
cs.cy = rc.Height();
return true;
}

/////////////////////////////////////////////////////////////////////////////
@@ -67,9 +81,16 @@ void CChildFrame::Dump(CDumpContext& dc) const

BOOL CChildFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
static_cast<CMainFrame*>(AfxGetMainWnd())->GetLayoutManager().NotifyChildOpened(this);
return m_wndSplitter.Create(this, 2, 2, CSize(30, 30), pContext);
}

BOOL CChildFrame::DestroyWindow()
{
static_cast<CMainFrame*>(AfxGetMainWnd())->GetLayoutManager().NotifyChildClosed(this);
return __super::DestroyWindow();
}

void CChildFrame::OnSize(UINT nType, int cx, int cy)
{
__super::OnSize(nType, cx, cy);
@@ -82,5 +103,6 @@ void CChildFrame::OnSize(UINT nType, int cx, int cy)
AdjustWindowRectEx(&rc, GetStyle(), FALSE, GetExStyle());
SetWindowPos(nullptr, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, SWP_NOZORDER | SWP_NOACTIVATE);
}
static_cast<CMainFrame*>(AfxGetMainWnd())->GetLayoutManager().NotifyChildResized(this);
}

1 change: 1 addition & 0 deletions Externals/crystaledit/Sample/ChildFrm.h
Original file line number Diff line number Diff line change
@@ -26,6 +26,7 @@ class CChildFrame : public DpiAware::CDpiAwareWnd<CMDIChildWnd>
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext);
virtual BOOL DestroyWindow();
//}}AFX_VIRTUAL

// Implementation
74 changes: 60 additions & 14 deletions Externals/crystaledit/Sample/MainFrm.cpp
Original file line number Diff line number Diff line change
@@ -24,6 +24,14 @@ BEGIN_MESSAGE_MAP(CMainFrame, DpiAware::CDpiAwareWnd<CMDIFrameWnd>)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code !
ON_WM_CREATE()
ON_WM_SIZE()
ON_COMMAND_EX(ID_WINDOW_ARRANGE, OnMDIWindowCmd)
ON_COMMAND_EX(ID_WINDOW_CASCADE, OnMDIWindowCmd)
ON_COMMAND_EX(ID_WINDOW_TILE_HORZ, OnMDIWindowCmd)
ON_COMMAND_EX(ID_WINDOW_TILE_VERT, OnMDIWindowCmd)
ON_COMMAND_EX(ID_WINDOW_SPLIT_VERTICALLY, OnWindowSplit)
ON_COMMAND_EX(ID_WINDOW_SPLIT_HORIZONTALLY, OnWindowSplit)
ON_COMMAND(ID_WINDOW_COMBINE, OnWindowCombine)
ON_MESSAGE(WM_DPICHANGED, OnDpiChanged)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
@@ -45,7 +53,7 @@ static UINT indicators[] =
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction

CMainFrame::CMainFrame()
CMainFrame::CMainFrame() : m_layoutManager(this)
{
// TODO: add member initialization code here

@@ -88,19 +96,6 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
return 0;
}

LRESULT CMainFrame::OnDpiChanged(WPARAM wParam, LPARAM lParam)
{
__super::OnDpiChanged(wParam, lParam);
DpiAware::UpdateAfxDataSysMetrics(GetDpi());
LoadToolBar();
const RECT* pRect = reinterpret_cast<RECT *>(lParam);
SetWindowPos(nullptr, pRect->left, pRect->top,
pRect->right - pRect->left,
pRect->bottom - pRect->top, SWP_NOZORDER | SWP_NOACTIVATE);
Default();
return 0;
}

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
@@ -147,3 +142,54 @@ void CMainFrame::Dump(CDumpContext& dc) const

/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers

BOOL CMainFrame::OnMDIWindowCmd(UINT nID)
{
switch (nID)
{
case ID_WINDOW_TILE_HORZ:
case ID_WINDOW_TILE_VERT:
{
bool bHorizontal = (nID == ID_WINDOW_TILE_HORZ);
m_layoutManager.SetTileLayoutEnabled(true);
m_layoutManager.Tile(bHorizontal);
break;
}
case ID_WINDOW_CASCADE:
m_layoutManager.SetTileLayoutEnabled(false);
__super::OnMDIWindowCmd(nID);
break;
}
return 0;
}

BOOL CMainFrame::OnWindowSplit(UINT nID)
{
m_layoutManager.SplitActivePane(nID == ID_WINDOW_SPLIT_HORIZONTALLY, 0.5);
return 0;
}

void CMainFrame::OnWindowCombine()
{
m_layoutManager.CombineActivePane();
}

void CMainFrame::OnSize(UINT nType, int cx, int cy)
{
__super::OnSize(nType, cx, cy);
m_layoutManager.NotifyMainResized();
}

LRESULT CMainFrame::OnDpiChanged(WPARAM wParam, LPARAM lParam)
{
__super::OnDpiChanged(wParam, lParam);
DpiAware::UpdateAfxDataSysMetrics(GetDpi());
LoadToolBar();
const RECT* pRect = reinterpret_cast<RECT *>(lParam);
SetWindowPos(nullptr, pRect->left, pRect->top,
pRect->right - pRect->left,
pRect->bottom - pRect->top, SWP_NOZORDER | SWP_NOACTIVATE);
Default();
return 0;
}

8 changes: 8 additions & 0 deletions Externals/crystaledit/Sample/MainFrm.h
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
#pragma once

#include "utils/DpiAware.h"
#include "utils/MDITileLayout.h"

class CMainFrame : public DpiAware::CDpiAwareWnd<CMDIFrameWnd>
{
@@ -32,18 +33,25 @@ class CMainFrame : public DpiAware::CDpiAwareWnd<CMDIFrameWnd>
virtual void Dump(CDumpContext& dc) const;
#endif
BOOL LoadToolBar();
MDITileLayout::LayoutManager& GetLayoutManager() { return m_layoutManager; };

protected: // control bar embedded members
CStatusBar m_wndStatusBar;
CToolBar m_wndToolBar;
CImageList m_imgListToolBar;
CSplitterWnd m_wndSplitter;
MDITileLayout::LayoutManager m_layoutManager;

// Generated message map functions
protected:
//{{AFX_MSG(CMainFrame)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code!
afx_msg BOOL OnMDIWindowCmd(UINT nID);
afx_msg BOOL OnWindowSplit(UINT nID);
afx_msg void OnWindowCombine();
afx_msg void OnSize(UINT nType, int cx, int cy);
//}}AFX_MSG
afx_msg LRESULT OnDpiChanged(WPARAM wParam, LPARAM lParam);
DECLARE_MESSAGE_MAP()
6 changes: 5 additions & 1 deletion Externals/crystaledit/Sample/Sample.rc
Original file line number Diff line number Diff line change
@@ -197,8 +197,12 @@ BEGIN
BEGIN
MENUITEM "&New Window", ID_WINDOW_NEW
MENUITEM "&Cascade", ID_WINDOW_CASCADE
MENUITEM "&Tile", ID_WINDOW_TILE_HORZ
MENUITEM "Tile &Vertically", ID_WINDOW_TILE_VERT
MENUITEM "Tile &Horizontally", ID_WINDOW_TILE_HORZ
MENUITEM "&Arrange Icons", ID_WINDOW_ARRANGE
MENUITEM "Split V&ertically", ID_WINDOW_SPLIT_VERTICALLY
MENUITEM "Split H&orizontally", ID_WINDOW_SPLIT_HORIZONTALLY
MENUITEM "Com&bine", ID_WINDOW_COMBINE
END
POPUP "&Help"
BEGIN
3 changes: 2 additions & 1 deletion Externals/crystaledit/Sample/SampleStatic.vs2017.vcxproj
Original file line number Diff line number Diff line change
@@ -585,6 +585,7 @@
<ClCompile Include="..\editlib\parsers\po.cpp" />
<ClCompile Include="..\editlib\parsers\powershell.cpp" />
<ClCompile Include="..\editlib\parsers\python.cpp" />
<ClCompile Include="..\editlib\utils\MDITileLayout.cpp" />
<ClCompile Include="..\editlib\utils\registry.cpp" />
<ClCompile Include="..\editlib\parsers\rexx.cpp" />
<ClCompile Include="..\editlib\parsers\rsrc.cpp" />
@@ -647,7 +648,7 @@
<ClInclude Include="..\editlib\LineInfo.h" />
<ClInclude Include="..\editlib\parsers\crystallineparser.h" />
<ClInclude Include="..\editlib\dialogs\memcombo.h" />
<ClInclude Include="..\editlib\utils\mfc_templ_defines.h" />
<ClInclude Include="..\editlib\utils\MDITileLayout.h" />
<ClInclude Include="..\editlib\utils\registry.h" />
<ClInclude Include="..\editlib\utils\string_util.h" />
<ClInclude Include="..\editlib\SyntaxColors.h" />
2 changes: 2 additions & 0 deletions Externals/crystaledit/Sample/SampleStatic.vs2019.vcxproj
Original file line number Diff line number Diff line change
@@ -584,6 +584,7 @@
<ClCompile Include="..\editlib\parsers\po.cpp" />
<ClCompile Include="..\editlib\parsers\powershell.cpp" />
<ClCompile Include="..\editlib\parsers\python.cpp" />
<ClCompile Include="..\editlib\utils\MDITileLayout.cpp" />
<ClCompile Include="..\editlib\utils\registry.cpp" />
<ClCompile Include="..\editlib\parsers\rexx.cpp" />
<ClCompile Include="..\editlib\parsers\rsrc.cpp" />
@@ -646,6 +647,7 @@
<ClInclude Include="..\editlib\LineInfo.h" />
<ClInclude Include="..\editlib\parsers\crystallineparser.h" />
<ClInclude Include="..\editlib\dialogs\memcombo.h" />
<ClInclude Include="..\editlib\utils\MDITileLayout.h" />
<ClInclude Include="..\editlib\utils\registry.h" />
<ClInclude Include="..\editlib\utils\string_util.h" />
<ClInclude Include="..\editlib\SyntaxColors.h" />
Original file line number Diff line number Diff line change
@@ -255,6 +255,9 @@
<ClCompile Include="..\editlib\utils\DpiAware.cpp">
<Filter>editlib\utils</Filter>
</ClCompile>
<ClCompile Include="..\editlib\utils\MDITileLayout.cpp">
<Filter>editlib\utils</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Sample.rc">
@@ -385,6 +388,9 @@
<ClInclude Include="..\editlib\utils\DpiAware.h">
<Filter>editlib\utils</Filter>
</ClInclude>
<ClInclude Include="..\editlib\utils\MDITileLayout.h">
<Filter>editlib\utils</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Image Include="res\mg_icons.bmp">
5 changes: 4 additions & 1 deletion Externals/crystaledit/Sample/resource.h
Original file line number Diff line number Diff line change
@@ -51,6 +51,9 @@
#define ID_EDIT_DISABLEDRAGANDDROP 32797
#define ID_EDIT_FIND_PREVIOUS 32799
#define ID_VIEW_WHITESPACE 32800
#define ID_WINDOW_SPLIT_VERTICALLY 32801
#define ID_WINDOW_SPLIT_HORIZONTALLY 32802
#define ID_WINDOW_COMBINE 32803
#define ID_EDIT_INDICATOR_COL 37900
#define ID_READ_ONLY 37901
#define ID_INDICATOR_ENCODING 37905
@@ -62,7 +65,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_3D_CONTROLS 1
#define _APS_NEXT_RESOURCE_VALUE 135
#define _APS_NEXT_COMMAND_VALUE 32802
#define _APS_NEXT_COMMAND_VALUE 32804
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
Loading