ReactOS 0.4.16-dev-2216-ga08d639
kbswitch.c File Reference
#include "kbswitch.h"
#include <shlobj.h>
#include <shlwapi_undoc.h>
#include <undocuser.h>
#include <imm.h>
#include <immdev.h>
#include <imm32_undoc.h>
#include <assert.h>
#include "imemenu.h"
#include <wine/debug.h>
Include dependency graph for kbswitch.c:

Go to the source code of this file.

Classes

struct  tagSPECIAL_ID
 
struct  tagLOAD_ICON
 

Macros

#define WM_NOTIFYICONMSG   0x8064
 
#define WM_PENICONMSG   0x8065
 
#define NOTIFY_ICON_ID_LANGUAGE   223
 
#define NOTIFY_ICON_ID_SYSTEM_PEN   224
 
#define TIMER_ID_LANG_CHANGED_DELAYED   0x10000
 
#define TIMER_LANG_CHANGED_DELAY   200
 
#define IME_HKL_MASK   0xF000FFFF
 
#define IS_KOREAN_IME_HKL(hKL)   ((HandleToUlong(hKL) & IME_HKL_MASK) == 0xE0000412)
 
#define MAX_KLS   64
 
#define LAYOUTF_FAR_EAST   0x1
 
#define LAYOUTF_IME_ICON   0x2
 
#define LAYOUTF_TOOLTIP_ATOM   0x4
 
#define LAYOUTF_REMOVE_LEFT_DEF_MENU   0x8
 
#define LAYOUTF_REMOVE_RIGHT_DEF_MENU   0x10
 
#define MAX_SPECIAL_IDS   256
 
#define IFN_KbSwitchSetHooks   1
 
#define IFN_SetPenMenuData   14
 

Typedefs

typedef BOOL(APIENTRYFN_KbSwitchSetHooks) (BOOL bDoHook)
 
typedef VOID(APIENTRYFN_SetPenMenuData) (UINT nID, DWORD_PTR dwItemData)
 
typedef struct tagSPECIAL_ID SPECIAL_ID
 
typedef struct tagSPECIAL_IDPSPECIAL_ID
 
typedef struct tagLOAD_ICON LOAD_ICON
 
typedef struct tagLOAD_ICONPLOAD_ICON
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (internat)
 
static BOOL IsImeOpen (HWND hwndIme)
 
static DWORD GetImeConversionMode (HWND hwndIme)
 
static VOID UpdateTrayInfo (VOID)
 
static VOID LoadSpecialIds (VOID)
 
static VOID GetKLIDFromHKL (HKL hKL, LPTSTR szKLID, SIZE_T KLIDLength)
 
static HWND GetTargetWindow (HWND hwndFore OPTIONAL)
 
static HKL GetActiveKL (VOID)
 
static VOID DeletePenIcon (HWND hwnd, UINT iKL)
 
static VOID DestroyPenIcons (VOID)
 
static UINT GetLayoutIndexFromHKL (HKL hKL)
 
static VOID UpdateLayoutList (HKL hKL OPTIONAL)
 
static HKL GetHKLFromLayoutNum (UINT iKL)
 
static VOID GetKLIDFromLayoutNum (UINT iKL, LPTSTR szKLID, SIZE_T KLIDLength)
 
static BOOL GetSystemLibraryPath (LPTSTR szPath, SIZE_T cchPath, LPCTSTR FileName)
 
static BOOL GetLayoutName (UINT iKL, LPTSTR szName, SIZE_T NameLength)
 
static BOOL GetImeFile (LPTSTR szImeFile, SIZE_T cchImeFile, LPCTSTR szKLID)
 
static BOOL CALLBACK EnumResNameProc (HMODULE hModule, LPCTSTR lpszType, LPTSTR lpszName, LPARAM lParam)
 
static HICON FakeExtractIcon (PCTSTR pszImeFile, INT nIconIndex)
 
static HBITMAP BitmapFromIcon (HICON hIcon)
 
static DWORD GetImeStatus (HWND hwndTarget)
 
static HICON LoadDefaultPenIcon (PCWSTR szImeFile, HKL hKL)
 
static VOID DeletePenNotifyIcon (HWND hwnd)
 
static VOID UpdatePenIcon (HWND hwnd, UINT iKL)
 
static HICON CreateTrayIcon (LPTSTR szKLID, LPCTSTR szImeFile OPTIONAL)
 
static VOID AddTrayIcon (HWND hwnd)
 
static VOID DeleteTrayIcon (HWND hwnd)
 
static VOID UpdateTrayIcon (HWND hwnd, LPTSTR szKLID, LPTSTR szName)
 
static BOOL CALLBACK EnumWindowsProc (HWND hwnd, LPARAM lParam)
 
static VOID ActivateLayout (HWND hwnd, UINT iKL, HWND hwndTarget OPTIONAL, BOOL bNoActivate)
 
static HMENU BuildLeftPopupMenu (VOID)
 
static BOOL SetHooks (VOID)
 
static VOID DeleteHooks (VOID)
 
static UINT GetLayoutNum (HKL hKL)
 
UINT UpdateLanguageDisplay (HWND hwnd, HKL hKL)
 
UINT UpdateLanguageDisplayCurrent (HWND hwnd, HWND hwndFore)
 
static BOOL RememberLastActive (HWND hwnd, HWND hwndFore)
 
static INT KbSwitch_OnCreate (HWND hwnd)
 
static void KbSwitch_OnDestroy (HWND hwnd)
 
static void KbSwitch_OnTimer (HWND hwnd, UINT_PTR nTimerID)
 
static void KbSwitch_OnNotifyIconMsg (HWND hwnd, UINT uMouseMsg)
 
static BOOL IsRegImeToolbarShown (VOID)
 
static VOID ShowImeToolbar (HWND hwndTarget, BOOL bShowToolbar)
 
static VOID KbSwitch_OnPenIconMsg (HWND hwnd, UINT uMouseMsg)
 
static void KbSwitch_OnCommand (HWND hwnd, UINT nID)
 
static LRESULT KbSwitch_OnLangChanged (HWND hwnd, HWND hwndTarget OPTIONAL, HKL hKL OPTIONAL)
 
static LRESULT KbSwitch_OnWindowActivate (HWND hwnd, HWND hwndTarget OPTIONAL, LPARAM lParam OPTIONAL)
 
static void KbSwitch_OnSettingChange (HWND hwnd, WPARAM wParam, LPARAM lParam)
 
