ReactOS 0.4.16-dev-1535-gea189a3
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 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 845 of file kbswitch.c.

◆ IFN_SetPenMenuData

#define IFN_SetPenMenuData   14

Definition at line 846 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 94 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 1459 of file kbswitch.c.

1460{
1462 MSG msg;
1463 HANDLE hMutex;
1464 HWND hwnd;
1465
1466 switch (GetUserDefaultUILanguage())
1467 {
1469 TRACE("LAYOUT_RTL\n");
1471 break;
1472 default:
1473 break;
1474 }
1475
1477 if (!hMutex)
1478 {
1479 ERR("!hMutex\n");
1480 return 1;
1481 }
1482
1484 {
1485 ERR("Another instance is already running\n");
1487 return 1;
1488 }
1489
1491
1492 ZeroMemory(&WndClass, sizeof(WndClass));
1493 WndClass.lpfnWndProc = WndProc;
1494 WndClass.hInstance = hInstance;
1495 WndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
1496 WndClass.lpszClassName = INDICATOR_CLASS;
1497 if (!RegisterClass(&WndClass))
1498 {
1500 return 1;
1501 }
1502
1506 {
1507 ERR("RegisterShellHookWindow failed\n");
1510 return 1;
1511 }
1512
1513 while (GetMessage(&msg, NULL, 0, 0))
1514 {
1517 }
1518
1520 return 0;
1521}
#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:1400
HINSTANCE g_hInst
Definition: kbswitch.c:56
#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
#define ZeroMemory
Definition: winbase.h:1753
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define CreateMutex
Definition: winbase.h:3797
_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 770 of file kbswitch.c.

771{
772 HKL hKl;
773 TCHAR szKLID[CCH_LAYOUT_ID + 1], szLangName[MAX_PATH];
775
776 if (iKL >= g_cKLs) /* Invalid */
777 return;
778
779 GetKLIDFromLayoutNum(iKL, szKLID, _countof(szKLID));
780 LangID = (LANGID)_tcstoul(szKLID, NULL, 16);
781
782 /* Switch to the new keyboard layout */
783 GetLocaleInfo(LangID, LOCALE_SLANGUAGE, szLangName, _countof(szLangName));
784 UpdateTrayIcon(hwnd, szKLID, szLangName);
785
786 if (hwndTarget && !bNoActivate)
787 SetForegroundWindow(hwndTarget);
788
789 hKl = LoadKeyboardLayout(szKLID, KLF_ACTIVATE);
790 if (hKl)
792
793 /* Post WM_INPUTLANGCHANGEREQUEST */
794 if (hwndTarget)
795 {
796 PostMessage(hwndTarget, WM_INPUTLANGCHANGEREQUEST,
797 INPUTLANGCHANGE_SYSCHARSET, (LPARAM)hKl);
798 }
799 else
800 {
802 }
803
804 g_iKL = iKL;
805}
#define MAX_PATH
Definition: compat.h:34
#define _tcstoul
Definition: tchar.h:595
static BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
Definition: kbswitch.c:763
static VOID UpdateTrayIcon(HWND hwnd, LPTSTR szKLID, LPTSTR szName)
Definition: kbswitch.c:741
static VOID GetKLIDFromLayoutNum(UINT iKL, LPTSTR szKLID, SIZE_T KLIDLength)
Definition: kbswitch.c:308
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
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
LONG_PTR LPARAM
Definition: windef.h:208
#define GetLocaleInfo
Definition: winnls.h:1289
#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 702 of file kbswitch.c.

703{
704 NOTIFYICONDATA tnid =
705 {
707 };
708 TCHAR szKLID[CCH_LAYOUT_ID + 1], szName[MAX_PATH], szImeFile[80];
709
710 GetKLIDFromLayoutNum(g_iKL, szKLID, _countof(szKLID));
712 GetImeFile(szImeFile, _countof(szImeFile), szKLID);
713
715 tnid.hIcon = CreateTrayIcon(szKLID, szImeFile);
717
718 if (!Shell_NotifyIcon(NIM_ADD, &tnid))
719 ERR("Shell_NotifyIcon(NIM_ADD) failed\n");
720
721 if (g_hTrayIcon)
723 g_hTrayIcon = tnid.hIcon;
724}
static BOOL GetLayoutName(UINT iKL, LPTSTR szName, SIZE_T NameLength)
Definition: kbswitch.c:325
#define NOTIFY_ICON_ID_LANGUAGE
Definition: kbswitch.c:39
static HICON CreateTrayIcon(LPTSTR szKLID, LPCTSTR szImeFile OPTIONAL)
Definition: kbswitch.c:605
static BOOL GetImeFile(LPTSTR szImeFile, SIZE_T cchImeFile, LPCTSTR szKLID)
Definition: kbswitch.c:361
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 442 of file kbswitch.c.

443{
444 HDC hdcScreen = GetDC(NULL);
445 HDC hdc = CreateCompatibleDC(hdcScreen);
448 HBITMAP hbm = CreateCompatibleBitmap(hdcScreen, cxIcon, cyIcon);
449 HGDIOBJ hbmOld;
450
451 if (hbm != NULL)
452 {
453 hbmOld = SelectObject(hdc, hbm);
454 DrawIconEx(hdc, 0, 0, hIcon, cxIcon, cyIcon, 0, GetSysColorBrush(COLOR_MENU), DI_NORMAL);
455 SelectObject(hdc, hbmOld);
456 }
457
458 DeleteDC(hdc);
459 ReleaseDC(NULL, hdcScreen);
460 return hbm;
461}
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 808 of file kbswitch.c.

809{
810 HMENU hMenu = CreatePopupMenu();
811 TCHAR szName[MAX_PATH], szKLID[CCH_LAYOUT_ID + 1], szImeFile[80];
812 HICON hIcon;
813 MENUITEMINFO mii = { sizeof(mii) };
814 UINT iKL;
815
816 for (iKL = 0; iKL < g_cKLs; ++iKL)
817 {
818 GetKLIDFromHKL(g_ahKLs[iKL], szKLID, _countof(szKLID));
819 GetImeFile(szImeFile, _countof(szImeFile), szKLID);
820
821 if (!GetLayoutName(iKL, szName, _countof(szName)))
822 continue;
823
824 mii.fMask = MIIM_ID | MIIM_STRING;
825 mii.wID = ID_LANG_BASE + iKL;
826 mii.dwTypeData = szName;
827
828 hIcon = CreateTrayIcon(szKLID, szImeFile);
829 if (hIcon)
830 {
831 mii.hbmpItem = BitmapFromIcon(hIcon);
832 if (mii.hbmpItem)
833 mii.fMask |= MIIM_BITMAP;
834 }
835
836 InsertMenuItem(hMenu, -1, TRUE, &mii);
838 }
839
841
842 return hMenu;
843}
#define ID_LANG_BASE
Definition: resource.h:24
#define TRUE
Definition: types.h:120
static HBITMAP BitmapFromIcon(HICON hIcon)
Definition: kbswitch.c:442
static VOID GetKLIDFromHKL(HKL hKL, LPTSTR szKLID, SIZE_T KLIDLength)
Definition: kbswitch.c:152
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:63
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 605 of file kbswitch.c.

