ReactOS 0.4.17-dev-470-gf9e3448
kbswitch.c File Reference
#include "kbswitch.h"
#include <shlobj.h>
#include <shlwapi.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 855 of file kbswitch.c.

◆ IFN_SetPenMenuData

#define IFN_SetPenMenuData   14

Definition at line 856 of file kbswitch.c.

◆ IME_HKL_MASK

#define IME_HKL_MASK   0xF000FFFF

Definition at line 46 of file kbswitch.c.

◆ IS_KOREAN_IME_HKL

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

Definition at line 47 of file kbswitch.c.

◆ LAYOUTF_FAR_EAST

#define LAYOUTF_FAR_EAST   0x1

Definition at line 75 of file kbswitch.c.

◆ LAYOUTF_IME_ICON

#define LAYOUTF_IME_ICON   0x2

Definition at line 76 of file kbswitch.c.

◆ LAYOUTF_REMOVE_LEFT_DEF_MENU

#define LAYOUTF_REMOVE_LEFT_DEF_MENU   0x8

Definition at line 78 of file kbswitch.c.

◆ LAYOUTF_REMOVE_RIGHT_DEF_MENU

#define LAYOUTF_REMOVE_RIGHT_DEF_MENU   0x10

Definition at line 79 of file kbswitch.c.

◆ LAYOUTF_TOOLTIP_ATOM

#define LAYOUTF_TOOLTIP_ATOM   0x4

Definition at line 77 of file kbswitch.c.

◆ MAX_KLS

#define MAX_KLS   64

Definition at line 49 of file kbswitch.c.

◆ MAX_SPECIAL_IDS

#define MAX_SPECIAL_IDS   256

Definition at line 107 of file kbswitch.c.

◆ NOTIFY_ICON_ID_LANGUAGE

#define NOTIFY_ICON_ID_LANGUAGE   223

Definition at line 40 of file kbswitch.c.

◆ NOTIFY_ICON_ID_SYSTEM_PEN

#define NOTIFY_ICON_ID_SYSTEM_PEN   224

Definition at line 41 of file kbswitch.c.

◆ TIMER_ID_LANG_CHANGED_DELAYED

#define TIMER_ID_LANG_CHANGED_DELAYED   0x10000

Definition at line 43 of file kbswitch.c.

◆ TIMER_LANG_CHANGED_DELAY

#define TIMER_LANG_CHANGED_DELAY   200

Definition at line 44 of file kbswitch.c.

◆ WM_NOTIFYICONMSG

#define WM_NOTIFYICONMSG   0x8064

Definition at line 37 of file kbswitch.c.

◆ WM_PENICONMSG

#define WM_PENICONMSG   0x8065

Definition at line 38 of file kbswitch.c.

Typedef Documentation

◆ FN_KbSwitchSetHooks

typedef BOOL(APIENTRY * FN_KbSwitchSetHooks) (BOOL bDoHook)

Definition at line 51 of file kbswitch.c.

◆ FN_SetPenMenuData

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

Definition at line 52 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 1472 of file kbswitch.c.

1473{
1475 MSG msg;
1476 HANDLE hMutex;
1477 HWND hwnd;
1478
1479 switch (GetUserDefaultUILanguage())
1480 {
1482 TRACE("LAYOUT_RTL\n");
1484 break;
1485 default:
1486 break;
1487 }
1488
1490 if (!hMutex)
1491 {
1492 ERR("!hMutex\n");
1493 return 1;
1494 }
1495
1497 {
1498 ERR("Another instance is already running\n");
1500 return 1;
1501 }
1502
1504
1505 ZeroMemory(&WndClass, sizeof(WndClass));
1506 WndClass.lpfnWndProc = WndProc;
1507 WndClass.hInstance = hInstance;
1508 WndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
1509 WndClass.lpszClassName = INDICATOR_CLASS;
1510 if (!RegisterClass(&WndClass))
1511 {
1513 return 1;
1514 }
1515
1519 {
1520 ERR("RegisterShellHookWindow failed\n");
1523 return 1;
1524 }
1525
1526 while (GetMessage(&msg, NULL, 0, 0))
1527 {
1530 }
1531
1533 return 0;
1534}
static const WCHAR WndClass[]
#define msg(x)
Definition: auth_time.c:54
#define ERR(fmt,...)
Definition: precomp.h:57
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:70
LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: kbswitch.c:1413
HINSTANCE g_hInst
Definition: kbswitch.c:57
#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:1713
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define CreateMutex
Definition: winbase.h:3477
_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:5920
#define HWND_DESKTOP
Definition: winuser.h:1220
#define GetMessage
Definition: winuser.h:5956
#define RegisterWindowMessage
Definition: winuser.h:6006
#define LoadCursor
Definition: winuser.h:5978
#define RegisterClass
Definition: winuser.h:6002
#define DispatchMessage
Definition: winuser.h:5931
BOOL WINAPI DestroyWindow(_In_ HWND)

◆ ActivateLayout()

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

Definition at line 780 of file kbswitch.c.

781{
782 HKL hKl;
783 TCHAR szKLID[CCH_LAYOUT_ID + 1], szLangName[MAX_PATH];
785
786 if (iKL >= g_cKLs) /* Invalid */
787 return;
788
789 GetKLIDFromLayoutNum(iKL, szKLID, _countof(szKLID));
790 LangID = (LANGID)_tcstoul(szKLID, NULL, 16);
791
792 /* Switch to the new keyboard layout */
793 GetLocaleInfo(LangID, LOCALE_SLANGUAGE, szLangName, _countof(szLangName));
794 UpdateTrayIcon(hwnd, szKLID, szLangName);
795
796 if (hwndTarget && !bNoActivate)
797 SetForegroundWindow(hwndTarget);
798
799 hKl = LoadKeyboardLayout(szKLID, KLF_ACTIVATE);
800 if (hKl)
802
803 /* Post WM_INPUTLANGCHANGEREQUEST */
804 if (hwndTarget)
805 {
806 PostMessage(hwndTarget, WM_INPUTLANGCHANGEREQUEST,
807 INPUTLANGCHANGE_SYSCHARSET, (LPARAM)hKl);
808 }
809 else
810 {
812 }
813
814 g_iKL = iKL;
815}
#define MAX_PATH
Definition: compat.h:34
char TCHAR
Definition: tchar.h:1402
#define _tcstoul
Definition: tchar.h:595
static BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
Definition: kbswitch.c:773
static VOID UpdateTrayIcon(HWND hwnd, LPTSTR szKLID, LPTSTR szName)
Definition: kbswitch.c:751
static VOID GetKLIDFromLayoutNum(UINT iKL, LPTSTR szKLID, SIZE_T KLIDLength)
Definition: kbswitch.c:321
UINT g_cKLs
Definition: kbswitch.c:62
UINT g_iKL
Definition: kbswitch.c:61
#define CCH_LAYOUT_ID
Definition: kbswitch.h:19
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:1369
#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:5982
BOOL WINAPI EnumWindows(_In_ WNDENUMPROC lpEnumFunc, _In_ LPARAM lParam)
#define PostMessage
Definition: winuser.h:5998
HKL WINAPI ActivateKeyboardLayout(_In_ HKL, _In_ UINT)

