https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c6ccb92bdd93116891537e...
commit c6ccb92bdd93116891537e0006e54844bf7e8e81 Author: Katayama Hirofumi MZ katayama.hirofumi.mz@gmail.com AuthorDate: Thu Sep 29 07:32:39 2022 +0900 Commit: GitHub noreply@github.com CommitDate: Thu Sep 29 07:32:39 2022 +0900
[KBSWITCH] Fix keyboard indicator text and font (#4723)
- Do the same behaviour as input.dll in getting indicator text. - Use full color DIB (device-independent bitmap) to improve icon. - Use SPI_GETICONTITLELOGFONT for font. CORE-10667 --- base/applications/kbswitch/kbswitch.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-)
diff --git a/base/applications/kbswitch/kbswitch.c b/base/applications/kbswitch/kbswitch.c index 187661e7d1b..d6d2a513e8d 100644 --- a/base/applications/kbswitch/kbswitch.c +++ b/base/applications/kbswitch/kbswitch.c @@ -147,7 +147,7 @@ static HICON CreateTrayIcon(LPTSTR szLCID) { LANGID LangID; - TCHAR szBuf[3]; + TCHAR szBuf[4]; HDC hdc; HBITMAP hbmColor, hbmMono, hBmpOld; RECT rect; @@ -155,27 +155,35 @@ CreateTrayIcon(LPTSTR szLCID) ICONINFO IconInfo; HICON hIcon; LOGFONT lf; + BITMAPINFO bmi;
/* Getting "EN", "FR", etc. from English, French, ... */ - LangID = (LANGID)_tcstoul(szLCID, NULL, 16); - if (!GetLocaleInfo(LangID, LOCALE_SISO639LANGNAME, szBuf, ARRAYSIZE(szBuf))) + LangID = LOWORD(_tcstoul(szLCID, NULL, 16)); + if (!GetLocaleInfo(LangID, LOCALE_SABBREVLANGNAME | LOCALE_NOUSEROVERRIDE, + szBuf, ARRAYSIZE(szBuf))) { StringCchCopy(szBuf, ARRAYSIZE(szBuf), _T("??")); } - CharUpper(szBuf); + szBuf[2] = 0; /* Truncate the identifiers to two characters: "ENG" --> "EN" etc. */ + + /* Prepare for DIB (device-independent bitmap) */ + ZeroMemory(&bmi, sizeof(bmi)); + bmi.bmiHeader.biSize = sizeof(bmi.bmiHeader); + bmi.bmiHeader.biWidth = CX_ICON; + bmi.bmiHeader.biHeight = CY_ICON; + bmi.bmiHeader.biPlanes = 1; + bmi.bmiHeader.biBitCount = 24;
/* Create hdc, hbmColor and hbmMono */ hdc = CreateCompatibleDC(NULL); - hbmColor = CreateCompatibleBitmap(hdc, CX_ICON, CY_ICON); + hbmColor = CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, NULL, NULL, 0); hbmMono = CreateBitmap(CX_ICON, CY_ICON, 1, 1, NULL);
/* Create a font */ - ZeroMemory(&lf, sizeof(lf)); - lf.lfHeight = -11; - lf.lfCharSet = ANSI_CHARSET; - lf.lfWeight = FW_NORMAL; - StringCchCopy(lf.lfFaceName, ARRAYSIZE(lf.lfFaceName), _T("Tahoma")); - hFont = CreateFontIndirect(&lf); + if (SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(lf), &lf, 0)) + hFont = CreateFontIndirect(&lf); + else + hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
/* Checking NULL */ if (!hdc || !hbmColor || !hbmMono || !hFont)