Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
RatinCN committed Nov 1, 2024
1 parent afdfba6 commit 1b3117f
Show file tree
Hide file tree
Showing 7 changed files with 649 additions and 24 deletions.
26 changes: 15 additions & 11 deletions Source/KNSoft.MakeLifeEasier/Main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#pragma region I18N Support

static _Interlocked_operand_ LONG volatile g_I18N_Init = FALSE;
static PS_RUNONCE g_I18N_Init = PS_RUNONCE_INIT;

static
_Function_class_(SYS_ENUM_PREFERRED_LANGUAGES_FN)
Expand All @@ -16,19 +16,19 @@ Mlep_EnumPreferredLang(
}

static
FORCEINLINE
VOID
Mlep_InitializeI18N(VOID)
{
/* Initialize once */
if (_InterlockedCompareExchange(&g_I18N_Init, TRUE, FALSE) != FALSE)
if (PS_RunOnceBegin(&g_I18N_Init))
{
return;
}

/* Select preferred language */
if (Sys_EnumPreferredLanguages(Mlep_EnumPreferredLang) != STATUS_SUCCESS)
{
Precomp4C_I18N_SetCurrentLocale(&Precomp4C_I18N_Table_All, NULL);
/* Choose system preferred language */
if (Sys_EnumPreferredLanguages(Mlep_EnumPreferredLang) != STATUS_SUCCESS)
{
/* Fallback to the default */
Precomp4C_I18N_SetCurrentLocale(&Precomp4C_I18N_Table_All, NULL);
}
PS_RunOnceEnd(&g_I18N_Init, TRUE);
}
}

Expand Down Expand Up @@ -58,6 +58,7 @@ Mlep_DlgBox(
INT_PTR DlgRet;
DPI_AWARENESS_CONTEXT DPIContext;

/* Access resource embedded by KNSoft.Precomp4C */
if (!Precomp4C_Res2C_AccessResource(Precomp4C_Res2C_Resource_Embedded,
ARRAYSIZE(Precomp4C_Res2C_Resource_Embedded),
MAKEINTRESOURCEW(RT_DIALOG),
Expand All @@ -68,9 +69,13 @@ Mlep_DlgBox(
{
return ERROR_RESOURCE_DATA_NOT_FOUND;
}

/* All dialog boxes are DPI awared */
DPIContext = UI_EnableDPIAwareContext();
DlgRet = DialogBoxIndirectParamW((HINSTANCE)&__ImageBase, Res, Owner, DlgProc, InitParam);
UI_RestoreDPIAwareContext(DPIContext);

/* Handle return code */
if (DlgRet == -1)
{
Ret = NtGetLastError();
Expand All @@ -82,7 +87,6 @@ Mlep_DlgBox(
}
Ret = ERROR_SUCCESS;
}

return Ret;
}

Expand Down
2 changes: 1 addition & 1 deletion Source/KNSoft.MakeLifeEasier/MakeLifeEasier.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* KNSoft.MakeLifeEasier (https://github.com/KNSoft/KNSoft.MakeLifeEasier)
* Copyright (c) KNSoft.org (https://github.com/KNSoft). All rights reserved.
* Licensed under the MIT license.
*
*
* A fast, stable and convenient C/C++ library
* to "Make Life Easier" when suffering from Windows NT development.
*/
Expand Down
5 changes: 4 additions & 1 deletion Source/KNSoft.MakeLifeEasier/MakeLifeEasier.inl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
#include "Resource.Embedded.rc.g.h"
#include "I18N.xml.g.h"

EXTERN_C
EXTERN_C_START

PCWSTR
Mlep_GetString(
_In_ INT Index);
Expand All @@ -37,3 +38,5 @@ Mlep_DlgBox(
_In_opt_ DLGPROC DlgProc,
_In_opt_ LPARAM InitParam,
_Out_opt_ PINT_PTR Result);

EXTERN_C_END
Loading

0 comments on commit 1b3117f

Please sign in to comment.