Commit 100504d2 authored by Petrichor Park's avatar Petrichor Park Committed by Alexandre Julliard

notepad: Use GetDpiForWindow().

Instead of querying the registry, just calls `GetDpiForWindow`. Winecfg's DPI slider sets `Control Panel\\Desktop\\LogPixels`. See `programs/winecfg/x11drvdlg.c` Notepad queries `Software\\Fonts\\LogPixels`, and so doesn't pick up on the change.
parent 224b771c
...@@ -958,7 +958,7 @@ VOID DIALOG_FilePrint(VOID) ...@@ -958,7 +958,7 @@ VOID DIALOG_FilePrint(VOID)
/* Create a font for the printer resolution */ /* Create a font for the printer resolution */
lfFont = Globals.lfFont; lfFont = Globals.lfFont;
lfFont.lfHeight = MulDiv(lfFont.lfHeight, GetDeviceCaps(printer.hDC, LOGPIXELSY), get_dpi()); lfFont.lfHeight = MulDiv(lfFont.lfHeight, GetDeviceCaps(printer.hDC, LOGPIXELSY), GetDpiForWindow(Globals.hMainWnd));
/* Make the font a bit lighter */ /* Make the font a bit lighter */
lfFont.lfWeight -= 100; lfFont.lfWeight -= 100;
hTextFont = CreateFontIndirectW(&lfFont); hTextFont = CreateFontIndirectW(&lfFont);
......
...@@ -81,33 +81,6 @@ VOID SetFileNameAndEncoding(LPCWSTR szFileName, ENCODING enc) ...@@ -81,33 +81,6 @@ VOID SetFileNameAndEncoding(LPCWSTR szFileName, ENCODING enc)
Globals.encFile = enc; Globals.encFile = enc;
} }
/******************************************************************************
* get_dpi
*
* Get the dpi from registry HKCC\Software\Fonts\LogPixels.
*/
DWORD get_dpi(void)
{
static const WCHAR dpi_key_name[] = {'S','o','f','t','w','a','r','e','\\','F','o','n','t','s','\0'};
static const WCHAR dpi_value_name[] = {'L','o','g','P','i','x','e','l','s','\0'};
DWORD dpi = 96;
HKEY hkey;
if (RegOpenKeyW(HKEY_CURRENT_CONFIG, dpi_key_name, &hkey) == ERROR_SUCCESS)
{
DWORD type, size, new_dpi;
size = sizeof(new_dpi);
if(RegQueryValueExW(hkey, dpi_value_name, NULL, &type, (LPBYTE)&new_dpi, &size) == ERROR_SUCCESS)
{
if(type == REG_DWORD && new_dpi != 0)
dpi = new_dpi;
}
RegCloseKey(hkey);
}
return dpi;
}
void UpdateStatusBar(void) void UpdateStatusBar(void)
{ {
int currentLine; int currentLine;
...@@ -210,7 +183,7 @@ static VOID NOTEPAD_SaveSettingToRegistry(void) ...@@ -210,7 +183,7 @@ static VOID NOTEPAD_SaveSettingToRegistry(void)
#undef SET_NOTEPAD_REG #undef SET_NOTEPAD_REG
/* Store the current value as 10 * twips */ /* Store the current value as 10 * twips */
data = MulDiv(abs(Globals.lfFont.lfHeight), 720 , get_dpi()); data = MulDiv(abs(Globals.lfFont.lfHeight), 720, GetDpiForWindow(Globals.hMainWnd));
RegSetValueExW(hkey, value_iPointSize, 0, REG_DWORD, (LPBYTE)&data, sizeof(DWORD)); RegSetValueExW(hkey, value_iPointSize, 0, REG_DWORD, (LPBYTE)&data, sizeof(DWORD));
RegSetValueExW(hkey, value_lfFaceName, 0, REG_SZ, (LPBYTE)&Globals.lfFont.lfFaceName, RegSetValueExW(hkey, value_lfFaceName, 0, REG_SZ, (LPBYTE)&Globals.lfFont.lfFaceName,
...@@ -309,7 +282,7 @@ static VOID NOTEPAD_LoadSettingFromRegistry(void) ...@@ -309,7 +282,7 @@ static VOID NOTEPAD_LoadSettingFromRegistry(void)
if(RegQueryValueExW(hkey, value_iPointSize, 0, &type, (LPBYTE)&point_size, &size) == ERROR_SUCCESS) if(RegQueryValueExW(hkey, value_iPointSize, 0, &type, (LPBYTE)&point_size, &size) == ERROR_SUCCESS)
if(type == REG_DWORD) if(type == REG_DWORD)
/* The value is stored as 10 * twips */ /* The value is stored as 10 * twips */
Globals.lfFont.lfHeight = -MulDiv(abs(point_size), get_dpi(), 720); Globals.lfFont.lfHeight = -MulDiv(abs(point_size), GetDpiForWindow(Globals.hMainWnd), 720);
size = sizeof(Globals.lfFont.lfFaceName); size = sizeof(Globals.lfFont.lfFaceName);
if(RegQueryValueExW(hkey, value_lfFaceName, 0, &type, (LPBYTE)&data_helper, &size) == ERROR_SUCCESS) if(RegQueryValueExW(hkey, value_lfFaceName, 0, &type, (LPBYTE)&data_helper, &size) == ERROR_SUCCESS)
......
...@@ -76,7 +76,6 @@ extern NOTEPAD_GLOBALS Globals; ...@@ -76,7 +76,6 @@ extern NOTEPAD_GLOBALS Globals;
VOID SetFileNameAndEncoding(LPCWSTR szFileName, ENCODING enc); VOID SetFileNameAndEncoding(LPCWSTR szFileName, ENCODING enc);
void NOTEPAD_DoFind(FINDREPLACEW *fr); void NOTEPAD_DoFind(FINDREPLACEW *fr);
DWORD get_dpi(void);
void UpdateStatusBar(void); void UpdateStatusBar(void);
void updateWindowSize(int width, int height); void updateWindowSize(int width, int height);
LRESULT CALLBACK EDIT_CallBackProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData); LRESULT CALLBACK EDIT_CallBackProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment