Author: dchapyshev
Date: Thu Oct 30 04:41:37 2008
New Revision: 37085
URL:
http://svn.reactos.org/svn/reactos?rev=37085&view=rev
Log:
- Add getting system font and icon size settings
- Other small changes
Modified:
trunk/reactos/base/applications/kbswitch/kbswitch.c
Modified: trunk/reactos/base/applications/kbswitch/kbswitch.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/kbswitch…
==============================================================================
--- trunk/reactos/base/applications/kbswitch/kbswitch.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/kbswitch/kbswitch.c [iso-8859-1] Thu Oct 30 04:41:37
2008
@@ -24,6 +24,8 @@
HANDLE hProcessHeap;
HMODULE hDllLib;
ULONG ulCurrentLayoutNum = 1;
+UINT cxSmIcon, cySmIcon;
+
static HICON
CreateTrayIcon(LPTSTR szLCID)
@@ -49,18 +51,18 @@
hdcsrc = GetDC(NULL);
hdc = CreateCompatibleDC(hdcsrc);
- hBitmap = CreateCompatibleBitmap(hdcsrc, 16, 16);
+ hBitmap = CreateCompatibleBitmap(hdcsrc, cxSmIcon, cySmIcon);
ReleaseDC(NULL, hdcsrc);
if (hdc && hBitmap)
{
- hBmpNew = CreateBitmap(16, 16, 1, 1, NULL);
+ hBmpNew = CreateBitmap(cxSmIcon, cySmIcon, 1, 1, NULL);
if (hBmpNew)
{
hBmpOld = SelectObject(hdc, hBitmap);
- rect.right = 16;
+ rect.right = cxSmIcon;
rect.left = 0;
- rect.bottom = 16;
+ rect.bottom = cySmIcon;
rect.top = 0;
bkColor = SetBkColor(hdc, GetSysColor(COLOR_HIGHLIGHT));
@@ -68,14 +70,14 @@
ExtTextOut(hdc, rect.left, rect.top, ETO_OPAQUE, &rect, _T(""),
0, NULL);
- hFont = CreateFont(-11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
ANSI_CHARSET,
- OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
- DEFAULT_QUALITY, FF_DONTCARE, _T("Tahoma"));
+ hFont = (HFONT) GetStockObject(DEFAULT_GUI_FONT);
+ if (!hFont)
+ goto End;
hFontOld = SelectObject(hdc, hFont);
DrawText(hdc, _tcsupr(szBuf), 2, &rect,
DT_SINGLELINE|DT_CENTER|DT_VCENTER);
SelectObject(hdc, hBmpNew);
- PatBlt(hdc, 0, 0, 16, 16, BLACKNESS);
+ PatBlt(hdc, 0, 0, cxSmIcon, cySmIcon, BLACKNESS);
SelectObject(hdc, hBmpOld);
SelectObject(hdc, hFontOld);
@@ -84,15 +86,15 @@
IconInfo.fIcon = TRUE;
hIcon = CreateIconIndirect(&IconInfo);
-
- DeleteObject(hBmpNew);
- DeleteObject(hBmpOld);
- DeleteObject(hFont);
- }
- }
-
- DeleteDC(hdc);
- DeleteObject(hBitmap);
+End:
+ if (hBmpNew) DeleteObject(hBmpNew);
+ if (hBmpOld) DeleteObject(hBmpOld);
+ if (hFont) DeleteObject(hFont);
+ }
+ }
+
+ if (hdc) DeleteDC(hdc);
+ if (hBitmap) DeleteObject(hBitmap);
return hIcon;
}
@@ -384,6 +386,23 @@
return -1;
}
+static VOID
+SettingsChanging(HWND hwnd)
+{
+ UINT cxSmIconCur = 0, cySmIconCur = 0;
+
+ cxSmIconCur = GetSystemMetrics(SM_CXSMICON);
+ cySmIconCur = GetSystemMetrics(SM_CYSMICON);
+
+ if ((cxSmIcon != cxSmIconCur) || (cySmIcon != cySmIconCur))
+ {
+ cxSmIcon = cxSmIconCur;
+ cySmIcon = cySmIconCur;
+ }
+
+ ActivateLayout(hwnd, ulCurrentLayoutNum);
+}
+
LRESULT CALLBACK
WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
@@ -394,6 +413,9 @@
{
case WM_CREATE:
{
+ cxSmIcon = GetSystemMetrics(SM_CXSMICON);
+ cySmIcon = GetSystemMetrics(SM_CYSMICON);
+
SetHooks();
AddTrayIcon(hwnd);
hRightPopupMenu = GetSubMenu(LoadMenu(hInst, MAKEINTRESOURCE(IDR_POPUP)),
0);
@@ -489,6 +511,8 @@
case WM_SETTINGCHANGE:
{
+ SettingsChanging(hwnd);
+
if (wParam == SPI_SETDEFAULTINPUTLANG)
{
//FIXME: Should detect default language changes by CPL applet or by other
tools and update UI