Skip to content

Commit c6ccb92

Browse files
authored
[KBSWITCH] Fix keyboard indicator text and font (reactos#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
1 parent 5f4bb73 commit c6ccb92

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

base/applications/kbswitch/kbswitch.c

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -147,35 +147,43 @@ static HICON
147147
CreateTrayIcon(LPTSTR szLCID)
148148
{
149149
LANGID LangID;
150-
TCHAR szBuf[3];
150+
TCHAR szBuf[4];
151151
HDC hdc;
152152
HBITMAP hbmColor, hbmMono, hBmpOld;
153153
RECT rect;
154154
HFONT hFontOld, hFont;
155155
ICONINFO IconInfo;
156156
HICON hIcon;
157157
LOGFONT lf;
158+
BITMAPINFO bmi;
158159

159160
/* Getting "EN", "FR", etc. from English, French, ... */
160-
LangID = (LANGID)_tcstoul(szLCID, NULL, 16);
161-
if (!GetLocaleInfo(LangID, LOCALE_SISO639LANGNAME, szBuf, ARRAYSIZE(szBuf)))
161+
LangID = LOWORD(_tcstoul(szLCID, NULL, 16));
162+
if (!GetLocaleInfo(LangID, LOCALE_SABBREVLANGNAME | LOCALE_NOUSEROVERRIDE,
163+
szBuf, ARRAYSIZE(szBuf)))
162164
{
163165
StringCchCopy(szBuf, ARRAYSIZE(szBuf), _T("??"));
164166
}
165-
CharUpper(szBuf);
167+
szBuf[2] = 0; /* Truncate the identifiers to two characters: "ENG" --> "EN" etc. */
168+
169+
/* Prepare for DIB (device-independent bitmap) */
170+
ZeroMemory(&bmi, sizeof(bmi));
171+
bmi.bmiHeader.biSize = sizeof(bmi.bmiHeader);
172+
bmi.bmiHeader.biWidth = CX_ICON;
173+
bmi.bmiHeader.biHeight = CY_ICON;
174+
bmi.bmiHeader.biPlanes = 1;
175+
bmi.bmiHeader.biBitCount = 24;
166176

167177
/* Create hdc, hbmColor and hbmMono */
168178
hdc = CreateCompatibleDC(NULL);
169-
hbmColor = CreateCompatibleBitmap(hdc, CX_ICON, CY_ICON);
179+
hbmColor = CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, NULL, NULL, 0);
170180
hbmMono = CreateBitmap(CX_ICON, CY_ICON, 1, 1, NULL);
171181

172182
/* Create a font */
173-
ZeroMemory(&lf, sizeof(lf));
174-
lf.lfHeight = -11;
175-
lf.lfCharSet = ANSI_CHARSET;
176-
lf.lfWeight = FW_NORMAL;
177-
StringCchCopy(lf.lfFaceName, ARRAYSIZE(lf.lfFaceName), _T("Tahoma"));
178-
hFont = CreateFontIndirect(&lf);
183+
if (SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(lf), &lf, 0))
184+
hFont = CreateFontIndirect(&lf);
185+
else
186+
hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
179187

180188
/* Checking NULL */
181189
if (!hdc || !hbmColor || !hbmMono || !hFont)

0 commit comments

Comments
 (0)