ReactOS  0.4.13-dev-249-gcba1a2f
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)
 
LRESULT APIENTRY OSK_ThemeHandler (HWND hDlg, NMCUSTOMDRAW *pNmDraw)
 
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 109 of file main.c.

110 {
112  WCHAR szAuthors[MAX_BUFF];
113  HICON OSKIcon;
114 
115  /* Load the icon */
117 
118  /* Load the strings into the "About" dialog */
120  LoadStringW(Globals.hInstance, STRING_AUTHORS, szAuthors, countof(szAuthors));
121 
122  /* Finally, execute the "About" dialog by using the Shell routine */
123  ShellAboutW(Globals.hMainWnd, szTitle, szAuthors, OSKIcon);
124 
125  /* Once done, destroy the icon */
126  DestroyIcon(OSKIcon);
127 }
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:53
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
#define IDI_OSK
Definition: osk_res.h:19
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:37
#define STRING_AUTHORS
Definition: osk_res.h:54
#define MAX_BUFF
Definition: main.h:38
#define LR_DEFAULTSIZE
Definition: winuser.h:1084
__wchar_t WCHAR
Definition: xmlstorage.h:180
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 252 of file main.c.

253 {
255 
256  /* Release Ctrl, Shift, Alt keys */
257  OSK_ReleaseKey(SCAN_CODE_44); // Left shift
258  OSK_ReleaseKey(SCAN_CODE_57); // Right shift
259  OSK_ReleaseKey(SCAN_CODE_58); // Left ctrl
260  OSK_ReleaseKey(SCAN_CODE_60); // Left alt
261  OSK_ReleaseKey(SCAN_CODE_62); // Right alt
262  OSK_ReleaseKey(SCAN_CODE_64); // Right ctrl
263 
264  /* delete GDI objects */
265  if (Globals.hBrushGreenLed) DeleteObject(Globals.hBrushGreenLed);
266 
267  /* Save the settings to the registry hive */
269 
270  return TRUE;
271 }
#define TRUE
Definition: types.h:120
#define SCAN_CODE_60
Definition: osk_res.h:119
NOTEPAD_GLOBALS Globals
Definition: main.c:29
#define SCAN_CODE_64
Definition: osk_res.h:122
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define SCAN_CODE_62
Definition: osk_res.h:121
#define SCAN_CODE_57
Definition: osk_res.h:117
#define SCAN_CODE_58
Definition: osk_res.h:118
BOOL SaveDataToRegistry()
Definition: settings.c:138
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
BOOL OSK_ReleaseKey(WORD ScanCode)
Definition: main.c:397
#define SCAN_CODE_44
Definition: osk_res.h:105
HWND hMainWnd
Definition: main.h:56

Referenced by OSK_DlgProc().

◆ OSK_DlgCommand()

BOOL OSK_DlgCommand ( WPARAM  wCommand,
HWND  hWndControl 
)

Definition at line 304 of file main.c.

305 {
306  WORD ScanCode;
307  INPUT Input;
308  BOOL bExtendedKey;
309  BOOL bKeyDown;
310  BOOL bKeyUp;
311  LONG WindowStyle;
312 
313  /* FIXME: To be deleted when ReactOS will support WS_EX_NOACTIVATE */
314  if (Globals.hActiveWnd)
315  {
316  MSG msg;
317 
318  SetForegroundWindow(Globals.hActiveWnd);
319  while (PeekMessageW(&msg, 0, 0, 0, PM_REMOVE))
320  {
323  }
324  }
325 
326  /* KeyDown and/or KeyUp ? */
327  WindowStyle = GetWindowLongW(hWndControl, GWL_STYLE);
328  if ((WindowStyle & BS_AUTOCHECKBOX) == BS_AUTOCHECKBOX)
329  {
330  /* 2-states key like Shift, Alt, Ctrl, ... */
331  if (SendMessageW(hWndControl, BM_GETCHECK, 0, 0) == BST_CHECKED)
332  {
333  bKeyDown = TRUE;
334  bKeyUp = FALSE;
335  }
336  else
337  {
338  bKeyDown = FALSE;
339  bKeyUp = TRUE;
340  }
341  }
342  else
343  {
344  /* Other key */
345  bKeyDown = TRUE;
346  bKeyUp = TRUE;
347  }
348 
349  /* Extended key ? */
350  ScanCode = wCommand;
351  if (ScanCode & 0x0200)
352  bExtendedKey = TRUE;
353  else
354  bExtendedKey = FALSE;
355  ScanCode &= 0xFF;
356 
357  /* Press and release the key */
358  if (bKeyDown)
359  {
360  Input.type = INPUT_KEYBOARD;
361  Input.ki.wVk = 0;
362  Input.ki.wScan = ScanCode;
363  Input.ki.time = GetTickCount();
364  Input.ki.dwExtraInfo = GetMessageExtraInfo();
365  Input.ki.dwFlags = KEYEVENTF_SCANCODE;
366  if (bExtendedKey) Input.ki.dwFlags |= KEYEVENTF_EXTENDEDKEY;
367  SendInput(1, &Input, sizeof(Input));
368  }
369 
370  if (bKeyUp)
371  {
372  Input.type = INPUT_KEYBOARD;
373  Input.ki.wVk = 0;
374  Input.ki.wScan = ScanCode;
375  Input.ki.time = GetTickCount();
376  Input.ki.dwExtraInfo = GetMessageExtraInfo();
377  Input.ki.dwFlags = KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP;
378  if (bExtendedKey) Input.ki.dwFlags |= KEYEVENTF_EXTENDEDKEY;
379  SendInput(1, &Input, sizeof(Input));
380  }
381 
382  /* Play the sound during clicking event (only if "Use Click Sound" menu option is ticked) */
383  if (Globals.bSoundClick)
384  {
386  }
387 
388  return TRUE;
389 }
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 *)
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
smooth NULL
Definition: ftsmooth.c:416
LPARAM WINAPI GetMessageExtraInfo(void)
Definition: message.c:1339
#define BS_AUTOCHECKBOX
Definition: pedump.c:654
#define BM_GETCHECK
Definition: winuser.h:1879
unsigned short WORD
Definition: ntddk_ex.h:93
#define SND_ASYNC
Definition: mmsystem.h:154
#define SND_RESOURCE
Definition: mmsystem.h:163
#define GWL_STYLE
Definition: winuser.h:846
#define IDI_SOUNDCLICK
Definition: osk_res.h:12
#define GetModuleHandle
Definition: winbase.h:3641
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)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
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
BOOL WINAPI PlaySoundW(LPCWSTR pszSoundW, HMODULE hmod, DWORD fdwSound)
Definition: playsound.c:531

Referenced by OSK_DlgProc().

◆ OSK_DlgInitDialog()

int OSK_DlgInitDialog ( HWND  hDlg)

Definition at line 136 of file main.c.