Referenced by KbSwitch_OnCommand(), and KbSwitch_OnCreate().

◆ AddTrayIcon()

static VOID AddTrayIcon ( HWND  hwnd)
static

Definition at line 712 of file kbswitch.c.

713{
714 NOTIFYICONDATA tnid =
715 {
717 };
718 TCHAR szKLID[CCH_LAYOUT_ID + 1], szName[MAX_PATH], szImeFile[80];
719
720 GetKLIDFromLayoutNum(g_iKL, szKLID, _countof(szKLID));
722 GetImeFile(szImeFile, _countof(szImeFile), szKLID);
723
725 tnid.hIcon = CreateTrayIcon(szKLID, szImeFile);
727
728 if (!Shell_NotifyIcon(NIM_ADD, &tnid))
729 ERR("Shell_NotifyIcon(NIM_ADD) failed\n");
730
731 if (g_hTrayIcon)
733 g_hTrayIcon = tnid.hIcon;
734}
static BOOL GetLayoutName(UINT iKL, LPTSTR szName, SIZE_T NameLength)
Definition: kbswitch.c:338
#define NOTIFY_ICON_ID_LANGUAGE
Definition: kbswitch.c:40
static HICON CreateTrayIcon(LPTSTR szKLID, LPCTSTR szImeFile OPTIONAL)
Definition: kbswitch.c:615
static BOOL GetImeFile(LPTSTR szImeFile, SIZE_T cchImeFile, LPCTSTR szKLID)
Definition: kbswitch.c:374
HICON g_hTrayIcon
Definition: kbswitch.c:59
#define WM_NOTIFYICONMSG
Definition: kbswitch.c:37
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:744
#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:2422

Referenced by KbSwitch_OnCreate(), and KbSwitch_OnDefault().

◆ BitmapFromIcon()

static HBITMAP BitmapFromIcon ( HICON  hIcon)
static

Definition at line 455 of file kbswitch.c.

456{
457 HDC hdcScreen = GetDC(NULL);
458 HDC hdc = CreateCompatibleDC(hdcScreen);
461 HBITMAP hbm = CreateCompatibleBitmap(hdcScreen, cxIcon, cyIcon);
462 HGDIOBJ hbmOld;
463
464 if (hbm != NULL)
465 {
466 hbmOld = SelectObject(hdc, hbm);
467 DrawIconEx(hdc, 0, 0, hIcon, cxIcon, cyIcon, 0, GetSysColorBrush(COLOR_MENU), DI_NORMAL);
468 SelectObject(hdc, hbmOld);
469 }
470
471 DeleteDC(hdc);
472 ReleaseDC(NULL, hdcScreen);
473 return hbm;
474}
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:2397
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 818 of file kbswitch.c.

819{
820 HMENU hMenu = CreatePopupMenu();
821 TCHAR szName[MAX_PATH], szKLID[CCH_LAYOUT_ID + 1], szImeFile[80];
822 HICON hIcon;
823 MENUITEMINFO mii = { sizeof(mii) };
824 UINT iKL;
825
826 for (iKL = 0; iKL < g_cKLs; ++iKL)
827 {
828 GetKLIDFromHKL(g_ahKLs[iKL], szKLID, _countof(szKLID));
829 GetImeFile(szImeFile, _countof(szImeFile), szKLID);
830
831 if (!GetLayoutName(iKL, szName, _countof(szName)))
832 continue;
833
834 mii.fMask = MIIM_ID | MIIM_STRING;
835 mii.wID = ID_LANG_BASE + iKL;
836 mii.dwTypeData = szName;
837
838 hIcon = CreateTrayIcon(szKLID, szImeFile);
839 if (hIcon)
840 {
841 mii.hbmpItem = BitmapFromIcon(hIcon);
842 if (mii.hbmpItem)
843 mii.fMask |= MIIM_BITMAP;
844 }
845
846 InsertMenuItem(hMenu, -1, TRUE, &mii);
848 }
849
851
852 return hMenu;
853}
#define ID_LANG_BASE
Definition: resource.h:24
#define TRUE
Definition: types.h:120
unsigned int UINT
Definition: sysinfo.c:13
static HBITMAP BitmapFromIcon(HICON hIcon)
Definition: kbswitch.c:455
static VOID GetKLIDFromHKL(HKL hKL, LPTSTR szKLID, SIZE_T KLIDLength)
Definition: kbswitch.c:165
HKL g_ahKLs[MAX_KLS]
Definition: kbswitch.c:63
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
LPSTR dwTypeData
Definition: winuser.h:3359
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:5970
#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 615 of file kbswitch.c.

616{
618 TCHAR szBuf[4];
619 HDC hdcScreen, hdc;
620 HBITMAP hbmColor, hbmMono, hBmpOld;
621 HFONT hFont, hFontOld;
622 LOGFONT lf;
623 RECT rect;
625 HICON hIcon;
629
630 if (szImeFile && szImeFile[0])
631 {
632 if (GetSystemLibraryPath(szPath, _countof(szPath), szImeFile))
633 return FakeExtractIcon(szPath, 0);
634 }
635
636 /* Getting "EN", "FR", etc. from English, French, ... */
637 LangID = LANGIDFROMLCID(_tcstoul(szKLID, NULL, 16));
640 szBuf,
641 _countof(szBuf)) == 0)
642 {
643 szBuf[0] = szBuf[1] = _T('?');
644 }
645 szBuf[2] = 0; /* Truncate the identifier to two characters: "ENG" --> "EN" etc. */
646
647 /* Create hdc, hbmColor and hbmMono */
648 hdcScreen = GetDC(NULL);
649 hdc = CreateCompatibleDC(hdcScreen);
650 hbmColor = CreateCompatibleBitmap(hdcScreen, cxIcon, cyIcon);
651 ReleaseDC(NULL, hdcScreen);
652 hbmMono = CreateBitmap(cxIcon, cyIcon, 1, 1, NULL);
653
654 /* Checking NULL */
655 if (!hdc || !hbmColor || !hbmMono)
656 {
657 if (hbmMono)
658 DeleteObject(hbmMono);
659 if (hbmColor)
660 DeleteObject(hbmColor);
661 if (hdc)
662 DeleteDC(hdc);
663 return NULL;
664 }
665
666 /* Create a font */
667 hFont = NULL;
668 if (SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(lf), &lf, 0))
669 {
670 /* Override the current size with something manageable */
671 lf.lfHeight = -11;
672 lf.lfWidth = 0;
674 }
675 if (!hFont)
677
678 SetRect(&rect, 0, 0, cxIcon, cyIcon);
679
680 /* Draw hbmColor */
681 hBmpOld = SelectObject(hdc, hbmColor);
683 FillRect(hdc, &rect, (HBRUSH)GetStockObject(DC_BRUSH));
684 hFontOld = SelectObject(hdc, hFont);
688 SelectObject(hdc, hFontOld);
689
690 /* Fill hbmMono with black */
691 SelectObject(hdc, hbmMono);
692 PatBlt(hdc, 0, 0, cxIcon, cyIcon, BLACKNESS);
693 SelectObject(hdc, hBmpOld);
694
695 /* Create an icon from hbmColor and hbmMono */
698 IconInfo.hbmColor = hbmColor;
699 IconInfo.hbmMask = hbmMono;
701
702 /* Clean up */
704 DeleteObject(hbmMono);
705 DeleteObject(hbmColor);
706 DeleteDC(hdc);
707
708 return hIcon;
709}
HFONT hFont
Definition: main.c:53
RECT rect
Definition: combotst.c:67
pKey DeleteObject()
_Out_opt_ PICONINFO IconInfo
Definition: ntuser.h:2310
static HICON FakeExtractIcon(PCTSTR pszImeFile, INT nIconIndex)
Definition: kbswitch.c:438
static BOOL GetSystemLibraryPath(LPTSTR szPath, SIZE_T cchPath, LPCTSTR FileName)
Definition: kbswitch.c:327
LPCWSTR szPath
Definition: env.c:37
#define LANGIDFROMLCID(l)
Definition: nls.h:18
LONG lfHeight
Definition: dimm.idl:42
LONG lfWidth
Definition: dimm.idl:43
DWORD yHotspot
Definition: winuser.h:3233
BOOL fIcon
Definition: winuser.h:3231
DWORD xHotspot
Definition: winuser.h:3232
HBITMAP hbmColor
Definition: winuser.h:3235
HBITMAP hbmMask
Definition: winuser.h:3234
#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:37
DWORD WINAPI GetSysColor(_In_ int)
HICON WINAPI CreateIconIndirect(_In_ PICONINFO)
Definition: cursoricon.c:2975
#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:5937
#define COLOR_HIGHLIGHTTEXT
Definition: winuser.h:938
#define DT_VCENTER
Definition: winuser.h:543
#define SystemParametersInfo
Definition: winuser.h:6024
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 881 of file kbswitch.c.

882{
884 {
887 }
888
889 if (g_hHookDLL)
890 {
893 }
894
895 TRACE("DeleteHooks OK\n");
896}
#define FreeLibrary(x)
Definition: compat.h:748
HMODULE g_hHookDLL
Definition: kbswitch.c:58
FN_KbSwitchSetHooks KbSwitchSetHooks
Definition: kbswitch.c:54

Referenced by KbSwitch_OnDestroy().

◆ DeletePenIcon()

static VOID DeletePenIcon ( HWND  hwnd,
UINT  iKL 
)
static

Definition at line 216 of file kbswitch.c.

217{
219
220 if (g_ahSysPenIcons[iKL])
221 {
223 g_ahSysPenIcons[iKL] = NULL;
224 }
225}
HICON g_ahSysPenIcons[MAX_KLS]
Definition: kbswitch.c:66
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329

Referenced by UpdatePenIcon().

◆ DeletePenNotifyIcon()

static VOID DeletePenNotifyIcon ( HWND  hwnd)
static

Definition at line 552 of file kbswitch.c.

553{
555 return;
556
559 ERR("Shell_NotifyIcon(NIM_DELETE) failed\n");
560 else
562}
BOOL g_bSysPenNotifyAdded
Definition: kbswitch.c:67
#define NOTIFY_ICON_ID_SYSTEM_PEN
Definition: kbswitch.c:41
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 737 of file kbswitch.c.

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

Referenced by KbSwitch_OnDestroy().

◆ DestroyPenIcons()

static VOID DestroyPenIcons ( VOID  )
static

Definition at line 228 of file kbswitch.c.

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

Referenced by KbSwitch_OnDestroy(), and UpdateLayoutList().

◆ EnumResNameProc()

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

Definition at line 415 of file kbswitch.c.

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

Referenced by FakeExtractIcon().

◆ EnumWindowsProc()

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

Definition at line 773 of file kbswitch.c.

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

Referenced by ActivateLayout().

◆ FakeExtractIcon()

static HICON FakeExtractIcon ( PCTSTR  pszImeFile,
INT  nIconIndex 
)
static

Definition at line 438 of file kbswitch.c.

439{
440 HMODULE hImeDLL = LoadLibraryEx(pszImeFile, NULL, LOAD_LIBRARY_AS_DATAFILE);
441 if (!hImeDLL)
442 return NULL;
443
445 {
447 };
449
450 FreeLibrary(hImeDLL);
451
452 return LoadIcon.hIcon;
453}
static BOOL CALLBACK EnumResNameProc(HMODULE hModule, LPCTSTR lpszType, LPTSTR lpszName, LPARAM lParam)
Definition: kbswitch.c:415
#define RT_GROUP_ICON
Definition: pedump.c:375
#define LoadLibraryEx
Definition: winbase.h:3584
#define LOAD_LIBRARY_AS_DATAFILE
Definition: winbase.h:338
#define EnumResourceNames
Definition: winbase.h:3493
#define LoadIcon
Definition: winuser.h:5979

Referenced by CreateTrayIcon(), and UpdatePenIcon().

◆ GetActiveKL()

static HKL GetActiveKL ( VOID  )
static

Definition at line 206 of file kbswitch.c.

207{
208 /* FIXME: Get correct console window's HKL when console window */
209 HWND hwndTarget = GetTargetWindow(NULL);
210 TRACE("hwndTarget: %p\n", hwndTarget);
211 DWORD dwTID = GetWindowThreadProcessId(hwndTarget, NULL);
212 return GetKeyboardLayout(dwTID);
213}
unsigned long DWORD
Definition: ntddk_ex.h:95
static HWND GetTargetWindow(HWND hwndFore OPTIONAL)
Definition: kbswitch.c:194
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 315 of file kbswitch.c.

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

Referenced by GetKLIDFromLayoutNum().

◆ GetImeConversionMode()

static DWORD GetImeConversionMode ( HWND  hwndIme)
inlinestatic

Definition at line 88 of file kbswitch.c.

89{
91}
#define IMC_GETCONVERSIONMODE
Definition: immdev.h:86
#define SendMessage
Definition: winuser.h:6009
#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 374 of file kbswitch.c.

375{
376 HKEY hKey;
377 DWORD dwBufLen;
378 TCHAR szBuf[MAX_PATH];
379
380 szImeFile[0] = UNICODE_NULL;
381
382 if (_tcslen(szKLID) != CCH_LAYOUT_ID)
383 return FALSE; /* Invalid LCID */
384
385 if (szKLID[0] != TEXT('E') && szKLID[0] != TEXT('e'))
386 return FALSE; /* Not an IME HKL */
387
388 StringCchPrintf(szBuf, _countof(szBuf),
389 _T("SYSTEM\\CurrentControlSet\\Control\\Keyboard Layouts\\%s"), szKLID);
390
392 return FALSE;
393
394 dwBufLen = cchImeFile * sizeof(TCHAR);
395 if (RegQueryValueEx(hKey, _T("IME File"), NULL, NULL,
396 (LPBYTE)szImeFile, &dwBufLen) != ERROR_SUCCESS)
397 {
398 szImeFile[0] = UNICODE_NULL;
399 }
400
402
403 return (szImeFile[0] != UNICODE_NULL);
404}
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
FxAutoRegKey hKey
#define _tcslen
Definition: tchar.h:626
#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:552
#define RegQueryValueEx
Definition: winreg.h:556

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

◆ GetImeStatus()

static DWORD GetImeStatus ( HWND  hwndTarget)
static

Definition at line 477 of file kbswitch.c.

478{
479 HWND hwndIme = ImmGetDefaultIMEWnd(hwndTarget);
480 if (!hwndIme)
482
483 HIMC hIMC = (HIMC)SendMessage(hwndIme, WM_IME_SYSTEM, IMS_GETCONTEXT, (LPARAM)hwndTarget);
484 if (!hIMC)
485 return IME_STATUS_NO_IME;
486
487 DWORD dwImeStatus = (IsImeOpen(hwndIme) ? IME_STATUS_IME_OPEN : IME_STATUS_IME_CLOSED);
488 if (GetACP() == 949) // Korean
489 {
490 DWORD dwConversion = GetImeConversionMode(hwndIme);
491 if (dwConversion & IME_CMODE_NATIVE)
492 dwImeStatus |= IME_STATUS_IME_NATIVE;
493
494 if (dwConversion & IME_CMODE_FULLSHAPE)
495 dwImeStatus |= IME_STATUS_IME_FULLSHAPE;
496 }
497
498 return dwImeStatus;
499}
DWORD HIMC
Definition: dimm.idl:75
UINT WINAPI GetACP(void)
Definition: locale.c:2023
#define IMS_GETCONTEXT
Definition: imm32_undoc.h:65
#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:441
#define IME_CMODE_FULLSHAPE
Definition: imm.h:345
static BOOL IsImeOpen(HWND hwndIme)
Definition: kbswitch.c:82
static DWORD GetImeConversionMode(HWND hwndIme)
Definition: kbswitch.c:88
#define IME_STATUS_IME_CLOSED
Definition: kbswitch.h:26
#define IME_STATUS_IME_OPEN
Definition: kbswitch.h:27
#define IME_STATUS_NO_IME
Definition: kbswitch.h:25
#define IME_STATUS_IME_FULLSHAPE
Definition: kbswitch.h:29
#define IME_STATUS_IME_NATIVE
Definition: kbswitch.h:28

Referenced by LoadDefaultPenIcon().

◆ GetKLIDFromHKL()

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

Definition at line 165 of file kbswitch.c.

166{
167 szKLID[0] = 0;
168
169 if (IS_IME_HKL(hKL))
170 {
171 StringCchPrintf(szKLID, KLIDLength, _T("%08lx"), (DWORD)(DWORD_PTR)hKL);
172 return;
173 }
174
175 if (IS_SPECIAL_HKL(hKL))
176 {
177 INT i;
178 for (i = 0; i < g_cSpecialIds; ++i)
179 {
180 if (g_SpecialIds[i].hKL == hKL)
181 {
182 StringCchCopy(szKLID, KLIDLength, g_SpecialIds[i].szKLID);
183 return;
184 }
185 }
186 }
187 else
188 {
189 StringCchPrintf(szKLID, KLIDLength, _T("%08lx"), LOWORD(hKL));
190 }
191}
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:110
SPECIAL_ID g_SpecialIds[MAX_SPECIAL_IDS]
Definition: kbswitch.c:109
#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 321 of file kbswitch.c.

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

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

◆ GetLayoutIndexFromHKL()

static UINT GetLayoutIndexFromHKL ( HKL  hKL)
static

Definition at line 242 of file kbswitch.c.

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

Referenced by OnIndicatorMsg(), and UpdateLayoutList().

◆ GetLayoutName()

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

Definition at line 338 of file kbswitch.c.

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

Referenced by AddTrayIcon(), and BuildLeftPopupMenu().

◆ GetLayoutNum()

static UINT GetLayoutNum ( HKL  hKL)
static

Definition at line 898 of file kbswitch.c.

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

Referenced by UpdateLanguageDisplay().

◆ GetSystemLibraryPath()

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

Definition at line 327 of file kbswitch.c.

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

Referenced by CreateTrayIcon(), and LayoutList_ReadLayout().

◆ GetTargetWindow()

static HWND GetTargetWindow ( HWND hwndFore  OPTIONAL)
static

Definition at line 194 of file kbswitch.c.

195{
196 HWND hwndTarget = (hwndFore ? hwndFore : GetForegroundWindow());
197 if (!hwndTarget ||
198 IsWndClassName(hwndTarget, INDICATOR_CLASS) ||
199 IsWndClassName(hwndTarget, TEXT("Shell_TrayWnd")))
200 {
201 hwndTarget = g_hwndLastActive;
202 }
203 return hwndTarget;
204}
HWND g_hwndLastActive
Definition: kbswitch.c:60
static BOOL IsWndClassName(_In_opt_ HWND hwndTarget, PCTSTR pszName)
Definition: kbswitch.h:32
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 82 of file kbswitch.c.

83{
85}
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 1044 of file kbswitch.c.

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

Referenced by KbSwitch_OnPenIconMsg().

◆ KbSwitch_OnCommand()

static void KbSwitch_OnCommand ( HWND  hwnd,
UINT  nID 
)
static

Definition at line 1263 of file kbswitch.c.

1264{
1265 switch (nID)
1266 {
1267 case ID_EXIT:
1268 PostMessage(hwnd, WM_CLOSE, 0, 0);
1269 break;
1270
1271 case ID_PREFERENCES:
1272 {
1274 TEXT("control.exe"), TEXT("input.dll"),
1276 if (ret <= 32)
1277 MessageBox(hwnd, _T("Can't start input.dll"), NULL, MB_ICONERROR);
1278 break;
1279 }
1280
1281 default:
1282 {
1283 if (nID >= ID_LANG_BASE)
1284 {
1286 {
1288 }
1290 }
1291 break;
1292 }
1293 }
1294}
#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:780
#define ShellExecute
Definition: shellapi.h:746
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:5988

Referenced by WndProc().

◆ KbSwitch_OnCreate()

static INT KbSwitch_OnCreate ( HWND  hwnd)
static

Definition at line 956 of file kbswitch.c.

957{
958 if (!SetHooks())
959 {
960 MessageBox(NULL, TEXT("SetHooks failed."), NULL, MB_ICONERROR);
961 return -1; /* Failed */
962 }
963
969
972
973 return 0; /* Success */
974}
static VOID LoadSpecialIds(VOID)
Definition: kbswitch.c:112
static VOID UpdatePenIcon(HWND hwnd, UINT iKL)
Definition: kbswitch.c:565
static VOID UpdateLayoutList(HKL hKL OPTIONAL)
Definition: kbswitch.c:252
static VOID UpdateTrayInfo(VOID)
Definition: kbswitch.c:94
static BOOL SetHooks(VOID)
Definition: kbswitch.c:859
static VOID AddTrayIcon(HWND hwnd)
Definition: kbswitch.c:712
UINT g_uTaskbarRestartMsg
Definition: kbswitch.c:69

Referenced by WndProc().

◆ KbSwitch_OnDefault()

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

Definition at line 1327 of file kbswitch.c.

1328{
1329 if (uMsg == g_uTaskbarRestartMsg)
1330 {
1335 return 0;
1336 }
1337
1338 if (uMsg == g_uShellHookMessage)
1339 {
1340 TRACE("g_uShellHookMessage: wParam:%p, lParam:%p\n", wParam, lParam);
1341 if (wParam == HSHELL_LANGUAGE)
1343 else if (wParam == HSHELL_WINDOWACTIVATED || wParam == HSHELL_RUDEAPPACTIVATED)
1345 return 0;
1346 }
1347
1348 return DefWindowProc(hwnd, uMsg, wParam, lParam);
1349}
WPARAM wParam
Definition: combotst.c:138
#define WM_WINDOW_ACTIVATE
Definition: kbswitch.h:23
#define WM_LANG_CHANGED
Definition: kbswitch.h:22
#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 978 of file kbswitch.c.

979{
981 DeleteHooks();
986}
#define TIMER_ID_LANG_CHANGED_DELAYED
Definition: kbswitch.c:43
static VOID DeleteHooks(VOID)
Definition: kbswitch.c:881
static VOID DestroyPenIcons(VOID)
Definition: kbswitch.c:228
static VOID DeletePenNotifyIcon(HWND hwnd)
Definition: kbswitch.c:552
static VOID DeleteTrayIcon(HWND hwnd)
Definition: kbswitch.c:737
__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 1298 of file kbswitch.c.

1299{
1300 TRACE("WM_LANG_CHANGED: hwndTarget:%p, hKL:%p\n", hwndTarget, hKL);
1301 /* Delayed action */
1304 return 0;
1305}
#define TIMER_LANG_CHANGED_DELAY
Definition: kbswitch.c:44
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 1004 of file kbswitch.c.

1005{
1006 if (uMouseMsg != WM_LBUTTONUP && uMouseMsg != WM_RBUTTONUP)
1007 return;
1008
1010
1011 POINT pt;
1012 GetCursorPos(&pt);
1013
1015
1016 TPMPARAMS params = { sizeof(params) };
1018
1019 INT nID;
1020 if (uMouseMsg == WM_LBUTTONUP)
1021 {
1022 /* Rebuild the left popup menu on every click to take care of keyboard layout changes */
1023 HMENU hPopupMenu = BuildLeftPopupMenu();
1025 nID = TrackPopupMenuEx(hPopupMenu, uFlags, pt.x, pt.y, hwnd, &params);
1026 DestroyMenu(hPopupMenu);
1027 }
1028 else /* WM_RBUTTONUP */
1029 {
1031 HMENU hSubMenu = GetSubMenu(hPopupMenu, 0);
1033 nID = TrackPopupMenuEx(hSubMenu, uFlags, pt.x, pt.y, hwnd, &params);
1034 DestroyMenu(hPopupMenu);
1035 }
1036
1037 PostMessage(hwnd, WM_NULL, 0, 0);
1038
1039 if (nID)
1040 PostMessage(hwnd, WM_COMMAND, nID, 0);
1041}
#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:72
static HMENU BuildLeftPopupMenu(VOID)
Definition: kbswitch.c:818
#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:3064
#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:5983
#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 1092 of file kbswitch.c.

