mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-23 13:54:54 +02:00
Add dpi support to dialogs
- About - DebugInfo - Save All - Close All ref #14959 Close #14989
This commit is contained in:
parent
01a088f994
commit
27e77cf6d6
@ -85,27 +85,37 @@ intptr_t CALLBACK AboutDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lPar
|
|||||||
case NPPM_INTERNAL_REFRESHDARKMODE:
|
case NPPM_INTERNAL_REFRESHDARKMODE:
|
||||||
{
|
{
|
||||||
NppDarkMode::autoThemeChildControls(_hSelf);
|
NppDarkMode::autoThemeChildControls(_hSelf);
|
||||||
|
if (_hIcon != nullptr)
|
||||||
|
{
|
||||||
|
::DestroyIcon(_hIcon);
|
||||||
|
_hIcon = nullptr;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
case WM_DPICHANGED:
|
||||||
|
{
|
||||||
|
DPIManagerV2::setDpiWP(wParam);
|
||||||
|
destroy();
|
||||||
|
//setPositionDpi(lParam);
|
||||||
|
getClientRect(_rc);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_DRAWITEM:
|
case WM_DRAWITEM:
|
||||||
{
|
{
|
||||||
DPIManager& dpiManager = NppParameters::getInstance()._dpiManager;
|
const int iconSize = DPIManagerV2::scale(80);
|
||||||
int iconSideSize = 80;
|
if (_hIcon == nullptr)
|
||||||
int w = dpiManager.scaleX(iconSideSize);
|
{
|
||||||
int h = dpiManager.scaleY(iconSideSize);
|
DPIManagerV2::loadIcon(_hInst, MAKEINTRESOURCE(NppDarkMode::isEnabled() ? IDI_CHAMELEON_DM : IDI_CHAMELEON), iconSize, iconSize, &_hIcon);
|
||||||
|
}
|
||||||
HICON hIcon = nullptr;
|
|
||||||
if (NppDarkMode::isEnabled())
|
|
||||||
hIcon = (HICON)::LoadImage(_hInst, MAKEINTRESOURCE(IDI_CHAMELEON_DM), IMAGE_ICON, w, h, LR_DEFAULTSIZE);
|
|
||||||
else
|
|
||||||
hIcon = (HICON)::LoadImage(_hInst, MAKEINTRESOURCE(IDI_CHAMELEON), IMAGE_ICON, w, h, LR_DEFAULTSIZE);
|
|
||||||
|
|
||||||
//HICON hIcon = (HICON)::LoadImage(_hInst, MAKEINTRESOURCE(IDI_JESUISCHARLIE), IMAGE_ICON, 64, 64, LR_DEFAULTSIZE);
|
//HICON hIcon = (HICON)::LoadImage(_hInst, MAKEINTRESOURCE(IDI_JESUISCHARLIE), IMAGE_ICON, 64, 64, LR_DEFAULTSIZE);
|
||||||
//HICON hIcon = (HICON)::LoadImage(_hInst, MAKEINTRESOURCE(IDI_GILETJAUNE), IMAGE_ICON, 64, 64, LR_DEFAULTSIZE);
|
//HICON hIcon = (HICON)::LoadImage(_hInst, MAKEINTRESOURCE(IDI_GILETJAUNE), IMAGE_ICON, 64, 64, LR_DEFAULTSIZE);
|
||||||
//HICON hIcon = (HICON)::LoadImage(_hInst, MAKEINTRESOURCE(IDI_SAMESEXMARRIAGE), IMAGE_ICON, 64, 64, LR_DEFAULTSIZE);
|
//HICON hIcon = (HICON)::LoadImage(_hInst, MAKEINTRESOURCE(IDI_SAMESEXMARRIAGE), IMAGE_ICON, 64, 64, LR_DEFAULTSIZE);
|
||||||
DRAWITEMSTRUCT *pdis = (DRAWITEMSTRUCT *)lParam;
|
auto pdis = reinterpret_cast<DRAWITEMSTRUCT*>(lParam);
|
||||||
::DrawIconEx(pdis->hDC, 0, 0, hIcon, w, h, 0, NULL, DI_NORMAL);
|
::DrawIconEx(pdis->hDC, 0, 0, _hIcon, iconSize, iconSize, 0, nullptr, DI_NORMAL);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,6 +136,7 @@ intptr_t CALLBACK AboutDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lPar
|
|||||||
|
|
||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
{
|
{
|
||||||
|
destroy();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -138,11 +149,12 @@ void AboutDlg::doDialog()
|
|||||||
create(IDD_ABOUTBOX);
|
create(IDD_ABOUTBOX);
|
||||||
|
|
||||||
// Adjust the position of AboutBox
|
// Adjust the position of AboutBox
|
||||||
|
goToCenter(SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOACTIVATE);
|
||||||
goToCenter(SWP_SHOWWINDOW | SWP_NOSIZE);
|
goToCenter(SWP_SHOWWINDOW | SWP_NOSIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
intptr_t CALLBACK DebugInfoDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM /*lParam*/)
|
intptr_t CALLBACK DebugInfoDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
switch (message)
|
switch (message)
|
||||||
{
|
{
|
||||||
@ -364,6 +376,15 @@ intptr_t CALLBACK DebugInfoDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case WM_DPICHANGED:
|
||||||
|
{
|
||||||
|
DPIManagerV2::setDpiWP(wParam);
|
||||||
|
getClientRect(_rc);
|
||||||
|
setPositionDpi(lParam);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
{
|
{
|
||||||
switch (wParam)
|
switch (wParam)
|
||||||
@ -409,7 +430,8 @@ void DebugInfoDlg::doDialog()
|
|||||||
// For example, the command line parameters may have changed since this dialog was last opened during this session.
|
// For example, the command line parameters may have changed since this dialog was last opened during this session.
|
||||||
refreshDebugInfo();
|
refreshDebugInfo();
|
||||||
|
|
||||||
// Adjust the position of AboutBox
|
// Adjust the position of DebugBox
|
||||||
|
goToCenter(SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOACTIVATE);
|
||||||
goToCenter(SWP_SHOWWINDOW | SWP_NOSIZE);
|
goToCenter(SWP_SHOWWINDOW | SWP_NOSIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -465,7 +487,7 @@ void DoSaveOrNotBox::changeLang()
|
|||||||
::SetDlgItemText(_hSelf, IDC_DOSAVEORNOTTEXT, msg.c_str());
|
::SetDlgItemText(_hSelf, IDC_DOSAVEORNOTTEXT, msg.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
intptr_t CALLBACK DoSaveOrNotBox::run_dlgProc(UINT message, WPARAM wParam, LPARAM /*lParam*/)
|
intptr_t CALLBACK DoSaveOrNotBox::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
switch (message)
|
switch (message)
|
||||||
{
|
{
|
||||||
@ -495,6 +517,14 @@ intptr_t CALLBACK DoSaveOrNotBox::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case WM_DPICHANGED:
|
||||||
|
{
|
||||||
|
DPIManagerV2::setDpiWP(wParam);
|
||||||
|
setPositionDpi(lParam);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
{
|
{
|
||||||
switch (LOWORD(wParam))
|
switch (LOWORD(wParam))
|
||||||
@ -577,7 +607,7 @@ void DoSaveAllBox::changeLang()
|
|||||||
::SetDlgItemText(_hSelf, IDC_DOSAVEALLTEXT, msg.c_str());
|
::SetDlgItemText(_hSelf, IDC_DOSAVEALLTEXT, msg.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
intptr_t CALLBACK DoSaveAllBox::run_dlgProc(UINT message, WPARAM wParam, LPARAM /*lParam*/)
|
intptr_t CALLBACK DoSaveAllBox::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
switch (message)
|
switch (message)
|
||||||
{
|
{
|
||||||
@ -605,6 +635,14 @@ intptr_t CALLBACK DoSaveAllBox::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case WM_DPICHANGED:
|
||||||
|
{
|
||||||
|
DPIManagerV2::setDpiWP(wParam);
|
||||||
|
setPositionDpi(lParam);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
{
|
{
|
||||||
switch (LOWORD(wParam))
|
switch (LOWORD(wParam))
|
||||||
|
@ -46,6 +46,11 @@ public :
|
|||||||
void destroy() override {
|
void destroy() override {
|
||||||
//_emailLink.destroy();
|
//_emailLink.destroy();
|
||||||
_pageLink.destroy();
|
_pageLink.destroy();
|
||||||
|
if (_hIcon != nullptr)
|
||||||
|
{
|
||||||
|
::DestroyIcon(_hIcon);
|
||||||
|
_hIcon = nullptr;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
protected :
|
protected :
|
||||||
@ -54,6 +59,7 @@ protected :
|
|||||||
private :
|
private :
|
||||||
//URLCtrl _emailLink;
|
//URLCtrl _emailLink;
|
||||||
URLCtrl _pageLink;
|
URLCtrl _pageLink;
|
||||||
|
HICON _hIcon = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -76,8 +76,8 @@ public :
|
|||||||
DPIManagerV2::setDpi(_hSelf);
|
DPIManagerV2::setDpi(_hSelf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setPositionDpi(LPARAM lParam) {
|
void setPositionDpi(LPARAM lParam, UINT flags = SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE) {
|
||||||
DPIManagerV2::setPositionDpi(lParam, _hSelf);
|
DPIManagerV2::setPositionDpi(lParam, _hSelf, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendDpiMsgToChildCtrls(WPARAM wParam = 0, LPARAM lParam = 0) {
|
void sendDpiMsgToChildCtrls(WPARAM wParam = 0, LPARAM lParam = 0) {
|
||||||
|
@ -116,7 +116,7 @@ UINT DPIManagerV2::getDpiForWindow(HWND hWnd)
|
|||||||
return getDpiForSystem();
|
return getDpiForSystem();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DPIManagerV2::setPositionDpi(LPARAM lParam, HWND hWnd)
|
void DPIManagerV2::setPositionDpi(LPARAM lParam, HWND hWnd, UINT flags)
|
||||||
{
|
{
|
||||||
const auto prcNewWindow = reinterpret_cast<RECT*>(lParam);
|
const auto prcNewWindow = reinterpret_cast<RECT*>(lParam);
|
||||||
|
|
||||||
@ -126,7 +126,7 @@ void DPIManagerV2::setPositionDpi(LPARAM lParam, HWND hWnd)
|
|||||||
prcNewWindow->top,
|
prcNewWindow->top,
|
||||||
prcNewWindow->right - prcNewWindow->left,
|
prcNewWindow->right - prcNewWindow->left,
|
||||||
prcNewWindow->bottom - prcNewWindow->top,
|
prcNewWindow->bottom - prcNewWindow->top,
|
||||||
SWP_NOZORDER | SWP_NOACTIVATE);
|
flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGFONT DPIManagerV2::getDefaultGUIFontForDpi(UINT dpi, FontType type)
|
LOGFONT DPIManagerV2::getDefaultGUIFontForDpi(UINT dpi, FontType type)
|
||||||
@ -264,3 +264,11 @@ void DPIManagerV2::sendMessageToChildControls(HWND hwndParent, UINT msg, WPARAM
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}, reinterpret_cast<LPARAM>(&p));
|
}, reinterpret_cast<LPARAM>(&p));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DPIManagerV2::loadIcon(HINSTANCE hinst, wchar_t* pszName, int cx, int cy, HICON* phico, UINT fuLoad)
|
||||||
|
{
|
||||||
|
if (::LoadIconWithScaleDown(hinst, pszName, cx, cy, phico) != S_OK)
|
||||||
|
{
|
||||||
|
*phico = static_cast<HICON>(::LoadImage(hinst, pszName, IMAGE_ICON, cx, cy, fuLoad));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -80,7 +80,7 @@ public:
|
|||||||
return _dpi;
|
return _dpi;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setPositionDpi(LPARAM lParam, HWND hWnd);
|
static void setPositionDpi(LPARAM lParam, HWND hWnd, UINT flags = SWP_NOZORDER | SWP_NOACTIVATE);
|
||||||
|
|
||||||
static int scale(int x, UINT dpi, UINT dpi2) {
|
static int scale(int x, UINT dpi, UINT dpi2) {
|
||||||
return MulDiv(x, dpi, dpi2);
|
return MulDiv(x, dpi, dpi2);
|
||||||
@ -132,6 +132,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void sendMessageToChildControls(HWND hwndParent, UINT msg, WPARAM wParam, LPARAM lParam);
|
static void sendMessageToChildControls(HWND hwndParent, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||||
|
static void loadIcon(HINSTANCE hinst, wchar_t* pszName, int cx, int cy, HICON* phico, UINT fuLoad = LR_DEFAULTCOLOR);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UINT _dpi = USER_DEFAULT_SCREEN_DPI;
|
UINT _dpi = USER_DEFAULT_SCREEN_DPI;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user