137 {
139  HMONITOR monitor;
141  POINT Pt;
142  RECT rcWindow, rcDlgIntersect;
143 
144  /* Save handle */
145  Globals.hMainWnd = hDlg;
146 
147  /* Check the checked menu item before displaying the modal box */
148  if (Globals.bIsEnhancedKeyboard)
149  {
150  /* Enhanced keyboard dialog chosen, set the respective menu item as checked */
153  }
154  else
155  {
156  /* Standard keyboard dialog chosen, set the respective menu item as checked */
159  }
160 
161  /* Check if the "Click Sound" option was chosen before (and if so, then tick the menu item) */
162  if (Globals.bSoundClick)
163  {
165  }
166 
167  /* Set the application's icon */
170  if (hIcon || hIconSm)
171  {
172  /* Set the window icons (they are deleted when the process terminates) */
175  }
176 
177  /* Get screen info */
178  memset(&Pt, 0, sizeof(Pt));
179  monitor = MonitorFromPoint(Pt, MONITOR_DEFAULTTOPRIMARY);
180  info.cbSize = sizeof(info);
181  GetMonitorInfoW(monitor, &info);
182  GetWindowRect(hDlg, &rcWindow);
183 
184  /*
185  If the coordination values are default then re-initialize using the specific formulas
186  to move the dialog at the bottom of the screen.
187  */
188  if (Globals.PosX == CW_USEDEFAULT && Globals.PosY == CW_USEDEFAULT)
189  {
190  Globals.PosX = (info.rcMonitor.left + info.rcMonitor.right - (rcWindow.right - rcWindow.left)) / 2;
191  Globals.PosY = info.rcMonitor.bottom - (rcWindow.bottom - rcWindow.top);
192  }
193 
194  /*
195  Calculate the intersection of two rectangle sources (dialog and work desktop area).
196  If such sources do not intersect, then the dialog is deemed as "off screen".
197  */
198  if (IntersectRect(&rcDlgIntersect, &rcWindow, &info.rcWork) == 0)
199  {
200  Globals.PosX = (info.rcMonitor.left + info.rcMonitor.right - (rcWindow.right - rcWindow.left)) / 2;
201  Globals.PosY = info.rcMonitor.bottom - (rcWindow.bottom - rcWindow.top);
202  }
203  else
204  {
205  /*
206  There's still some intersection but we're not for sure if it is sufficient (the dialog could also be partially hidden).
207  Therefore, check the remaining intersection if it's enough.
208  */
209  if (rcWindow.top < info.rcWork.top || rcWindow.left < info.rcWork.left || rcWindow.right > info.rcWork.right || rcWindow.bottom > info.rcWork.bottom)
210  {
211  Globals.PosX = (info.rcMonitor.left + info.rcMonitor.right - (rcWindow.right - rcWindow.left)) / 2;
212  Globals.PosY = info.rcMonitor.bottom - (rcWindow.bottom - rcWindow.top);
213  }
214  }
215 
216  /* Move the dialog according to the placement coordination */
217  SetWindowPos(hDlg, HWND_TOP, Globals.PosX, Globals.PosY, 0, 0, SWP_NOSIZE);
218 
219  /* Set icon on visual buttons */
236 
237  /* Create a green brush for leds */
238  Globals.hBrushGreenLed = CreateSolidBrush(RGB(0, 255, 0));
239 
240  /* Set a timer for periodics tasks */
241  Globals.iTimer = SetTimer(hDlg, 0, 200, NULL);
242 
243  return TRUE;
244 }
#define SCAN_CODE_30
Definition: osk_res.h:91
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:168
#define IDI_PG_UP
Definition: osk_res.h:28
#define IDI_OSK
Definition: osk_res.h:19
LONG top
Definition: windef.h:292
#define IDI_RIGHT
Definition: osk_res.h:32
#define HWND_TOP
Definition: winuser.h:1193
#define SM_CYSMICON
Definition: winuser.h:1003
#define SCAN_CODE_79
Definition: osk_res.h:125
#define IDI_TOP
Definition: osk_res.h:31
#define IDI_TAB
Definition: osk_res.h:21
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
#define IDI_SHIFT
Definition: osk_res.h:24
#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:126
#define SCAN_CODE_16
Definition: osk_res.h:77
#define IDI_LEFT
Definition: osk_res.h:30
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:2172
int OSK_SetImage(int IdDlgItem, int IdResource)
Definition: main.c:38
#define IDI_BACK
Definition: osk_res.h:20
#define SCAN_CODE_57
Definition: osk_res.h:117
HANDLE WINAPI CopyImage(_In_ HANDLE, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:1956
#define IDI_MENU
Definition: osk_res.h:26
#define CW_USEDEFAULT
Definition: winuser.h:225
#define IDI_HOME
Definition: osk_res.h:27
#define SCAN_CODE_86
Definition: osk_res.h:131
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define IDI_CAPS_LOCK
Definition: osk_res.h:22
#define IDM_STANDARD_KB
Definition: osk_res.h:37
#define MF_CHECKED
Definition: winuser.h:132
#define IDM_ENHANCED_KB
Definition: osk_res.h:38
#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:25
#define SCAN_CODE_89
Definition: osk_res.h:132
#define MF_UNCHECKED
Definition: winuser.h:204
#define SCAN_CODE_15
Definition: osk_res.h:76
BOOL WINAPI IntersectRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)
#define IDI_RETURN
Definition: osk_res.h:23
#define SWP_NOSIZE
Definition: winuser.h:1230
#define LR_COPYFROMRESOURCE
Definition: winuser.h:1089
#define SCAN_CODE_127
Definition: osk_res.h:167
HICON hIcon
Definition: msconfig.c:44
#define SCAN_CODE_84
Definition: osk_res.h:129
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define IDI_BOTTOM
Definition: osk_res.h:33
#define SCAN_CODE_43
Definition: osk_res.h:104
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
HICON hIconSm
Definition: msconfig.c:44
LONG bottom
Definition: windef.h:294
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define SCAN_CODE_85
Definition: osk_res.h:130
#define SCAN_CODE_44
Definition: osk_res.h:105
#define SCAN_CODE_83
Definition: osk_res.h:128
#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:29
#define IDM_CLICK_SOUND
Definition: osk_res.h:45
#define ICON_BIG
Definition: tnclass.cpp:51
#define SCAN_CODE_129
Definition: osk_res.h:169