606{
608 TCHAR szBuf[4];
609 HDC hdcScreen, hdc;
610 HBITMAP hbmColor, hbmMono, hBmpOld;
611 HFONT hFont, hFontOld;
612 LOGFONT lf;
613 RECT rect;
615 HICON hIcon;
619
620 if (szImeFile && szImeFile[0])
621 {
622 if (GetSystemLibraryPath(szPath, _countof(szPath), szImeFile))
623 return FakeExtractIcon(szPath, 0);
624 }
625
626 /* Getting "EN", "FR", etc. from English, French, ... */
627 LangID = LANGIDFROMLCID(_tcstoul(szKLID, NULL, 16));
630 szBuf,
631 _countof(szBuf)) == 0)
632 {
633 szBuf[0] = szBuf[1] = _T('?');
634 }
635 szBuf[2] = 0; /* Truncate the identifier to two characters: "ENG" --> "EN" etc. */
636
637 /* Create hdc, hbmColor and hbmMono */
638 hdcScreen = GetDC(NULL);
639 hdc = CreateCompatibleDC(hdcScreen);
640 hbmColor = CreateCompatibleBitmap(hdcScreen, cxIcon, cyIcon);
641 ReleaseDC(NULL, hdcScreen);
642 hbmMono = CreateBitmap(cxIcon, cyIcon, 1, 1, NULL);
643
644 /* Checking NULL */
645 if (!hdc || !hbmColor || !hbmMono)
646 {
647 if (hbmMono)
648 DeleteObject(hbmMono);
649 if (hbmColor)
650 DeleteObject(hbmColor);
651 if (hdc)
652 DeleteDC(hdc);
653 return NULL;
654 }
655
656 /* Create a font */
657 hFont = NULL;
658 if (SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(lf), &lf, 0))
659 {
660 /* Override the current size with something manageable */
661 lf.lfHeight = -11;
662 lf.lfWidth = 0;
664 }
665 if (!hFont)
667
668 SetRect(&rect, 0, 0, cxIcon, cyIcon);
669
670 /* Draw hbmColor */
671 hBmpOld = SelectObject(hdc, hbmColor);
673 FillRect(hdc, &rect, (HBRUSH)GetStockObject(DC_BRUSH));
674 hFontOld = SelectObject(hdc, hFont);
678 SelectObject(hdc, hFontOld);
679
680 /* Fill hbmMono with black */
681 SelectObject(hdc, hbmMono);
682 PatBlt(hdc, 0, 0, cxIcon, cyIcon, BLACKNESS);
683 SelectObject(hdc, hBmpOld);
684
685 /* Create an icon from hbmColor and hbmMono */
688 IconInfo.hbmColor = hbmColor;
689 IconInfo.hbmMask = hbmMono;
691
692 /* Clean up */
694 DeleteObject(hbmMono);
695 DeleteObject(hbmColor);
696 DeleteDC(hdc);
697
698 return hIcon;
699}
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:425
static BOOL GetSystemLibraryPath(LPTSTR szPath, SIZE_T cchPath, LPCTSTR FileName)
Definition: kbswitch.c:314
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 871 of file kbswitch.c.

872{
874 {
877 }
878
879 if (g_hHookDLL)
880 {
883 }
884
885 TRACE("DeleteHooks OK\n");
886}
#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 203 of file kbswitch.c.

204{
206
207 if (g_ahSysPenIcons[iKL])
208 {
210 g_ahSysPenIcons[iKL] = NULL;
211 }
212}
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 542 of file kbswitch.c.

543{
545 return;
546
549 ERR("Shell_NotifyIcon(NIM_DELETE) failed\n");
550 else
552}
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 727 of file kbswitch.c.

728{
729 NOTIFYICONDATA tnid = { sizeof(tnid), hwnd, NOTIFY_ICON_ID_LANGUAGE };
730 if (!Shell_NotifyIcon(NIM_DELETE, &tnid))
731 ERR("Shell_NotifyIcon(NIM_DELETE) failed\n");
732
733 if (g_hTrayIcon)
734 {
737 }
738}

Referenced by KbSwitch_OnDestroy().

◆ DestroyPenIcons()

static VOID DestroyPenIcons ( VOID  )
static

Definition at line 215 of file kbswitch.c.

216{
217 INT iKL;
218 for (iKL = 0; iKL < g_cKLs; ++iKL)
219 {
220 if (g_ahSysPenIcons[iKL])
221 {
223 g_ahSysPenIcons[iKL] = NULL;
224 }
225 }
226}

Referenced by KbSwitch_OnDestroy(), and UpdateLayoutList().

◆ EnumResNameProc()

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

Definition at line 402 of file kbswitch.c.

407{
408 UNREFERENCED_PARAMETER(lpszType);
409
410 PLOAD_ICON pLoadIcon = (PLOAD_ICON)lParam;
411 if (pLoadIcon->iIcon == pLoadIcon->nIconIndex)
412 {
413 pLoadIcon->hIcon = (HICON)LoadImage(hModule, lpszName, IMAGE_ICON,
414 pLoadIcon->cxIcon, pLoadIcon->cyIcon,
416 if (pLoadIcon->hIcon)
417 return FALSE; /* Stop enumeration */
418 }
419
420 ++pLoadIcon->iIcon;
421 return TRUE;
422}
LPARAM lParam
Definition: combotst.c:139
HMODULE hModule
Definition: animate.c:44
struct tagLOAD_ICON * PLOAD_ICON
INT nIconIndex
Definition: kbswitch.c:395
HICON hIcon
Definition: kbswitch.c:398
#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 763 of file kbswitch.c.

764{
765 PostMessage(hwnd, WM_INPUTLANGCHANGEREQUEST, INPUTLANGCHANGE_SYSCHARSET, lParam);
766 return TRUE;
767}

Referenced by ActivateLayout().

◆ FakeExtractIcon()

static HICON FakeExtractIcon ( PCTSTR  pszImeFile,
INT  nIconIndex 
)
static

Definition at line 425 of file kbswitch.c.

426{
427 HMODULE hImeDLL = LoadLibraryEx(pszImeFile, NULL, LOAD_LIBRARY_AS_DATAFILE);
428 if (!hImeDLL)
429 return NULL;
430
432 {
434 };
436
437 FreeLibrary(hImeDLL);
438
439 return LoadIcon.hIcon;
440}
static BOOL CALLBACK EnumResNameProc(HMODULE hModule, LPCTSTR lpszType, LPTSTR lpszName, LPARAM lParam)
Definition: kbswitch.c:402
#define RT_GROUP_ICON
Definition: pedump.c:375
#define LoadLibraryEx
Definition: winbase.h:3904
#define LOAD_LIBRARY_AS_DATAFILE
Definition: winbase.h:375
#define EnumResourceNames
Definition: winbase.h:3813
#define LoadIcon
Definition: winuser.h:5924

Referenced by CreateTrayIcon(), and UpdatePenIcon().

◆ GetActiveKL()

static HKL GetActiveKL ( VOID  )
static

Definition at line 193 of file kbswitch.c.

194{
195 /* FIXME: Get correct console window's HKL when console window */
196 HWND hwndTarget = GetTargetWindow(NULL);
197 TRACE("hwndTarget: %p\n", hwndTarget);
198 DWORD dwTID = GetWindowThreadProcessId(hwndTarget, NULL);
199 return GetKeyboardLayout(dwTID);
200}
unsigned long DWORD
Definition: ntddk_ex.h:95
static HWND GetTargetWindow(HWND hwndFore OPTIONAL)
Definition: kbswitch.c:181
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 302 of file kbswitch.c.

303{
304 return (iKL < g_cKLs) ? g_ahKLs[iKL] : GetActiveKL();
305}
static HKL GetActiveKL(VOID)
Definition: kbswitch.c:193

Referenced by GetKLIDFromLayoutNum().

◆ GetImeFile()

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

Definition at line 361 of file kbswitch.c.

362{
363 HKEY hKey;
364 DWORD dwBufLen;
365 TCHAR szBuf[MAX_PATH];
366
367 szImeFile[0] = UNICODE_NULL;
368
369 if (_tcslen(szKLID) != CCH_LAYOUT_ID)
370 return FALSE; /* Invalid LCID */
371
372 if (szKLID[0] != TEXT('E') && szKLID[0] != TEXT('e'))
373 return FALSE; /* Not an IME HKL */
374
375 StringCchPrintf(szBuf, _countof(szBuf),
376 _T("SYSTEM\\CurrentControlSet\\Control\\Keyboard Layouts\\%s"), szKLID);
377
379 return FALSE;
380
381 dwBufLen = cchImeFile * sizeof(TCHAR);
382 if (RegQueryValueEx(hKey, _T("IME File"), NULL, NULL,
383 (LPBYTE)szImeFile, &dwBufLen) != ERROR_SUCCESS)
384 {
385 szImeFile[0] = UNICODE_NULL;
386 }
387
389
390 return (szImeFile[0] != UNICODE_NULL);
391}
#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:1016
#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:520
#define RegQueryValueEx
Definition: winreg.h:524
#define _tcslen
Definition: xmlstorage.h:198

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

◆ GetImeStatus()

static DWORD GetImeStatus ( HWND  hwndTarget)
static

Definition at line 464 of file kbswitch.c.

465{
466 HWND hwndIme = ImmGetDefaultIMEWnd(hwndTarget);
467 if (!hwndIme)
469
470 HIMC hIMC = (HIMC)SendMessage(hwndIme, WM_IME_SYSTEM, IMS_GETCONTEXT, (LPARAM)hwndTarget);
471 if (!hIMC)
472 return IME_STATUS_NO_IME;
473
475 if (GetACP() == 949) // Korean
476 {
477 DWORD dwConversion = 0, dwSentence = 0;
478 if (ImmGetConversionStatus(hIMC, &dwConversion, &dwSentence))
479 {
480 if (dwConversion & IME_CMODE_NATIVE)
481 dwImeStatus |= IME_STATUS_IME_NATIVE;
482
483 if (dwConversion & IME_CMODE_FULLSHAPE)
484 dwImeStatus |= IME_STATUS_IME_FULLSHAPE;
485 }
486 }
487
488 return dwImeStatus;
489}
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
BOOL WINAPI ImmGetConversionStatus(_In_ HIMC hIMC, _Out_opt_ LPDWORD lpfdwConversion, _Out_opt_ LPDWORD lpfdwSentence)
Definition: ime.c:1501
#define IME_CMODE_NATIVE
Definition: imm.h:337
BOOL WINAPI ImmGetOpenStatus(_In_ HIMC hIMC)
Definition: ime.c:996
HWND WINAPI ImmGetDefaultIMEWnd(_In_opt_ HWND hWnd)
Definition: ime.c:440
#define IME_CMODE_FULLSHAPE
Definition: imm.h:345
#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
#define SendMessage
Definition: winuser.h:5954

Referenced by KbSwitch_OnPenIconMsg(), and LoadDefaultPenIcon().

◆ GetKLIDFromHKL()

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

Definition at line 152 of file kbswitch.c.

153{
154 szKLID[0] = 0;
155
156 if (IS_IME_HKL(hKL))
157 {
158 StringCchPrintf(szKLID, KLIDLength, _T("%08lx"), (DWORD)(DWORD_PTR)hKL);
159 return;
160 }
161
162 if (IS_SPECIAL_HKL(hKL))
163 {
164 INT i;
165 for (i = 0; i < g_cSpecialIds; ++i)
166 {
167 if (g_SpecialIds[i].hKL == hKL)
168 {
169 StringCchCopy(szKLID, KLIDLength, g_SpecialIds[i].szKLID);
170 return;
171 }
172 }
173 }
174 else
175 {
176 StringCchPrintf(szKLID, KLIDLength, _T("%08lx"), LOWORD(hKL));
177 }
178}
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:97
SPECIAL_ID g_SpecialIds[MAX_SPECIAL_IDS]
Definition: kbswitch.c:96
#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 308 of file kbswitch.c.

309{
310 GetKLIDFromHKL(GetHKLFromLayoutNum(iKL), szKLID, KLIDLength);
311}
static HKL GetHKLFromLayoutNum(UINT iKL)
Definition: kbswitch.c:302

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

◆ GetLayoutIndexFromHKL()

static UINT GetLayoutIndexFromHKL ( HKL  hKL)
static

Definition at line 229 of file kbswitch.c.

230{
231 for (UINT iKL = 0; iKL < g_cKLs; ++iKL)
232 {
233 if (g_ahKLs[iKL] == hKL)
234 return iKL;
235 }
236 return 0;
237}

Referenced by OnIndicatorMsg(), and UpdateLayoutList().

◆ GetLayoutName()

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

Definition at line 325 of file kbswitch.c.

326{
327 HKEY hKey;
328 HRESULT hr;
329 DWORD dwBufLen;
330 TCHAR szBuf[MAX_PATH], szKLID[CCH_LAYOUT_ID + 1];
331
332 GetKLIDFromLayoutNum(iKL, szKLID, _countof(szKLID));
333
334 StringCchPrintf(szBuf, _countof(szBuf),
335 _T("SYSTEM\\CurrentControlSet\\Control\\Keyboard Layouts\\%s"), szKLID);
336
338 return FALSE;
339
340 /* Use "Layout Display Name" value as an entry name if possible */
341 hr = SHLoadRegUIString(hKey, _T("Layout Display Name"), szName, NameLength);
342 if (SUCCEEDED(hr))
343 {
345 return TRUE;
346 }
347
348 /* Otherwise, use "Layout Text" value as an entry name */
349 dwBufLen = NameLength * sizeof(TCHAR);
350 if (RegQueryValueEx(hKey, _T("Layout Text"), NULL, NULL,
351 (LPBYTE)szName, &dwBufLen) == ERROR_SUCCESS)
352 {
354 return TRUE;
355 }
356
358 return FALSE;
359}
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define KEY_READ
Definition: nt_native.h:1023
HRESULT hr
Definition: shlfolder.c:183
#define SHLoadRegUIString

Referenced by AddTrayIcon(), and BuildLeftPopupMenu().

◆ GetLayoutNum()

static UINT GetLayoutNum ( HKL  hKL)
static

Definition at line 888 of file kbswitch.c.

889{
890 UINT iKL;
891
892 for (iKL = 0; iKL < g_cKLs; ++iKL)
893 {
894 if (g_ahKLs[iKL] == hKL)
895 return iKL;
896 }
897
898 return 0;
899}

Referenced by UpdateLanguageDisplay().

◆ GetSystemLibraryPath()

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

Definition at line 314 of file kbswitch.c.

315{
316 if (!GetSystemDirectory(szPath, cchPath))
317 return FALSE;
318
319 StringCchCat(szPath, cchPath, TEXT("\\"));
320 StringCchCat(szPath, cchPath, FileName);
321 return TRUE;
322}
#define StringCchCat
Definition: strsafe.h:317
#define GetSystemDirectory
Definition: winbase.h:3883

Referenced by CreateTrayIcon(), and LayoutList_ReadLayout().

◆ GetTargetWindow()

static HWND GetTargetWindow ( HWND hwndFore  OPTIONAL)
static

Definition at line 181 of file kbswitch.c.

182{
183 HWND hwndTarget = (hwndFore ? hwndFore : GetForegroundWindow());
184 if (!hwndTarget ||
185 IsWndClassName(hwndTarget, INDICATOR_CLASS) ||
186 IsWndClassName(hwndTarget, TEXT("Shell_TrayWnd")))
187 {
188 hwndTarget = g_hwndLastActive;
189 }
190 return hwndTarget;
191}
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().

◆ IsRegImeToolbarShown()

static BOOL IsRegImeToolbarShown ( VOID  )
static

Definition at line 1034 of file kbswitch.c.

1035{
1036 HKEY hKey;
1037 LSTATUS error = RegOpenKey(HKEY_CURRENT_USER, TEXT("Control Panel\\Input Method"), &hKey);
1038 if (error)
1039 {
1040 ERR("Cannot open regkey: 0x%lX\n", error);
1041 return TRUE;
1042 }
1043
1044 WCHAR szText[8];
1045 DWORD cbValue = sizeof(szText);
1046 error = RegQueryValueEx(hKey, TEXT("Show Status"), NULL, NULL, (PBYTE)szText, &cbValue);
1047 if (error)
1048 {
1050 return TRUE;
1051 }
1052
1053 BOOL ret = !!_wtoi(szText);
1055 return ret;
1056}
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
return ret
Definition: mutex.c:146
unsigned int BOOL
Definition: ntddk_ex.h:94
#define error(str)
Definition: mkdosfs.c:1605
BYTE * PBYTE
Definition: pedump.c:66
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define RegOpenKey
Definition: winreg.h:519
__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 1250 of file kbswitch.c.

1251{
1252 switch (nID)
1253 {
1254 case ID_EXIT:
1255 PostMessage(hwnd, WM_CLOSE, 0, 0);
1256 break;
1257
1258 case ID_PREFERENCES:
1259 {
1261 TEXT("control.exe"), TEXT("input.dll"),
1263 if (ret <= 32)
1264 MessageBox(hwnd, _T("Can't start input.dll"), NULL, MB_ICONERROR);
1265 break;
1266 }
1267
1268 default:
1269 {
1270 if (nID >= ID_LANG_BASE)
1271 {
1273 {
1275 }
1277 }
1278 break;
1279 }
1280 }
1281}
#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:770
#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 946 of file kbswitch.c.

947{
948 if (!SetHooks())
949 {
950 MessageBox(NULL, TEXT("SetHooks failed."), NULL, MB_ICONERROR);
951 return -1; /* Failed */
952 }
953
959
962
963 return 0; /* Success */
964}
static VOID LoadSpecialIds(VOID)
Definition: kbswitch.c:99
static VOID UpdatePenIcon(HWND hwnd, UINT iKL)
Definition: kbswitch.c:555
static VOID UpdateLayoutList(HKL hKL OPTIONAL)
Definition: kbswitch.c:239
static VOID UpdateTrayInfo(VOID)
Definition: kbswitch.c:81
static BOOL SetHooks(VOID)
Definition: kbswitch.c:849
static VOID AddTrayIcon(HWND hwnd)
Definition: kbswitch.c:702
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 1314 of file kbswitch.c.

1315{
1316 if (uMsg == g_uTaskbarRestartMsg)
1317 {
1322 return 0;
1323 }
1324
1325 if (uMsg == g_uShellHookMessage)
1326 {
1327 TRACE("g_uShellHookMessage: wParam:%p, lParam:%p\n", wParam, lParam);
1328 if (wParam == HSHELL_LANGUAGE)
1330 else if (wParam == HSHELL_WINDOWACTIVATED || wParam == HSHELL_RUDEAPPACTIVATED)
1332 return 0;
1333 }
1334
1335 return DefWindowProc(hwnd, uMsg, wParam, lParam);
1336}
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 968 of file kbswitch.c.

969{
971 DeleteHooks();
976}
#define TIMER_ID_LANG_CHANGED_DELAYED
Definition: kbswitch.c:42
static VOID DeleteHooks(VOID)
Definition: kbswitch.c:871
static VOID DestroyPenIcons(VOID)
Definition: kbswitch.c:215
static VOID DeletePenNotifyIcon(HWND hwnd)
Definition: kbswitch.c:542
static VOID DeleteTrayIcon(HWND hwnd)
Definition: kbswitch.c:727
__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 1285 of file kbswitch.c.

1286{
1287 TRACE("WM_LANG_CHANGED: hwndTarget:%p, hKL:%p\n", hwndTarget, hKL);
1288 /* Delayed action */
1291 return 0;
1292}
#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 994 of file kbswitch.c.

995{
996 if (uMouseMsg != WM_LBUTTONUP && uMouseMsg != WM_RBUTTONUP)
997 return;
998
1000
1001 POINT pt;
1002 GetCursorPos(&pt);
1003
1005
1006 TPMPARAMS params = { sizeof(params) };
1008
1009 INT nID;
1010 if (uMouseMsg == WM_LBUTTONUP)
1011 {
1012 /* Rebuild the left popup menu on every click to take care of keyboard layout changes */
1013 HMENU hPopupMenu = BuildLeftPopupMenu();
1015 nID = TrackPopupMenuEx(hPopupMenu, uFlags, pt.x, pt.y, hwnd, &params);
1016 DestroyMenu(hPopupMenu);
1017 }
1018 else /* WM_RBUTTONUP */
1019 {
1021 HMENU hSubMenu = GetSubMenu(hPopupMenu, 0);
1023 nID = TrackPopupMenuEx(hSubMenu, uFlags, pt.x, pt.y, hwnd, &params);
1024 DestroyMenu(hPopupMenu);
1025 }
1026
1027 PostMessage(hwnd, WM_NULL, 0, 0);
1028
1029 if (nID)
1030 PostMessage(hwnd, WM_COMMAND, nID, 0);
1031}
#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:808
#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 1082 of file kbswitch.c.

1083{
1084 if (uMouseMsg != WM_LBUTTONUP && uMouseMsg != WM_RBUTTONUP)
1085 return;
1086
1088 return;
1089
1090 POINT pt;
1091 GetCursorPos(&pt);
1092
1093 // Get target window
1094 TRACE("g_hwndLastActive: %p\n", g_hwndLastActive);
1096 TRACE("hwndTarget: %p\n", hwndTarget);
1097
1098 // Get default IME window
1099 HWND hwndIme = ImmGetDefaultIMEWnd(hwndTarget);
1100 if (!hwndIme)
1101 {
1102 WARN("No default IME\n");
1103 return;
1104 }
1105
1106 // Get IME context from another process
1107 HIMC hIMC = (HIMC)SendMessage(hwndIme, WM_IME_SYSTEM, IMS_GETCONTEXT, (LPARAM)hwndTarget);
1108 if (!hIMC)
1109 {
1110 WARN("No HIMC\n");
1111 return;
1112 }
1113
1114 // Workaround of TrackPopupMenu's bug
1116
1117 // Create IME menu
1118 BOOL bRightButton = (uMouseMsg == WM_RBUTTONUP);
1119 PIMEMENUNODE pImeMenu = CreateImeMenu(hIMC, NULL, bRightButton);
1120 HMENU hMenu = MenuFromImeMenu(pImeMenu);
1121
1122 HKL hKL = g_ahKLs[g_iKL];
1123 DWORD dwImeStatus = GetImeStatus(hwndTarget);
1124 BOOL bImeOn = FALSE, bSoftOn = FALSE, bShowToolbar = FALSE;
1125 TCHAR szText[128];
1126 if (bRightButton)
1127 {
1128 if (!(g_anFlags[g_iKL] & LAYOUTF_REMOVE_RIGHT_DEF_MENU)) // Add default menu items?
1129 {
1130 if (GetMenuItemCount(hMenu))
1131 AppendMenu(hMenu, MF_SEPARATOR, 0, NULL); // Separator
1132
1133 // "Input System (IME) configuration..."
1134 LoadString(g_hInst, IDS_INPUTSYSTEM, szText, _countof(szText));
1135 AppendMenu(hMenu, MF_STRING, ID_INPUTSYSTEM, szText);
1136 }
1137 }
1138 else
1139 {
1140 if (!(g_anFlags[g_iKL] & LAYOUTF_REMOVE_LEFT_DEF_MENU)) // Add default menu items?
1141 {
1142 if (GetMenuItemCount(hMenu))
1143 AppendMenu(hMenu, MF_SEPARATOR, 0, NULL); // Separator
1144
1145 if (!IS_KOREAN_IME_HKL(hKL)) // Not Korean IME?
1146 {
1147 // "IME ON / OFF"
1148 bImeOn = (dwImeStatus == IME_STATUS_IME_OPEN);
1149 UINT nId = (bImeOn ? IDS_IME_ON : IDS_IME_OFF);
1150 LoadString(g_hInst, nId, szText, _countof(szText));
1151 AppendMenu(hMenu, MF_STRING, ID_IMEONOFF, szText);
1152 }
1153
1155 IsWindow(hwndIme)) // Is Soft Keyboard available?
1156 {
1157 // "Soft Keyboard ON / OFF"
1159 UINT nId = (bSoftOn ? IDS_SOFTKBD_ON : IDS_SOFTKBD_OFF);
1160 LoadString(g_hInst, nId, szText, _countof(szText));
1161 AppendMenu(hMenu, MF_STRING, ID_SOFTKBDONOFF, szText);
1162 }
1163
1164 if (GetMenuItemCount(hMenu))
1165 AppendMenu(hMenu, MF_SEPARATOR, 0, NULL); // Separator
1166
1167 // "Show toolbar"
1168 LoadString(g_hInst, IDS_SHOWTOOLBAR, szText, _countof(szText));
1169 AppendMenu(hMenu, MF_STRING, ID_SHOWTOOLBAR, szText);
1170 bShowToolbar = IsRegImeToolbarShown();
1171 if (bShowToolbar)
1173 }
1174 }
1175
1176 if (!GetMenuItemCount(hMenu)) // No items?
1177 {
1178 // Clean up
1179 DestroyMenu(hMenu);
1181
1182 SetForegroundWindow(hwndTarget);
1183 return;
1184 }
1185
1186 // TrackPopupMenuEx flags
1188 uFlags |= (bRightButton ? TPM_RIGHTBUTTON : TPM_LEFTBUTTON);
1189
1190 // Exclude the notification area
1191 TPMPARAMS params = { sizeof(params) };
1193
1194 // Show the popup menu
1195 INT nID = TrackPopupMenuEx(hMenu, uFlags, pt.x, pt.y, hwnd, &params);
1196
1197 // Workaround of TrackPopupMenu's bug
1198 PostMessage(hwnd, WM_NULL, 0, 0);
1199
1200 if (nID) // Action!
1201 {
1202 if (nID >= ID_STARTIMEMENU) // IME internal menu ID?
1203 {
1204 MENUITEMINFO mii = { sizeof(mii), MIIM_DATA };
1205 GetMenuItemInfo(hMenu, nID, FALSE, &mii);
1206
1207 if (pImeMenu)
1208 nID = GetRealImeMenuID(pImeMenu, nID);
1209
1210 if (SetPenMenuData)
1211 SetPenMenuData(nID, mii.dwItemData);
1212
1214 }
1215 else // Otherwise action of IME menu item
1216 {
1217 switch (nID)
1218 {
1219 case ID_INPUTSYSTEM:
1220 if (IS_IME_HKL(hKL))
1222 break;
1223 case ID_IMEONOFF:
1224 ImmSetOpenStatus(hIMC, !bImeOn);
1225 break;
1226 case ID_SOFTKBDONOFF:
1227 PostMessage(hwndIme, WM_IME_SYSTEM, IMS_SOFTKBDONOFF, !bSoftOn);
1228 break;
1229 case ID_SHOWTOOLBAR:
1230 ShowImeToolbar(hwndTarget, !bShowToolbar);
1231 break;
1232 default:
1233 {
1234 PostMessage(hwnd, WM_COMMAND, nID, 0);
1235 break;
1236 }
1237 }
1238 }
1239 }
1240
1241 // Clean up
1242 DestroyMenu(hMenu);
1244
1245 SetForegroundWindow(hwndTarget);
1246}
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_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
BOOL WINAPI ImmSetOpenStatus(_In_ HIMC hIMC, _In_ BOOL fOpen)
Definition: ime.c:1020
static BOOL IsRegImeToolbarShown(VOID)
Definition: kbswitch.c:1034
static DWORD GetImeStatus(HWND hwndTarget)
Definition: kbswitch.c:464
#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:1059
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 1307 of file kbswitch.c.

1308{
1309 if (wParam == SPI_SETNONCLIENTMETRICS)
1311}

Referenced by WndProc().

◆ KbSwitch_OnTimer()

static void KbSwitch_OnTimer ( HWND  hwnd,
UINT_PTR  nTimerID 
)
static

Definition at line 980 of file kbswitch.c.

981{
982 if (nTimerID == TIMER_ID_LANG_CHANGED_DELAYED)
983 {
984 KillTimer(hwnd, nTimerID);
985 HKL hKL = GetActiveKL();
986 UpdateLayoutList(hKL);
989 }
990}
UINT UpdateLanguageDisplay(HWND hwnd, HKL hKL)
Definition: kbswitch.c:902

Referenced by WndProc().

◆ KbSwitch_OnWindowActivate()

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

Definition at line 1296 of file kbswitch.c.

1297{
1298 TRACE("WM_WINDOW_ACTIVATE: hwndTarget:%p, lParam:%p\n", hwndTarget, lParam);
1299 HWND hwndFore = hwndTarget ? hwndTarget : GetForegroundWindow();
1300 if (RememberLastActive(hwnd, hwndFore))
1301 return UpdateLanguageDisplayCurrent(hwnd, hwndFore);
1302 return 0;
1303}
static BOOL RememberLastActive(HWND hwnd, HWND hwndFore)
Definition: kbswitch.c:927
UINT UpdateLanguageDisplayCurrent(HWND hwnd, HWND hwndFore)
Definition: kbswitch.c:917