1093{
1094 if (uMouseMsg != WM_LBUTTONUP && uMouseMsg != WM_RBUTTONUP)
1095 return;
1096
1098 return;
1099
1100 POINT pt;
1101 GetCursorPos(&pt);
1102
1103 // Get target window
1104 TRACE("g_hwndLastActive: %p\n", g_hwndLastActive);
1106 TRACE("hwndTarget: %p\n", hwndTarget);
1107
1108 // Get default IME window
1109 HWND hwndIme = ImmGetDefaultIMEWnd(hwndTarget);
1110 if (!hwndIme)
1111 {
1112 WARN("No default IME\n");
1113 return;
1114 }
1115
1116 // Get IME context from another process
1117 HIMC hIMC = (HIMC)SendMessage(hwndIme, WM_IME_SYSTEM, IMS_GETCONTEXT, (LPARAM)hwndTarget);
1118 if (!hIMC)
1119 {
1120 WARN("No HIMC\n");
1121 return;
1122 }
1123
1124 // Is IME open?
1125 BOOL bImeOn = IsImeOpen(hwndIme);
1126
1127 // Workaround of TrackPopupMenu's bug.
1128 // NOTE: This might change IME status.
1130
1131 // Create IME menu
1132 BOOL bRightButton = (uMouseMsg == WM_RBUTTONUP);
1133 PIMEMENUNODE pImeMenu = CreateImeMenu(hIMC, NULL, bRightButton);
1134 HMENU hMenu = MenuFromImeMenu(pImeMenu);
1135
1136 HKL hKL = g_ahKLs[g_iKL];
1137 BOOL bSoftOn = FALSE, bShowToolbar = FALSE;
1138 TCHAR szText[128];
1139 if (bRightButton)
1140 {
1141 if (!(g_anFlags[g_iKL] & LAYOUTF_REMOVE_RIGHT_DEF_MENU)) // Add default menu items?
1142 {
1143 if (GetMenuItemCount(hMenu))
1144 AppendMenu(hMenu, MF_SEPARATOR, 0, NULL); // Separator
1145
1146 // "Input System (IME) configuration..."
1147 LoadString(g_hInst, IDS_INPUTSYSTEM, szText, _countof(szText));
1148 AppendMenu(hMenu, MF_STRING, ID_INPUTSYSTEM, szText);
1149 }
1150 }
1151 else
1152 {
1153 if (!(g_anFlags[g_iKL] & LAYOUTF_REMOVE_LEFT_DEF_MENU)) // Add default menu items?
1154 {
1155 if (GetMenuItemCount(hMenu))
1156 AppendMenu(hMenu, MF_SEPARATOR, 0, NULL); // Separator
1157
1158 if (!IS_KOREAN_IME_HKL(hKL)) // Not Korean IME?
1159 {
1160 // "IME ON / OFF"
1161 UINT nId = (bImeOn ? IDS_IME_ON : IDS_IME_OFF);
1162 LoadString(g_hInst, nId, szText, _countof(szText));
1163 AppendMenu(hMenu, MF_STRING, ID_IMEONOFF, szText);
1164 }
1165
1167 IsWindow(hwndIme)) // Is Soft Keyboard available?
1168 {
1169 // "Soft Keyboard ON / OFF"
1171 UINT nId = (bSoftOn ? IDS_SOFTKBD_ON : IDS_SOFTKBD_OFF);
1172 LoadString(g_hInst, nId, szText, _countof(szText));
1173 AppendMenu(hMenu, MF_STRING, ID_SOFTKBDONOFF, szText);
1174 }
1175
1176 if (GetMenuItemCount(hMenu))
1177 AppendMenu(hMenu, MF_SEPARATOR, 0, NULL); // Separator
1178
1179 // "Show toolbar"
1180 LoadString(g_hInst, IDS_SHOWTOOLBAR, szText, _countof(szText));
1181 AppendMenu(hMenu, MF_STRING, ID_SHOWTOOLBAR, szText);
1182 bShowToolbar = IsRegImeToolbarShown();
1183 if (bShowToolbar)
1185 }
1186 }
1187
1188 if (!GetMenuItemCount(hMenu)) // No items?
1189 {
1190 // Clean up
1191 DestroyMenu(hMenu);
1193
1194 SetForegroundWindow(hwndTarget);
1195 return;
1196 }
1197
1198 // TrackPopupMenuEx flags
1200 uFlags |= (bRightButton ? TPM_RIGHTBUTTON : TPM_LEFTBUTTON);
1201
1202 // Exclude the notification area
1203 TPMPARAMS params = { sizeof(params) };
1205
1206 // Show the popup menu
1207 INT nID = TrackPopupMenuEx(hMenu, uFlags, pt.x, pt.y, hwnd, &params);
1208
1209 // Workaround of TrackPopupMenu's bug
1210 PostMessage(hwnd, WM_NULL, 0, 0);
1211
1212 // Back to target window
1213 SetForegroundWindow(hwndTarget);
1214
1215 if (nID) // Action!
1216 {
1217 if (nID >= ID_STARTIMEMENU) // IME internal menu ID?
1218 {
1219 MENUITEMINFO mii = { sizeof(mii), MIIM_DATA };
1220 GetMenuItemInfo(hMenu, nID, FALSE, &mii);
1221
1222 if (pImeMenu)
1223 nID = GetRealImeMenuID(pImeMenu, nID);
1224
1225 if (SetPenMenuData)
1226 SetPenMenuData(nID, mii.dwItemData);
1227
1229 }
1230 else // Otherwise action of IME menu item
1231 {
1232 switch (nID)
1233 {
1234 case ID_INPUTSYSTEM:
1235 if (IS_IME_HKL(hKL))
1237 break;
1238 case ID_IMEONOFF:
1239 PostMessage(hwndIme, WM_IME_SYSTEM, IMS_SETOPENSTATUS, !bImeOn);
1240 break;
1241 case ID_SOFTKBDONOFF:
1242 PostMessage(hwndIme, WM_IME_SYSTEM, IMS_SOFTKBDONOFF, !bSoftOn);
1243 break;
1244 case ID_SHOWTOOLBAR:
1245 ShowImeToolbar(hwndTarget, !bShowToolbar);
1246 break;
1247 default:
1248 {
1249 PostMessage(hwnd, WM_COMMAND, nID, 0);
1250 break;
1251 }
1252 }
1253 }
1254 }
1255
1256 // Clean up
1257 DestroyMenu(hMenu);
1259}
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:53
#define IMS_IMEMENUITEMSELECTED
Definition: imm32_undoc.h:64
#define IMS_GETCONVSTATUS
Definition: imm32_undoc.h:56
#define IMS_CONFIGURE
Definition: imm32_undoc.h:52
#define IMS_SOFTKBDONOFF
Definition: imm32_undoc.h:55
#define IME_CMODE_SOFTKBD
Definition: imm.h:349
DWORD WINAPI ImmGetProperty(_In_ HKL hKL, _In_ DWORD fdwIndex)
Definition: ime.c:768
#define IGP_CONVERSION
Definition: imm.h:301
static BOOL IsRegImeToolbarShown(VOID)
Definition: kbswitch.c:1044
#define LAYOUTF_REMOVE_LEFT_DEF_MENU
Definition: kbswitch.c:78
BYTE g_anFlags[MAX_KLS]
Definition: kbswitch.c:68
#define LAYOUTF_FAR_EAST
Definition: kbswitch.c:75
#define LAYOUTF_REMOVE_RIGHT_DEF_MENU
Definition: kbswitch.c:79
#define IS_KOREAN_IME_HKL(hKL)
Definition: kbswitch.c:47
FN_SetPenMenuData SetPenMenuData
Definition: kbswitch.c:55
static VOID ShowImeToolbar(HWND hwndTarget, BOOL bShowToolbar)
Definition: kbswitch.c:1069
ULONG_PTR dwItemData
Definition: winuser.h:3358
int WINAPI GetMenuItemCount(_In_opt_ HMENU)
#define AppendMenu
Definition: winuser.h:5897
#define MF_STRING
Definition: winuser.h:138
#define MF_SEPARATOR
Definition: winuser.h:137
#define LoadString
Definition: winuser.h:5985
#define GetMenuItemInfo
Definition: winuser.h:5954
#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 1320 of file kbswitch.c.

1321{
1322 if (wParam == SPI_SETNONCLIENTMETRICS)
1324}

Referenced by WndProc().

◆ KbSwitch_OnTimer()

static void KbSwitch_OnTimer ( HWND  hwnd,
UINT_PTR  nTimerID 
)
static

Definition at line 990 of file kbswitch.c.

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

Referenced by WndProc().

◆ KbSwitch_OnWindowActivate()

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

Definition at line 1309 of file kbswitch.c.

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

Referenced by WndProc().

◆ LoadDefaultPenIcon()

static HICON LoadDefaultPenIcon ( PCWSTR  szImeFile,
HKL  hKL 
)
static

Definition at line 502 of file kbswitch.c.

503{
505 DWORD dwImeStatus = GetImeStatus(hwndTarget);
506
507 INT nIconID = -1;
508 if (IS_KOREAN_IME_HKL(hKL)) // Korean IME?
509 {
510 if (dwImeStatus != IME_STATUS_NO_IME)
511 {
512 if (dwImeStatus & IME_STATUS_IME_CLOSED)
513 {
514 nIconID = IDI_KOREAN_A_HALF;
515 }
516 else
517 {
518 if (dwImeStatus & IME_STATUS_IME_FULLSHAPE)
519 {
520 if (dwImeStatus & IME_STATUS_IME_NATIVE)
521 nIconID = IDI_KOREAN_JR_FULL;
522 else
523 nIconID = IDI_KOREAN_A_FULL;
524 }
525 else
526 {
527 if (dwImeStatus & IME_STATUS_IME_NATIVE)
528 nIconID = IDI_KOREAN_JR_HALF;
529 else
530 nIconID = IDI_KOREAN_A_HALF;
531 }
532 }
533 }
534 }
535 else
536 {
537 if (dwImeStatus & IME_STATUS_IME_CLOSED)
538 nIconID = IDI_IME_CLOSED;
539 else if (dwImeStatus & IME_STATUS_IME_OPEN)
540 nIconID = IDI_IME_OPEN;
541 else
542 nIconID = IDI_IME_DISABLED;
543 }
544
545 if (nIconID < 0)
546 return NULL;
547
548 return LoadIcon(g_hHookDLL, MAKEINTRESOURCE(nIconID));
549}
#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:477

Referenced by UpdatePenIcon().

◆ LoadSpecialIds()

static VOID LoadSpecialIds ( VOID  )
static

Definition at line 112 of file kbswitch.c.