Referenced by OSK_DlgProc().

◆ OSK_DlgProc()

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

Definition at line 514 of file main.c.

515 {
516  switch (msg)
517  {
518  case WM_INITDIALOG:
519  OSK_DlgInitDialog(hDlg);
520  return TRUE;
521 
522  case WM_TIMER:
523  OSK_DlgTimer();
524  return TRUE;
525 
526  case WM_NOTIFY:
527  return OSK_ThemeHandler(hDlg, (LPNMCUSTOMDRAW)lParam);
528 
529  case WM_CTLCOLORSTATIC:
530  if ((HWND)lParam == GetDlgItem(hDlg, IDC_LED_NUM))
531  {
532  if (GetKeyState(VK_NUMLOCK) & 0x0001)
533  return (INT_PTR)Globals.hBrushGreenLed;
534  else
536  }
537  if ((HWND)lParam == GetDlgItem(hDlg, IDC_LED_CAPS))
538  {
539  if (GetKeyState(VK_CAPITAL) & 0x0001)
540  return (INT_PTR)Globals.hBrushGreenLed;
541  else
543  }
544  if ((HWND)lParam == GetDlgItem(hDlg, IDC_LED_SCROLL))
545  {
546  if (GetKeyState(VK_SCROLL) & 0x0001)
547  return (INT_PTR)Globals.hBrushGreenLed;
548  else
550  }
551  break;
552 
553  case WM_COMMAND:
554  switch (LOWORD(wParam))
555  {
556  case IDCANCEL:
557  {
558  EndDialog(hDlg, FALSE);
559  break;
560  }
561 
562  case IDM_EXIT:
563  {
564  EndDialog(hDlg, FALSE);
565  break;
566  }
567 
568  case IDM_ENHANCED_KB:
569  {
570  if (!Globals.bIsEnhancedKeyboard)
571  {
572  /*
573  The user attempted to switch to enhanced keyboard dialog type.
574  Set the member value as TRUE, destroy the dialog and save the data configuration into the registry.
575  */
576  Globals.bIsEnhancedKeyboard = TRUE;
577  EndDialog(hDlg, FALSE);
579 
580  /* Change the condition of enhanced keyboard item menu to checked */
583 
584  /* Finally, display the dialog modal box with the enhanced keyboard dialog */
588  OSK_DlgProc);
589  }
590 
591  break;
592  }
593 
594  case IDM_STANDARD_KB:
595  {
596  if (Globals.bIsEnhancedKeyboard)
597  {
598  /*
599  The user attempted to switch to standard keyboard dialog type.
600  Set the member value as FALSE, destroy the dialog and save the data configuration into the registry.
601  */
602  Globals.bIsEnhancedKeyboard = FALSE;
603  EndDialog(hDlg, FALSE);
605 
606  /* Change the condition of standard keyboard item menu to checked */
609 
610  /* Finally, display the dialog modal box with the standard keyboard dialog */
614  OSK_DlgProc);
615  }
616 
617  break;
618  }
619 
620  case IDM_CLICK_SOUND:
621  {
622  /*
623  This case is triggered when the user attempts to click on the menu item. Before doing anything,
624  we must check the condition state of such menu item so that we can tick/untick the menu item accordingly.
625  */
626  if (!Globals.bSoundClick)
627  {
628  Globals.bSoundClick = TRUE;
630  }
631  else
632  {
633  Globals.bSoundClick = FALSE;
635  }
636 
637  break;
638  }
639 
640  case IDM_ABOUT:
641  {
642  OSK_About();
643  break;
644  }
645 
646  default:
648  break;
649  }
650  break;
651 
652  case WM_THEMECHANGED:
653  /* Redraw the dialog (and its control buttons) using the new theme */
654  InvalidateRect(hDlg, NULL, FALSE);
655  break;
656 
657  case WM_CLOSE:
658  OSK_DlgClose();
659  break;
660  }
661 
662  return 0;
663 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
INT_PTR APIENTRY OSK_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: main.c:514
int OSK_DlgClose(void)
Definition: main.c:252
#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:136
#define IDC_LED_CAPS
Definition: osk_res.h:15
LRESULT APIENTRY OSK_ThemeHandler(HWND hDlg, NMCUSTOMDRAW *pNmDraw)
Definition: main.c:438
smooth NULL
Definition: ftsmooth.c:416
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:37
#define MF_CHECKED
Definition: winuser.h:132
BOOL OSK_DlgCommand(WPARAM wCommand, HWND hWndControl)
Definition: main.c:304
#define IDM_ENHANCED_KB
Definition: osk_res.h:38
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:279
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
DWORD WINAPI CheckMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define IDC_LED_SCROLL
Definition: osk_res.h:16
BOOL SaveDataToRegistry()
Definition: settings.c:138
#define WM_COMMAND
Definition: winuser.h:1716
#define MF_UNCHECKED
Definition: winuser.h:204
VOID OSK_About(VOID)
Definition: main.c:109
#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 msg(x)
Definition: auth_time.c:54
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define IDC_LED_NUM
Definition: osk_res.h:14
#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
#define WM_NOTIFY
Definition: richedit.h:61
#define IDM_CLICK_SOUND
Definition: osk_res.h:45