Referenced by WndProc().

◆ LoadDefaultPenIcon()

static HICON LoadDefaultPenIcon ( PCWSTR  szImeFile,
HKL  hKL 
)
static

Definition at line 492 of file kbswitch.c.

493{
495 DWORD dwImeStatus = GetImeStatus(hwndTarget);
496
497 INT nIconID = -1;
498 if (IS_KOREAN_IME_HKL(hKL)) // Korean IME?
499 {
500 if (dwImeStatus != IME_STATUS_NO_IME)
501 {
502 if (dwImeStatus & IME_STATUS_IME_CLOSED)
503 {
504 nIconID = IDI_KOREAN_A_HALF;
505 }
506 else
507 {
508 if (dwImeStatus & IME_STATUS_IME_FULLSHAPE)
509 {
510 if (dwImeStatus & IME_STATUS_IME_NATIVE)
511 nIconID = IDI_KOREAN_JR_FULL;
512 else
513 nIconID = IDI_KOREAN_A_FULL;
514 }
515 else
516 {
517 if (dwImeStatus & IME_STATUS_IME_NATIVE)
518 nIconID = IDI_KOREAN_JR_HALF;
519 else
520 nIconID = IDI_KOREAN_A_HALF;
521 }
522 }
523 }
524 }
525 else
526 {
527 if (dwImeStatus & IME_STATUS_IME_CLOSED)
528 nIconID = IDI_IME_CLOSED;
529 else if (dwImeStatus & IME_STATUS_IME_OPEN)
530 nIconID = IDI_IME_OPEN;
531 else
532 nIconID = IDI_IME_DISABLED;
533 }
534
535 if (nIconID < 0)
536 return NULL;
537
538 return LoadIcon(g_hHookDLL, MAKEINTRESOURCE(nIconID));
539}
#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

Referenced by UpdatePenIcon().

◆ LoadSpecialIds()

static VOID LoadSpecialIds ( VOID  )
static

Definition at line 99 of file kbswitch.c.

100{
101 TCHAR szKLID[KL_NAMELENGTH], szLayoutId[16];
102 DWORD dwSize, dwIndex;
103 HKEY hKey, hLayoutKey;
104
105 g_cSpecialIds = 0;
106
108 TEXT("SYSTEM\\CurrentControlSet\\Control\\Keyboard Layouts"),
109 0, KEY_READ, &hKey) != ERROR_SUCCESS)
110 {
111 return;
112 }
113
114 for (dwIndex = 0; dwIndex < 1000; ++dwIndex)
115 {
116 dwSize = _countof(szKLID);
117 if (RegEnumKeyEx(hKey, dwIndex, szKLID, &dwSize, NULL, NULL, NULL, NULL) != ERROR_SUCCESS)
118 break;
119
120 if (RegOpenKeyEx(hKey, szKLID, 0, KEY_READ, &hLayoutKey) != ERROR_SUCCESS)
121 continue;
122
123 dwSize = sizeof(szLayoutId);
124 if (RegQueryValueEx(hLayoutKey, TEXT("Layout Id"), NULL, NULL,
125 (LPBYTE)szLayoutId, &dwSize) == ERROR_SUCCESS)
126 {
127 DWORD dwKLID = _tcstoul(szKLID, NULL, 16);
128 WORD wLangId = LOWORD(dwKLID), wLayoutId = LOWORD(_tcstoul(szLayoutId, NULL, 16));
129 HKL hKL = (HKL)(LONG_PTR)(SPECIAL_MASK | MAKELONG(wLangId, wLayoutId));
130
131 /* Add a special ID */
135 _countof(g_SpecialIds[g_cSpecialIds].szKLID), szKLID);
137 }
138
139 RegCloseKey(hLayoutKey);
140
142 {
143 ERR("g_SpecialIds is full!");
144 break;
145 }
146 }
147
149}
#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:89
#define MAKELONG(a, b)
Definition: typedefs.h:249
#define RegEnumKeyEx
Definition: winreg.h:510
#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 1339 of file kbswitch.c.