113{
114 TCHAR szKLID[KL_NAMELENGTH], szLayoutId[16];
115 DWORD dwSize, dwIndex;
116 HKEY hKey, hLayoutKey;
117
118 g_cSpecialIds = 0;
119
121 TEXT("SYSTEM\\CurrentControlSet\\Control\\Keyboard Layouts"),
122 0, KEY_READ, &hKey) != ERROR_SUCCESS)
123 {
124 return;
125 }
126
127 for (dwIndex = 0; dwIndex < 1000; ++dwIndex)
128 {
129 dwSize = _countof(szKLID);
130 if (RegEnumKeyEx(hKey, dwIndex, szKLID, &dwSize, NULL, NULL, NULL, NULL) != ERROR_SUCCESS)
131 break;
132
133 if (RegOpenKeyEx(hKey, szKLID, 0, KEY_READ, &hLayoutKey) != ERROR_SUCCESS)
134 continue;
135
136 dwSize = sizeof(szLayoutId);
137 if (RegQueryValueEx(hLayoutKey, TEXT("Layout Id"), NULL, NULL,
138 (LPBYTE)szLayoutId, &dwSize) == ERROR_SUCCESS)
139 {
140 DWORD dwKLID = _tcstoul(szKLID, NULL, 16);
141 WORD wLangId = LOWORD(dwKLID), wLayoutId = LOWORD(_tcstoul(szLayoutId, NULL, 16));
142 HKL hKL = (HKL)(LONG_PTR)(SPECIAL_MASK | MAKELONG(wLangId, wLayoutId));
143
144 /* Add a special ID */
148 _countof(g_SpecialIds[g_cSpecialIds].szKLID), szKLID);
150 }
151
152 RegCloseKey(hLayoutKey);
153
155 {
156 ERR("g_SpecialIds is full!");
157 break;
158 }
159 }
160
162}
#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:102
#define MAKELONG(a, b)
Definition: typedefs.h:249
#define RegEnumKeyEx
Definition: winreg.h:541
#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 1352 of file kbswitch.c.

1353{
1354 HKL hKL = (HKL)lParam;
1355 UINT iKL = GetLayoutIndexFromHKL(hKL);
1356 if (iKL >= g_cKLs)
1357 return;
1358
1359 g_iKL = iKL;
1360
1361 switch (uMsg)
1362 {
1363 case INDICM_SETIMEICON:
1364 if (LOWORD(wParam) == MAXWORD)
1365 {
1366 g_anFlags[iKL] &= ~LAYOUTF_IME_ICON;
1367 g_aiSysPenIcons[iKL] = MAXWORD;
1368 }
1369 else
1370 {
1372 g_aiSysPenIcons[iKL] = (WORD)wParam;
1373 }
1374 UpdatePenIcon(hwnd, iKL);
1375 break;
1376
1378 if (LOWORD(wParam) == MAXWORD)
1379 {
1380 g_anFlags[iKL] &= ~LAYOUTF_TOOLTIP_ATOM;
1381 }
1382 else
1383 {
1386 }
1387 UpdatePenIcon(hwnd, iKL);
1388 break;
1389
1391 if (wParam)
1392 {
1393 if (wParam & RDMI_LEFT)
1395 if (wParam & RDMI_RIGHT)
1397 }
1398 else
1399 {
1401 }
1402 break;
1403
1404 default:
1405 {
1406 ERR("uMsg: %u\n", uMsg);
1407 return;
1408 }
1409 }
1410}
#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:242
WORD g_anToolTipAtoms[MAX_KLS]
Definition: kbswitch.c:65
#define LAYOUTF_TOOLTIP_ATOM
Definition: kbswitch.c:77
WORD g_aiSysPenIcons[MAX_KLS]
Definition: kbswitch.c:64
#define LAYOUTF_IME_ICON
Definition: kbswitch.c:76
#define MAXWORD

Referenced by WndProc().

◆ RememberLastActive()

static BOOL RememberLastActive ( HWND  hwnd,
HWND  hwndFore 
)
static

Definition at line 937 of file kbswitch.c.

938{
939 hwndFore = GetAncestor(hwndFore, GA_ROOT);
940
941 if (!IsWindowVisible(hwndFore))
942 return FALSE;
943
944 if (IsWndClassName(hwndFore, INDICATOR_CLASS) ||
945 IsWndClassName(hwndFore, TEXT("Shell_TrayWnd")))
946 {
947 return FALSE; /* Special window */
948 }
949
950 g_hwndLastActive = hwndFore;
951 return TRUE;
952}
#define GA_ROOT
Definition: winuser.h:2893
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 859 of file kbswitch.c.

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

Referenced by KbSwitch_OnCreate().

◆ ShowImeToolbar()

static VOID ShowImeToolbar ( HWND  hwndTarget,
BOOL  bShowToolbar 
)
static

Definition at line 1069 of file kbswitch.c.

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

Referenced by KbSwitch_OnPenIconMsg().

◆ UpdateLanguageDisplay()

UINT UpdateLanguageDisplay ( HWND  hwnd,
HKL  hKL 
)

Definition at line 912 of file kbswitch.c.

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

Referenced by KbSwitch_OnTimer(), and UpdateLanguageDisplayCurrent().

◆ UpdateLanguageDisplayCurrent()

UINT UpdateLanguageDisplayCurrent ( HWND  hwnd,
HWND  hwndFore 
)

Definition at line 927 of file kbswitch.c.

928{
930 DWORD dwThreadID = GetWindowThreadProcessId(GetTargetWindow(hwndFore), NULL);
931 HKL hKL = GetKeyboardLayout(dwThreadID);
934 return 0;
935}

Referenced by KbSwitch_OnWindowActivate().

◆ UpdateLayoutList()

static VOID UpdateLayoutList ( HKL hKL  OPTIONAL)
static

Definition at line 252 of file kbswitch.c.

253{
254 if (!hKL)
255 hKL = GetActiveKL();
256
257 HICON ahSysPenIcons[MAX_KLS];
258 WORD aiSysPenIcons[MAX_KLS];
259 BYTE anFlags[MAX_KLS];
260 ZeroMemory(ahSysPenIcons, sizeof(ahSysPenIcons));
261 FillMemory(aiSysPenIcons, sizeof(aiSysPenIcons), 0xFF);
262 ZeroMemory(anFlags, sizeof(anFlags));
263
264 HKL ahKLs[MAX_KLS];
265 UINT iKL, nKLs = GetKeyboardLayoutList(_countof(ahKLs), ahKLs);
266
267 /* Reuse old icons and flags */
268 for (iKL = 0; iKL < nKLs; ++iKL)
269 {
270 LANGID wLangID = LOWORD(ahKLs[iKL]);
271 switch (wLangID)
272 {
275 case LANGID_JAPANESE:
276 case LANGID_KOREAN:
277 anFlags[iKL] |= LAYOUTF_FAR_EAST;
278 break;
279 default:
280 anFlags[iKL] &= ~LAYOUTF_FAR_EAST;
281 break;
282 }
283
284 UINT iKL2;
285 for (iKL2 = 0; iKL2 < g_cKLs; ++iKL2)
286 {
287 if (ahKLs[iKL] == g_ahKLs[iKL2])
288 {
289 ahSysPenIcons[iKL] = g_ahSysPenIcons[iKL2];
290 aiSysPenIcons[iKL] = g_aiSysPenIcons[iKL2];
291 anFlags[iKL] = g_anFlags[iKL2];
292
293 g_ahSysPenIcons[iKL2] = NULL;
294 break;
295 }
296 }
297 }
298
300
301 g_cKLs = nKLs;
302
303 C_ASSERT(sizeof(g_ahKLs) == sizeof(ahKLs));
304 CopyMemory(g_ahKLs, ahKLs, sizeof(g_ahKLs));
305
306 C_ASSERT(sizeof(g_ahSysPenIcons) == sizeof(ahSysPenIcons));
307 CopyMemory(g_ahSysPenIcons, ahSysPenIcons, sizeof(g_ahSysPenIcons));
308
309 C_ASSERT(sizeof(g_anFlags) == sizeof(anFlags));
310 CopyMemory(g_anFlags, anFlags, sizeof(g_anFlags));
311
313}
#define LANGID_KOREAN
Definition: cjkcode.h:53
#define LANGID_JAPANESE
Definition: cjkcode.h:52
#define LANGID_CHINESE_SIMPLIFIED
Definition: cjkcode.h:50
#define LANGID_CHINESE_TRADITIONAL
Definition: cjkcode.h:51
#define FillMemory(BUF, SIZ, MASK)
Definition: strucsup.c:31
#define C_ASSERT(e)
Definition: intsafe.h:73
#define MAX_KLS
Definition: kbswitch.c:49
#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 565 of file kbswitch.c.

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

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 751 of file kbswitch.c.

