Apply dark mode on hash dialogs

Also allow typing newline in multiple lines for generating hash.

Fix #10255, close #10256
pull/10265/head
ozone10 2021-07-25 21:17:44 +02:00 committed by Don Ho
parent a9002c81e5
commit b0d4e776c6
2 changed files with 98 additions and 4 deletions

View File

@ -22,13 +22,16 @@
#include "CustomFileDialog.h" #include "CustomFileDialog.h"
#include "Parameters.h" #include "Parameters.h"
#include <shlwapi.h> #include <shlwapi.h>
#include "resource.h"
INT_PTR CALLBACK HashFromFilesDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM /*lParam*/) INT_PTR CALLBACK HashFromFilesDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
{ {
switch (message) switch (message)
{ {
case WM_INITDIALOG: case WM_INITDIALOG:
{ {
NppDarkMode::autoSubclassAndThemeChildControls(_hSelf);
int fontDpiDynamicalHeight = NppParameters::getInstance()._dpiManager.scaleY(13); int fontDpiDynamicalHeight = NppParameters::getInstance()._dpiManager.scaleY(13);
HFONT hFont = ::CreateFontA(fontDpiDynamicalHeight, 0, 0, 0, 0, FALSE, FALSE, FALSE, ANSI_CHARSET, HFONT hFont = ::CreateFontA(fontDpiDynamicalHeight, 0, 0, 0, 0, FALSE, FALSE, FALSE, ANSI_CHARSET,
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
@ -48,6 +51,38 @@ INT_PTR CALLBACK HashFromFilesDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
} }
return TRUE; return TRUE;
case WM_CTLCOLORDLG:
{
if (NppDarkMode::isEnabled())
{
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
}
break;
}
case WM_CTLCOLORSTATIC:
{
if (NppDarkMode::isEnabled())
{
HWND hwnd = reinterpret_cast<HWND>(lParam);
if (hwnd == ::GetDlgItem(_hSelf, IDC_HASH_PATH_EDIT) || hwnd == ::GetDlgItem(_hSelf, IDC_HASH_RESULT_EDIT))
{
return NppDarkMode::onCtlColor(reinterpret_cast<HDC>(wParam));
}
else
{
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
}
}
break;
}
case NPPM_INTERNAL_REFRESHDARKMODE:
{
NppDarkMode::autoThemeChildControls(_hSelf);
return TRUE;
}
case WM_COMMAND : case WM_COMMAND :
{ {
switch (wParam) switch (wParam)
@ -292,12 +327,14 @@ void HashFromTextDlg::generateHashPerLine()
} }
} }
INT_PTR CALLBACK HashFromTextDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM /*lParam*/) INT_PTR CALLBACK HashFromTextDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
{ {
switch (message) switch (message)
{ {
case WM_INITDIALOG: case WM_INITDIALOG:
{ {
NppDarkMode::autoSubclassAndThemeChildControls(_hSelf);
int fontDpiDynamicalHeight = NppParameters::getInstance()._dpiManager.scaleY(13); int fontDpiDynamicalHeight = NppParameters::getInstance()._dpiManager.scaleY(13);
HFONT hFont = ::CreateFontA(fontDpiDynamicalHeight, 0, 0, 0, 0, FALSE, FALSE, FALSE, ANSI_CHARSET, HFONT hFont = ::CreateFontA(fontDpiDynamicalHeight, 0, 0, 0, 0, FALSE, FALSE, FALSE, ANSI_CHARSET,
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
@ -317,6 +354,64 @@ INT_PTR CALLBACK HashFromTextDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
} }
return TRUE; return TRUE;
case WM_CTLCOLOREDIT:
{
if (NppDarkMode::isEnabled())
{
HWND hwnd = reinterpret_cast<HWND>(lParam);
if (hwnd == ::GetDlgItem(_hSelf, IDC_HASH_TEXT_EDIT))
{
return NppDarkMode::onCtlColorSofter(reinterpret_cast<HDC>(wParam));
}
else
{
return NppDarkMode::onCtlColor(reinterpret_cast<HDC>(wParam));
}
}
break;
}
case WM_CTLCOLORDLG:
{
if (NppDarkMode::isEnabled())
{
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
}
break;
}
case WM_CTLCOLORSTATIC:
{
if (NppDarkMode::isEnabled())
{
HWND hwnd = reinterpret_cast<HWND>(lParam);
if (hwnd == ::GetDlgItem(_hSelf, IDC_HASH_RESULT_FOMTEXT_EDIT))
{
return NppDarkMode::onCtlColor(reinterpret_cast<HDC>(wParam));
}
else
{
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
}
}
break;
}
case WM_PRINTCLIENT:
{
if (NppDarkMode::isEnabled())
{
return TRUE;
}
break;
}
case NPPM_INTERNAL_REFRESHDARKMODE:
{
NppDarkMode::autoThemeChildControls(_hSelf);
return TRUE;
}
case WM_COMMAND : case WM_COMMAND :
{ {
if (HIWORD(wParam) == EN_CHANGE && LOWORD(wParam) == IDC_HASH_TEXT_EDIT) if (HIWORD(wParam) == EN_CHANGE && LOWORD(wParam) == IDC_HASH_TEXT_EDIT)

View File

@ -39,9 +39,8 @@ CAPTION "Generate MD5 digest"
FONT 8, "MS Shell Dlg", 400, 0, 0x1 FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN BEGIN
CONTROL "Treat each line as a separate string",IDC_HASH_EACHLINE_CHECK,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,9,3,179,16 CONTROL "Treat each line as a separate string",IDC_HASH_EACHLINE_CHECK,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,9,3,179,16
EDITTEXT IDC_HASH_TEXT_EDIT, 9, 21, 340, 64, ES_MULTILINE | ES_AUTOVSCROLL | NOT WS_BORDER | WS_VSCROLL | WS_HSCROLL, WS_EX_CLIENTEDGE EDITTEXT IDC_HASH_TEXT_EDIT, 9, 21, 340, 64, ES_MULTILINE | ES_AUTOVSCROLL | NOT WS_BORDER | WS_VSCROLL | WS_HSCROLL | ES_WANTRETURN,WS_EX_CLIENTEDGE
EDITTEXT IDC_HASH_RESULT_FOMTEXT_EDIT,9,105,340,64,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | NOT WS_BORDER | WS_VSCROLL | WS_HSCROLL,WS_EX_CLIENTEDGE EDITTEXT IDC_HASH_RESULT_FOMTEXT_EDIT,9,105,340,64,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | NOT WS_BORDER | WS_VSCROLL | WS_HSCROLL,WS_EX_CLIENTEDGE
PUSHBUTTON "Copy to Clipboard",IDC_HASH_FROMTEXT_TOCLIPBOARD_BUTTON,259,172,90,14 PUSHBUTTON "Copy to Clipboard",IDC_HASH_FROMTEXT_TOCLIPBOARD_BUTTON,259,172,90,14
PUSHBUTTON "Close",IDCANCEL,148,190,60,14 PUSHBUTTON "Close",IDCANCEL,148,190,60,14
END END