1340{
1341 HKL hKL = (HKL)lParam;
1342 UINT iKL = GetLayoutIndexFromHKL(hKL);
1343 if (iKL >= g_cKLs)
1344 return;
1345
1346 g_iKL = iKL;
1347
1348 switch (uMsg)
1349 {
1350 case INDICM_SETIMEICON:
1351 if (LOWORD(wParam) == MAXWORD)
1352 {
1353 g_anFlags[iKL] &= ~LAYOUTF_IME_ICON;
1354 g_aiSysPenIcons[iKL] = MAXWORD;
1355 }
1356 else
1357 {
1359 g_aiSysPenIcons[iKL] = (WORD)wParam;
1360 }
1361 UpdatePenIcon(hwnd, iKL);
1362 break;
1363
1365 if (LOWORD(wParam) == MAXWORD)
1366 {
1367 g_anFlags[iKL] &= ~LAYOUTF_TOOLTIP_ATOM;
1368 }
1369 else
1370 {
1373 }
1374 UpdatePenIcon(hwnd, iKL);
1375 break;
1376
1378 if (wParam)
1379 {
1380 if (wParam & RDMI_LEFT)
1382 if (wParam & RDMI_RIGHT)
1384 }
1385 else
1386 {
1388 }
1389 break;
1390
1391 default:
1392 {
1393 ERR("uMsg: %u\n", uMsg);
1394 return;
1395 }
1396 }
1397}
#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:229
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 927 of file kbswitch.c.

928{
929 hwndFore = GetAncestor(hwndFore, GA_ROOT);
930
931 if (!IsWindowVisible(hwndFore))
932 return FALSE;
933
934 if (IsWndClassName(hwndFore, INDICATOR_CLASS) ||
935 IsWndClassName(hwndFore, TEXT("Shell_TrayWnd")))
936 {
937 return FALSE; /* Special window */
938 }
939
940 g_hwndLastActive = hwndFore;
941 return TRUE;
942}
#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 849 of file kbswitch.c.

850{
851 g_hHookDLL = LoadLibrary(_T("indicdll.dll"));
852 if (!g_hHookDLL)
853 return FALSE;
854
859
861 {
862 ERR("SetHooks failed\n");
863 return FALSE;
864 }
865
866 TRACE("SetHooks OK\n");
867 return TRUE;
868}
#define GetProcAddress(x, y)
Definition: compat.h:753
#define IFN_KbSwitchSetHooks
Definition: kbswitch.c:845
#define IFN_SetPenMenuData
Definition: kbswitch.c:846
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:3903
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581

Referenced by KbSwitch_OnCreate().

◆ ShowImeToolbar()

static VOID ShowImeToolbar ( HWND  hwndTarget,
BOOL  bShowToolbar 
)
static

Definition at line 1059 of file kbswitch.c.

1060{
1061 HKEY hKey;
1062 LSTATUS error = RegOpenKey(HKEY_CURRENT_USER, TEXT("Control Panel\\Input Method"), &hKey);
1063 if (error)
1064 {
1065 ERR("Cannot open regkey: 0x%lX\n", error);
1066 return;
1067 }
1068
1069 WCHAR szText[8];
1070 StringCchPrintf(szText, _countof(szText), TEXT("%d"), bShowToolbar);
1071
1072 DWORD cbValue = (lstrlen(szText) + 1) * sizeof(TCHAR);
1073 RegSetValueEx(hKey, TEXT("Show Status"), 0, REG_SZ, (PBYTE)szText, cbValue);
1075
1076 HWND hwndIme = ImmGetDefaultIMEWnd(hwndTarget);
1077 PostMessage(hwndIme, WM_IME_SYSTEM, IMS_NOTIFYIMESHOW, bShowToolbar);
1078}
#define IMS_NOTIFYIMESHOW
Definition: imm32_undoc.h:35
#define REG_SZ
Definition: layer.c:22
#define lstrlen
Definition: winbase.h:3917
#define RegSetValueEx
Definition: winreg.h:533

Referenced by KbSwitch_OnPenIconMsg().

◆ UpdateLanguageDisplay()

UINT UpdateLanguageDisplay ( HWND  hwnd,
HKL  hKL 
)

Definition at line 902 of file kbswitch.c.

903{
904 TCHAR szKLID[MAX_PATH], szLangName[MAX_PATH];
906
907 GetKLIDFromHKL(hKL, szKLID, _countof(szKLID));
908 LangID = (LANGID)_tcstoul(szKLID, NULL, 16);
909 GetLocaleInfo(LangID, LOCALE_SLANGUAGE, szLangName, _countof(szLangName));
910 UpdateTrayIcon(hwnd, szKLID, szLangName);
911 g_iKL = GetLayoutNum(hKL);
912
913 return 0;
914}
static UINT GetLayoutNum(HKL hKL)
Definition: kbswitch.c:888

Referenced by KbSwitch_OnTimer(), and UpdateLanguageDisplayCurrent().

◆ UpdateLanguageDisplayCurrent()

UINT UpdateLanguageDisplayCurrent ( HWND  hwnd,
HWND  hwndFore 
)

Definition at line 917 of file kbswitch.c.

918{
920 DWORD dwThreadID = GetWindowThreadProcessId(GetTargetWindow(hwndFore), NULL);
921 HKL hKL = GetKeyboardLayout(dwThreadID);
924 return 0;
925}

Referenced by KbSwitch_OnWindowActivate().

◆ UpdateLayoutList()

static VOID UpdateLayoutList ( HKL hKL  OPTIONAL)
static

Definition at line 239 of file kbswitch.c.

