1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-02 09:03:37 +00:00

GLideNUI-wtl: Add DPI-aware icon handling code

Other: Minor layout fixes
This commit is contained in:
oddMLan 2020-04-03 02:44:25 -07:00 committed by Sergey Lipskiy
parent 5cb23ede3a
commit 66175d82de
6 changed files with 88 additions and 6 deletions

View File

@ -173,7 +173,7 @@
<Image Include="..\..\src\GLideNUI\BottomLeft.ico" />
<Image Include="..\..\src\GLideNUI\BottomRight.ico" />
<Image Include="..\..\src\GLideNUI\Down.ico" />
<Image Include="..\..\src\GLideNUI\Icon.ico" />
<Image Include="..\..\src\GLideNUI\Icon-Original.ico" />
<Image Include="..\..\src\GLideNUI\Info.ico" />
<Image Include="..\..\src\GLideNUI\Left.ico" />
<Image Include="..\..\src\GLideNUI\Right.ico" />

View File

@ -241,7 +241,7 @@
<Image Include="..\..\src\GLideNUI-wtl\Down.ico">
<Filter>Resource Files</Filter>
</Image>
<Image Include="..\..\src\GLideNUI-wtl\Icon.ico">
<Image Include="..\..\src\GLideNUI-wtl\Icon-Original.ico">
<Filter>Resource Files</Filter>
</Image>
<Image Include="..\..\src\GLideNUI-wtl\Icon-Original.ico">

View File

@ -217,7 +217,8 @@ public:
L"famicom4\r\n"
L"Keith_at_UMR\r\n"
L"sweatypickle\r\n"
L"jeremydmiller"
L"jeremydmiller\r\n\r\n"
L"... and more"
};
CWindow Funders = GetDlgItem(IDC_FUNDERS);
Funders.SetWindowText(Funders1);
@ -290,7 +291,7 @@ BOOL CAboutTab::OnInitDialog(CWindow /*wndFocus*/, LPARAM /*lInitParam*/)
return true;
}
LRESULT CAboutTab::OnColorStatic(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
LRESULT CAboutTab::OnColorStatic(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
return (LRESULT)GetStockObject(WHITE_BRUSH);
}
@ -304,16 +305,24 @@ CAboutDlg::~CAboutDlg()
m_TabWindows.clear();
}
LRESULT CAboutDlg::OnInitDialog(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
LRESULT CAboutDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/ , LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
HICON hIcon = AtlLoadIconImage(IDI_APPICON, LR_DEFAULTCOLOR, ::GetSystemMetrics(SM_CXICON), ::GetSystemMetrics(SM_CYICON));
SetIcon(hIcon, TRUE);
HICON hIconSmall = AtlLoadIconImage(IDI_APPICON, LR_DEFAULTCOLOR, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON));
SetIcon(hIconSmall, FALSE);
SIZEF dpiScale = DpiScale(m_hWnd);
SIZE iconSz = { (LONG)(48 * dpiScale.cx), (LONG)(48 * dpiScale.cy) };
m_TitleFont.Apply(m_hWnd, CWindowFont::typeBold | CWindowFont::typeHeading, IDC_ABOUT_TITLE);
m_AboutIcon.SubclassWindow(GetDlgItem(IDC_ABOUT_ICON));
m_AboutIcon.SetIcon(MAKEINTRESOURCE(IDI_APPICON), 48, 48);
if (dpiScale.cx > 1.0 || dpiScale.cy > 1.0) {
m_AboutIcon.SetIcon(MAKEINTRESOURCE(IDI_APPICON), 256, 256); //load hi-def icon
}
else {
m_AboutIcon.SetIcon(MAKEINTRESOURCE(IDI_APPICON), 48, 48); //load regular icon
}
m_AboutIcon.SetWindowPos(HWND_TOP, 0, 0, iconSz.cx, iconSz.cy, SWP_NOMOVE | SWP_NOZORDER);
m_Tabs.Attach(GetDlgItem(IDC_TABS));
AddTab(L"About", new CAboutTab(IDD_TAB_ABOUT));

Binary file not shown.

View File

@ -520,6 +520,78 @@ static LRESULT Atl3ForwardNotifications(HWND hWnd, UINT uMsg, WPARAM wParam, LPA
#endif // (_ATL_VER < 0x0700)
#define DEFAULT_DPI 96.0
typedef struct tagSIZEF
{
FLOAT cx;
FLOAT cy;
} SIZEF, *PSIZEF, *LPSIZEF;
inline ATLAPI_(SIZE) Dpi()
{
SIZE dpi;
int nPixelsPerInchX; // Pixels per logical inch along width
int nPixelsPerInchY; // Pixels per logical inch along height
HDC hDCScreen = GetDC(NULL); // Gets DC of virtual display
ATLASSUME(hDCScreen != NULL);
nPixelsPerInchX = GetDeviceCaps(hDCScreen, LOGPIXELSX);
nPixelsPerInchY = GetDeviceCaps(hDCScreen, LOGPIXELSY);
ReleaseDC(NULL, hDCScreen);
dpi.cx = nPixelsPerInchX;
dpi.cy = nPixelsPerInchY;
return dpi;
}
inline ATLAPI_(SIZEF) DpiScale()
{
SIZE dpi = Dpi();
ATLASSUME(dpi != NULL);
SIZEF dpiScale = { (FLOAT)dpi.cx, (FLOAT)dpi.cy };
dpiScale.cx /= DEFAULT_DPI;
dpiScale.cy /= DEFAULT_DPI;
return dpiScale;
}
inline ATLAPI_(SIZE) Dpi(
_In_ const HWND &hWnd)
{
ATLENSURE_THROW(hWnd != NULL, E_POINTER);
SIZE dpi;
int nPixelsPerInchX; // Pixels per logical inch along width
int nPixelsPerInchY; // Pixels per logical inch along height
HDC hDCWindow = GetDC(hWnd);
ATLASSUME(hDCWindow != NULL);
nPixelsPerInchX = GetDeviceCaps(hDCWindow, LOGPIXELSX);
nPixelsPerInchY = GetDeviceCaps(hDCWindow, LOGPIXELSY);
ReleaseDC(hWnd, hDCWindow);
dpi.cx = nPixelsPerInchX;
dpi.cy = nPixelsPerInchY;
return dpi;
}
inline ATLAPI_(SIZEF) DpiScale(
_In_ const HWND &hWnd)
{
ATLENSURE_THROW(hWnd != NULL, E_POINTER);
SIZE dpi = Dpi(hWnd);
ATLASSUME(dpi != NULL);
SIZEF dpiScale = { (FLOAT)dpi.cx, (FLOAT)dpi.cy };
dpiScale.cx /= DEFAULT_DPI;
dpiScale.cy /= DEFAULT_DPI;
return dpiScale;
}
}; // namespace WTL
#endif // __ATLWINX_H__

View File

@ -16,5 +16,6 @@
#include "WTL\atlctrlx.h"
#include "WTL\atlgdi.h"
#include "WTL\atlmisc.h"
#include "WTL\atlwinx.h"
#include <atlwin.h>
#pragma warning(pop)