static LRESULT KbSwitch_OnDefault (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static VOID OnIndicatorMsg (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
LRESULT CALLBACK WndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
INT WINAPI _tWinMain (HINSTANCE hInstance, HINSTANCE hPrevInst, LPTSTR lpCmdLine, INT nCmdShow)
 

Variables

FN_KbSwitchSetHooks KbSwitchSetHooks = NULL
 
FN_SetPenMenuData SetPenMenuData = NULL
 
HINSTANCE g_hInst = NULL
 
HMODULE g_hHookDLL = NULL
 
HICON g_hTrayIcon = NULL
 
HWND g_hwndLastActive = NULL
 
UINT g_iKL = 0
 
UINT g_cKLs = 0
 
HKL g_ahKLs [MAX_KLS] = { NULL }
 
WORD g_aiSysPenIcons [MAX_KLS] = { 0 }
 
WORD g_anToolTipAtoms [MAX_KLS] = { 0 }
 
HICON g_ahSysPenIcons [MAX_KLS] = { NULL }
 
BOOL g_bSysPenNotifyAdded = FALSE
 
BYTE g_anFlags [MAX_KLS] = { 0 }
 
UINT g_uTaskbarRestartMsg = 0
 
UINT g_uShellHookMessage = 0
 
HWND g_hTrayWnd = NULL
 
HWND g_hTrayNotifyWnd = NULL
 
SPECIAL_ID g_SpecialIds [MAX_SPECIAL_IDS]
 
INT g_cSpecialIds = 0
 

Macro Definition Documentation

◆ IFN_KbSwitchSetHooks

#define IFN_KbSwitchSetHooks   1

Definition at line 854 of file kbswitch.c.

◆ IFN_SetPenMenuData

#define IFN_SetPenMenuData   14

Definition at line 855 of file kbswitch.c.

◆ IME_HKL_MASK

#define IME_HKL_MASK   0xF000FFFF

Definition at line 45 of file kbswitch.c.

◆ IS_KOREAN_IME_HKL

#define IS_KOREAN_IME_HKL (   hKL)    ((HandleToUlong(hKL) & IME_HKL_MASK) == 0xE0000412)

Definition at line 46 of file kbswitch.c.

◆ LAYOUTF_FAR_EAST

#define LAYOUTF_FAR_EAST   0x1

Definition at line 74 of file kbswitch.c.

◆ LAYOUTF_IME_ICON

#define LAYOUTF_IME_ICON   0x2

Definition at line 75 of file kbswitch.c.

◆ LAYOUTF_REMOVE_LEFT_DEF_MENU

#define LAYOUTF_REMOVE_LEFT_DEF_MENU   0x8

Definition at line 77 of file kbswitch.c.

◆ LAYOUTF_REMOVE_RIGHT_DEF_MENU

#define LAYOUTF_REMOVE_RIGHT_DEF_MENU   0x10

Definition at line 78 of file kbswitch.c.

◆ LAYOUTF_TOOLTIP_ATOM

#define LAYOUTF_TOOLTIP_ATOM   0x4

Definition at line 76 of file kbswitch.c.

◆ MAX_KLS

#define MAX_KLS   64

Definition at line 48 of file kbswitch.c.

◆ MAX_SPECIAL_IDS

#define MAX_SPECIAL_IDS   256

Definition at line 106 of file kbswitch.c.

◆ NOTIFY_ICON_ID_LANGUAGE

#define NOTIFY_ICON_ID_LANGUAGE   223

Definition at line 39 of file kbswitch.c.

◆ NOTIFY_ICON_ID_SYSTEM_PEN

#define NOTIFY_ICON_ID_SYSTEM_PEN   224

Definition at line 40 of file kbswitch.c.

◆ TIMER_ID_LANG_CHANGED_DELAYED

#define TIMER_ID_LANG_CHANGED_DELAYED   0x10000

Definition at line 42 of file kbswitch.c.

◆ TIMER_LANG_CHANGED_DELAY

#define TIMER_LANG_CHANGED_DELAY   200

Definition at line 43 of file kbswitch.c.

◆ WM_NOTIFYICONMSG

#define WM_NOTIFYICONMSG   0x8064

Definition at line 36 of file kbswitch.c.

◆ WM_PENICONMSG

#define WM_PENICONMSG   0x8065

Definition at line 37 of file kbswitch.c.

Typedef Documentation

◆ FN_KbSwitchSetHooks

typedef BOOL(APIENTRY * FN_KbSwitchSetHooks) (BOOL bDoHook)

Definition at line 50 of file kbswitch.c.

◆ FN_SetPenMenuData

typedef VOID(APIENTRY * FN_SetPenMenuData) (UINT nID, DWORD_PTR dwItemData)

Definition at line 51 of file kbswitch.c.

◆ LOAD_ICON

◆ PLOAD_ICON

◆ PSPECIAL_ID

◆ SPECIAL_ID

Function Documentation

◆ _tWinMain()

INT WINAPI _tWinMain ( HINSTANCE  hInstance,
HINSTANCE  hPrevInst,
LPTSTR  lpCmdLine,
INT  nCmdShow 
)

Definition at line 1471 of file kbswitch.c.

1472{
1474 MSG msg;
1475 HANDLE hMutex;
1476 HWND hwnd;
1477
1478 switch (GetUserDefaultUILanguage())
1479 {
1481 TRACE("LAYOUT_RTL\n");
1483 break;
1484 default:
1485 break;
1486 }
1487
1489 if (!hMutex)
1490 {
1491 ERR("!hMutex\n");
1492 return 1;
1493 }
1494
1496 {
1497 ERR("Another instance is already running\n");
1499 return 1;
1500 }
1501
1503
1504 ZeroMemory(&WndClass, sizeof(WndClass));
1505 WndClass.lpfnWndProc = WndProc;
1506 WndClass.hInstance = hInstance;
1507 WndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
1508 WndClass.lpszClassName = INDICATOR_CLASS;
1509 if (!RegisterClass(&WndClass))
1510 {
1512 return 1;
1513 }
1514
1518 {
1519 ERR("RegisterShellHookWindow failed\n");
1522 return 1;
1523 }
1524
1525 while (GetMessage(&msg, NULL, 0, 0))
1526 {
1529 }
1530
1532 return 0;
1533}
#define msg(x)
Definition: auth_time.c:54
#define ERR(fmt,...)
Definition: precomp.h:57
WCHAR WndClass[]
Definition: capicon.c:23
HINSTANCE hInstance
Definition: charmap.c:19
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
LANGID WINAPI GetUserDefaultUILanguage(void)
Definition: locale.c:1380
#define L(x)
Definition: resources.c:13
#define INDICATOR_CLASS
Definition: indicml.h:19
UINT g_uShellHookMessage
Definition: kbswitch.c:69
LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: kbswitch.c:1412
HINSTANCE g_hInst
Definition: kbswitch.c:56
#define ZeroMemory
Definition: minwinbase.h:31
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
HANDLE hMutex
Definition: mutex.c:11
#define MAKELANGID(p, s)
Definition: nls.h:15
#define LANG_HEBREW
Definition: nls.h:67
#define SUBLANG_DEFAULT
Definition: nls.h:168
#define TRACE(s)
Definition: solgame.cpp:4
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
BOOL WINAPI SetProcessDefaultLayout(DWORD dwDefaultLayout)
Definition: window.c:1689
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define CreateMutex
Definition: winbase.h:3505
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define LAYOUT_RTL
Definition: wingdi.h:1371
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI RegisterShellHookWindow(_In_ HWND)
#define IDC_ARROW
Definition: winuser.h:695
#define CreateWindow
Definition: winuser.h:5865
#define HWND_DESKTOP
Definition: winuser.h:1220
#define GetMessage
Definition: winuser.h:5901
#define RegisterWindowMessage
Definition: winuser.h:5951
#define LoadCursor
Definition: winuser.h:5923
#define RegisterClass
Definition: winuser.h:5947
#define DispatchMessage
Definition: winuser.h:5876
BOOL WINAPI DestroyWindow(_In_ HWND)

◆ ActivateLayout()

static VOID ActivateLayout ( HWND  hwnd,
UINT  iKL,
HWND hwndTarget  OPTIONAL,
BOOL  bNoActivate 
)
static

Definition at line 779 of file kbswitch.c.

780{
781 HKL hKl;
782 TCHAR szKLID[CCH_LAYOUT_ID + 1], szLangName[MAX_PATH];
784
785 if (iKL >= g_cKLs) /* Invalid */
786 return;
787
788 GetKLIDFromLayoutNum(iKL, szKLID, _countof(szKLID));
789 LangID = (LANGID)_tcstoul(szKLID, NULL, 16);
790
791 /* Switch to the new keyboard layout */
792 GetLocaleInfo(LangID, LOCALE_SLANGUAGE, szLangName, _countof(szLangName));
793 UpdateTrayIcon(hwnd, szKLID, szLangName);
794
795 if (hwndTarget && !bNoActivate)
796 SetForegroundWindow(hwndTarget);
797
798 hKl = LoadKeyboardLayout(szKLID, KLF_ACTIVATE);
799 if (hKl)
801
802 /* Post WM_INPUTLANGCHANGEREQUEST */
803 if (hwndTarget)
804 {
805 PostMessage(hwndTarget, WM_INPUTLANGCHANGEREQUEST,
806 INPUTLANGCHANGE_SYSCHARSET, (LPARAM)hKl);
807 }
808 else
809 {
811 }
812
813 g_iKL = iKL;
814}
#define MAX_PATH
Definition: compat.h:34
#define _tcstoul
Definition: tchar.h:595
static BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
Definition: kbswitch.c:772
static VOID UpdateTrayIcon(HWND hwnd, LPTSTR szKLID, LPTSTR szName)
Definition: kbswitch.c:750
static VOID GetKLIDFromLayoutNum(UINT iKL, LPTSTR szKLID, SIZE_T KLIDLength)
Definition: kbswitch.c:320
UINT g_cKLs
Definition: kbswitch.c:61
UINT g_iKL
Definition: kbswitch.c:60
#define CCH_LAYOUT_ID
Definition: kbswitch.h:18
USHORT LANGID
Definition: mui.h:9
LONG_PTR LPARAM
Definition: minwindef.h:175
UINT_PTR HKL
Definition: msctf.idl:125
#define _countof(array)
Definition: sndvol32.h:70
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_writes_opt_ NumCharacters PUSHORT _Inout_ PUSHORT _In_ UCHAR _In_opt_ USHORT LangID
Definition: wdfusb.h:1083
#define GetLocaleInfo
Definition: winnls.h:1358
#define LOCALE_SLANGUAGE
Definition: winnls.h:31
#define KLF_SETFORPROCESS
Definition: winuser.h:117
#define KLF_ACTIVATE
Definition: winuser.h:111
BOOL WINAPI SetForegroundWindow(_In_ HWND)
#define LoadKeyboardLayout
Definition: winuser.h:5927
BOOL WINAPI EnumWindows(_In_ WNDENUMPROC lpEnumFunc, _In_ LPARAM lParam)
#define PostMessage
Definition: winuser.h:5943
HKL WINAPI ActivateKeyboardLayout(_In_ HKL, _In_ UINT)
char TCHAR
Definition: xmlstorage.h:189

Referenced by KbSwitch_OnCommand(), and KbSwitch_OnCreate().

◆ AddTrayIcon()

static VOID AddTrayIcon ( HWND  hwnd)
static

Definition at line 711 of file kbswitch.c.

712{
713 NOTIFYICONDATA tnid =
714 {
716 };
717 TCHAR szKLID[CCH_LAYOUT_ID + 1], szName[MAX_PATH], szImeFile[80];
718
719 GetKLIDFromLayoutNum(g_iKL, szKLID, _countof(szKLID));
721 GetImeFile(szImeFile, _countof(szImeFile), szKLID);
722
724 tnid.hIcon = CreateTrayIcon(szKLID, szImeFile);
726
727 if (!Shell_NotifyIcon(NIM_ADD, &tnid))
728 ERR("Shell_NotifyIcon(NIM_ADD) failed\n");
729
730 if (g_hTrayIcon)
732 g_hTrayIcon = tnid.hIcon;
733}
static BOOL GetLayoutName(UINT iKL, LPTSTR szName, SIZE_T NameLength)
Definition: kbswitch.c:337
#define NOTIFY_ICON_ID_LANGUAGE
Definition: kbswitch.c:39
static HICON CreateTrayIcon(LPTSTR szKLID, LPCTSTR szImeFile OPTIONAL)
Definition: kbswitch.c:614
static BOOL GetImeFile(LPTSTR szImeFile, SIZE_T cchImeFile, LPCTSTR szKLID)
Definition: kbswitch.c:373
HICON g_hTrayIcon
Definition: kbswitch.c:58
#define WM_NOTIFYICONMSG
Definition: kbswitch.c:36
static const WCHAR szName[]
Definition: powrprof.c:45
#define NIF_ICON
Definition: shellapi.h:106
#define NIF_MESSAGE
Definition: shellapi.h:105
#define NIM_ADD
Definition: shellapi.h:94
#define Shell_NotifyIcon
Definition: shellapi.h:730
#define NIF_TIP
Definition: shellapi.h:107
#define StringCchCopy
Definition: strsafe.h:139
UINT uCallbackMessage
Definition: shellapi.h:231
CHAR szTip[128]
Definition: shellapi.h:237
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2405

Referenced by KbSwitch_OnCreate(), and KbSwitch_OnDefault().

◆ BitmapFromIcon()

static HBITMAP BitmapFromIcon ( HICON  hIcon)
static

Definition at line 454 of file kbswitch.c.

455{
456 HDC hdcScreen = GetDC(NULL);
457 HDC hdc = CreateCompatibleDC(hdcScreen);
460 HBITMAP hbm = CreateCompatibleBitmap(hdcScreen, cxIcon, cyIcon);
461 HGDIOBJ hbmOld;
462
463 if (hbm != NULL)
464 {
465 hbmOld = SelectObject(hdc, hbm);
466 DrawIconEx(hdc, 0, 0, hIcon, cxIcon, cyIcon, 0, GetSysColorBrush(COLOR_MENU), DI_NORMAL);
467 SelectObject(hdc, hbmOld);
468 }
469
470 DeleteDC(hdc);
471 ReleaseDC(NULL, hdcScreen);
472 return hbm;
473}
HDC hdc
Definition: main.c:9
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:88
HICON hIcon
Definition: msconfig.c:44
_In_ HBITMAP hbm
Definition: ntgdi.h:2776
int32_t INT
Definition: typedefs.h:58
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
#define DI_NORMAL
Definition: wingdi.h:72
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
BOOL WINAPI DeleteDC(_In_ HDC)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define COLOR_MENU
Definition: winuser.h:928
HBRUSH WINAPI GetSysColorBrush(_In_ int)
#define SM_CYSMICON
Definition: winuser.h:1024
#define SM_CXSMICON
Definition: winuser.h:1023
BOOL WINAPI DrawIconEx(_In_ HDC, _In_ int, _In_ int, _In_ HICON, _In_ int, _In_ int, _In_ UINT, _In_opt_ HBRUSH, _In_ UINT)
Definition: cursoricon.c:2380
HDC WINAPI GetDC(_In_opt_ HWND)
int WINAPI GetSystemMetrics(_In_ int)

Referenced by BuildLeftPopupMenu(), and FileTypesDlg_OnItemChanging().

◆ BuildLeftPopupMenu()

static HMENU BuildLeftPopupMenu ( VOID  )
static

Definition at line 817 of file kbswitch.c.

818{
819 HMENU hMenu = CreatePopupMenu();
820 TCHAR szName[MAX_PATH], szKLID[CCH_LAYOUT_ID + 1], szImeFile[80];
821 HICON hIcon;
822 MENUITEMINFO mii = { sizeof(mii) };
823 UINT iKL;
824
825 for (iKL = 0; iKL < g_cKLs; ++iKL)
826 {
827 GetKLIDFromHKL(g_ahKLs[iKL], szKLID, _countof(szKLID));
828 GetImeFile(szImeFile, _countof(szImeFile), szKLID);
829
830 if (!GetLayoutName(iKL, szName, _countof(szName)))
831 continue;
832
833 mii.fMask = MIIM_ID | MIIM_STRING;
834 mii.wID = ID_LANG_BASE + iKL;
835 mii.dwTypeData = szName;
836
837 hIcon = CreateTrayIcon(szKLID, szImeFile);
838 if (hIcon)
839 {
840 mii.hbmpItem = BitmapFromIcon(hIcon);
841 if (mii.hbmpItem)
842 mii.fMask |= MIIM_BITMAP;
843 }
844
845 InsertMenuItem(hMenu, -1, TRUE, &mii);
847 }
848
850
851 return hMenu;
852}
#define ID_LANG_BASE
Definition: resource.h:24
#define TRUE
Definition: types.h:120
static HBITMAP BitmapFromIcon(HICON hIcon)
Definition: kbswitch.c:454
static VOID GetKLIDFromHKL(HKL hKL, LPTSTR szKLID, SIZE_T KLIDLength)
Definition: kbswitch.c:164
HKL g_ahKLs[MAX_KLS]
Definition: kbswitch.c:62
static HICON
Definition: imagelist.c:80
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
unsigned int UINT
Definition: ndis.h:50
LPSTR dwTypeData
Definition: winuser.h:3353
HMENU WINAPI CreatePopupMenu(void)
Definition: menu.c:838
#define MIIM_STRING
Definition: winuser.h:738
#define MIIM_ID
Definition: winuser.h:733
#define InsertMenuItem
Definition: winuser.h:5915
#define MF_CHECKED
Definition: winuser.h:132
DWORD WINAPI CheckMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define MIIM_BITMAP
Definition: winuser.h:739

Referenced by KbSwitch_OnNotifyIconMsg().

◆ CreateTrayIcon()

static HICON CreateTrayIcon ( LPTSTR  szKLID,
LPCTSTR szImeFile  OPTIONAL 
)
static

Definition at line 614 of file kbswitch.c.

615{
617 TCHAR szBuf[4];
618 HDC hdcScreen, hdc;
619 HBITMAP hbmColor, hbmMono, hBmpOld;
620 HFONT hFont, hFontOld;
621 LOGFONT lf;
622 RECT rect;
624 HICON hIcon;
628
629 if (szImeFile && szImeFile[0])
630 {
631 if (GetSystemLibraryPath(szPath, _countof(szPath), szImeFile))
632 return FakeExtractIcon(szPath, 0);
633 }
634
635 /* Getting "EN", "FR", etc. from English, French, ... */
636 LangID = LANGIDFROMLCID(_tcstoul(szKLID, NULL, 16));
639 szBuf,
640 _countof(szBuf)) == 0)
641 {
642 szBuf[0] = szBuf[1] = _T('?');
643 }
644 szBuf[2] = 0; /* Truncate the identifier to two characters: "ENG" --> "EN" etc. */
645
646 /* Create hdc, hbmColor and hbmMono */
647 hdcScreen = GetDC(NULL);
648 hdc = CreateCompatibleDC(hdcScreen);
649 hbmColor = CreateCompatibleBitmap(hdcScreen, cxIcon, cyIcon);
650 ReleaseDC(NULL, hdcScreen);
651 hbmMono = CreateBitmap(cxIcon, cyIcon, 1, 1, NULL);
652
653 /* Checking NULL */
654 if (!hdc || !hbmColor || !hbmMono)
655 {
656 if (hbmMono)
657 DeleteObject(hbmMono);
658 if (hbmColor)
659 DeleteObject(hbmColor);
660 if (hdc)
661 DeleteDC(hdc);
662 return NULL;
663 }
664
665 /* Create a font */
666 hFont = NULL;
667 if (SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(lf), &lf, 0))
668 {
669 /* Override the current size with something manageable */
670 lf.lfHeight = -11;
671 lf.lfWidth = 0;
673 }
674 if (!hFont)
676
677 SetRect(&rect, 0, 0, cxIcon, cyIcon);
678
679 /* Draw hbmColor */
680 hBmpOld = SelectObject(hdc, hbmColor);
682 FillRect(hdc, &rect, (HBRUSH)GetStockObject(DC_BRUSH));
683 hFontOld = SelectObject(hdc, hFont);
687 SelectObject(hdc, hFontOld);
688
689 /* Fill hbmMono with black */
690 SelectObject(hdc, hbmMono);
691 PatBlt(hdc, 0, 0, cxIcon, cyIcon, BLACKNESS);
692 SelectObject(hdc, hBmpOld);
693
694 /* Create an icon from hbmColor and hbmMono */
697 IconInfo.hbmColor = hbmColor;
698 IconInfo.hbmMask = hbmMono;
700
701 /* Clean up */
703 DeleteObject(hbmMono);
704 DeleteObject(hbmColor);
705 DeleteDC(hdc);
706
707 return hIcon;
708}
HFONT hFont
Definition: main.c:53
pKey DeleteObject()
_Out_opt_ PICONINFO IconInfo
Definition: ntuser.h:2310
static HICON FakeExtractIcon(PCTSTR pszImeFile, INT nIconIndex)
Definition: kbswitch.c:437
static BOOL GetSystemLibraryPath(LPTSTR szPath, SIZE_T cchPath, LPCTSTR FileName)
Definition: kbswitch.c:326
LPCWSTR szPath
Definition: env.c:37
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
#define LANGIDFROMLCID(l)
Definition: nls.h:18
& rect
Definition: startmenu.cpp:1413
LONG lfHeight
Definition: dimm.idl:42
LONG lfWidth
Definition: dimm.idl:43
DWORD yHotspot
Definition: winuser.h:3227
BOOL fIcon
Definition: winuser.h:3225
DWORD xHotspot
Definition: winuser.h:3226
HBITMAP hbmColor
Definition: winuser.h:3229
HBITMAP hbmMask
Definition: winuser.h:3228
#define _T(x)
Definition: vfdio.h:22
COLORREF WINAPI SetDCBrushColor(_In_ HDC hdc, _In_ COLORREF crColor)
Definition: dc.c:905
#define BLACKNESS
Definition: wingdi.h:323
HGDIOBJ WINAPI GetStockObject(_In_ int)
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)
#define DEFAULT_GUI_FONT
Definition: wingdi.h:909
#define TRANSPARENT
Definition: wingdi.h:950
BOOL WINAPI PatBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1056
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:917
#define CreateFontIndirect
Definition: wingdi.h:4890
#define LOCALE_NOUSEROVERRIDE
Definition: winnls.h:19
#define LOCALE_SABBREVLANGNAME
Definition: winnls.h:34
DWORD WINAPI GetSysColor(_In_ int)
HICON WINAPI CreateIconIndirect(_In_ PICONINFO)
Definition: cursoricon.c:2958
#define DT_CENTER
Definition: winuser.h:527
#define COLOR_HIGHLIGHT
Definition: winuser.h:937
#define DT_SINGLELINE
Definition: winuser.h:540
#define SPI_GETICONTITLELOGFONT
Definition: winuser.h:1391
#define DrawText
Definition: winuser.h:5882
#define COLOR_HIGHLIGHTTEXT
Definition: winuser.h:938
#define DT_VCENTER
Definition: winuser.h:543
#define SystemParametersInfo
Definition: winuser.h:5969
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)

