mirror of
https://github.com/reactos/reactos.git
synced 2024-07-01 10:20:03 +00:00
[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
This commit is contained in:
parent
5f4bb73eda
commit
c6ccb92bdd
|
@ -147,7 +147,7 @@ static HICON
|
||||||
CreateTrayIcon(LPTSTR szLCID)
|
CreateTrayIcon(LPTSTR szLCID)
|
||||||
{
|
{
|
||||||
LANGID LangID;
|
LANGID LangID;
|
||||||
TCHAR szBuf[3];
|
TCHAR szBuf[4];
|
||||||
HDC hdc;
|
HDC hdc;
|
||||||
HBITMAP hbmColor, hbmMono, hBmpOld;
|
HBITMAP hbmColor, hbmMono, hBmpOld;
|
||||||
RECT rect;
|
RECT rect;
|
||||||
|
@ -155,27 +155,35 @@ CreateTrayIcon(LPTSTR szLCID)
|
||||||
ICONINFO IconInfo;
|
ICONINFO IconInfo;
|
||||||
HICON hIcon;
|
HICON hIcon;
|
||||||
LOGFONT lf;
|
LOGFONT lf;
|
||||||
|
BITMAPINFO bmi;
|
||||||
|
|
||||||
/* Getting "EN", "FR", etc. from English, French, ... */
|
/* Getting "EN", "FR", etc. from English, French, ... */
|
||||||
LangID = (LANGID)_tcstoul(szLCID, NULL, 16);
|
LangID = LOWORD(_tcstoul(szLCID, NULL, 16));
|
||||||
if (!GetLocaleInfo(LangID, LOCALE_SISO639LANGNAME, szBuf, ARRAYSIZE(szBuf)))
|
if (!GetLocaleInfo(LangID, LOCALE_SABBREVLANGNAME | LOCALE_NOUSEROVERRIDE,
|
||||||
|
szBuf, ARRAYSIZE(szBuf)))
|
||||||
{
|
{
|
||||||
StringCchCopy(szBuf, ARRAYSIZE(szBuf), _T("??"));
|
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 */
|
/* Create hdc, hbmColor and hbmMono */
|
||||||
hdc = CreateCompatibleDC(NULL);
|
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);
|
hbmMono = CreateBitmap(CX_ICON, CY_ICON, 1, 1, NULL);
|
||||||
|
|
||||||
/* Create a font */
|
/* Create a font */
|
||||||
ZeroMemory(&lf, sizeof(lf));
|
if (SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(lf), &lf, 0))
|
||||||
lf.lfHeight = -11;
|
hFont = CreateFontIndirect(&lf);
|
||||||
lf.lfCharSet = ANSI_CHARSET;
|
else
|
||||||
lf.lfWeight = FW_NORMAL;
|
hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
|
||||||
StringCchCopy(lf.lfFaceName, ARRAYSIZE(lf.lfFaceName), _T("Tahoma"));
|
|
||||||
hFont = CreateFontIndirect(&lf);
|
|
||||||
|
|
||||||
/* Checking NULL */
|
/* Checking NULL */
|
||||||
if (!hdc || !hbmColor || !hbmMono || !hFont)
|
if (!hdc || !hbmColor || !hbmMono || !hFont)
|
||||||
|
|
Loading…
Reference in a new issue