ReactOS  0.4.12-dev-722-g4ba3c90
main.c File Reference
#include "osk.h"
#include "settings.h"
Include dependency graph for main.c:

Go to the source code of this file.

Functions

int OSK_SetImage (int IdDlgItem, int IdResource)
 
int OSK_DlgInitDialog (HWND hDlg)
 
int OSK_DlgClose (void)
 
int OSK_DlgTimer (void)
 
BOOL OSK_DlgCommand (WPARAM wCommand, HWND hWndControl)
 
BOOL OSK_ReleaseKey (WORD ScanCode)
 
INT_PTR APIENTRY OSK_DlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
 
int WINAPI wWinMain (HINSTANCE, HINSTANCE, LPWSTR, int)
 
INT_PTR CALLBACK OSK_WarningProc (HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
 
VOID OSK_About (VOID)
 

Variables

OSK_GLOBALS Globals
 

Function Documentation

◆ OSK_About()

VOID OSK_About ( VOID  )

Definition at line 108 of file main.c.

109 {
111  WCHAR szAuthors[MAX_BUFF];
112  HICON OSKIcon;
113 
114  /* Load the icon */
116 
117  /* Load the strings into the "About" dialog */
119  LoadStringW(Globals.hInstance, STRING_AUTHORS, szAuthors, countof(szAuthors));
120 
121  /* Finally, execute the "About" dialog by using the Shell routine */
122  ShellAboutW(Globals.hMainWnd, szTitle, szAuthors, OSKIcon);
123 
124  /* Once done, destroy the icon */
125  DestroyIcon(OSKIcon);
126 }
static HICON
Definition: imagelist.c:84
NOTEPAD_GLOBALS Globals
Definition: main.c:29
#define IMAGE_ICON
Definition: winuser.h:212
#define STRING_OSK
Definition: osk_res.h:51
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define IDI_OSK
Definition: osk_res.h:17
WCHAR szTitle[MAX_LOADSTRING]
Definition: main.c:38
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
HINSTANCE hInstance
Definition: main.h:55
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:2172
#define countof(x)
Definition: main.h:34
#define STRING_AUTHORS
Definition: osk_res.h:52
#define MAX_BUFF
Definition: main.h:35
#define LR_DEFAULTSIZE
Definition: winuser.h:1084
BOOL WINAPI ShellAboutW(HWND hWnd, LPCWSTR szApp, LPCWSTR szOtherStuff, HICON hIcon)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
HWND hMainWnd
Definition: main.h:56

Referenced by OSK_DlgProc().

◆ OSK_DlgClose()

int OSK_DlgClose ( void  )

Definition at line 220 of file main.c.

221 {
223 
224  /* Release Ctrl, Shift, Alt keys */
225  OSK_ReleaseKey(SCAN_CODE_44); // Left shift
226  OSK_ReleaseKey(SCAN_CODE_57); // Right shift
227  OSK_ReleaseKey(SCAN_CODE_58); // Left ctrl
228  OSK_ReleaseKey(SCAN_CODE_60); // Left alt
229  OSK_ReleaseKey(SCAN_CODE_62); // Right alt
230  OSK_ReleaseKey(SCAN_CODE_64); // Right ctrl
231 
232  /* delete GDI objects */
233  if (Globals.hBrushGreenLed) DeleteObject(Globals.hBrushGreenLed);
234 
235  /* Save the settings to the registry hive */
237 
238  return TRUE;
239 }
#define TRUE
Definition: types.h:120
#define SCAN_CODE_60
Definition: osk_res.h:117
NOTEPAD_GLOBALS Globals
Definition: main.c:29
#define SCAN_CODE_64
Definition: osk_res.h:120
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define SCAN_CODE_62
Definition: osk_res.h:119
#define SCAN_CODE_57
Definition: osk_res.h:115
#define SCAN_CODE_58
Definition: osk_res.h:116
BOOL SaveDataToRegistry()
Definition: settings.c:80
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
BOOL OSK_ReleaseKey(WORD ScanCode)
Definition: main.c:359
#define SCAN_CODE_44
Definition: osk_res.h:103
HWND hMainWnd
Definition: main.h:56

Referenced by OSK_DlgProc().

◆ OSK_DlgCommand()

BOOL OSK_DlgCommand ( WPARAM  wCommand,
HWND  hWndControl 
)

Definition at line 272 of file main.c.

273 {
274  WORD ScanCode;
275  INPUT Input;
276  BOOL bExtendedKey;
277  BOOL bKeyDown;
278  BOOL bKeyUp;
279  LONG WindowStyle;
280 
281  /* FIXME: To be deleted when ReactOS will support WS_EX_NOACTIVATE */
282  if (Globals.hActiveWnd)
283  {
284  MSG msg;
285 
286  SetForegroundWindow(Globals.hActiveWnd);
287  while (PeekMessageW(&msg, 0, 0, 0, PM_REMOVE))
288  {
291  }
292  }
293 
294  /* KeyDown and/or KeyUp ? */
295  WindowStyle = GetWindowLongW(hWndControl, GWL_STYLE);
296  if ((WindowStyle & BS_AUTOCHECKBOX) == BS_AUTOCHECKBOX)
297  {
298  /* 2-states key like Shift, Alt, Ctrl, ... */
299  if (SendMessageW(hWndControl, BM_GETCHECK, 0, 0) == BST_CHECKED)
300  {
301  bKeyDown = TRUE;
302  bKeyUp = FALSE;
303  }
304  else
305  {
306  bKeyDown = FALSE;
307  bKeyUp = TRUE;
308  }
309  }
310  else
311  {
312  /* Other key */
313  bKeyDown = TRUE;
314  bKeyUp = TRUE;
315  }
316 
317  /* Extended key ? */
318  ScanCode = wCommand;
319  if (ScanCode & 0x0200)
320  bExtendedKey = TRUE;
321  else
322  bExtendedKey = FALSE;
323  ScanCode &= 0xFF;
324 
325  /* Press and release the key */
326  if (bKeyDown)
327  {
328  Input.type = INPUT_KEYBOARD;
329  Input.ki.wVk = 0;
330  Input.ki.wScan = ScanCode;
331  Input.ki.time = GetTickCount();
332  Input.ki.dwExtraInfo = GetMessageExtraInfo();
333  Input.ki.dwFlags = KEYEVENTF_SCANCODE;
334  if (bExtendedKey) Input.ki.dwFlags |= KEYEVENTF_EXTENDEDKEY;
335  SendInput(1, &Input, sizeof(Input));
336  }
337 
338  if (bKeyUp)
339  {
340  Input.type = INPUT_KEYBOARD;
341  Input.ki.wVk = 0;
342  Input.ki.wScan = ScanCode;
343  Input.ki.time = GetTickCount();
344  Input.ki.dwExtraInfo = GetMessageExtraInfo();
345  Input.ki.dwFlags = KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP;
346  if (bExtendedKey) Input.ki.dwFlags |= KEYEVENTF_EXTENDEDKEY;
347  SendInput(1, &Input, sizeof(Input));
348  }
349 
350  return TRUE;
351 }
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define TRUE
Definition: types.h:120
NOTEPAD_GLOBALS Globals
Definition: main.c:29
ULONG ScanCode
Definition: api.c:39
#define KEYEVENTF_KEYUP
Definition: winuser.h:1092
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:445
Definition: arc.h:84
#define INPUT_KEYBOARD
Definition: winable.h:10
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
long LONG
Definition: pedump.c:60
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
UINT msg
Definition: msvc.h:92
LPARAM WINAPI GetMessageExtraInfo(void)
Definition: message.c:1315
#define BS_AUTOCHECKBOX
Definition: pedump.c:654
#define BM_GETCHECK
Definition: winuser.h:1879
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned short WORD
Definition: ntddk_ex.h:93
#define GWL_STYLE
Definition: winuser.h:846
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define KEYEVENTF_EXTENDEDKEY
Definition: winuser.h:1091
#define BST_CHECKED
Definition: winuser.h:197
#define msg(x)
Definition: auth_time.c:54
BOOL WINAPI SetForegroundWindow(_In_ HWND)
BOOL WINAPI PeekMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
#define PM_REMOVE
Definition: winuser.h:1182
UINT WINAPI SendInput(UINT, LPINPUT, int)
Definition: ntwrapper.h:344

Referenced by OSK_DlgProc().

◆ OSK_DlgInitDialog()

int OSK_DlgInitDialog ( HWND  hDlg)

Definition at line 135 of file main.c.

136 {
138  HMONITOR monitor;
140  POINT Pt;
141  RECT rcWindow;
142 
143  /* Save handle */
144  Globals.hMainWnd = hDlg;
145 
146  /* Check the checked menu item before displaying the modal box */
147  if (Globals.bIsEnhancedKeyboard)
148  {
149  /* Enhanced keyboard dialog chosen, set the respective menu item as checked */
152  }
153  else
154  {
155  /* Standard keyboard dialog chosen, set the respective menu item as checked */
158  }
159 
160  /* Set the application's icon */
163  if (hIcon || hIconSm)
164  {
165  /* Set the window icons (they are deleted when the process terminates) */
168  }
169 
170  /* Get screen info */
171  memset(&Pt, 0, sizeof(Pt));
172  monitor = MonitorFromPoint(Pt, MONITOR_DEFAULTTOPRIMARY);
173  info.cbSize = sizeof(info);
174  GetMonitorInfoW(monitor, &info);
175 
176  /* Move the dialog on the bottom of main screen */
177  GetWindowRect(hDlg, &rcWindow);
178  MoveWindow(hDlg,
179  (info.rcMonitor.left + info.rcMonitor.right) / 2 - // Center of screen
180  (rcWindow.right - rcWindow.left) / 2, // - half size of dialog
181  info.rcMonitor.bottom - // Bottom of screen
182  (rcWindow.bottom - rcWindow.top), // - size of window
183  rcWindow.right - rcWindow.left, // Width
184  rcWindow.bottom - rcWindow.top, // Height
185  TRUE);
186 
187  /* Set icon on visual buttons */
204 
205  /* Create a green brush for leds */
206  Globals.hBrushGreenLed = CreateSolidBrush(RGB(0, 255, 0));
207 
208  /* Set a timer for periodics tasks */
209  Globals.iTimer = SetTimer(hDlg, 0, 200, NULL);
210 
211  return TRUE;
212 }
#define SCAN_CODE_30
Definition: osk_res.h:89
HMONITOR WINAPI MonitorFromPoint(POINT, DWORD)
static HICON
Definition: imagelist.c:84
#define TRUE
Definition: types.h:120
NOTEPAD_GLOBALS Globals
Definition: main.c:29
#define LR_SHARED
Definition: winuser.h:1090
#define IMAGE_ICON
Definition: winuser.h:212
#define MF_BYCOMMAND
Definition: winuser.h:202
#define SCAN_CODE_128
Definition: osk_res.h:166
#define IDI_PG_UP
Definition: osk_res.h:26
#define IDI_OSK
Definition: osk_res.h:17
LONG top
Definition: windef.h:292
#define IDI_RIGHT
Definition: osk_res.h:30
#define SM_CYSMICON
Definition: winuser.h:1003
#define SCAN_CODE_79
Definition: osk_res.h:123
#define IDI_TOP
Definition: osk_res.h:29
#define IDI_TAB
Definition: osk_res.h:19
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
#define IDI_SHIFT
Definition: osk_res.h:22
#define ICON_SMALL
Definition: tnclass.cpp:48
struct _test_info info[]
Definition: SetCursorPos.c:19
HINSTANCE hInstance
Definition: main.h:55
#define SCAN_CODE_80
Definition: osk_res.h:124
#define SCAN_CODE_16
Definition: osk_res.h:75
#define IDI_LEFT
Definition: osk_res.h:28
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:2172
LONG_PTR LPARAM
Definition: windef.h:208
int OSK_SetImage(int IdDlgItem, int IdResource)
Definition: main.c:37
#define IDI_BACK
Definition: osk_res.h:18
#define SCAN_CODE_57
Definition: osk_res.h:115
HANDLE WINAPI CopyImage(_In_ HANDLE, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:1956
#define IDI_MENU
Definition: osk_res.h:24
#define IDI_HOME
Definition: osk_res.h:25
#define SCAN_CODE_86
Definition: osk_res.h:129
smooth NULL
Definition: ftsmooth.c:416
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define IDI_CAPS_LOCK
Definition: osk_res.h:20
#define IDM_STANDARD_KB
Definition: osk_res.h:35
#define MF_CHECKED
Definition: winuser.h:132
#define IDM_ENHANCED_KB
Definition: osk_res.h:36
#define LR_DEFAULTSIZE
Definition: winuser.h:1084
BOOL WINAPI GetMonitorInfoW(_In_ HMONITOR, _Inout_ LPMONITORINFO)
#define RGB(r, g, b)
Definition: wingdi.h:2918
int WINAPI GetSystemMetrics(_In_ int)
DWORD WINAPI CheckMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define SM_CXSMICON
Definition: winuser.h:1002
#define IDI_REACTOS
Definition: osk_res.h:23
#define SCAN_CODE_89
Definition: osk_res.h:130
#define MF_UNCHECKED
Definition: winuser.h:204
#define SCAN_CODE_15
Definition: osk_res.h:74
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)
#define IDI_RETURN
Definition: osk_res.h:21
#define LR_COPYFROMRESOURCE
Definition: winuser.h:1089
#define SCAN_CODE_127
Definition: osk_res.h:165
HICON hIcon
Definition: msconfig.c:44
#define SCAN_CODE_84
Definition: osk_res.h:127
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define IDI_BOTTOM
Definition: osk_res.h:31
#define SCAN_CODE_43
Definition: osk_res.h:102
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
HICON hIconSm
Definition: msconfig.c:44
LONG bottom
Definition: windef.h:294
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define SCAN_CODE_85
Definition: osk_res.h:128
#define SCAN_CODE_44
Definition: osk_res.h:103
#define SCAN_CODE_83
Definition: osk_res.h:126
#define memset(x, y, z)
Definition: compat.h:39
HMENU WINAPI GetMenu(_In_ HWND)
HWND hMainWnd
Definition: main.h:56
#define IDI_PG_DOWN
Definition: osk_res.h:27
#define ICON_BIG
Definition: tnclass.cpp:51
#define SCAN_CODE_129
Definition: osk_res.h:167

Referenced by OSK_DlgProc().

◆ OSK_DlgProc()

INT_PTR APIENTRY OSK_DlgProc ( HWND  hDlg,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 398 of file main.c.

399 {
400  switch (msg)
401  {
402  case WM_INITDIALOG:
403  OSK_DlgInitDialog(hDlg);
404  return TRUE;
405 
406  case WM_TIMER:
407  OSK_DlgTimer();
408  return TRUE;
409 
410  case WM_CTLCOLORSTATIC:
411  if ((HWND)lParam == GetDlgItem(hDlg, IDC_LED_NUM))
412  {
413  if (GetKeyState(VK_NUMLOCK) & 0x0001)
414  return (INT_PTR)Globals.hBrushGreenLed;
415  else
417  }
418  if ((HWND)lParam == GetDlgItem(hDlg, IDC_LED_CAPS))
419  {
420  if (GetKeyState(VK_CAPITAL) & 0x0001)
421  return (INT_PTR)Globals.hBrushGreenLed;
422  else
424  }
425  if ((HWND)lParam == GetDlgItem(hDlg, IDC_LED_SCROLL))
426  {
427  if (GetKeyState(VK_SCROLL) & 0x0001)
428  return (INT_PTR)Globals.hBrushGreenLed;
429  else
431  }
432  break;
433 
434  case WM_COMMAND:
435  switch (LOWORD(wParam))
436  {
437  case IDCANCEL:
438  {
439  EndDialog(hDlg, FALSE);
440  break;
441  }
442 
443  case IDM_EXIT:
444  {
445  EndDialog(hDlg, FALSE);
446  break;
447  }
448 
449  case IDM_ENHANCED_KB:
450  {
451  if (!Globals.bIsEnhancedKeyboard)
452  {
453  /*
454  The user attempted to switch to enhanced keyboard dialog type.
455  Set the member value as TRUE, destroy the dialog and save the data configuration into the registry.
456  */
457  Globals.bIsEnhancedKeyboard = TRUE;
458  EndDialog(hDlg, FALSE);
460 
461  /* Change the condition of enhanced keyboard item menu to checked */
464 
465  /* Finally, display the dialog modal box with the enhanced keyboard dialog */
469  OSK_DlgProc);
470  }
471 
472  break;
473  }
474 
475  case IDM_STANDARD_KB:
476  {
477  if (Globals.bIsEnhancedKeyboard)
478  {
479  /*
480  The user attempted to switch to standard keyboard dialog type.
481  Set the member value as FALSE, destroy the dialog and save the data configuration into the registry.
482  */
483  Globals.bIsEnhancedKeyboard = FALSE;
484  EndDialog(hDlg, FALSE);
486 
487  /* Change the condition of standard keyboard item menu to checked */
490 
491  /* Finally, display the dialog modal box with the standard keyboard dialog */
495  OSK_DlgProc);
496  }
497 
498  break;
499  }
500 
501  case IDM_ABOUT:
502  {
503  OSK_About();
504  break;
505  }
506 
507  default:
509  break;
510  }
511  break;
512 
513  case WM_CLOSE:
514  OSK_DlgClose();
515  break;
516  }
517 
518  return 0;
519 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
INT_PTR APIENTRY OSK_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: main.c:398
int OSK_DlgClose(void)
Definition: main.c:220
#define TRUE
Definition: types.h:120
NOTEPAD_GLOBALS Globals
Definition: main.c:29
#define MF_BYCOMMAND
Definition: winuser.h:202
#define IDM_ABOUT
Definition: resource.h:29
#define WM_CTLCOLORSTATIC
Definition: winuser.h:1748
#define MAIN_DIALOG_STANDARD_KB
Definition: osk_res.h:10
int32_t INT_PTR
Definition: typedefs.h:62
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
HINSTANCE hInstance
Definition: main.h:55
int OSK_DlgInitDialog(HWND hDlg)
Definition: main.c:135
#define IDC_LED_CAPS
Definition: osk_res.h:13
UINT msg
Definition: msvc.h:92
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:622
#define DialogBoxW(i, t, p, f)
Definition: winuser.h:4268
SHORT WINAPI GetKeyState(_In_ int)
#define BLACK_BRUSH
Definition: wingdi.h:895
#define IDM_STANDARD_KB
Definition: osk_res.h:35
#define MF_CHECKED
Definition: winuser.h:132
BOOL OSK_DlgCommand(WPARAM wCommand, HWND hWndControl)
Definition: main.c:272
#define IDM_ENHANCED_KB
Definition: osk_res.h:36
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define WM_TIMER
Definition: winuser.h:1718
#define WM_CLOSE
Definition: winuser.h:1603
int OSK_DlgTimer(void)
Definition: main.c:247
DWORD WINAPI CheckMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define IDC_LED_SCROLL
Definition: osk_res.h:14
BOOL SaveDataToRegistry()
Definition: settings.c:80
#define WM_COMMAND
Definition: winuser.h:1716
#define MF_UNCHECKED
Definition: winuser.h:204
VOID OSK_About(VOID)
Definition: main.c:108
#define VK_SCROLL
Definition: winuser.h:2234
#define VK_NUMLOCK
Definition: winuser.h:2233
#define MAIN_DIALOG_ENHANCED_KB
Definition: osk_res.h:9
#define VK_CAPITAL
Definition: winuser.h:2160
#define IDM_EXIT
Definition: resource.h:27
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define IDC_LED_NUM
Definition: osk_res.h:12
#define IDCANCEL
Definition: winuser.h:825
HMENU WINAPI GetMenu(_In_ HWND)
#define WM_INITDIALOG
Definition: winuser.h:1715
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82

Referenced by wWinMain().

◆ OSK_DlgTimer()

int OSK_DlgTimer ( void  )

Definition at line 247 of file main.c.

248 {
249  /* FIXME: To be deleted when ReactOS will support WS_EX_NOACTIVATE */
250  HWND hWndActiveWindow;
251 
252  hWndActiveWindow = GetForegroundWindow();
253  if (hWndActiveWindow != NULL && hWndActiveWindow != Globals.hMainWnd)
254  {
255  Globals.hActiveWnd = hWndActiveWindow;
256  }
257 
258  /* Always redraw leds because it can be changed by the real keyboard) */
262 
263  return TRUE;
264 }
#define TRUE
Definition: types.h:120
NOTEPAD_GLOBALS Globals
Definition: main.c:29
#define IDC_LED_CAPS
Definition: osk_res.h:13
smooth NULL
Definition: ftsmooth.c:416
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define IDC_LED_SCROLL
Definition: osk_res.h:14
HWND WINAPI GetForegroundWindow(void)
Definition: ntwrapper.h:392
#define IDC_LED_NUM
Definition: osk_res.h:12
HWND hMainWnd
Definition: main.h:56

Referenced by OSK_DlgProc().

◆ OSK_ReleaseKey()

BOOL OSK_ReleaseKey ( WORD  ScanCode)

Definition at line 359 of file main.c.

360 {
361  INPUT Input;
362  BOOL bExtendedKey;
363  LONG WindowStyle;
364  HWND hWndControl;
365 
366  /* Is it a 2-states key ? */
367  hWndControl = GetDlgItem(Globals.hMainWnd, ScanCode);
368  WindowStyle = GetWindowLongW(hWndControl, GWL_STYLE);
369  if ((WindowStyle & BS_AUTOCHECKBOX) != BS_AUTOCHECKBOX) return FALSE;
370 
371  /* Is the key down ? */
372  if (SendMessageW(hWndControl, BM_GETCHECK, 0, 0) != BST_CHECKED) return TRUE;
373 
374  /* Extended key ? */
375  if (ScanCode & 0x0200)
376  bExtendedKey = TRUE;
377  else
378  bExtendedKey = FALSE;
379  ScanCode &= 0xFF;
380 
381  /* Release the key */
382  Input.type = INPUT_KEYBOARD;
383  Input.ki.wVk = 0;
384  Input.ki.wScan = ScanCode;
385  Input.ki.time = GetTickCount();
386  Input.ki.dwExtraInfo = GetMessageExtraInfo();
387  Input.ki.dwFlags = KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP;
388  if (bExtendedKey) Input.ki.dwFlags |= KEYEVENTF_EXTENDEDKEY;
389  SendInput(1, &Input, sizeof(Input));
390 
391  return TRUE;
392 }
#define TRUE
Definition: types.h:120
NOTEPAD_GLOBALS Globals
Definition: main.c:29
ULONG ScanCode
Definition: api.c:39
#define KEYEVENTF_KEYUP
Definition: winuser.h:1092
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:445
Definition: arc.h:84
#define INPUT_KEYBOARD
Definition: winable.h:10
long LONG
Definition: pedump.c:60
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
LPARAM WINAPI GetMessageExtraInfo(void)
Definition: message.c:1315
#define BS_AUTOCHECKBOX
Definition: pedump.c:654
#define BM_GETCHECK
Definition: winuser.h:1879
unsigned int BOOL
Definition: ntddk_ex.h:94
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define GWL_STYLE
Definition: winuser.h:846
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define KEYEVENTF_EXTENDEDKEY
Definition: winuser.h:1091
#define BST_CHECKED
Definition: winuser.h:197
HWND hMainWnd
Definition: main.h:56
UINT WINAPI SendInput(UINT, LPINPUT, int)
Definition: ntwrapper.h:344

Referenced by OSK_DlgClose().

◆ OSK_SetImage()

int OSK_SetImage ( int  IdDlgItem,
int  IdResource 
)

Definition at line 37 of file main.c.

38 {
39  HICON hIcon;
40  HWND hWndItem;
41 
43  IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
44  if (hIcon == NULL)
45  return FALSE;
46 
47  hWndItem = GetDlgItem(Globals.hMainWnd, IdDlgItem);
48  if (hWndItem == NULL)
49  {
51  return FALSE;
52  }
53 
55 
56  /* The system automatically deletes these resources when the process that created them terminates (MSDN) */
57 
58  return TRUE;
59 }
static HICON
Definition: imagelist.c:84
#define TRUE
Definition: types.h:120
NOTEPAD_GLOBALS Globals
Definition: main.c:29
#define IMAGE_ICON
Definition: winuser.h:212
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
#define BM_SETIMAGE
Definition: winuser.h:1883
UINT_PTR WPARAM
Definition: windef.h:207
HINSTANCE hInstance
Definition: main.h:55
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:2172
LONG_PTR LPARAM
Definition: windef.h:208
smooth NULL
Definition: ftsmooth.c:416
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
HICON hIcon
Definition: msconfig.c:44
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define LR_DEFAULTCOLOR
Definition: winuser.h:1077
HWND hMainWnd
Definition: main.h:56

Referenced by OSK_DlgInitDialog().

◆ OSK_WarningProc()

INT_PTR CALLBACK OSK_WarningProc ( HWND  hDlg,
UINT  Msg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 67 of file main.c.

68 {
70 
71  switch (Msg)
72  {
73  case WM_INITDIALOG:
74  {
75  return TRUE;
76  }
77 
78  case WM_COMMAND:
79  {
80  switch (LOWORD(wParam))
81  {
83  {
84  Globals.bShowWarning = !IsDlgButtonChecked(hDlg, IDC_SHOWWARNINGCHECK);
85  return TRUE;
86  }
87 
88  case IDOK:
89  case IDCANCEL:
90  {
91  EndDialog(hDlg, LOWORD(wParam));
92  return TRUE;
93  }
94  }
95  break;
96  }
97  }
98 
99  return FALSE;
100 }
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
NOTEPAD_GLOBALS Globals
Definition: main.c:29
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define IDC_SHOWWARNINGCHECK
Definition: resource.h:25
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
UINT WINAPI IsDlgButtonChecked(_In_ HWND, _In_ int)
#define WM_COMMAND
Definition: winuser.h:1716
struct @1565 Msg[]
#define IDCANCEL
Definition: winuser.h:825
#define WM_INITDIALOG
Definition: winuser.h:1715
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82

Referenced by wWinMain().

◆ wWinMain()

int WINAPI wWinMain ( HINSTANCE  hInstance,
HINSTANCE  hPrevInstance,
LPWSTR  lpCmdLine,
int  nShowCmd 
)

This file has no copyright assigned and is placed in the Public Domain. This file is part of the w64 mingw-runtime package. No warranty is given; refer to the file DISCLAIMER.PD within this package.

Definition at line 525 of file main.c.

529 {
530  HANDLE hMutex;
531  INT LayoutResource;
532 
536 
537  ZeroMemory(&Globals, sizeof(Globals));
539 
540  /* Load the settings from the registry hive */
542 
543  /* If the member of the struct (bShowWarning) is set then display the dialog box */
544  if (Globals.bShowWarning)
545  {
547  }
548 
549  /* Before initializing the dialog execution, check if the chosen keyboard type is standard or enhanced */
550  if (Globals.bIsEnhancedKeyboard)
551  {
552  LayoutResource = MAIN_DIALOG_ENHANCED_KB;
553  }
554  else
555  {
556  LayoutResource = MAIN_DIALOG_STANDARD_KB;
557  }
558 
559  /* Rry to open a mutex for a single instance */
561 
562  if (!hMutex)
563  {
564  /* Mutex doesn’t exist. This is the first instance so create the mutex. */
565  hMutex = CreateMutexW(NULL, FALSE, L"osk");
566 
567  /* Create the modal box based on the configuration registry */
569  MAKEINTRESOURCEW(LayoutResource),
571  OSK_DlgProc);
572 
573  /* Delete the mutex */
574  if (hMutex) CloseHandle(hMutex);
575  }
576  else
577  {
578  /* Programme already launched */
579 
580  /* Delete the mutex */
582 
583  ExitProcess(0);
584  }
585 
586  return 0;
587 }
INT_PTR APIENTRY OSK_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: main.c:398
#define CloseHandle
Definition: compat.h:398
NOTEPAD_GLOBALS Globals
Definition: main.c:29
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define MAIN_DIALOG_STANDARD_KB
Definition: osk_res.h:10
VOID WINAPI ExitProcess(IN UINT uExitCode)
Definition: proc.c:1517
#define ZeroMemory
Definition: winbase.h:1635
TCHAR * cmdline
Definition: stretchblt.cpp:32
#define MUTEX_ALL_ACCESS
Definition: winbase.h:158
int32_t INT
Definition: typedefs.h:56
HINSTANCE hInstance
Definition: main.h:55
HANDLE WINAPI DECLSPEC_HOTPATCH OpenMutexW(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN LPCWSTR lpName)
Definition: synch.c:551
smooth NULL
Definition: ftsmooth.c:416
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:622
HANDLE hMutex
Definition: mutex.c:11
BOOL LoadDataFromRegistry()
Definition: settings.c:15
#define DialogBoxW(i, t, p, f)
Definition: winuser.h:4268
HINSTANCE hInstance
Definition: main.c:36
static const WCHAR L[]
Definition: oid.c:1250
INT_PTR CALLBACK OSK_WarningProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: main.c:67
#define MAIN_DIALOG_ENHANCED_KB
Definition: osk_res.h:9
HANDLE WINAPI DECLSPEC_HOTPATCH CreateMutexW(IN LPSECURITY_ATTRIBUTES lpMutexAttributes OPTIONAL, IN BOOL bInitialOwner, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:522
#define IDD_WARNINGDIALOG_OSK
Definition: osk_res.h:49
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
HWND hMainWnd
Definition: main.h:56

Variable Documentation

◆ Globals

OSK_GLOBALS Globals

Definition at line 16 of file main.c.