Referenced by AddTrayIcon(), BuildLeftPopupMenu(), and UpdateTrayIcon().

◆ DeleteHooks()

static VOID DeleteHooks ( VOID  )
static

Definition at line 880 of file kbswitch.c.

881{
883 {
886 }
887
888 if (g_hHookDLL)
889 {
892 }
893
894 TRACE("DeleteHooks OK\n");
895}
#define FreeLibrary(x)
Definition: compat.h:748
HMODULE g_hHookDLL
Definition: kbswitch.c:57
FN_KbSwitchSetHooks KbSwitchSetHooks
Definition: kbswitch.c:53

Referenced by KbSwitch_OnDestroy().

◆ DeletePenIcon()

static VOID DeletePenIcon ( HWND  hwnd,
UINT  iKL 
)
static

Definition at line 215 of file kbswitch.c.

216{
218
219 if (g_ahSysPenIcons[iKL])
220 {
222 g_ahSysPenIcons[iKL] = NULL;
223 }
224}
HICON g_ahSysPenIcons[MAX_KLS]
Definition: kbswitch.c:65
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329

Referenced by UpdatePenIcon().

◆ DeletePenNotifyIcon()

static VOID DeletePenNotifyIcon ( HWND  hwnd)
static

Definition at line 551 of file kbswitch.c.

552{
554 return;
555
558 ERR("Shell_NotifyIcon(NIM_DELETE) failed\n");
559 else
561}
BOOL g_bSysPenNotifyAdded
Definition: kbswitch.c:66
#define NOTIFY_ICON_ID_SYSTEM_PEN
Definition: kbswitch.c:40
NOTIFYICONDATA nid
Definition: magnifier.c:44
#define NIM_DELETE
Definition: shellapi.h:96

Referenced by KbSwitch_OnDestroy(), and UpdatePenIcon().

◆ DeleteTrayIcon()

static VOID DeleteTrayIcon ( HWND  hwnd)
static

Definition at line 736 of file kbswitch.c.

737{
738 NOTIFYICONDATA tnid = { sizeof(tnid), hwnd, NOTIFY_ICON_ID_LANGUAGE };
739 if (!Shell_NotifyIcon(NIM_DELETE, &tnid))
740 ERR("Shell_NotifyIcon(NIM_DELETE) failed\n");
741
742 if (g_hTrayIcon)
743 {
746 }
747}

Referenced by KbSwitch_OnDestroy().

◆ DestroyPenIcons()

static VOID DestroyPenIcons ( VOID  )
static

Definition at line 227 of file kbswitch.c.

228{
229 INT iKL;
230 for (iKL = 0; iKL < g_cKLs; ++iKL)
231 {
232 if (g_ahSysPenIcons[iKL])
233 {
235 g_ahSysPenIcons[iKL] = NULL;
236 }
237 }
238}

Referenced by KbSwitch_OnDestroy(), and UpdateLayoutList().

◆ EnumResNameProc()

static BOOL CALLBACK EnumResNameProc ( HMODULE  hModule,
LPCTSTR  lpszType,
LPTSTR  lpszName,
LPARAM  lParam 
)
static

Definition at line 414 of file kbswitch.c.