240{
241 if (!hKL)
242 hKL = GetActiveKL();
243
244 HICON ahSysPenIcons[MAX_KLS];
245 WORD aiSysPenIcons[MAX_KLS];
246 BYTE anFlags[MAX_KLS];
247 ZeroMemory(ahSysPenIcons, sizeof(ahSysPenIcons));
248 FillMemory(aiSysPenIcons, sizeof(aiSysPenIcons), 0xFF);
249 ZeroMemory(anFlags, sizeof(anFlags));
250
251 HKL ahKLs[MAX_KLS];
252 UINT iKL, nKLs = GetKeyboardLayoutList(_countof(ahKLs), ahKLs);
253
254 /* Reuse old icons and flags */
255 for (iKL = 0; iKL < nKLs; ++iKL)
256 {
257 LANGID wLangID = LOWORD(ahKLs[iKL]);
258 switch (wLangID)
259 {
262 case LANGID_JAPANESE:
263 case LANGID_KOREAN:
264 anFlags[iKL] |= LAYOUTF_FAR_EAST;
265 break;
266 default:
267 anFlags[iKL] &= ~LAYOUTF_FAR_EAST;
268 break;
269 }
270
271 UINT iKL2;
272 for (iKL2 = 0; iKL2 < g_cKLs; ++iKL2)
273 {
274 if (ahKLs[iKL] == g_ahKLs[iKL2])
275 {
276 ahSysPenIcons[iKL] = g_ahSysPenIcons[iKL2];
277 aiSysPenIcons[iKL] = g_aiSysPenIcons[iKL2];
278 anFlags[iKL] = g_anFlags[iKL2];
279
280 g_ahSysPenIcons[iKL2] = NULL;
281 break;
282 }
283 }
284 }
285
287
288 g_cKLs = nKLs;
289
290 C_ASSERT(sizeof(g_ahKLs) == sizeof(ahKLs));
291 CopyMemory(g_ahKLs, ahKLs, sizeof(g_ahKLs));
292
293 C_ASSERT(sizeof(g_ahSysPenIcons) == sizeof(ahSysPenIcons));
294 CopyMemory(g_ahSysPenIcons, ahSysPenIcons, sizeof(g_ahSysPenIcons));
295
296 C_ASSERT(sizeof(g_anFlags) == sizeof(anFlags));
297 CopyMemory(g_anFlags, anFlags, sizeof(g_anFlags));
298
300}
#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: winbase.h:1751
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 555 of file kbswitch.c.

556{
557 DeletePenIcon(hwnd, iKL);
558
559 // Not Far-East?
560 if (!(g_anFlags[iKL] & LAYOUTF_FAR_EAST))
561 {
563 return;
564 }
565
566 // Get IME file
567 TCHAR szKLID[CCH_LAYOUT_ID + 1], szImeFile[MAX_PATH];
568 GetKLIDFromHKL(g_ahKLs[iKL], szKLID, _countof(szKLID));
569 if (!GetImeFile(szImeFile, _countof(szImeFile), szKLID))
570 {
572 return;
573 }
574
575 // Load pen icon
576 assert(!g_ahSysPenIcons[iKL]);
577 if (g_anFlags[iKL] & LAYOUTF_IME_ICON)
578 g_ahSysPenIcons[iKL] = FakeExtractIcon(szImeFile, g_aiSysPenIcons[iKL]);
579 if (!g_ahSysPenIcons[iKL])
580 g_ahSysPenIcons[iKL] = LoadDefaultPenIcon(szImeFile, g_ahKLs[iKL]);
581 if (!g_ahSysPenIcons[iKL])
582 {
584 return;
585 }
586
587 // Add pen icon
592
593 if (g_anToolTipAtoms[iKL])
595 else
597
599 ERR("Shell_NotifyIcon failed\n");
600 else
602}
#define assert(x)
Definition: debug.h:53
#define ImmGetDescription
Definition: imm.h:827
#define WM_PENICONMSG
Definition: kbswitch.c:37
static HICON LoadDefaultPenIcon(PCWSTR szImeFile, HKL hKL)
Definition: kbswitch.c:492
static VOID DeletePenIcon(HWND hwnd, UINT iKL)
Definition: kbswitch.c:203
#define NIM_MODIFY
Definition: shellapi.h:95
#define GlobalGetAtomName
Definition: winbase.h:3901

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

742{
743 NOTIFYICONDATA tnid =
744 {
746 };
747 TCHAR szImeFile[80];
748
749 GetImeFile(szImeFile, _countof(szImeFile), szKLID);
750
752 tnid.hIcon = CreateTrayIcon(szKLID, szImeFile);
754
756
757 if (g_hTrayIcon)
759 g_hTrayIcon = tnid.hIcon;
760}

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

◆ UpdateTrayInfo()

static VOID UpdateTrayInfo ( VOID  )
static

Definition at line 81 of file kbswitch.c.

82{
83 g_hTrayWnd = FindWindow(TEXT("Shell_TrayWnd"), NULL);
85}
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 1400 of file kbswitch.c.

1401{
1402 switch (uMsg)
1403 {
1404 case WM_CREATE:
1405 return KbSwitch_OnCreate(hwnd);
1406
1407 case WM_TIMER:
1409 break;
1410
1411 case WM_LANG_CHANGED: /* Comes from indicdll.dll and this module */
1413
1414 case WM_WINDOW_ACTIVATE: /* Comes from indicdll.dll and this module */
1416
1417 case WM_NOTIFYICONMSG:
1419 break;
1420
1421 case WM_PENICONMSG:
1423 break;
1424
1425 case WM_COMMAND:
1427 break;
1428
1429 case WM_SETTINGCHANGE:
1431 break;
1432
1433 case WM_DESTROY:
1435 break;
1436
1437 case INDICM_SETIMEICON:
1440 if (InSendMessageEx(NULL))
1441 break; /* Must be a PostMessage call for quick response, not SendMessage */
1442
1444 break;
1445
1446 case WM_INPUTLANGCHANGEREQUEST:
1447 TRACE("WM_INPUTLANGCHANGEREQUEST(%p, %p)\n", wParam, lParam);
1449 break;
1450
1451 default:
1452 return KbSwitch_OnDefault(hwnd, uMsg, wParam, lParam);
1453 }
1454
1455 return 0;
1456}
static void KbSwitch_OnCommand(HWND hwnd, UINT nID)
Definition: kbswitch.c:1250
static LRESULT KbSwitch_OnWindowActivate(HWND hwnd, HWND hwndTarget OPTIONAL, LPARAM lParam OPTIONAL)
Definition: kbswitch.c:1296
static LRESULT KbSwitch_OnDefault(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: kbswitch.c:1314
static void KbSwitch_OnSettingChange(HWND hwnd, WPARAM wParam, LPARAM lParam)
Definition: kbswitch.c:1307
static VOID KbSwitch_OnPenIconMsg(HWND hwnd, UINT uMouseMsg)
Definition: kbswitch.c:1082
static LRESULT KbSwitch_OnLangChanged(HWND hwnd, HWND hwndTarget OPTIONAL, HKL hKL OPTIONAL)
Definition: kbswitch.c:1285
static void KbSwitch_OnNotifyIconMsg(HWND hwnd, UINT uMouseMsg)
Definition: kbswitch.c:994
static void KbSwitch_OnTimer(HWND hwnd, UINT_PTR nTimerID)
Definition: kbswitch.c:980
static VOID OnIndicatorMsg(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: kbswitch.c:1339
static INT KbSwitch_OnCreate(HWND hwnd)
Definition: kbswitch.c:946
static void KbSwitch_OnDestroy(HWND hwnd)
Definition: kbswitch.c:968
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 97 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 96 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().