+ chg: title font change DPI-Awareness for About and Customize Schemes dialog

+ fix: no read-only file attribute if removed externally
This commit is contained in:
RaiKoHoff 2020-08-03 17:46:20 +02:00
parent 19fc26bd1e
commit 5de36021d9
7 changed files with 138 additions and 93 deletions

View File

@ -106,9 +106,7 @@ bool CanAccessPath(LPCWSTR lpIniFilePath, DWORD genericAccessRights)
// check for read-only file attribute
if (genericAccessRights & GENERIC_WRITE)
{
DWORD const dwFileAttributes = GetFileAttributes(lpIniFilePath);
if ((dwFileAttributes == INVALID_FILE_ATTRIBUTES) || (dwFileAttributes & FILE_ATTRIBUTE_READONLY))
{
if (IsReadOnly(GetFileAttributes(lpIniFilePath))) {
return false;
}
}
@ -2146,10 +2144,10 @@ void CmdSaveSettingsNow()
}
if (Globals.bCanSaveIniFile && SaveAllSettings(true)) {
InfoBoxLng(MB_ICONINFORMATION, L"MsgSaveSettingsInfo", IDS_MUI_SAVEDSETTINGS);
if (dwFileAttributes != 0) {
if ((dwFileAttributes != 0) && (dwFileAttributes != INVALID_FILE_ATTRIBUTES)) {
SetFileAttributes(Globals.IniFile, dwFileAttributes); // reset
Globals.bCanSaveIniFile = CanAccessPath(Globals.IniFile, GENERIC_WRITE);
}
Globals.bCanSaveIniFile = CanAccessPath(Globals.IniFile, GENERIC_WRITE);
}
else {
Globals.dwLastError = GetLastError();

View File

@ -803,30 +803,33 @@ INT_PTR CALLBACK AboutDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam
case WM_PAINT:
{
HDC const hDC = GetWindowDC(hwnd);
HDC const hdc = GetWindowDC(hwnd);
SetMapMode(hdc, MM_TEXT);
int const iconSize = 128;
int const dpiWidth = ScaleIntByDPI(iconSize, dpi.x);
int const dpiHeight = ScaleIntByDPI(iconSize, dpi.y);
HICON const hicon = (dpiHeight > 128) ? Globals.hDlgIcon256 : Globals.hDlgIcon128;
if (hicon) {
DrawIconEx(hDC, ScaleIntByDPI(22, dpi.x), ScaleIntByDPI(44, dpi.x), hicon, dpiWidth, dpiHeight, 0, NULL, DI_NORMAL);
DrawIconEx(hdc, ScaleIntByDPI(22, dpi.x), ScaleIntByDPI(44, dpi.x), hicon, dpiWidth, dpiHeight, 0, NULL, DI_NORMAL);
}
// --- larger bold condensed version string
if (hVersionFont) { DeleteObject(hVersionFont); }
hVersionFont = GetStockObject(DEFAULT_GUI_FONT);
LOGFONT lf; GetObject(hVersionFont, sizeof(LOGFONT), &lf);
int const newWidth = -MulDiv(MulDiv(lf.lfWidth, 3, 2), GetDeviceCaps(hDC, LOGPIXELSX), 72);
int const newHeight = -MulDiv(MulDiv(lf.lfHeight, 3, 2), GetDeviceCaps(hDC, LOGPIXELSY), 72);
lf.lfWeight = FW_BOLD;
lf.lfWidth = ScaleIntByDPI(newWidth, dpi.x); // =0: the aspect ratio of the device is matched against the digitization aspect ratio of the available fonts
lf.lfHeight = ScaleIntByDPI(newHeight, dpi.y);
//~StringCchCopy(lf.lfFaceName, LF_FACESIZE, L"Tahoma");
hVersionFont = CreateFontIndirect(&lf);
SendDlgItemMessage(hwnd, IDC_VERSION, WM_SETFONT, (WPARAM)hVersionFont, true);
NONCLIENTMETRICSW ncMetrics = {0};
ncMetrics.cbSize = sizeof(NONCLIENTMETRICSW);
if (SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICSW), &ncMetrics, 0))
{
if (hVersionFont) {
DeleteObject(hVersionFont);
}
int const verFontSize = ScaleIntByDPI(14, dpi.y);
ncMetrics.lfMessageFont.lfWeight = FW_BOLD;
ncMetrics.lfMessageFont.lfHeight = -MulDiv(verFontSize, GetDeviceCaps(hdc, LOGPIXELSY), 72);
hVersionFont = CreateFontIndirectW(&ncMetrics.lfMessageFont);
SendDlgItemMessage(hwnd, IDC_VERSION, WM_SETFONT, (WPARAM)hVersionFont, true);
}
ReleaseDC(hwnd, hDC);
ReleaseDC(hwnd, hdc);
}
return 0;
@ -4667,27 +4670,28 @@ static void _GetIconInfo(HICON hIcon, int* width, int* height, WORD* bitsPerPix)
// ConvertIconToBitmap()
// cx/cy = 0 => use resource width/height
//
HBITMAP ConvertIconToBitmap(HWND hwnd, const HICON hIcon, const int cx, const int cy)
HBITMAP ConvertIconToBitmap(const HICON hIcon, const int cx, const int cy)
{
UNUSED(hwnd);
int wdc = cx;
int hdc = cy;
if ((cx == 0) || (cy == 0)) {
_GetIconInfo(hIcon, &wdc, &hdc, NULL);
}
HDC const hScreenDC = GetDC(NULL);
// increase & condense size
wdc <<= 4; hdc <<= 4;
HDC const hScreenDC = GetDC(NULL);
HBITMAP const hbmpTmp = CreateCompatibleBitmap(hScreenDC, wdc, hdc);
HDC const hMemDC = CreateCompatibleDC(hScreenDC);
HBITMAP const hOldBmp = SelectObject(hMemDC, hbmpTmp);
DrawIconEx(hMemDC, 0, 0, hIcon, cx, cy, 0, NULL, DI_NORMAL /*&~DI_DEFAULTSIZE*/ );
HDC const hMemDC = CreateCompatibleDC(hScreenDC);
HBITMAP const hOldBmp = SelectObject(hMemDC, hbmpTmp);
DrawIconEx(hMemDC, 0, 0, hIcon, wdc, hdc, 0, NULL, DI_NORMAL /*&~DI_DEFAULTSIZE*/);
SelectObject(hMemDC, hOldBmp);
HBITMAP const hDibBmp = (HBITMAP)CopyImage((HANDLE)hbmpTmp, IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE | LR_CREATEDIBSECTION);
UINT const copyFlags = LR_COPYDELETEORG | LR_COPYRETURNORG | LR_DEFAULTSIZE | LR_CREATEDIBSECTION;
HBITMAP const hDibBmp = (HBITMAP)CopyImage((HANDLE)hbmpTmp, IMAGE_BITMAP, cx, cy, copyFlags);
DeleteObject(hbmpTmp);
DeleteDC(hMemDC);
ReleaseDC(NULL, hScreenDC);
return hDibBmp;
}
@ -4697,7 +4701,8 @@ HBITMAP ConvertIconToBitmap(HWND hwnd, const HICON hIcon, const int cx, const in
//
HBITMAP ResampleIconToBitmap(HWND hwnd, const HICON hIcon, const int cx, const int cy)
{
HBITMAP const hBmp = ConvertIconToBitmap(hwnd, hIcon, 0, 0);
//~return ConvertIconToBitmap(hwnd, hIcon, cx, cy);
HBITMAP const hBmp = ConvertIconToBitmap(hIcon, 0, 0);
return ResampleImageBitmap(hwnd, hBmp, cx, cy);
}
@ -4720,7 +4725,7 @@ void SetUACIcon(HWND hwnd, const HMENU hMenu, const UINT nItem)
MENUITEMINFO mii = { 0 };
mii.cbSize = sizeof(MENUITEMINFO);
mii.fMask = MIIM_BITMAP;
mii.hbmpItem = ConvertIconToBitmap(hwnd, Globals.hIconMsgShieldSmall, cx, cy);
mii.hbmpItem = ConvertIconToBitmap(Globals.hIconMsgShieldSmall, cx, cy);
SetMenuItemInfo(hMenu, nItem, FALSE, &mii);
}
bInitialized = true;
@ -4731,32 +4736,37 @@ void SetUACIcon(HWND hwnd, const HMENU hMenu, const UINT nItem)
//
// UpdateWindowLayoutForDPI()
//
void UpdateWindowLayoutForDPI(HWND hwnd, const RECT* pRC, const DPI_T* pDPI)
inline WRCT_T _ConvWinRectW(const RECT* pRC)
{
WRCT_T wrc;
wrc.left = pRC->left;
wrc.top = pRC->top;
wrc.right = pRC->right;
wrc.bottom = pRC->bottom;
return wrc;
}
void UpdateWindowLayoutForDPI(HWND hwnd, const RECT* prc, const DPI_T* pdpi)
{
UINT const uWndFlags = SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED; //~ SWP_NOMOVE | SWP_NOSIZE | SWP_NOREPOSITION
if (pRC) {
SetWindowPos(hwnd, NULL, pRC->left, pRC->top, (pRC->right - pRC->left), (pRC->bottom - pRC->top), uWndFlags);
if (prc) {
SetWindowPos(hwnd, NULL, prc->left, prc->top, (prc->right - prc->left), (prc->bottom - prc->top), uWndFlags);
return;
}
DPI_T const wndDPI = pDPI ? *pDPI : Scintilla_GetWindowDPI(hwnd);
DPI_T const dpi = pdpi ? *pdpi : Scintilla_GetWindowDPI(hwnd);
RECT rc;
GetWindowRect(hwnd, &rc);
RECT rc; GetWindowRect(hwnd, &rc);
//~MapWindowPoints(NULL, hWnd, (LPPOINT)&rc, 2);
LONG const width = rc.right - rc.left;
LONG const height = rc.bottom - rc.top;
int const dpiScaledX = MulDiv(rc.left, wndDPI.x, USER_DEFAULT_SCREEN_DPI);
int const dpiScaledY = MulDiv(rc.top, wndDPI.y, USER_DEFAULT_SCREEN_DPI);
int const dpiScaledWidth = MulDiv(width, wndDPI.x, USER_DEFAULT_SCREEN_DPI);
int const dpiScaledHeight = MulDiv(height, wndDPI.y, USER_DEFAULT_SCREEN_DPI);
SetWindowPos(hwnd, NULL, dpiScaledX, dpiScaledY, dpiScaledWidth, dpiScaledHeight, uWndFlags);
WRCT_T wrc = _ConvWinRectW(prc);
Scintilla_AdjustWindowRectForDpi(&wrc, uWndFlags, 0, dpi);
SetWindowPos(hwnd, NULL, wrc.left, wrc.top, (wrc.right - wrc.left), (wrc.bottom - wrc.top), uWndFlags);
}
//=============================================================================
//
// ResampleImageBitmap()
// ResampleImageBitmap() (resample_delete_orig)
// if width|height <= 0 : scale bitmap to current dpi
//
HBITMAP ResampleImageBitmap(HWND hwnd, HBITMAP hbmp, int width, int height)
@ -4770,12 +4780,12 @@ HBITMAP ResampleImageBitmap(HWND hwnd, HBITMAP hbmp, int width, int height)
height = ScaleIntByDPI(bmp.bmHeight, dpi.y);
}
if (((LONG)width != bmp.bmWidth) || ((LONG)height != bmp.bmHeight)) {
#if FALSE
//HBITMAP hCopy = CopyImage(hbmp, IMAGE_BITMAP, width, height, LR_CREATEDIBSECTION | LR_COPYRETURNORG | LR_COPYDELETEORG);
#else
#if TRUE
HDC const hdc = GetDC(hwnd);
HBITMAP hCopy = CreateResampledBitmap(hdc, hbmp, width, height, BMP_RESAMPLE_FILTER);
ReleaseDC(hwnd, hdc);
#else
HBITMAP hCopy = CopyImage(hbmp, IMAGE_BITMAP, width, height, LR_CREATEDIBSECTION | LR_COPYRETURNORG | LR_COPYDELETEORG);
#endif
if (hCopy && (hCopy != hbmp)) {
DeleteObject(hbmp);
@ -4804,7 +4814,7 @@ LRESULT SendWMSize(HWND hwnd, RECT* rc)
//=============================================================================
#if 0
#if FALSE
void Handle_WM_PAINT(HWND hwnd)
{
static HFONT hVersionFont = NULL;

View File

@ -152,7 +152,7 @@ inline unsigned LargeIconDPI() { return (unsigned)MulDiv(USER_DEFAULT_SCREEN_DPI
// ----------------------------------------------------------------------------
HBITMAP ConvertIconToBitmap(HWND hwnd, const HICON hIcon, const int cx, const int cy);
HBITMAP ConvertIconToBitmap(const HICON hIcon, const int cx, const int cy);
HBITMAP ResampleIconToBitmap(HWND hwnd, const HICON hIcon, const int cx, const int cy);
void SetUACIcon(HWND hwnd, const HMENU hMenu, const UINT nItem);
void UpdateWindowLayoutForDPI(HWND hwnd, const RECT* pRC, const DPI_T* pDPI);

View File

@ -7942,37 +7942,56 @@ static INT_PTR CALLBACK EditModifyLinesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam
{
static PMODLINESDATA pdata;
static int id_hover;
static int id_capture;
static unsigned id_hover = 0;
static unsigned id_capture = 0;
static HFONT hFontNormal = NULL;
static HFONT hFontHover = NULL;
static HCURSOR hCursorNormal;
static HCURSOR hCursorHover;
switch(umsg)
{
static HFONT hFontHover;
case WM_INITDIALOG:
{
id_hover = 0;
id_capture = 0;
SetDialogIconNP3(hwnd);
HDC const hdc = GetWindowDC(hwnd);
static HFONT hFontNormal;
if (NULL == (hFontNormal = (HFONT)SendDlgItemMessage(hwnd, 200, WM_GETFONT, 0, 0))) {
hFontNormal = GetStockObject(DEFAULT_GUI_FONT);
hFontNormal = (HFONT)SendDlgItemMessage(hwnd, 200, WM_GETFONT, 0, 0);
if (hFontNormal) {
LOGFONT lf;
GetObject(hFontNormal, sizeof(LOGFONT), &lf);
lf.lfUnderline = true;
//lf.lfWeight = FW_BOLD;
if (hFontHover) {
DeleteObject(hFontHover);
}
hFontHover = CreateFontIndirectW(&lf);
}
else {
NONCLIENTMETRICSW ncMetrics = {0};
ncMetrics.cbSize = sizeof(NONCLIENTMETRICSW);
if (SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICSW), &ncMetrics, 0)) {
int const hoverFontSize = ScaleIntToDPI_Y(hwnd, 10);
//ncMetrics.lfMessageFont.lfWeight = FW_BOLD;
ncMetrics.lfMessageFont.lfUnderline = true;
ncMetrics.lfMessageFont.lfHeight = -MulDiv(hoverFontSize, GetDeviceCaps(hdc, LOGPIXELSY), 72);
if (hFontHover) {
DeleteObject(hFontHover);
}
hFontHover = CreateFontIndirectW(&ncMetrics.lfMessageFont);
}
}
LOGFONT lf;
GetObject(hFontNormal,sizeof(LOGFONT),&lf);
lf.lfUnderline = true;
hFontHover = CreateFontIndirect(&lf);
hCursorNormal = LoadCursor(NULL,IDC_ARROW);
hCursorHover = LoadCursor(NULL,IDC_HAND);
if (!hCursorHover)
if (!hCursorHover) {
hCursorHover = LoadCursor(Globals.hInstance, IDC_ARROW);
}
pdata = (PMODLINESDATA)lParam;
SetDlgItemTextW(hwnd,100,pdata->pwsz1);
SendDlgItemMessage(hwnd,100,EM_LIMITTEXT,255,0);
@ -7987,9 +8006,21 @@ static INT_PTR CALLBACK EditModifyLinesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam
DPI_T dpi;
dpi.x = LOWORD(wParam);
dpi.y = HIWORD(wParam);
hFontNormal = (HFONT)SendDlgItemMessage(hwnd, 200, WM_GETFONT, 0, 0);
if (hFontNormal) {
LOGFONT lf;
GetObject(hFontNormal, sizeof(LOGFONT), &lf);
lf.lfUnderline = true;
//lf.lfWeight = FW_BOLD;
if (hFontHover) {
DeleteObject(hFontHover);
}
hFontHover = CreateFontIndirectW(&lf);
}
UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, &dpi);
}
return true;
return !0;
case WM_DESTROY:
DeleteObject(hFontHover);
@ -8003,7 +8034,7 @@ static INT_PTR CALLBACK EditModifyLinesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam
id_capture = 0;
}
}
return false;
return 0;
case WM_CTLCOLORSTATIC:
{
@ -8018,7 +8049,8 @@ static INT_PTR CALLBACK EditModifyLinesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam
else {
SetTextColor(hdc, RGB(0, 0, 0xFF));
}
SelectObject(hdc,/*dwId == id_hover?*/hFontHover/*:hFontNormal*/);
SelectObject(hdc,hFontHover);
//SelectObject(hdc, (dwId == id_hover) ? hFontHover : hFontNormal);
return (INT_PTR)GetSysColorBrush(COLOR_BTNFACE);
}
}
@ -8045,7 +8077,7 @@ static INT_PTR CALLBACK EditModifyLinesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam
else {
id_hover = 0;
}
SetCursor(id_hover != 0 ? hCursorHover : hCursorNormal);
SetCursor((id_hover != 0) ? hCursorHover : hCursorNormal);
}
}
break;
@ -8062,7 +8094,7 @@ static INT_PTR CALLBACK EditModifyLinesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam
id_hover = dwId;
id_capture = dwId;
}
SetCursor(id_hover != 0?hCursorHover:hCursorNormal);
SetCursor((id_hover != 0) ? hCursorHover : hCursorNormal);
}
break;
@ -8086,7 +8118,7 @@ static INT_PTR CALLBACK EditModifyLinesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam
}
id_capture = 0;
}
SetCursor(id_hover != 0?hCursorHover:hCursorNormal);
SetCursor((id_hover != 0) ? hCursorHover : hCursorNormal);
}
break;
@ -8112,9 +8144,9 @@ static INT_PTR CALLBACK EditModifyLinesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam
EndDialog(hwnd,IDCANCEL);
break;
}
return true;
return !0;
}
return false;
return 0;
}