419{
420 UNREFERENCED_PARAMETER(lpszType);
421
422 PLOAD_ICON pLoadIcon = (PLOAD_ICON)lParam;
423 if (pLoadIcon->iIcon == pLoadIcon->nIconIndex)
424 {
425 pLoadIcon->hIcon = (HICON)LoadImage(hModule, lpszName, IMAGE_ICON,
426 pLoadIcon->cxIcon, pLoadIcon->cyIcon,
428 if (pLoadIcon->hIcon)
429 return FALSE; /* Stop enumeration */
430 }
431
432 ++pLoadIcon->iIcon;
433 return TRUE;
434}
LPARAM lParam
Definition: combotst.c:139
struct tagLOAD_ICON * PLOAD_ICON
HMODULE hModule
Definition: netsh.c:17
INT nIconIndex
Definition: kbswitch.c:407
HICON hIcon
Definition: kbswitch.c:410
#define IMAGE_ICON
Definition: winuser.h:212
#define LoadImage
Definition: winuser.h:5926
#define LR_DEFAULTCOLOR
Definition: winuser.h:1098

Referenced by FakeExtractIcon().

◆ EnumWindowsProc()

static BOOL CALLBACK EnumWindowsProc ( HWND  hwnd,
LPARAM  lParam 
)
static

Definition at line 772 of file kbswitch.c.

773{
774 PostMessage(hwnd, WM_INPUTLANGCHANGEREQUEST, INPUTLANGCHANGE_SYSCHARSET, lParam);
775 return TRUE;
776}

Referenced by ActivateLayout().

◆ FakeExtractIcon()

static HICON FakeExtractIcon ( PCTSTR  pszImeFile,
INT  nIconIndex 
)
static

Definition at line 437 of file kbswitch.c.

438{
439 HMODULE hImeDLL = LoadLibraryEx(pszImeFile, NULL, LOAD_LIBRARY_AS_DATAFILE);
440 if (!hImeDLL)
441 return NULL;
442
444 {
446 };
448
449 FreeLibrary(hImeDLL);
450
451 return LoadIcon.hIcon;
452}
static BOOL CALLBACK EnumResNameProc(HMODULE hModule, LPCTSTR lpszType, LPTSTR lpszName, LPARAM lParam)
Definition: kbswitch.c:414
#define RT_GROUP_ICON
Definition: pedump.c:375
#define LoadLibraryEx
Definition: winbase.h:3612
#define LOAD_LIBRARY_AS_DATAFILE
Definition: winbase.h:338
#define EnumResourceNames
Definition: winbase.h:3521
#define LoadIcon
Definition: winuser.h:5924

Referenced by CreateTrayIcon(), and UpdatePenIcon().

◆ GetActiveKL()

static HKL GetActiveKL ( VOID  )
static

Definition at line 205 of file kbswitch.c.

206{
207 /* FIXME: Get correct console window's HKL when console window */
208 HWND hwndTarget = GetTargetWindow(NULL);
209 TRACE("hwndTarget: %p\n", hwndTarget);
210 DWORD dwTID = GetWindowThreadProcessId(hwndTarget, NULL);
211 return GetKeyboardLayout(dwTID);
212}
unsigned long DWORD
Definition: ntddk_ex.h:95
static HWND GetTargetWindow(HWND hwndFore OPTIONAL)
Definition: kbswitch.c:193
DWORD WINAPI GetWindowThreadProcessId(HWND hWnd, PDWORD lpdwProcessId)
HKL WINAPI GetKeyboardLayout(_In_ DWORD)

Referenced by GetHKLFromLayoutNum(), KbSwitch_OnTimer(), and UpdateLayoutList().

◆ GetHKLFromLayoutNum()

static HKL GetHKLFromLayoutNum ( UINT  iKL)
static

Definition at line 314 of file kbswitch.c.

315{
316 return (iKL < g_cKLs) ? g_ahKLs[iKL] : GetActiveKL();
317}
static HKL GetActiveKL(VOID)
Definition: kbswitch.c:205

Referenced by GetKLIDFromLayoutNum().

◆ GetImeConversionMode()

static DWORD GetImeConversionMode ( HWND  hwndIme)
inlinestatic

Definition at line 87 of file kbswitch.c.

88{
90}
#define IMC_GETCONVERSIONMODE
Definition: immdev.h:86
#define SendMessage
Definition: winuser.h:5954
#define WM_IME_CONTROL
Definition: winuser.h:1859

Referenced by GetImeStatus().

◆ GetImeFile()

static BOOL GetImeFile ( LPTSTR  szImeFile,
SIZE_T  cchImeFile,
LPCTSTR  szKLID 
)
static

Definition at line 373 of file kbswitch.c.

374{
375 HKEY hKey;
376 DWORD dwBufLen;
377 TCHAR szBuf[MAX_PATH];
378
379 szImeFile[0] = UNICODE_NULL;
380
381 if (_tcslen(szKLID) != CCH_LAYOUT_ID)
382 return FALSE; /* Invalid LCID */
383
384 if (szKLID[0] != TEXT('E') && szKLID[0] != TEXT('e'))
385 return FALSE; /* Not an IME HKL */
386
387 StringCchPrintf(szBuf, _countof(szBuf),
388 _T("SYSTEM\\CurrentControlSet\\Control\\Keyboard Layouts\\%s"), szKLID);
389
391 return FALSE;
392
393 dwBufLen = cchImeFile * sizeof(TCHAR);
394 if (RegQueryValueEx(hKey, _T("IME File"), NULL, NULL,
395 (LPBYTE)szImeFile, &dwBufLen) != ERROR_SUCCESS)
396 {
397 szImeFile[0] = UNICODE_NULL;
398 }
399
401
402 return (szImeFile[0] != UNICODE_NULL);
403}
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
FxAutoRegKey hKey
#define TEXT(s)
Definition: k32.h:28
#define KEY_QUERY_VALUE
Definition: nt_native.h:1019
#define UNICODE_NULL
#define StringCchPrintf
Definition: strsafe.h:517
unsigned char * LPBYTE
Definition: typedefs.h:53
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define RegOpenKeyEx
Definition: winreg.h:527
#define RegQueryValueEx
Definition: winreg.h:531
#define _tcslen
Definition: xmlstorage.h:198

Referenced by AddTrayIcon(), BuildLeftPopupMenu(), UpdatePenIcon(), and UpdateTrayIcon().

◆ GetImeStatus()

static DWORD GetImeStatus ( HWND  hwndTarget)
static

Definition at line 476 of file kbswitch.c.

477{
478 HWND hwndIme = ImmGetDefaultIMEWnd(hwndTarget);
479 if (!hwndIme)
481
482 HIMC hIMC = (HIMC)SendMessage(hwndIme, WM_IME_SYSTEM, IMS_GETCONTEXT, (LPARAM)hwndTarget);
483 if (!hIMC)
484 return IME_STATUS_NO_IME;
485
486 DWORD dwImeStatus = (IsImeOpen(hwndIme) ? IME_STATUS_IME_OPEN : IME_STATUS_IME_CLOSED);
487 if (GetACP() == 949) // Korean
488 {
489 DWORD dwConversion = GetImeConversionMode(hwndIme);
490 if (dwConversion & IME_CMODE_NATIVE)
491 dwImeStatus |= IME_STATUS_IME_NATIVE;
492
493 if (dwConversion & IME_CMODE_FULLSHAPE)
494 dwImeStatus |= IME_STATUS_IME_FULLSHAPE;
495 }
496
497 return dwImeStatus;
498}
DWORD HIMC
Definition: dimm.idl:75
UINT WINAPI GetACP(void)
Definition: locale.c:2023
#define IMS_GETCONTEXT
Definition: imm32_undoc.h:51
#define WM_IME_SYSTEM
Definition: imm32_undoc.h:32
#define IME_CMODE_NATIVE
Definition: imm.h:337
HWND WINAPI ImmGetDefaultIMEWnd(_In_opt_ HWND hWnd)
Definition: ime.c:440
#define IME_CMODE_FULLSHAPE
Definition: imm.h:345
static BOOL IsImeOpen(HWND hwndIme)
Definition: kbswitch.c:81
static DWORD GetImeConversionMode(HWND hwndIme)
Definition: kbswitch.c:87
#define IME_STATUS_IME_CLOSED
Definition: kbswitch.h:31
#define IME_STATUS_IME_OPEN
Definition: kbswitch.h:32
#define IME_STATUS_NO_IME
Definition: kbswitch.h:30
#define IME_STATUS_IME_FULLSHAPE
Definition: kbswitch.h:34
#define IME_STATUS_IME_NATIVE
Definition: kbswitch.h:33

Referenced by LoadDefaultPenIcon().

◆ GetKLIDFromHKL()

static VOID GetKLIDFromHKL ( HKL  hKL,
LPTSTR  szKLID,
SIZE_T  KLIDLength 
)
static

Definition at line 164 of file kbswitch.c.

165{
166 szKLID[0] = 0;
167
168 if (IS_IME_HKL(hKL))
169 {
170 StringCchPrintf(szKLID, KLIDLength, _T("%08lx"), (DWORD)(DWORD_PTR)hKL);
171 return;
172 }
173
174 if (IS_SPECIAL_HKL(hKL))
175 {
176 INT i;
177 for (i = 0; i < g_cSpecialIds; ++i)
178 {
179 if (g_SpecialIds[i].hKL == hKL)
180 {
181 StringCchCopy(szKLID, KLIDLength, g_SpecialIds[i].szKLID);
182 return;
183 }
184 }
185 }
186 else
187 {
188 StringCchPrintf(szKLID, KLIDLength, _T("%08lx"), LOWORD(hKL));
189 }
190}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define IS_SPECIAL_HKL(hKL)
Definition: imm32_undoc.h:22
#define IS_IME_HKL(hKL)
Definition: imm32_undoc.h:21
INT g_cSpecialIds
Definition: kbswitch.c:109
SPECIAL_ID g_SpecialIds[MAX_SPECIAL_IDS]
Definition: kbswitch.c:108
#define LOWORD(l)
Definition: pedump.c:82
uint32_t DWORD_PTR
Definition: typedefs.h:65

Referenced by BuildLeftPopupMenu(), GetKLIDFromLayoutNum(), UpdateLanguageDisplay(), and UpdatePenIcon().

◆ GetKLIDFromLayoutNum()

static VOID GetKLIDFromLayoutNum ( UINT  iKL,
LPTSTR  szKLID,
SIZE_T  KLIDLength 
)
static

Definition at line 320 of file kbswitch.c.

321{
322 GetKLIDFromHKL(GetHKLFromLayoutNum(iKL), szKLID, KLIDLength);
323}
static HKL GetHKLFromLayoutNum(UINT iKL)
Definition: kbswitch.c:314

Referenced by ActivateLayout(), AddTrayIcon(), and GetLayoutName().

◆ GetLayoutIndexFromHKL()

static UINT GetLayoutIndexFromHKL ( HKL  hKL)
static

Definition at line 241 of file kbswitch.c.

242{
243 for (UINT iKL = 0; iKL < g_cKLs; ++iKL)
244 {
245 if (g_ahKLs[iKL] == hKL)
246 return iKL;
247 }
248 return 0;
249}

Referenced by OnIndicatorMsg(), and UpdateLayoutList().

◆ GetLayoutName()

static BOOL GetLayoutName ( UINT  iKL,
LPTSTR  szName,
SIZE_T  NameLength 
)
static

Definition at line 337 of file kbswitch.c.

338{
339 HKEY hKey;
340 HRESULT hr;
341 DWORD dwBufLen;
342 TCHAR szBuf[MAX_PATH], szKLID[CCH_LAYOUT_ID + 1];
343
344 GetKLIDFromLayoutNum(iKL, szKLID, _countof(szKLID));
345
346 StringCchPrintf(szBuf, _countof(szBuf),
347 _T("SYSTEM\\CurrentControlSet\\Control\\Keyboard Layouts\\%s"), szKLID);
348
350 return FALSE;
351
352 /* Use "Layout Display Name" value as an entry name if possible */
353 hr = SHLoadRegUIString(hKey, _T("Layout Display Name"), szName, NameLength);
354 if (SUCCEEDED(hr))
355 {
357 return TRUE;
358 }
359
360 /* Otherwise, use "Layout Text" value as an entry name */
361 dwBufLen = NameLength * sizeof(TCHAR);
362 if (RegQueryValueEx(hKey, _T("Layout Text"), NULL, NULL,
363 (LPBYTE)szName, &dwBufLen) == ERROR_SUCCESS)
364 {
366 return TRUE;
367 }
368
370 return FALSE;
371}
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define KEY_READ
Definition: nt_native.h:1026
HRESULT hr
Definition: shlfolder.c:183
#define SHLoadRegUIString

Referenced by AddTrayIcon(), and BuildLeftPopupMenu().

◆ GetLayoutNum()

static UINT GetLayoutNum ( HKL  hKL)
static

Definition at line 897 of file kbswitch.c.

898{
899 UINT iKL;
900
901 for (iKL = 0; iKL < g_cKLs; ++iKL)
902 {
903 if (g_ahKLs[iKL] == hKL)
904 return iKL;
905 }
906
907 return 0;
908}

Referenced by UpdateLanguageDisplay().

◆ GetSystemLibraryPath()

static BOOL GetSystemLibraryPath ( LPTSTR  szPath,
SIZE_T  cchPath,
LPCTSTR  FileName 
)
static

Definition at line 326 of file kbswitch.c.

327{
328 if (!GetSystemDirectory(szPath, cchPath))
329 return FALSE;
330
331 StringCchCat(szPath, cchPath, TEXT("\\"));
332 StringCchCat(szPath, cchPath, FileName);
333 return TRUE;
334}
#define StringCchCat
Definition: strsafe.h:317
#define GetSystemDirectory
Definition: winbase.h:3591

Referenced by CreateTrayIcon(), and LayoutList_ReadLayout().

◆ GetTargetWindow()

static HWND GetTargetWindow ( HWND hwndFore  OPTIONAL)
static

Definition at line 193 of file kbswitch.c.

194{
195 HWND hwndTarget = (hwndFore ? hwndFore : GetForegroundWindow());
196 if (!hwndTarget ||
197 IsWndClassName(hwndTarget, INDICATOR_CLASS) ||
198 IsWndClassName(hwndTarget, TEXT("Shell_TrayWnd")))
199 {
200 hwndTarget = g_hwndLastActive;
201 }
202 return hwndTarget;
203}
HWND g_hwndLastActive
Definition: kbswitch.c:59
static BOOL IsWndClassName(_In_opt_ HWND hwndTarget, PCTSTR pszName)
Definition: kbswitch.h:37
HWND WINAPI GetForegroundWindow(void)
Definition: ntwrapper.h:392

Referenced by GetActiveKL(), KbSwitch_OnPenIconMsg(), and UpdateLanguageDisplayCurrent().

◆ IsImeOpen()

static BOOL IsImeOpen ( HWND  hwndIme)
inlinestatic

Definition at line 81 of file kbswitch.c.

82{
84}
unsigned int BOOL
Definition: ntddk_ex.h:94
#define IMC_GETOPENSTATUS
Definition: immdev.h:88

Referenced by GetImeStatus(), and KbSwitch_OnPenIconMsg().

◆ IsRegImeToolbarShown()

static BOOL IsRegImeToolbarShown ( VOID  )
static

Definition at line 1043 of file kbswitch.c.

1044{
1045 HKEY hKey;
1046 LSTATUS error = RegOpenKey(HKEY_CURRENT_USER, TEXT("Control Panel\\Input Method"), &hKey);
1047 if (error)
1048 {
1049 ERR("Cannot open regkey: 0x%lX\n", error);
1050 return TRUE;
1051 }
1052
1053 WCHAR szText[8];
1054 DWORD cbValue = sizeof(szText);
1055 error = RegQueryValueEx(hKey, TEXT("Show Status"), NULL, NULL, (PBYTE)szText, &cbValue);
1056 if (error)
1057 {
1059 return TRUE;
1060 }
1061
1062 BOOL ret = !!_wtoi(szText);
1064 return ret;
1065}
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
_ACRTIMP int __cdecl _wtoi(const wchar_t *)
Definition: wcs.c:2773
return ret
Definition: mutex.c:146
#define error(str)
Definition: mkdosfs.c:1605
BYTE * PBYTE
Definition: pedump.c:66
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define RegOpenKey
Definition: winreg.h:526
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by KbSwitch_OnPenIconMsg().

◆ KbSwitch_OnCommand()

static void KbSwitch_OnCommand ( HWND  hwnd,
UINT  nID 
)
static

Definition at line 1262 of file kbswitch.c.

1263{
1264 switch (nID)
1265 {
1266 case ID_EXIT:
1267 PostMessage(hwnd, WM_CLOSE, 0, 0);
1268 break;
1269
1270 case ID_PREFERENCES:
1271 {
1273 TEXT("control.exe"), TEXT("input.dll"),
1275 if (ret <= 32)
1276 MessageBox(hwnd, _T("Can't start input.dll"), NULL, MB_ICONERROR);
1277 break;
1278 }
1279
1280 default:
1281 {
1282 if (nID >= ID_LANG_BASE)
1283 {
1285 {
1287 }
1289 }
1290 break;
1291 }
1292 }
1293}
#define ID_EXIT
Definition: resource.h:18
#define ID_PREFERENCES
Definition: resource.h:19
static VOID ActivateLayout(HWND hwnd, UINT iKL, HWND hwndTarget OPTIONAL, BOOL bNoActivate)
Definition: kbswitch.c:779
#define ShellExecute
Definition: shellapi.h:732
int32_t INT_PTR
Definition: typedefs.h:64
#define SW_SHOWNORMAL
Definition: winuser.h:781
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define WM_CLOSE
Definition: winuser.h:1649
#define MB_ICONERROR
Definition: winuser.h:798
#define MessageBox
Definition: winuser.h:5933

Referenced by WndProc().

◆ KbSwitch_OnCreate()

static INT KbSwitch_OnCreate ( HWND  hwnd)
static

Definition at line 955 of file kbswitch.c.

956{
957 if (!SetHooks())
958 {
959 MessageBox(NULL, TEXT("SetHooks failed."), NULL, MB_ICONERROR);
960 return -1; /* Failed */
961 }
962
968
971
972 return 0; /* Success */
973}
static VOID LoadSpecialIds(VOID)
Definition: kbswitch.c:111
static VOID UpdatePenIcon(HWND hwnd, UINT iKL)
Definition: kbswitch.c:564
static VOID UpdateLayoutList(HKL hKL OPTIONAL)
Definition: kbswitch.c:251
static VOID UpdateTrayInfo(VOID)
Definition: kbswitch.c:93
static BOOL SetHooks(VOID)
Definition: kbswitch.c:858
static VOID AddTrayIcon(HWND hwnd)
Definition: kbswitch.c:711
UINT g_uTaskbarRestartMsg
Definition: kbswitch.c:68

Referenced by WndProc().

◆ KbSwitch_OnDefault()

static LRESULT KbSwitch_OnDefault ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 1326 of file kbswitch.c.

1327{
1328 if (uMsg == g_uTaskbarRestartMsg)
1329 {
1334 return 0;
1335 }
1336
1337 if (uMsg == g_uShellHookMessage)
1338 {
1339 TRACE("g_uShellHookMessage: wParam:%p, lParam:%p\n", wParam, lParam);
1340 if (wParam == HSHELL_LANGUAGE)
1342 else if (wParam == HSHELL_WINDOWACTIVATED || wParam == HSHELL_RUDEAPPACTIVATED)
1344 return 0;
1345 }
1346
1347 return DefWindowProc(hwnd, uMsg, wParam, lParam);
1348}
WPARAM wParam
Definition: combotst.c:138
#define WM_WINDOW_ACTIVATE
Definition: kbswitch.h:28
#define WM_LANG_CHANGED
Definition: kbswitch.h:27
#define DefWindowProc
Definition: ros2win.h:31
#define HSHELL_RUDEAPPACTIVATED
Definition: winuser.h:1292

Referenced by WndProc().

◆ KbSwitch_OnDestroy()

static void KbSwitch_OnDestroy ( HWND  hwnd)
static

Definition at line 977 of file kbswitch.c.

978{
980 DeleteHooks();
985}
#define TIMER_ID_LANG_CHANGED_DELAYED
Definition: kbswitch.c:42
static VOID DeleteHooks(VOID)
Definition: kbswitch.c:880
static VOID DestroyPenIcons(VOID)
Definition: kbswitch.c:227
static VOID DeletePenNotifyIcon(HWND hwnd)
Definition: kbswitch.c:551
static VOID DeleteTrayIcon(HWND hwnd)
Definition: kbswitch.c:736
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)

