ReactOS  0.4.15-dev-5462-g4d0d22a
kbsdll.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Keyboard Layout Switcher
3  * FILE: base/applications/kbswitch/kbsdll/kbsdll.c
4  * PROGRAMMER: Dmitry Chapyshev <dmitry@reactos.org>
5  *
6  */
7 
8 #include "../kbswitch.h"
9 
10 HHOOK hWinHook = NULL;
11 HHOOK hShellHook = NULL;
14 
15 static VOID
17 {
19 }
20 
23 {
24  if (code < 0)
25  {
27  }
28 
29  switch (code)
30  {
31  case HCBT_SETFOCUS:
32  {
33  HWND hwndFocus = (HWND)wParam;
34  if (hwndFocus && hwndFocus != hKbSwitchWnd)
35  {
37  }
38  }
39  break;
40  }
41 
43 }
44 
47 {
48  if (code < 0)
49  {
51  }
52 
53  switch (code)
54  {
55  case HSHELL_LANGUAGE:
56  {
58  }
59  break;
60  }
61 
63 }
64 
67 {
70 
71  if (!hWinHook || !hShellHook)
72  {
73  return FALSE;
74  }
75 
76  return TRUE;
77 }
78 
81 {
82  if (hWinHook)
83  {
85  hWinHook = NULL;
86  }
87  if (hShellHook)
88  {
90  hShellHook = NULL;
91  }
92 }
93 
95 DllMain(IN HINSTANCE hinstDLL,
98 {
99  switch (dwReason)
100  {
101  case DLL_PROCESS_ATTACH:
102  {
103  hInstance = hinstDLL;
105  if (!hKbSwitchWnd)
106  {
107  return FALSE;
108  }
109  }
110  break;
111  }
112 
113  return TRUE;
114 }
HWND hKbSwitchWnd
Definition: kbsdll.c:13
HINSTANCE hInstance
Definition: kbsdll.c:12
VOID WINAPI KbSwitchDeleteHooks(VOID)
Definition: kbsdll.c:80
#define IN
Definition: typedefs.h:39
#define FindWindow
Definition: winuser.h:5767
#define TRUE
Definition: types.h:120
#define CALLBACK
Definition: compat.h:35
#define WH_SHELL
Definition: winuser.h:40
HANDLE HWND
Definition: compat.h:19
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
UINT_PTR WPARAM
Definition: windef.h:207
#define HCBT_SETFOCUS
Definition: winuser.h:64
WPARAM wParam
Definition: combotst.c:138
static IN DWORD IN LPVOID lpvReserved
LRESULT CALLBACK WinHookProc(int code, WPARAM wParam, LPARAM lParam)
Definition: kbsdll.c:22
DWORD dwReason
Definition: misc.cpp:154
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI DllMain(IN HINSTANCE hinstDLL, IN DWORD dwReason, IN LPVOID lpvReserved)
Definition: kbsdll.c:95
LONG_PTR LPARAM
Definition: windef.h:208
HHOOK hShellHook
Definition: kbsdll.c:11
#define WH_CBT
Definition: winuser.h:35
#define WM_LANG_CHANGED
Definition: kbswitch.h:23
#define PostMessage
Definition: winuser.h:5822
#define WM_WINDOW_ACTIVATE
Definition: kbswitch.h:24
#define WINAPI
Definition: msvc.h:6
#define SetWindowsHookEx
Definition: winuser.h:5846
unsigned long DWORD
Definition: ntddk_ex.h:95
static VOID PostMessageToMainWnd(UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: kbsdll.c:16
Definition: inflate.c:139
BOOL WINAPI UnhookWindowsHookEx(_In_ HHOOK)
TCHAR szKbSwitcherName[]
Definition: kbswitch.h:29
LRESULT WINAPI CallNextHookEx(_In_opt_ HHOOK, _In_ int, _In_ WPARAM, _In_ LPARAM)
HHOOK hWinHook
Definition: kbsdll.c:10
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
LRESULT CALLBACK ShellHookProc(int code, WPARAM wParam, LPARAM lParam)
Definition: kbsdll.c:46
BOOL WINAPI KbSwitchSetHooks(VOID)
Definition: kbsdll.c:66
LONG_PTR LRESULT
Definition: windef.h:209
struct @1595 Msg[]
LPARAM lParam
Definition: combotst.c:139