Referenced by wWinMain().

◆ OSK_DlgTimer()

int OSK_DlgTimer ( void  )

Definition at line 279 of file main.c.

280 {
281  /* FIXME: To be deleted when ReactOS will support WS_EX_NOACTIVATE */
282  HWND hWndActiveWindow;
283 
284  hWndActiveWindow = GetForegroundWindow();
285  if (hWndActiveWindow != NULL && hWndActiveWindow != Globals.hMainWnd)
286  {
287  Globals.hActiveWnd = hWndActiveWindow;
288  }
289 
290  /* Always redraw leds because it can be changed by the real keyboard) */
294 
295  return TRUE;
296 }
#define TRUE
Definition: types.h:120
NOTEPAD_GLOBALS Globals
Definition: main.c:29
#define IDC_LED_CAPS
Definition: osk_res.h:15
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:16
HWND WINAPI GetForegroundWindow(void)
Definition: ntwrapper.h:392
#define IDC_LED_NUM
Definition: osk_res.h:14
HWND hMainWnd
Definition: main.h:56

Referenced by OSK_DlgProc().

◆ OSK_ReleaseKey()

BOOL OSK_ReleaseKey ( WORD  ScanCode)

Definition at line 397 of file main.c.

398 {
399  INPUT Input;
400  BOOL bExtendedKey;
401  LONG WindowStyle;
402  HWND hWndControl;
403 
404  /* Is it a 2-states key ? */
405  hWndControl = GetDlgItem(Globals.hMainWnd, ScanCode);
406  WindowStyle = GetWindowLongW(hWndControl, GWL_STYLE);
407  if ((WindowStyle & BS_AUTOCHECKBOX) != BS_AUTOCHECKBOX) return FALSE;
408 
409  /* Is the key down ? */
410  if (SendMessageW(hWndControl, BM_GETCHECK, 0, 0) != BST_CHECKED) return TRUE;
411 
412  /* Extended key ? */
413  if (ScanCode & 0x0200)
414  bExtendedKey = TRUE;
415  else
416  bExtendedKey = FALSE;
417  ScanCode &= 0xFF;
418 
419  /* Release the key */
420  Input.type = INPUT_KEYBOARD;
421  Input.ki.wVk = 0;
422  Input.ki.wScan = ScanCode;
423  Input.ki.time = GetTickCount();
424  Input.ki.dwExtraInfo = GetMessageExtraInfo();
425  Input.ki.dwFlags = KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP;
426  if (bExtendedKey) Input.ki.dwFlags |= KEYEVENTF_EXTENDEDKEY;
427  SendInput(1, &Input, sizeof(Input));
428 
429  return TRUE;
430 }
#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
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
LPARAM WINAPI GetMessageExtraInfo(void)
Definition: message.c:1339
#define BS_AUTOCHECKBOX
Definition: pedump.c:654
#define BM_GETCHECK
Definition: winuser.h:1879
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 38 of file main.c.