Referenced by WndProc().

◆ KbSwitch_OnLangChanged()

static LRESULT KbSwitch_OnLangChanged ( HWND  hwnd,
HWND hwndTarget  OPTIONAL,
HKL hKL  OPTIONAL 
)
static

Definition at line 1297 of file kbswitch.c.

1298{
1299 TRACE("WM_LANG_CHANGED: hwndTarget:%p, hKL:%p\n", hwndTarget, hKL);
1300 /* Delayed action */
1303 return 0;
1304}
#define TIMER_LANG_CHANGED_DELAY
Definition: kbswitch.c:43
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)

Referenced by WndProc().

◆ KbSwitch_OnNotifyIconMsg()

static void KbSwitch_OnNotifyIconMsg ( HWND  hwnd,
UINT  uMouseMsg 
)
static

Definition at line 1003 of file kbswitch.c.

1004{
1005 if (uMouseMsg != WM_LBUTTONUP && uMouseMsg != WM_RBUTTONUP)
1006 return;
1007
1009
1010 POINT pt;
1011 GetCursorPos(&pt);
1012
1014
1015 TPMPARAMS params = { sizeof(params) };
1017
1018 INT nID;
1019 if (uMouseMsg == WM_LBUTTONUP)
1020 {
1021 /* Rebuild the left popup menu on every click to take care of keyboard layout changes */
1022 HMENU hPopupMenu = BuildLeftPopupMenu();
1024 nID = TrackPopupMenuEx(hPopupMenu, uFlags, pt.x, pt.y, hwnd, &params);
1025 DestroyMenu(hPopupMenu);
1026 }
1027 else /* WM_RBUTTONUP */
1028 {
1030 HMENU hSubMenu = GetSubMenu(hPopupMenu, 0);
1032 nID = TrackPopupMenuEx(hSubMenu, uFlags, pt.x, pt.y, hwnd, &params);
1033 DestroyMenu(hPopupMenu);
1034 }
1035
1036 PostMessage(hwnd, WM_NULL, 0, 0);
1037
1038 if (nID)
1039 PostMessage(hwnd, WM_COMMAND, nID, 0);
1040}
#define IDR_POPUP
Definition: resource.h:7
UINT uFlags
Definition: api.c:59
#define pt(x, y)
Definition: drawing.c:79
GLenum const GLfloat * params
Definition: glext.h:5645
HWND g_hTrayNotifyWnd
Definition: kbswitch.c:71
static HMENU BuildLeftPopupMenu(VOID)
Definition: kbswitch.c:817
#define MAKEINTRESOURCE(i)
Definition: ntverrsrc.c:25
#define TPM_RIGHTBUTTON
Definition: winuser.h:2416
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define WM_COMMAND
Definition: winuser.h:1768
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:3047
#define WM_RBUTTONUP
Definition: winuser.h:1808
#define TPM_RIGHTALIGN
Definition: winuser.h:2414
BOOL WINAPI TrackPopupMenuEx(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _In_ HWND, _In_opt_ LPTPMPARAMS)
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
#define WM_NULL
Definition: winuser.h:1635
#define TPM_VERTICAL
Definition: winuser.h:2418
#define TPM_LEFTBUTTON
Definition: winuser.h:2415
#define LoadMenu
Definition: winuser.h:5928
#define WM_LBUTTONUP
Definition: winuser.h:1805
BOOL WINAPI DestroyMenu(_In_ HMENU)
#define TPM_RETURNCMD
Definition: winuser.h:2423

Referenced by WndProc().

◆ KbSwitch_OnPenIconMsg()

static VOID KbSwitch_OnPenIconMsg ( HWND  hwnd,
UINT  uMouseMsg 
)
static

Definition at line 1091 of file kbswitch.c.