View File

@ -585,6 +585,10 @@ inline HRESULT PathCchCanonicalize(PWSTR p,size_t l,PCWSTR a) { UNUSED(l); re
inline HRESULT PathCchRenameExtension(PWSTR p,size_t l,PCWSTR a) { UNUSED(l); return (PathRenameExtension(p,a) ? S_OK : E_FAIL); }
inline HRESULT PathCchRemoveFileSpec(PWSTR p,size_t l) { UNUSED(l); return (PathRemoveFileSpec(p) ? S_OK : E_FAIL); }
inline bool IsReadOnly(const DWORD dwFileAttr) {
return ((dwFileAttr != INVALID_FILE_ATTRIBUTES) && (dwFileAttr & FILE_ATTRIBUTE_READONLY));
}
// ----------------------------------------------------------------------------
#endif //_NP3_HELPERS_H_

View File

@ -3702,10 +3702,9 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
else {
InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_READONLY_MODIFY, PathFindFileName(Globals.CurrentFile));
}
dwFileAttributes = GetFileAttributes(Globals.CurrentFile);
s_bFileReadOnly = (dwFileAttributes == INVALID_FILE_ATTRIBUTES) || (dwFileAttributes & FILE_ATTRIBUTE_READONLY);
s_bFileReadOnly = IsReadOnly(GetFileAttributes(Globals.CurrentFile)); // ensure setting
if (Flags.bSettingsFileSoftLocked) {
Globals.bCanSaveIniFile = CanAccessPath(Globals.IniFile, GENERIC_WRITE);
UpdateSaveSettingsCmds();
@ -9348,9 +9347,8 @@ bool FileIO(bool fLoad,LPWSTR pszFileName,
fSuccess = EditSaveFile(Globals.hwndEdit, pszFileName, status, bSaveCopy, bPreserveTimeStamp);
}
DWORD const dwFileAttributes = GetFileAttributes(pszFileName);
s_bFileReadOnly = ((dwFileAttributes == INVALID_FILE_ATTRIBUTES) || (dwFileAttributes & FILE_ATTRIBUTE_READONLY));
s_bFileReadOnly = IsReadOnly(GetFileAttributes(pszFileName));
EndWaitCursor();
return(fSuccess);
@ -9951,8 +9949,7 @@ bool FileSave(bool bSaveAlways, bool bAsk, bool bSaveAs, bool bSaveCopy, bool bP
// Read only...
if (!bSaveAs && !bSaveCopy && StrIsNotEmpty(Globals.CurrentFile))
{
DWORD const dwFileAttributes = GetFileAttributes(Globals.CurrentFile);
s_bFileReadOnly = (dwFileAttributes == INVALID_FILE_ATTRIBUTES) || (dwFileAttributes & FILE_ATTRIBUTE_READONLY);
s_bFileReadOnly = IsReadOnly(GetFileAttributes(Globals.CurrentFile));
if (s_bFileReadOnly) {
INT_PTR const answer = (Settings.MuteMessageBeep) ?
InfoBoxLng(MB_YESNO | MB_ICONWARNING, NULL, IDS_MUI_READONLY_SAVE, PathFindFileName(Globals.CurrentFile)) :

View File

@ -4104,7 +4104,9 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
case WM_PAINT:
{
HDC const hDC = GetWindowDC(hwnd);
HDC const hdc = GetWindowDC(hwnd);
SetMapMode(hdc, MM_TEXT);
DPI_T const dpi = Scintilla_GetWindowDPI(hwnd);
int const iconSize = 64;
@ -4113,23 +4115,25 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
HICON const hicon = (dpiHeight > 128) ? Globals.hDlgIconPrefs256 : ((dpiHeight > 64) ? Globals.hDlgIconPrefs128 : Globals.hDlgIconPrefs64);
if (hicon)
{
DrawIconEx(hDC, ScaleIntByDPI(340, dpi.x), ScaleIntByDPI(62, dpi.x), hicon, dpiWidth, dpiHeight, 0, NULL, DI_NORMAL);
DrawIconEx(hdc, ScaleIntByDPI(340, dpi.x), ScaleIntByDPI(62, dpi.x), hicon, dpiWidth, dpiHeight, 0, NULL, DI_NORMAL);
}
// Set title font
if (hFontTitle) { DeleteObject(hFontTitle); }
hFontTitle = GetStockObject(DEFAULT_GUI_FONT);
LOGFONT lf; GetObject(hFontTitle, sizeof(LOGFONT), &lf);
int const newWidth = -MulDiv(MulDiv(lf.lfWidth,3,2), GetDeviceCaps(hDC, LOGPIXELSX), 72);
int const newHeight = -MulDiv(MulDiv(lf.lfHeight,3,2), GetDeviceCaps(hDC, LOGPIXELSY), 72);
lf.lfWeight = FW_BOLD;
lf.lfWidth = ScaleIntByDPI(newWidth, dpi.x); // =0: the aspect ratio of the device is matched against the digitization aspect ratio of the available fonts
lf.lfHeight = ScaleIntByDPI(newHeight, dpi.y);
//~StringCchCopy(lf.lfFaceName, LF_FACESIZE, L"Tahoma");
hFontTitle = CreateFontIndirect(&lf);
SendDlgItemMessage(hwnd, IDC_TITLE, WM_SETFONT, (WPARAM)hFontTitle, true);
NONCLIENTMETRICSW ncMetrics = {0};
ncMetrics.cbSize = sizeof(NONCLIENTMETRICSW);
if (SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICSW), &ncMetrics, 0))
{
if (hFontTitle) {
DeleteObject(hFontTitle);
}
int const verFontSize = ScaleIntByDPI(16, dpi.y);
ncMetrics.lfMessageFont.lfWeight = FW_BOLD;
ncMetrics.lfMessageFont.lfHeight = -MulDiv(verFontSize, GetDeviceCaps(hdc, LOGPIXELSY), 72);
hFontTitle = CreateFontIndirectW(&ncMetrics.lfMessageFont);
SendDlgItemMessage(hwnd, IDC_TITLE, WM_SETFONT, (WPARAM)hFontTitle, true);
}
ReleaseDC(hwnd, hDC);
ReleaseDC(hwnd, hdc);
}
return 0;