Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
RatinCN committed Oct 12, 2024
1 parent ed9caec commit c68bd41
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 114 deletions.
60 changes: 29 additions & 31 deletions Source/KNSoft.MakeLifeEasier/UI/DPI.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ UI_DPIScaleDialog(

#define UI_DIALOG_DPISCALE_PROP L"KNSoft.MakeLifeEasier.UI.DialogDPIScale"

static
W32ERROR
NTAPI
UI_InitializeDialogDPIScale(
Expand Down Expand Up @@ -274,46 +275,19 @@ UI_InitializeDialogDPIScale(
DPIUpdateInfo.DPIInfo = DPIInfo;
UI_EnumChildWindows(Dialog, UI_DPIScaleDialog_EnumChild_Proc, (LPARAM)&DPIUpdateInfo);

UI_Redraw(Dialog);
DPIInfo->DPIX = DPIUpdateInfo.NewDPIX;
DPIInfo->DPIY = DPIUpdateInfo.NewDPIY;
return SetPropW(Dialog, UI_DIALOG_DPISCALE_PROP, (HANDLE)DPIInfo) ? ERROR_SUCCESS : NtGetLastError();
}

_Success_(return != NULL)
_Ret_maybenull_
PUI_DIALOG_DPI_INFO
NTAPI
UI_GetDialogDPIScaleInfo(
_In_ HWND Dialog)
{
return GetPropW(Dialog, UI_DIALOG_DPISCALE_PROP);
}

VOID
NTAPI
UI_UninitializeDialogDPIScale(
_In_ HWND Dialog)
{
PUI_DIALOG_DPI_INFO DPIInfo;

DPIInfo = GetPropW(Dialog, UI_DIALOG_DPISCALE_PROP);
if (DPIInfo != NULL)
{
if (DPIInfo->Font != NULL)
{
DeleteObject(DPIInfo->Font);
}
Mem_Free(DPIInfo);
RemovePropW(Dialog, UI_DIALOG_DPISCALE_PROP);
}
}

INT_PTR
CALLBACK
UI_DPIScaleDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
if (uMsg == WM_DPICHANGED)
if (uMsg == WM_INITDIALOG)
{
UI_InitializeDialogDPIScale(hDlg);
} else if (uMsg == WM_DPICHANGED)
{
UINT DPIX = LOWORD(wParam), DPIY = HIWORD(wParam);
PUI_DIALOG_DPI_INFO DPIInfo = GetPropW(hDlg, UI_DIALOG_DPISCALE_PROP);
Expand All @@ -333,10 +307,34 @@ UI_DPIScaleDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
}
}
SetWindowLongPtrW(hDlg, DWLP_MSGRESULT, 0);
} else if (uMsg == WM_DESTROY)
{
PUI_DIALOG_DPI_INFO DPIInfo;

DPIInfo = GetPropW(hDlg, UI_DIALOG_DPISCALE_PROP);
if (DPIInfo != NULL)
{
if (DPIInfo->Font != NULL)
{
DeleteObject(DPIInfo->Font);
}
Mem_Free(DPIInfo);
RemovePropW(hDlg, UI_DIALOG_DPISCALE_PROP);
}
}
return 0;
}

_Success_(return != NULL)
_Ret_maybenull_
PUI_DIALOG_DPI_INFO
NTAPI
UI_GetDialogDPIScaleInfo(
_In_ HWND Dialog)
{
return GetPropW(Dialog, UI_DIALOG_DPISCALE_PROP);
}

_Success_(return != NULL)
PVOID
NTAPI
Expand Down
18 changes: 3 additions & 15 deletions Source/KNSoft.MakeLifeEasier/UI/DPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,9 @@ typedef struct _UI_DIALOG_DPI_INFO
} UI_DIALOG_DPI_INFO, *PUI_DIALOG_DPI_INFO;

MLE_API
W32ERROR
NTAPI
UI_InitializeDialogDPIScale(
_In_ HWND Dialog);
INT_PTR
CALLBACK
UI_DPIScaleDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);

MLE_API
_Success_(return != NULL)
Expand All @@ -106,17 +105,6 @@ NTAPI
UI_GetDialogDPIScaleInfo(
_In_ HWND Dialog);

MLE_API
VOID
NTAPI
UI_UninitializeDialogDPIScale(
_In_ HWND Dialog);

MLE_API
INT_PTR
CALLBACK
UI_DPIScaleDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);

MLE_API
_Success_(return != NULL)
PVOID
Expand Down
4 changes: 0 additions & 4 deletions Source/KNSoft.MakeLifeEasier/UI/Dialog/RectEditor.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
HWND hEdit;
PUI_RECTEDITOR_DATA pData = (PUI_RECTEDITOR_DATA)lParam;

UI_InitializeDialogDPIScale(hDlg);
SetWindowLongPtrW(hDlg, DWLP_USER, lParam);
UI_SetWindowTextW(hDlg, Mlep_GetString(Precomp4C_I18N_All_RectangleEditor));

Expand Down Expand Up @@ -113,9 +112,6 @@ DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
pData->Ret = ERROR_CANCELLED;
EndDialog(hDlg, 0);
SetWindowLongPtrW(hDlg, DWLP_MSGRESULT, 0);
} else if (uMsg == WM_DESTROY)
{
UI_UninitializeDialogDPIScale(hDlg);
}
return 0;
}
Expand Down
Loading

0 comments on commit c68bd41

Please sign in to comment.