1092{
1093 if (uMouseMsg != WM_LBUTTONUP && uMouseMsg != WM_RBUTTONUP)
1094 return;
1095
1097 return;
1098
1099 POINT pt;
1100 GetCursorPos(&pt);
1101
1102 // Get target window
1103 TRACE("g_hwndLastActive: %p\n", g_hwndLastActive);
1105 TRACE("hwndTarget: %p\n", hwndTarget);
1106
1107 // Get default IME window
1108 HWND hwndIme = ImmGetDefaultIMEWnd(hwndTarget);
1109 if (!hwndIme)
1110 {
1111 WARN("No default IME\n");
1112 return;
1113 }
1114
1115 // Get IME context from another process
1116 HIMC hIMC = (HIMC)SendMessage(hwndIme, WM_IME_SYSTEM, IMS_GETCONTEXT, (LPARAM)hwndTarget);
1117 if (!hIMC)
1118 {
1119 WARN("No HIMC\n");
1120 return;
1121 }
1122
1123 // Is IME open?
1124 BOOL bImeOn = IsImeOpen(hwndIme);
1125
1126 // Workaround of TrackPopupMenu's bug.
1127 // NOTE: This might change IME status.
1129
1130 // Create IME menu
1131 BOOL bRightButton = (uMouseMsg == WM_RBUTTONUP);
1132 PIMEMENUNODE pImeMenu = CreateImeMenu(hIMC, NULL, bRightButton);
1133 HMENU hMenu = MenuFromImeMenu(pImeMenu);
1134
1135 HKL hKL = g_ahKLs[g_iKL];
1136 BOOL bSoftOn = FALSE, bShowToolbar = FALSE;
1137 TCHAR szText[128];
1138 if (bRightButton)
1139 {
1140 if (!(g_anFlags[g_iKL] & LAYOUTF_REMOVE_RIGHT_DEF_MENU)) // Add default menu items?
1141 {
1142 if (GetMenuItemCount(hMenu))
1143 AppendMenu(hMenu, MF_SEPARATOR, 0, NULL); // Separator
1144
1145 // "Input System (IME) configuration..."
1146 LoadString(g_hInst, IDS_INPUTSYSTEM, szText, _countof(szText));
1147 AppendMenu(hMenu, MF_STRING, ID_INPUTSYSTEM, szText);
1148 }
1149 }
1150 else
1151 {
1152 if (!(g_anFlags[g_iKL] & LAYOUTF_REMOVE_LEFT_DEF_MENU)) // Add default menu items?
1153 {
1154 if (GetMenuItemCount(hMenu))
1155 AppendMenu(hMenu, MF_SEPARATOR, 0, NULL); // Separator
1156
1157 if (!IS_KOREAN_IME_HKL(hKL)) // Not Korean IME?
1158 {
1159 // "IME ON / OFF"
1160 UINT nId = (bImeOn ? IDS_IME_ON : IDS_IME_OFF);
1161 LoadString(g_hInst, nId, szText, _countof(szText));
1162 AppendMenu(hMenu, MF_STRING, ID_IMEONOFF, szText);
1163 }
1164
1166 IsWindow(hwndIme)) // Is Soft Keyboard available?
1167 {
1168 // "Soft Keyboard ON / OFF"
1170 UINT nId = (bSoftOn ? IDS_SOFTKBD_ON : IDS_SOFTKBD_OFF);
1171 LoadString(g_hInst, nId, szText, _countof(szText));
1172 AppendMenu(hMenu, MF_STRING, ID_SOFTKBDONOFF, szText);
1173 }
1174
1175 if (GetMenuItemCount(hMenu))
1176 AppendMenu(hMenu, MF_SEPARATOR, 0, NULL); // Separator
1177
1178 // "Show toolbar"
1179 LoadString(g_hInst, IDS_SHOWTOOLBAR, szText, _countof(szText));
1180 AppendMenu(hMenu, MF_STRING, ID_SHOWTOOLBAR, szText);
1181 bShowToolbar = IsRegImeToolbarShown();
1182 if (bShowToolbar)
1184 }
1185 }
1186
1187 if (!GetMenuItemCount(hMenu)) // No items?
1188 {
1189 // Clean up
1190 DestroyMenu(hMenu);
1192
1193 SetForegroundWindow(hwndTarget);
1194 return;
1195 }
1196
1197 // TrackPopupMenuEx flags
1199 uFlags |= (bRightButton ? TPM_RIGHTBUTTON : TPM_LEFTBUTTON);
1200
1201 // Exclude the notification area
1202 TPMPARAMS params = { sizeof(params) };
1204
1205 // Show the popup menu
1206 INT nID = TrackPopupMenuEx(hMenu, uFlags, pt.x, pt.y, hwnd, &params);
1207
1208 // Workaround of TrackPopupMenu's bug
1209 PostMessage(hwnd, WM_NULL, 0, 0);
1210
1211 // Back to target window
1212 SetForegroundWindow(hwndTarget);
1213
1214 if (nID) // Action!
1215 {
1216 if (nID >= ID_STARTIMEMENU) // IME internal menu ID?
1217 {
1218 MENUITEMINFO mii = { sizeof(mii), MIIM_DATA };
1219 GetMenuItemInfo(hMenu, nID, FALSE, &mii);
1220
1221 if (pImeMenu)
1222 nID = GetRealImeMenuID(pImeMenu, nID);
1223
1224 if (SetPenMenuData)
1225 SetPenMenuData(nID, mii.dwItemData);
1226
1228 }
1229 else // Otherwise action of IME menu item
1230 {
1231 switch (nID)
1232 {
1233 case ID_INPUTSYSTEM:
1234 if (IS_IME_HKL(hKL))
1236 break;
1237 case ID_IMEONOFF:
1238 PostMessage(hwndIme, WM_IME_SYSTEM, IMS_SETOPENSTATUS, !bImeOn);
1239 break;
1240 case ID_SOFTKBDONOFF:
1241 PostMessage(hwndIme, WM_IME_SYSTEM, IMS_SOFTKBDONOFF, !bSoftOn);
1242 break;
1243 case ID_SHOWTOOLBAR:
1244 ShowImeToolbar(hwndTarget, !bShowToolbar);
1245 break;
1246 default:
1247 {
1248 PostMessage(hwnd, WM_COMMAND, nID, 0);
1249 break;
1250 }
1251 }
1252 }
1253 }
1254
1255 // Clean up
1256 DestroyMenu(hMenu);
1258}
INT GetRealImeMenuID(_In_ const IMEMENUNODE *pMenu, _In_ INT nFakeID)
Definition: imemenu.c:202
PIMEMENUNODE CreateImeMenu(_In_ HIMC hIMC, _Inout_opt_ PIMEMENUITEMINFO lpImeParentMenu, _In_ BOOL bRightMenu)
Definition: imemenu.c:62
VOID CleanupImeMenus(VOID)
Definition: imemenu.c:246
HMENU MenuFromImeMenu(_In_ const IMEMENUNODE *pMenu)
Definition: imemenu.c:188
#define IDS_INPUTSYSTEM
Definition: resource.h:15
#define IDS_SOFTKBD_OFF
Definition: resource.h:13
#define ID_IMEONOFF
Definition: resource.h:21
#define IDS_SHOWTOOLBAR
Definition: resource.h:14
#define ID_SHOWTOOLBAR
Definition: resource.h:23
#define IDS_IME_OFF
Definition: resource.h:11
#define ID_INPUTSYSTEM
Definition: resource.h:20
#define IDS_SOFTKBD_ON
Definition: resource.h:12
#define IDS_IME_ON
Definition: resource.h:10
#define ID_SOFTKBDONOFF
Definition: resource.h:22
#define WARN(fmt,...)
Definition: precomp.h:61
#define ID_STARTIMEMENU
Definition: imemenu.h:12
#define IMS_SETOPENSTATUS
Definition: imm32_undoc.h:41
#define IMS_IMEMENUITEMSELECTED
Definition: imm32_undoc.h:50
#define IMS_GETCONVSTATUS
Definition: imm32_undoc.h:44
#define IMS_CONFIGURE
Definition: imm32_undoc.h:40
#define IMS_SOFTKBDONOFF
Definition: imm32_undoc.h:43
#define IME_CMODE_SOFTKBD
Definition: imm.h:349
DWORD WINAPI ImmGetProperty(_In_ HKL hKL, _In_ DWORD fdwIndex)
Definition: ime.c:767
#define IGP_CONVERSION
Definition: imm.h:301
static BOOL IsRegImeToolbarShown(VOID)
Definition: kbswitch.c:1043
#define LAYOUTF_REMOVE_LEFT_DEF_MENU
Definition: kbswitch.c:77
BYTE g_anFlags[MAX_KLS]
Definition: kbswitch.c:67
#define LAYOUTF_FAR_EAST
Definition: kbswitch.c:74
#define LAYOUTF_REMOVE_RIGHT_DEF_MENU
Definition: kbswitch.c:78
#define IS_KOREAN_IME_HKL(hKL)
Definition: kbswitch.c:46
FN_SetPenMenuData SetPenMenuData
Definition: kbswitch.c:54
static VOID ShowImeToolbar(HWND hwndTarget, BOOL bShowToolbar)
Definition: kbswitch.c:1068
ULONG_PTR dwItemData
Definition: winuser.h:3352
int WINAPI GetMenuItemCount(_In_opt_ HMENU)
#define AppendMenu
Definition: winuser.h:5842
#define MF_STRING
Definition: winuser.h:138
#define MF_SEPARATOR
Definition: winuser.h:137
#define LoadString
Definition: winuser.h:5930
#define GetMenuItemInfo
Definition: winuser.h:5899
#define MIIM_DATA
Definition: winuser.h:737

Referenced by WndProc().

◆ KbSwitch_OnSettingChange()

static void KbSwitch_OnSettingChange ( HWND  hwnd,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 1319 of file kbswitch.c.

1320{
1321 if (wParam == SPI_SETNONCLIENTMETRICS)
1323}

Referenced by WndProc().

◆ KbSwitch_OnTimer()

static void KbSwitch_OnTimer ( HWND  hwnd,
UINT_PTR  nTimerID 
)
static

Definition at line 989 of file kbswitch.c.

990{
991 if (nTimerID == TIMER_ID_LANG_CHANGED_DELAYED)
992 {
993 KillTimer(hwnd, nTimerID);
994 HKL hKL = GetActiveKL();
995 UpdateLayoutList(hKL);
998 }
999}
UINT UpdateLanguageDisplay(HWND hwnd, HKL hKL)
Definition: kbswitch.c:911

Referenced by WndProc().

◆ KbSwitch_OnWindowActivate()

static LRESULT KbSwitch_OnWindowActivate ( HWND  hwnd,
HWND hwndTarget  OPTIONAL,
LPARAM lParam  OPTIONAL 
)
static

Definition at line 1308 of file kbswitch.c.

1309{
1310 TRACE("WM_WINDOW_ACTIVATE: hwndTarget:%p, lParam:%p\n", hwndTarget, lParam);
1311 HWND hwndFore = hwndTarget ? hwndTarget : GetForegroundWindow();
1312 if (RememberLastActive(hwnd, hwndFore))
1313 return UpdateLanguageDisplayCurrent(hwnd, hwndFore);
1314 return 0;
1315}
static BOOL RememberLastActive(HWND hwnd, HWND hwndFore)
Definition: kbswitch.c:936
UINT UpdateLanguageDisplayCurrent(HWND hwnd, HWND hwndFore)
Definition: kbswitch.c:926

Referenced by WndProc().

◆ LoadDefaultPenIcon()

static HICON LoadDefaultPenIcon ( PCWSTR  szImeFile,
HKL  hKL 
)
static

Definition at line 501 of file kbswitch.c.

502{
504 DWORD dwImeStatus = GetImeStatus(hwndTarget);
505
506 INT nIconID = -1;
507 if (IS_KOREAN_IME_HKL(hKL)) // Korean IME?
508 {
509 if (dwImeStatus != IME_STATUS_NO_IME)
510 {
511 if (dwImeStatus & IME_STATUS_IME_CLOSED)
512 {
513 nIconID = IDI_KOREAN_A_HALF;
514 }
515 else
516 {
517 if (dwImeStatus & IME_STATUS_IME_FULLSHAPE)
518 {
519 if (dwImeStatus & IME_STATUS_IME_NATIVE)
520 nIconID = IDI_KOREAN_JR_FULL;
521 else
522 nIconID = IDI_KOREAN_A_FULL;
523 }
524 else
525 {
526 if (dwImeStatus & IME_STATUS_IME_NATIVE)
527 nIconID = IDI_KOREAN_JR_HALF;
528 else
529 nIconID = IDI_KOREAN_A_HALF;
530 }
531 }
532 }
533 }
534 else
535 {
536 if (dwImeStatus & IME_STATUS_IME_CLOSED)
537 nIconID = IDI_IME_CLOSED;
538 else if (dwImeStatus & IME_STATUS_IME_OPEN)
539 nIconID = IDI_IME_OPEN;
540 else
541 nIconID = IDI_IME_DISABLED;
542 }
543
544 if (nIconID < 0)
545 return NULL;
546
547 return LoadIcon(g_hHookDLL, MAKEINTRESOURCE(nIconID));
548}
#define IDI_IME_OPEN
Definition: resource.h:2
#define IDI_KOREAN_A_FULL
Definition: resource.h:6
#define IDI_KOREAN_A_HALF
Definition: resource.h:5
#define IDI_KOREAN_JR_HALF
Definition: resource.h:7
#define IDI_IME_CLOSED
Definition: resource.h:3
#define IDI_IME_DISABLED
Definition: resource.h:4
#define IDI_KOREAN_JR_FULL
Definition: resource.h:8
static DWORD GetImeStatus(HWND hwndTarget)
Definition: kbswitch.c:476

Referenced by UpdatePenIcon().

◆ LoadSpecialIds()

static VOID LoadSpecialIds ( VOID  )
static

Definition at line 111 of file kbswitch.c.

112{
113 TCHAR szKLID[KL_NAMELENGTH], szLayoutId[16];
114 DWORD dwSize, dwIndex;
115 HKEY hKey, hLayoutKey;
116
117 g_cSpecialIds = 0;
118
120 TEXT("SYSTEM\\CurrentControlSet\\Control\\Keyboard Layouts"),
121 0, KEY_READ, &hKey) != ERROR_SUCCESS)
122 {
123 return;
124 }
125
126 for (dwIndex = 0; dwIndex < 1000; ++dwIndex)
127 {
128 dwSize = _countof(szKLID);
129 if (RegEnumKeyEx(hKey, dwIndex, szKLID, &dwSize, NULL, NULL, NULL, NULL) != ERROR_SUCCESS)
130 break;
131
132 if (RegOpenKeyEx(hKey, szKLID, 0, KEY_READ, &hLayoutKey) != ERROR_SUCCESS)
133 continue;
134
135 dwSize = sizeof(szLayoutId);
136 if (RegQueryValueEx(hLayoutKey, TEXT("Layout Id"), NULL, NULL,
137 (LPBYTE)szLayoutId, &dwSize) == ERROR_SUCCESS)
138 {
139 DWORD dwKLID = _tcstoul(szKLID, NULL, 16);
140 WORD wLangId = LOWORD(dwKLID), wLayoutId = LOWORD(_tcstoul(szLayoutId, NULL, 16));
141 HKL hKL = (HKL)(LONG_PTR)(SPECIAL_MASK | MAKELONG(wLangId, wLayoutId));
142
143 /* Add a special ID */
147 _countof(g_SpecialIds[g_cSpecialIds].szKLID), szKLID);
149 }
150
151 RegCloseKey(hLayoutKey);
152
154 {
155 ERR("g_SpecialIds is full!");
156 break;
157 }
158 }
159
161}
#define SPECIAL_MASK
Definition: debug.h:13
unsigned short WORD
Definition: ntddk_ex.h:93
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
DWORD dwLayoutId
Definition: kbswitch.c:101
#define MAKELONG(a, b)
Definition: typedefs.h:249
#define RegEnumKeyEx
Definition: winreg.h:517
#define KL_NAMELENGTH
Definition: winuser.h:122

