Make Status Bar, About Dialog and Language Selector DPI Aware
This commit is contained in:
parent
2f9529a2cf
commit
05f98f8c09
|
@ -52,8 +52,11 @@ LRESULT CALLBACK CLanguageSelector::LangSelectProc(HWND hDlg, UINT uMsg, WPARAM
|
|||
SendMessage(GetDlgItem(hDlg, IDC_LANG_SEL), CB_SETCURSEL, 0, 0);
|
||||
}
|
||||
|
||||
//Get Windows DPI Scale
|
||||
float DPIScale = CClientDC(hDlg).GetDeviceCaps(LOGPIXELSX) / 96.0f;
|
||||
|
||||
// Use the size of the image
|
||||
hbmpBackgroundTop = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_ABOUT_LOGO));
|
||||
hbmpBackgroundTop = LoadBitmap(GetModuleHandle(NULL), DPIScale <= 1.0f ? MAKEINTRESOURCE(IDB_ABOUT_LOGO) : MAKEINTRESOURCE(IDB_ABOUT_LOGO_HDPI));
|
||||
BITMAP bmTL;
|
||||
GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL);
|
||||
|
||||
|
@ -99,7 +102,8 @@ LRESULT CALLBACK CLanguageSelector::LangSelectProc(HWND hDlg, UINT uMsg, WPARAM
|
|||
|
||||
HDC memdc = CreateCompatibleDC(ps.hdc);
|
||||
HGDIOBJ save = SelectObject(memdc, hbmpBackgroundTop);
|
||||
BitBlt(ps.hdc, 0, 0, bmTL_top.bmWidth, bmTL_top.bmHeight, memdc, 0, 0, SRCCOPY);
|
||||
SetStretchBltMode(ps.hdc, HALFTONE);
|
||||
StretchBlt(ps.hdc, 0, 0, rcClient.right, (int)(bmTL_top.bmHeight * rcClient.right / bmTL_top.bmWidth), memdc, 0, 0, bmTL_top.bmWidth, bmTL_top.bmHeight, SRCCOPY);
|
||||
SelectObject(memdc, save);
|
||||
DeleteDC(memdc);
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 492 KiB |
|
@ -526,7 +526,7 @@ void CMainGui::Resize(DWORD /*fwSizeType*/, WORD nWidth, WORD nHeight)
|
|||
GetClientRect((HWND)m_hStatusWnd, &swrect);
|
||||
|
||||
int Parts[2];
|
||||
Parts[0] = (nWidth - (int)(clrect.right * 0.25));
|
||||
Parts[0] = (int) (nWidth - 140 * DPIScale(m_hStatusWnd));
|
||||
Parts[1] = nWidth;
|
||||
|
||||
SendMessage((HWND)m_hStatusWnd, SB_SETPARTS, 2, (LPARAM)&Parts[0]);
|
||||
|
@ -573,6 +573,10 @@ int CMainGui::Width(void)
|
|||
return rect.right - rect.left;
|
||||
}
|
||||
|
||||
float CMainGui::DPIScale(HWND hWnd) {
|
||||
return CClientDC(hWnd).GetDeviceCaps(LOGPIXELSX) / 96.0f;
|
||||
}
|
||||
|
||||
void CMainGui::SetPos(int X, int Y)
|
||||
{
|
||||
SetWindowPos(m_hMainWindow, NULL, X, Y, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
|
||||
|
@ -1222,6 +1226,7 @@ LRESULT CALLBACK CMainGui::MainGui_Proc(HWND hWnd, DWORD uMsg, DWORD wParam, DWO
|
|||
|
||||
DWORD CALLBACK AboutBoxProc(HWND hWnd, DWORD uMsg, DWORD wParam, DWORD /*lParam*/)
|
||||
{
|
||||
CMainGui * Gui = NULL;
|
||||
static HBITMAP hbmpBackgroundTop = NULL;
|
||||
static HFONT hPageHeadingFont = NULL;
|
||||
static HFONT hTextFont = NULL;
|
||||
|
@ -1233,16 +1238,18 @@ DWORD CALLBACK AboutBoxProc(HWND hWnd, DWORD uMsg, DWORD wParam, DWORD /*lParam*
|
|||
//Title
|
||||
SetWindowTextW(hWnd, wGS(PLUG_ABOUT).c_str());
|
||||
|
||||
// Use the size of the image
|
||||
hbmpBackgroundTop = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_ABOUT_LOGO));
|
||||
// Get Windows DPI Scale
|
||||
float DPIScale = Gui->DPIScale(hWnd);
|
||||
|
||||
// Use the size of the image
|
||||
hbmpBackgroundTop = LoadBitmap(GetModuleHandle(NULL), DPIScale <= 1.0f ? MAKEINTRESOURCE(IDB_ABOUT_LOGO) : MAKEINTRESOURCE(IDB_ABOUT_LOGO_HDPI));
|
||||
BITMAP bmTL;
|
||||
GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL);
|
||||
|
||||
hTextFont = ::CreateFont(18, 0, 0, 0, FW_NORMAL, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial");
|
||||
hAuthorFont = ::CreateFont(18, 0, 0, 0, FW_BOLD, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial");
|
||||
hTextFont = ::CreateFont((int)(18 * DPIScale), 0, 0, 0, FW_NORMAL, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial");
|
||||
hAuthorFont = ::CreateFont((int)(18 * DPIScale), 0, 0, 0, FW_BOLD, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial");
|
||||
|
||||
hPageHeadingFont = ::CreateFont(24, 0, 0, 0, FW_BOLD, 0, FALSE, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial Bold");
|
||||
hPageHeadingFont = ::CreateFont((int)(24 * DPIScale), 0, 0, 0, FW_BOLD, 0, FALSE, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial Bold");
|
||||
|
||||
SendDlgItemMessage(hWnd, IDC_VERSION, WM_SETFONT, (WPARAM)hTextFont, TRUE);
|
||||
SendDlgItemMessage(hWnd, IDC_TEAM, WM_SETFONT, (WPARAM)hPageHeadingFont, TRUE);
|
||||
|
@ -1302,7 +1309,8 @@ DWORD CALLBACK AboutBoxProc(HWND hWnd, DWORD uMsg, DWORD wParam, DWORD /*lParam*
|
|||
|
||||
HDC memdc = CreateCompatibleDC(ps.hdc);
|
||||
HGDIOBJ save = SelectObject(memdc, hbmpBackgroundTop);
|
||||
BitBlt(ps.hdc, 0, 0, bmTL_top.bmWidth, bmTL_top.bmHeight, memdc, 0, 0, SRCCOPY);
|
||||
SetStretchBltMode(ps.hdc, HALFTONE);
|
||||
StretchBlt(ps.hdc, 0, 0, rcClient.right, (int)(bmTL_top.bmHeight * rcClient.right/bmTL_top.bmWidth), memdc, 0, 0, bmTL_top.bmWidth, bmTL_top.bmHeight, SRCCOPY);
|
||||
SelectObject(memdc, save);
|
||||
DeleteDC(memdc);
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@ public:
|
|||
//Get Information about the window
|
||||
int Height(void); //Get the Height of the window
|
||||
int Width(void); //Get the Width of the window
|
||||
float DPIScale(HWND hWnd);
|
||||
|
||||
//Manipulate the state of the window
|
||||
void SetPos(int X, int Y); //Move the window to this screen location
|
||||
|
|
|
@ -1847,6 +1847,8 @@ IDB_LISTITEMS BITMAP "Bitmaps\\ListItems.bmp"
|
|||
|
||||
IDB_ABOUT_LOGO BITMAP "Bitmaps\\AboutScreenLogo.bmp"
|
||||
|
||||
IDB_ABOUT_LOGO_HDPI BITMAP "Bitmaps\\AboutScreenLogoHDPI.bmp"
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#define IDD_About_UserInfo 141
|
||||
#define IDD_About_Ini 143
|
||||
#define IDB_ABOUT_LOGO 143
|
||||
#define IDB_ABOUT_LOGO_HDPI 144
|
||||
#define IDD_Settings_General 144
|
||||
#define IDD_Settings_Accelerator 145
|
||||
#define IDD_Settings_Config 149
|
||||
|
|
Loading…
Reference in New Issue