752{
753 NOTIFYICONDATA tnid =
754 {
756 };
757 TCHAR szImeFile[80];
758
759 GetImeFile(szImeFile, _countof(szImeFile), szKLID);
760
762 tnid.hIcon = CreateTrayIcon(szKLID, szImeFile);
764
766
767 if (g_hTrayIcon)
769 g_hTrayIcon = tnid.hIcon;
770}

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

◆ UpdateTrayInfo()

static VOID UpdateTrayInfo ( VOID  )
static

Definition at line 94 of file kbswitch.c.

95{
96 g_hTrayWnd = FindWindow(TEXT("Shell_TrayWnd"), NULL);
98}
HWND g_hTrayWnd
Definition: kbswitch.c:71
#define FindWindow
Definition: winuser.h:5943
#define FindWindowEx
Definition: winuser.h:5944

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 1413 of file kbswitch.c.

1414{
1415 switch (uMsg)
1416 {
1417 case WM_CREATE:
1418 return KbSwitch_OnCreate(hwnd);
1419
1420 case WM_TIMER:
1422 break;
1423
1424 case WM_LANG_CHANGED: /* Comes from indicdll.dll and this module */
1426
1427 case WM_WINDOW_ACTIVATE: /* Comes from indicdll.dll and this module */
1429
1430 case WM_NOTIFYICONMSG:
1432 break;
1433
1434 case WM_PENICONMSG:
1436 break;
1437
1438 case WM_COMMAND:
1440 break;
1441
1442 case WM_SETTINGCHANGE:
1444 break;
1445
1446 case WM_DESTROY:
1448 break;
1449
1450 case INDICM_SETIMEICON:
1453 if (InSendMessageEx(NULL))
1454 break; /* Must be a PostMessage call for quick response, not SendMessage */
1455
1457 break;
1458
1459 case WM_INPUTLANGCHANGEREQUEST:
1460 TRACE("WM_INPUTLANGCHANGEREQUEST(%p, %p)\n", wParam, lParam);
1462 break;
1463
1464 default:
1465 return KbSwitch_OnDefault(hwnd, uMsg, wParam, lParam);
1466 }
1467
1468 return 0;
1469}
static void KbSwitch_OnCommand(HWND hwnd, UINT nID)
Definition: kbswitch.c:1263
static LRESULT KbSwitch_OnWindowActivate(HWND hwnd, HWND hwndTarget OPTIONAL, LPARAM lParam OPTIONAL)
Definition: kbswitch.c:1309
static LRESULT KbSwitch_OnDefault(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: kbswitch.c:1327
static void KbSwitch_OnSettingChange(HWND hwnd, WPARAM wParam, LPARAM lParam)
Definition: kbswitch.c:1320
static VOID KbSwitch_OnPenIconMsg(HWND hwnd, UINT uMouseMsg)
Definition: kbswitch.c:1092
static LRESULT KbSwitch_OnLangChanged(HWND hwnd, HWND hwndTarget OPTIONAL, HKL hKL OPTIONAL)
Definition: kbswitch.c:1298
static void KbSwitch_OnNotifyIconMsg(HWND hwnd, UINT uMouseMsg)
Definition: kbswitch.c:1004
static void KbSwitch_OnTimer(HWND hwnd, UINT_PTR nTimerID)
Definition: kbswitch.c:990
static VOID OnIndicatorMsg(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: kbswitch.c:1352
static INT KbSwitch_OnCreate(HWND hwnd)
Definition: kbswitch.c:956
static void KbSwitch_OnDestroy(HWND hwnd)
Definition: kbswitch.c:978
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 66 of file kbswitch.c.

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

◆ g_aiSysPenIcons

WORD g_aiSysPenIcons[MAX_KLS] = { 0 }

Definition at line 64 of file kbswitch.c.

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

◆ g_anFlags

BYTE g_anFlags[MAX_KLS] = { 0 }

Definition at line 68 of file kbswitch.c.

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

◆ g_anToolTipAtoms

WORD g_anToolTipAtoms[MAX_KLS] = { 0 }

Definition at line 65 of file kbswitch.c.

Referenced by OnIndicatorMsg(), and UpdatePenIcon().

◆ g_bSysPenNotifyAdded

BOOL g_bSysPenNotifyAdded = FALSE

Definition at line 67 of file kbswitch.c.

Referenced by DeletePenNotifyIcon(), and UpdatePenIcon().

◆ g_cKLs

◆ g_cSpecialIds

INT g_cSpecialIds = 0

Definition at line 110 of file kbswitch.c.

Referenced by GetKLIDFromHKL(), and LoadSpecialIds().

◆ g_hHookDLL

HMODULE g_hHookDLL = NULL

Definition at line 58 of file kbswitch.c.

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

◆ g_hInst

◆ g_hTrayIcon

HICON g_hTrayIcon = NULL

Definition at line 59 of file kbswitch.c.

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

◆ g_hTrayNotifyWnd

HWND g_hTrayNotifyWnd = NULL

Definition at line 72 of file kbswitch.c.

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

◆ g_hTrayWnd

HWND g_hTrayWnd = NULL

Definition at line 71 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 109 of file kbswitch.c.

Referenced by GetKLIDFromHKL(), and LoadSpecialIds().

◆ g_uShellHookMessage

UINT g_uShellHookMessage = 0

Definition at line 70 of file kbswitch.c.

Referenced by _tWinMain(), and KbSwitch_OnDefault().

◆ g_uTaskbarRestartMsg

UINT g_uTaskbarRestartMsg = 0

Definition at line 69 of file kbswitch.c.

Referenced by KbSwitch_OnCreate(), and KbSwitch_OnDefault().

◆ KbSwitchSetHooks

FN_KbSwitchSetHooks KbSwitchSetHooks = NULL

Definition at line 54 of file kbswitch.c.

Referenced by DeleteHooks(), and SetHooks().

◆ SetPenMenuData

FN_SetPenMenuData SetPenMenuData = NULL

Definition at line 55 of file kbswitch.c.

Referenced by KbSwitch_OnPenIconMsg(), and SetHooks().