Referenced by KbSwitch_OnCreate().

◆ OnIndicatorMsg()

static VOID OnIndicatorMsg ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 1351 of file kbswitch.c.

1352{
1353 HKL hKL = (HKL)lParam;
1354 UINT iKL = GetLayoutIndexFromHKL(hKL);
1355 if (iKL >= g_cKLs)
1356 return;
1357
1358 g_iKL = iKL;
1359
1360 switch (uMsg)
1361 {
1362 case INDICM_SETIMEICON:
1363 if (LOWORD(wParam) == MAXWORD)
1364 {
1365 g_anFlags[iKL] &= ~LAYOUTF_IME_ICON;
1366 g_aiSysPenIcons[iKL] = MAXWORD;
1367 }
1368 else
1369 {
1371 g_aiSysPenIcons[iKL] = (WORD)wParam;
1372 }
1373 UpdatePenIcon(hwnd, iKL);
1374 break;
1375
1377 if (LOWORD(wParam) == MAXWORD)
1378 {
1379 g_anFlags[iKL] &= ~LAYOUTF_TOOLTIP_ATOM;
1380 }
1381 else
1382 {
1385 }
1386 UpdatePenIcon(hwnd, iKL);
1387 break;
1388
1390 if (wParam)
1391 {
1392 if (wParam & RDMI_LEFT)
1394 if (wParam & RDMI_RIGHT)
1396 }
1397 else
1398 {
1400 }
1401 break;
1402
1403 default:
1404 {
1405 ERR("uMsg: %u\n", uMsg);
1406 return;
1407 }
1408 }
1409}
#define INDICM_SETIMETOOLTIPS
Definition: indicml.h:23
#define RDMI_RIGHT
Definition: indicml.h:28
#define INDICM_REMOVEDEFAULTMENUITEMS
Definition: indicml.h:24
#define INDICM_SETIMEICON
Definition: indicml.h:22
#define RDMI_LEFT
Definition: indicml.h:27
static UINT GetLayoutIndexFromHKL(HKL hKL)
Definition: kbswitch.c:241
WORD g_anToolTipAtoms[MAX_KLS]
Definition: kbswitch.c:64
#define LAYOUTF_TOOLTIP_ATOM
Definition: kbswitch.c:76
WORD g_aiSysPenIcons[MAX_KLS]
Definition: kbswitch.c:63
#define LAYOUTF_IME_ICON
Definition: kbswitch.c:75
#define MAXWORD

Referenced by WndProc().

◆ RememberLastActive()

static BOOL RememberLastActive ( HWND  hwnd,
HWND  hwndFore 
)
static

Definition at line 936 of file kbswitch.c.

937{
938 hwndFore = GetAncestor(hwndFore, GA_ROOT);
939
940 if (!IsWindowVisible(hwndFore))
941 return FALSE;
942
943 if (IsWndClassName(hwndFore, INDICATOR_CLASS) ||
944 IsWndClassName(hwndFore, TEXT("Shell_TrayWnd")))
945 {
946 return FALSE; /* Special window */
947 }
948
949 g_hwndLastActive = hwndFore;
950 return TRUE;
951}
#define GA_ROOT
Definition: winuser.h:2891
BOOL WINAPI IsWindowVisible(_In_ HWND)
HWND WINAPI GetAncestor(_In_ HWND, _In_ UINT)
Definition: window.c:929

Referenced by KbSwitch_OnWindowActivate().

◆ SetHooks()

static BOOL SetHooks ( VOID  )
static

Definition at line 858 of file kbswitch.c.

859{
860 g_hHookDLL = LoadLibrary(_T("indicdll.dll"));
861 if (!g_hHookDLL)
862 return FALSE;
863
868
870 {
871 ERR("SetHooks failed\n");
872 return FALSE;
873 }
874
875 TRACE("SetHooks OK\n");
876 return TRUE;
877}
#define GetProcAddress(x, y)
Definition: compat.h:753
#define IFN_KbSwitchSetHooks
Definition: kbswitch.c:854
#define IFN_SetPenMenuData
Definition: kbswitch.c:855
VOID(APIENTRY * FN_SetPenMenuData)(UINT nID, DWORD_PTR dwItemData)
Definition: kbswitch.c:51
BOOL(APIENTRY * FN_KbSwitchSetHooks)(BOOL bDoHook)
Definition: kbswitch.c:50
#define LoadLibrary
Definition: winbase.h:3611
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581

Referenced by KbSwitch_OnCreate().

◆ ShowImeToolbar()

static VOID ShowImeToolbar ( HWND  hwndTarget,
BOOL  bShowToolbar 
)
static

Definition at line 1068 of file kbswitch.c.

1069{
1070 HKEY hKey;
1071 LSTATUS error = RegOpenKey(HKEY_CURRENT_USER, TEXT("Control Panel\\Input Method"), &hKey);
1072 if (error)
1073 {
1074 ERR("Cannot open regkey: 0x%lX\n", error);
1075 return;
1076 }
1077
1078 WCHAR szText[8];
1079 StringCchPrintf(szText, _countof(szText), TEXT("%d"), bShowToolbar);
1080
1081 DWORD cbValue = (lstrlen(szText) + 1) * sizeof(TCHAR);
1082 RegSetValueEx(hKey, TEXT("Show Status"), 0, REG_SZ, (PBYTE)szText, cbValue);
1084
1085 HWND hwndIme = ImmGetDefaultIMEWnd(hwndTarget);
1086 PostMessage(hwndIme, WM_IME_SYSTEM, IMS_NOTIFYIMESHOW, bShowToolbar);
1087}
#define IMS_NOTIFYIMESHOW
Definition: imm32_undoc.h:35
#define REG_SZ
Definition: layer.c:22
#define lstrlen
Definition: winbase.h:3625
#define RegSetValueEx
Definition: winreg.h:540

Referenced by KbSwitch_OnPenIconMsg().

◆ UpdateLanguageDisplay()

UINT UpdateLanguageDisplay ( HWND  hwnd,
HKL  hKL 
)

Definition at line 911 of file kbswitch.c.

912{
913 TCHAR szKLID[MAX_PATH], szLangName[MAX_PATH];
915
916 GetKLIDFromHKL(hKL, szKLID, _countof(szKLID));
917 LangID = (LANGID)_tcstoul(szKLID, NULL, 16);
918 GetLocaleInfo(LangID, LOCALE_SLANGUAGE, szLangName, _countof(szLangName));
919 UpdateTrayIcon(hwnd, szKLID, szLangName);
920 g_iKL = GetLayoutNum(hKL);
921
922 return 0;
923}
static UINT GetLayoutNum(HKL hKL)
Definition: kbswitch.c:897

Referenced by KbSwitch_OnTimer(), and UpdateLanguageDisplayCurrent().

◆ UpdateLanguageDisplayCurrent()

UINT UpdateLanguageDisplayCurrent ( HWND  hwnd,
HWND  hwndFore 
)

Definition at line 926 of file kbswitch.c.

927{
929 DWORD dwThreadID = GetWindowThreadProcessId(GetTargetWindow(hwndFore), NULL);
930 HKL hKL = GetKeyboardLayout(dwThreadID);
933 return 0;
934}

Referenced by KbSwitch_OnWindowActivate().

◆ UpdateLayoutList()

static VOID UpdateLayoutList ( HKL hKL  OPTIONAL)
static

Definition at line 251 of file kbswitch.c.

252{
253 if (!hKL)
254 hKL = GetActiveKL();
255
256 HICON ahSysPenIcons[MAX_KLS];
257 WORD aiSysPenIcons[MAX_KLS];
258 BYTE anFlags[MAX_KLS];
259 ZeroMemory(ahSysPenIcons, sizeof(ahSysPenIcons));
260 FillMemory(aiSysPenIcons, sizeof(aiSysPenIcons), 0xFF);
261 ZeroMemory(anFlags, sizeof(anFlags));
262
263 HKL ahKLs[MAX_KLS];
264 UINT iKL, nKLs = GetKeyboardLayoutList(_countof(ahKLs), ahKLs);
265
266 /* Reuse old icons and flags */
267 for (iKL = 0; iKL < nKLs; ++iKL)
268 {
269 LANGID wLangID = LOWORD(ahKLs[iKL]);
270 switch (wLangID)
271 {
274 case LANGID_JAPANESE:
275 case LANGID_KOREAN:
276 anFlags[iKL] |= LAYOUTF_FAR_EAST;
277 break;
278 default:
279 anFlags[iKL] &= ~LAYOUTF_FAR_EAST;
280 break;
281 }
282
283 UINT iKL2;
284 for (iKL2 = 0; iKL2 < g_cKLs; ++iKL2)
285 {
286 if (ahKLs[iKL] == g_ahKLs[iKL2])
287 {
288 ahSysPenIcons[iKL] = g_ahSysPenIcons[iKL2];
289 aiSysPenIcons[iKL] = g_aiSysPenIcons[iKL2];
290 anFlags[iKL] = g_anFlags[iKL2];
291
292 g_ahSysPenIcons[iKL2] = NULL;
293 break;
294 }
295 }
296 }
297
299
300 g_cKLs = nKLs;
301
302 C_ASSERT(sizeof(g_ahKLs) == sizeof(ahKLs));
303 CopyMemory(g_ahKLs, ahKLs, sizeof(g_ahKLs));
304
305 C_ASSERT(sizeof(g_ahSysPenIcons) == sizeof(ahSysPenIcons));
306 CopyMemory(g_ahSysPenIcons, ahSysPenIcons, sizeof(g_ahSysPenIcons));
307
308 C_ASSERT(sizeof(g_anFlags) == sizeof(anFlags));
309 CopyMemory(g_anFlags, anFlags, sizeof(g_anFlags));
310
312}
#define FillMemory(BUF, SIZ, MASK)
Definition: strucsup.c:31
#define C_ASSERT(e)
Definition: intsafe.h:73
#define MAX_KLS
Definition: kbswitch.c:48
#define LANGID_KOREAN
Definition: kbswitch.h:25
#define LANGID_JAPANESE
Definition: kbswitch.h:24
#define LANGID_CHINESE_SIMPLIFIED
Definition: kbswitch.h:22
#define LANGID_CHINESE_TRADITIONAL
Definition: kbswitch.h:23
#define CopyMemory
Definition: minwinbase.h:29
UINT WINAPI GetKeyboardLayoutList(_In_ int nBuff, _Out_writes_to_opt_(nBuff, return) HKL FAR *lpList)
unsigned char BYTE
Definition: xxhash.c:193