39 {
40  HICON hIcon;
41  HWND hWndItem;
42 
44  IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
45  if (hIcon == NULL)
46  return FALSE;
47 
48  hWndItem = GetDlgItem(Globals.hMainWnd, IdDlgItem);
49  if (hWndItem == NULL)
50  {
52  return FALSE;
53  }
54 
56 
57  /* The system automatically deletes these resources when the process that created them terminates (MSDN) */
58 
59  return TRUE;
60 }
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
UINT_PTR WPARAM
Definition: windef.h:207
#define BM_SETIMAGE
Definition: winuser.h:1883
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
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
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_ThemeHandler()

LRESULT APIENTRY OSK_ThemeHandler ( HWND  hDlg,
NMCUSTOMDRAW pNmDraw 
)

Definition at line 438 of file main.c.

439 {
440  HTHEME hTheme;
441  HWND hDlgButtonCtrl;
442  LRESULT Ret;
443  INT iState = PBS_NORMAL;
444 
445  /* Retrieve the theme handle for the button controls */
446  hDlgButtonCtrl = pNmDraw->hdr.hwndFrom;
447  hTheme = GetWindowTheme(hDlgButtonCtrl);
448 
449  /*
450  Begin the painting procedures if we retrieved
451  the theme for control buttons of the dialog.
452  */
453  if (hTheme)
454  {
455  /* Obtain CDDS drawing stages */
456  switch (pNmDraw->dwDrawStage)
457  {
458  case CDDS_PREPAINT:
459  {
460  /*
461  The button could be either in normal state or pushed.
462  Retrieve its state and save to a variable.
463  */
464  if (pNmDraw->uItemState & CDIS_DEFAULT)
465  {
466  iState = PBS_DEFAULTED;
467  }
468  else if (pNmDraw->uItemState & CDIS_SELECTED)
469  {
470  iState = PBS_PRESSED;
471  }
472  else if (pNmDraw->uItemState & CDIS_HOT)
473  {
474  iState = PBS_HOT;
475  }
476 
478  {
479  /* Draw the application if the theme is transparent */
480  DrawThemeParentBackground(hDlgButtonCtrl, pNmDraw->hdc, &pNmDraw->rc);
481  }
482 
483  /* Draw it */
484  DrawThemeBackground(hTheme, pNmDraw->hdc, BP_PUSHBUTTON, iState, &pNmDraw->rc, NULL);
485 
486  Ret = CDRF_SKIPDEFAULT;
487  break;
488  }
489 
490  case CDDS_PREERASE:
491  {
492  Ret = CDRF_DODEFAULT;
493  break;
494  }
495 
496  default:
497  Ret = CDRF_SKIPDEFAULT;
498  break;
499  }
500  }
501  else
502  {
503  /* hTheme is NULL so bail right away */
504  Ret = CDRF_DODEFAULT;
505  }
506 
507  return Ret;
508 }
static HTHEME(WINAPI *pOpenThemeDataEx)(HWND
#define CDRF_SKIPDEFAULT
Definition: commctrl.h:255
HRESULT WINAPI DrawThemeBackground(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, const RECT *pClipRect)
Definition: draw.c:128
int32_t INT
Definition: typedefs.h:56
BOOL WINAPI IsThemeBackgroundPartiallyTransparent(HTHEME hTheme, int iPartId, int iStateId)
Definition: draw.c:1883
smooth NULL
Definition: ftsmooth.c:416
#define CDIS_SELECTED
Definition: commctrl.h:276
HRESULT WINAPI DrawThemeParentBackground(HWND hwnd, HDC hdc, RECT *prc)
Definition: draw.c:72
#define CDIS_HOT
Definition: commctrl.h:282
#define CDRF_DODEFAULT
Definition: commctrl.h:253
HTHEME WINAPI GetWindowTheme(HWND hwnd)
Definition: system.c:851
#define CDDS_PREPAINT
Definition: commctrl.h:265
HWND hwndFrom
Definition: winuser.h:3110
LONG_PTR LRESULT
Definition: windef.h:209
#define CDIS_DEFAULT
Definition: commctrl.h:281
#define CDDS_PREERASE
Definition: commctrl.h:267

Referenced by OSK_DlgProc().

◆ OSK_WarningProc()

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

Definition at line 68 of file main.c.

69 {
71 
72  switch (Msg)
73  {
74  case WM_INITDIALOG:
75  {
76  return TRUE;
77  }
78 
79  case WM_COMMAND:
80  {
81  switch (LOWORD(wParam))
82  {
84  {
85  Globals.bShowWarning = !IsDlgButtonChecked(hDlg, IDC_SHOWWARNINGCHECK);
86  return TRUE;
87  }
88 
89  case IDOK:
90  case IDCANCEL:
91  {
92  EndDialog(hDlg, LOWORD(wParam));
93  return TRUE;
94  }
95  }
96  break;
97  }
98  }
99 
100  return FALSE;
101 }
#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
struct @1567 Msg[]
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
#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 669 of file main.c.

673 {
674  HANDLE hMutex;
675  DWORD dwError;
676  INT LayoutResource;
677  INITCOMMONCONTROLSEX iccex;
678 
682 
683  /*
684  Obtain a mutex for the program. This will ensure that
685  the program is launched only once.
686  */
687  hMutex = CreateMutexW(NULL, FALSE, L"OSKRunning");
688 
689  if (hMutex)
690  {
691  /* Check if there's already a mutex for the program */
692  dwError = GetLastError();
693 
694  if (dwError == ERROR_ALREADY_EXISTS)
695  {
696  /*
697  A mutex with the object name has been created previously.
698  Therefore, another instance is already running.
699  */
700  DPRINT("wWinMain(): Failed to create a mutex! The program instance is already running.\n");
702  return 0;
703  }
704  }
705 
706  /* Load the common controls */
707  iccex.dwSize = sizeof(INITCOMMONCONTROLSEX);
709  InitCommonControlsEx(&iccex);
710 
711  ZeroMemory(&Globals, sizeof(Globals));
713 
714  /* Load the settings from the registry hive */
716 
717  /* If the member of the struct (bShowWarning) is set then display the dialog box */
718  if (Globals.bShowWarning)
719  {
721  }
722 
723  /* Before initializing the dialog execution, check if the chosen keyboard type is standard or enhanced */
724  if (Globals.bIsEnhancedKeyboard)
725  {
726  LayoutResource = MAIN_DIALOG_ENHANCED_KB;
727  }
728  else
729  {
730  LayoutResource = MAIN_DIALOG_STANDARD_KB;
731  }
732 
733  /* Create the modal box based on the configuration registry */
735  MAKEINTRESOURCEW(LayoutResource),
737  OSK_DlgProc);
738 
739  /* Delete the mutex */
740  if (hMutex)
741  {
743  }
744 
745  return 0;
746 }
INT_PTR APIENTRY OSK_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: main.c:514
#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
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define ZeroMemory
Definition: winbase.h:1635
TCHAR * cmdline
Definition: stretchblt.cpp:32
struct tagINITCOMMONCONTROLSEX INITCOMMONCONTROLSEX
int32_t INT
Definition: typedefs.h:56
HINSTANCE hInstance
Definition: main.h:55
#define ICC_WIN95_CLASSES
Definition: commctrl.h:66
smooth NULL
Definition: ftsmooth.c:416
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:622
void DPRINT(...)
Definition: polytest.cpp:61
HANDLE hMutex
Definition: mutex.c:11
BOOL LoadDataFromRegistry()
Definition: settings.c:15
#define DialogBoxW(i, t, p, f)
Definition: winuser.h:4268
unsigned long DWORD
Definition: ntddk_ex.h:95
HINSTANCE hInstance
Definition: main.c:36
static const WCHAR L[]
Definition: oid.c:1250
BOOL WINAPI InitCommonControlsEx(const INITCOMMONCONTROLSEX *lpInitCtrls)
Definition: commctrl.c:893
INT_PTR CALLBACK OSK_WarningProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: main.c:68
#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:51
#define ICC_STANDARD_CLASSES
Definition: commctrl.h:73
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
HWND hMainWnd
Definition: main.h:56

Variable Documentation

◆ Globals

OSK_GLOBALS Globals

Definition at line 16 of file main.c.