Referenced by KbSwitch_OnCreate(), KbSwitch_OnDefault(), KbSwitch_OnNotifyIconMsg(), KbSwitch_OnTimer(), and UpdateLanguageDisplayCurrent().

◆ UpdatePenIcon()

static VOID UpdatePenIcon ( HWND  hwnd,
UINT  iKL 
)
static

Definition at line 564 of file kbswitch.c.

565{
566 DeletePenIcon(hwnd, iKL);
567
568 // Not Far-East?
569 if (!(g_anFlags[iKL] & LAYOUTF_FAR_EAST))
570 {
572 return;
573 }
574
575 // Get IME file
576 TCHAR szKLID[CCH_LAYOUT_ID + 1], szImeFile[MAX_PATH];
577 GetKLIDFromHKL(g_ahKLs[iKL], szKLID, _countof(szKLID));
578 if (!GetImeFile(szImeFile, _countof(szImeFile), szKLID))
579 {
581 return;
582 }
583
584 // Load pen icon
585 assert(!g_ahSysPenIcons[iKL]);
586 if (g_anFlags[iKL] & LAYOUTF_IME_ICON)
587 g_ahSysPenIcons[iKL] = FakeExtractIcon(szImeFile, g_aiSysPenIcons[iKL]);
588 if (!g_ahSysPenIcons[iKL])
589 g_ahSysPenIcons[iKL] = LoadDefaultPenIcon(szImeFile, g_ahKLs[iKL]);
590 if (!g_ahSysPenIcons[iKL])
591 {
593 return;
594 }
595
596 // Add pen icon
601
602 if (g_anToolTipAtoms[iKL])
604 else
606
608 ERR("Shell_NotifyIcon failed\n");
609 else
611}
#define assert(_expr)
Definition: assert.h:32
#define ImmGetDescription
Definition: imm.h:827
#define WM_PENICONMSG
Definition: kbswitch.c:37
static HICON LoadDefaultPenIcon(PCWSTR szImeFile, HKL hKL)
Definition: kbswitch.c:501
static VOID DeletePenIcon(HWND hwnd, UINT iKL)
Definition: kbswitch.c:215
#define NIM_MODIFY
Definition: shellapi.h:95
#define GlobalGetAtomName
Definition: winbase.h:3609

Referenced by KbSwitch_OnCreate(), KbSwitch_OnDefault(), KbSwitch_OnTimer(), OnIndicatorMsg(), and UpdateLanguageDisplayCurrent().

◆ UpdateTrayIcon()

static VOID UpdateTrayIcon ( HWND  hwnd,
LPTSTR  szKLID,
LPTSTR  szName 
)
static

Definition at line 750 of file kbswitch.c.

751{
752 NOTIFYICONDATA tnid =
753 {
755 };
756 TCHAR szImeFile[80];
757
758 GetImeFile(szImeFile, _countof(szImeFile), szKLID);
759
761 tnid.hIcon = CreateTrayIcon(szKLID, szImeFile);
763
765
766 if (g_hTrayIcon)
768 g_hTrayIcon = tnid.hIcon;
769}

Referenced by ActivateLayout(), AddJobW(), StartDocPrinterW(), and UpdateLanguageDisplay().

◆ UpdateTrayInfo()

static VOID UpdateTrayInfo ( VOID  )
static

Definition at line 93 of file kbswitch.c.

94{
95 g_hTrayWnd = FindWindow(TEXT("Shell_TrayWnd"), NULL);
97}
HWND g_hTrayWnd
Definition: kbswitch.c:70
#define FindWindow
Definition: winuser.h:5888
#define FindWindowEx
Definition: winuser.h:5889

Referenced by KbSwitch_OnCreate(), and KbSwitch_OnDefault().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( internat  )

◆ WndProc()

LRESULT CALLBACK WndProc ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 1412 of file kbswitch.c.

1413{
1414 switch (uMsg)
1415 {
1416 case WM_CREATE:
1417 return KbSwitch_OnCreate(hwnd);
1418
1419 case WM_TIMER:
1421 break;
1422
1423 case WM_LANG_CHANGED: /* Comes from indicdll.dll and this module */
1425
1426 case WM_WINDOW_ACTIVATE: /* Comes from indicdll.dll and this module */
1428
1429 case WM_NOTIFYICONMSG:
1431 break;
1432
1433 case WM_PENICONMSG:
1435 break;
1436
1437 case WM_COMMAND:
1439 break;
1440
1441 case WM_SETTINGCHANGE:
1443 break;
1444
1445 case WM_DESTROY:
1447 break;
1448
1449 case INDICM_SETIMEICON:
1452 if (InSendMessageEx(NULL))
1453 break; /* Must be a PostMessage call for quick response, not SendMessage */
1454
1456 break;
1457
1458 case WM_INPUTLANGCHANGEREQUEST:
1459 TRACE("WM_INPUTLANGCHANGEREQUEST(%p, %p)\n", wParam, lParam);
1461 break;
1462
1463 default:
1464 return KbSwitch_OnDefault(hwnd, uMsg, wParam, lParam);
1465 }
1466
1467 return 0;
1468}
static void KbSwitch_OnCommand(HWND hwnd, UINT nID)
Definition: kbswitch.c:1262
static LRESULT KbSwitch_OnWindowActivate(HWND hwnd, HWND hwndTarget OPTIONAL, LPARAM lParam OPTIONAL)
Definition: kbswitch.c:1308
static LRESULT KbSwitch_OnDefault(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: kbswitch.c:1326
static void KbSwitch_OnSettingChange(HWND hwnd, WPARAM wParam, LPARAM lParam)
Definition: kbswitch.c:1319
static VOID KbSwitch_OnPenIconMsg(HWND hwnd, UINT uMouseMsg)
Definition: kbswitch.c:1091
static LRESULT KbSwitch_OnLangChanged(HWND hwnd, HWND hwndTarget OPTIONAL, HKL hKL OPTIONAL)
Definition: kbswitch.c:1297
static void KbSwitch_OnNotifyIconMsg(HWND hwnd, UINT uMouseMsg)
Definition: kbswitch.c:1003
static void KbSwitch_OnTimer(HWND hwnd, UINT_PTR nTimerID)
Definition: kbswitch.c:989
static VOID OnIndicatorMsg(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: kbswitch.c:1351
static INT KbSwitch_OnCreate(HWND hwnd)
Definition: kbswitch.c:955
static void KbSwitch_OnDestroy(HWND hwnd)
Definition: kbswitch.c:977
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
DWORD WINAPI InSendMessageEx(LPVOID lpReserved)
Definition: message.c:1391
#define WM_CREATE
Definition: winuser.h:1636
#define WM_SETTINGCHANGE
Definition: winuser.h:1657
#define WM_TIMER
Definition: winuser.h:1770
#define WM_DESTROY
Definition: winuser.h:1637

Referenced by _tWinMain().

Variable Documentation

◆ g_ahKLs

◆ g_ahSysPenIcons

HICON g_ahSysPenIcons[MAX_KLS] = { NULL }

Definition at line 65 of file kbswitch.c.

Referenced by DeletePenIcon(), DestroyPenIcons(), UpdateLayoutList(), and UpdatePenIcon().

◆ g_aiSysPenIcons

WORD g_aiSysPenIcons[MAX_KLS] = { 0 }

Definition at line 63 of file kbswitch.c.

Referenced by OnIndicatorMsg(), UpdateLayoutList(), and UpdatePenIcon().

◆ g_anFlags

BYTE g_anFlags[MAX_KLS] = { 0 }

Definition at line 67 of file kbswitch.c.

Referenced by KbSwitch_OnPenIconMsg(), OnIndicatorMsg(), UpdateLayoutList(), and UpdatePenIcon().

◆ g_anToolTipAtoms

WORD g_anToolTipAtoms[MAX_KLS] = { 0 }

Definition at line 64 of file kbswitch.c.

Referenced by OnIndicatorMsg(), and UpdatePenIcon().

◆ g_bSysPenNotifyAdded

BOOL g_bSysPenNotifyAdded = FALSE

Definition at line 66 of file kbswitch.c.

Referenced by DeletePenNotifyIcon(), and UpdatePenIcon().

◆ g_cKLs

◆ g_cSpecialIds

INT g_cSpecialIds = 0

Definition at line 109 of file kbswitch.c.

Referenced by GetKLIDFromHKL(), and LoadSpecialIds().

◆ g_hHookDLL

HMODULE g_hHookDLL = NULL

Definition at line 57 of file kbswitch.c.

Referenced by DeleteHooks(), LoadDefaultPenIcon(), and SetHooks().

◆ g_hInst

◆ g_hTrayIcon

HICON g_hTrayIcon = NULL

Definition at line 58 of file kbswitch.c.

Referenced by AddTrayIcon(), DeleteTrayIcon(), and UpdateTrayIcon().

◆ g_hTrayNotifyWnd

HWND g_hTrayNotifyWnd = NULL

Definition at line 71 of file kbswitch.c.

Referenced by KbSwitch_OnNotifyIconMsg(), KbSwitch_OnPenIconMsg(), and UpdateTrayInfo().

◆ g_hTrayWnd

HWND g_hTrayWnd = NULL

Definition at line 70 of file kbswitch.c.

Referenced by UpdateTrayInfo().

◆ g_hwndLastActive

HWND g_hwndLastActive = NULL

◆ g_iKL

◆ g_SpecialIds

SPECIAL_ID g_SpecialIds[MAX_SPECIAL_IDS]

Definition at line 108 of file kbswitch.c.

Referenced by GetKLIDFromHKL(), and LoadSpecialIds().

◆ g_uShellHookMessage

UINT g_uShellHookMessage = 0

Definition at line 69 of file kbswitch.c.

Referenced by _tWinMain(), and KbSwitch_OnDefault().

◆ g_uTaskbarRestartMsg

UINT g_uTaskbarRestartMsg = 0

Definition at line 68 of file kbswitch.c.

Referenced by KbSwitch_OnCreate(), and KbSwitch_OnDefault().

◆ KbSwitchSetHooks

FN_KbSwitchSetHooks KbSwitchSetHooks = NULL

Definition at line 53 of file kbswitch.c.

Referenced by DeleteHooks(), and SetHooks().

◆ SetPenMenuData

FN_SetPenMenuData SetPenMenuData = NULL

Definition at line 54 of file kbswitch.c.

Referenced by KbSwitch_OnPenIconMsg(), and SetHooks().