ReactOS  0.4.15-dev-3302-ga37d9a4
main.c File Reference
#include "precomp.h"
Include dependency graph for main.c:

Go to the source code of this file.

Functions

int OSK_SetImage (int IdDlgItem, int IdResource)
 
INT_PTR CALLBACK OSK_WarningProc (HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
 
DWORD WINAPI OSK_WarningDlgThread (LPVOID lpParameter)
 
VOID OSK_About (VOID)
 
int OSK_DlgInitDialog (HWND hDlg)
 
VOID OSK_RestoreDlgPlacement (HWND hDlg)
 
int OSK_DlgClose (void)
 
VOID OSK_RefreshLEDKeys (VOID)
 
int OSK_DlgTimer (void)
 
BOOL OSK_DlgCommand (WPARAM wCommand, HWND hWndControl)
 
BOOL OSK_ReleaseKey (WORD ScanCode)
 
LRESULT APIENTRY OSK_ThemeHandler (HWND hDlg, NMCUSTOMDRAW *pNmDraw)
 
INT_PTR APIENTRY OSK_DlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
 
int WINAPI wWinMain (HINSTANCE hInstance, HINSTANCE prev, LPWSTR cmdline, int show)
 

Variables

OSK_GLOBALS Globals
 
OSK_KEYLEDINDICATOR LedKey []
 

Function Documentation

◆ OSK_About()

VOID OSK_About ( VOID  )

Definition at line 117 of file main.c.

118 {
120  WCHAR szAuthors[MAX_BUFF];
121  HICON OSKIcon;
122 
123  /* Load the icon */
125 
126  /* Load the strings into the "About" dialog */
128  LoadStringW(Globals.hInstance, STRING_AUTHORS, szAuthors, countof(szAuthors));
129 
130  /* Finally, execute the "About" dialog by using the Shell routine */
131  ShellAboutW(Globals.hMainWnd, szTitle, szAuthors, OSKIcon);
132 
133  /* Once done, destroy the icon */
134  DestroyIcon(OSKIcon);
135 }
static HICON
Definition: imagelist.c:84
NOTEPAD_GLOBALS Globals
Definition: main.c:31
#define IMAGE_ICON
Definition: winuser.h:212
#define STRING_OSK
Definition: osk_res.h:52
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
#define IDI_OSK
Definition: osk_res.h:18
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 STRING_AUTHORS
Definition: osk_res.h:53
#define LR_DEFAULTSIZE
Definition: winuser.h:1084
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define countof(x)
Definition: precomp.h:88
BOOL WINAPI ShellAboutW(HWND hWnd, LPCWSTR szApp, LPCWSTR szOtherStuff, HICON hIcon)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
HWND hMainWnd
Definition: main.h:56
#define MAX_BUFF
Definition: precomp.h:89

Referenced by OSK_DlgProc().

◆ OSK_DlgClose()

int OSK_DlgClose ( void  )

Definition at line 284 of file main.c.

285 {
287 
288  /* Release Ctrl, Shift, Alt keys */
289  OSK_ReleaseKey(SCAN_CODE_44); // Left shift
290  OSK_ReleaseKey(SCAN_CODE_57); // Right shift
291  OSK_ReleaseKey(SCAN_CODE_58); // Left ctrl
292  OSK_ReleaseKey(SCAN_CODE_60); // Left alt
293  OSK_ReleaseKey(SCAN_CODE_62); // Right alt
294  OSK_ReleaseKey(SCAN_CODE_64); // Right ctrl
295 
296  /* delete GDI objects */
297  if (Globals.hBrushGreenLed) DeleteObject(Globals.hBrushGreenLed);
298 
299  /* Save the application's settings on registry */
300  SaveSettings();
301 
302  return TRUE;
303 }
#define SCAN_CODE_60
Definition: osk_res.h:118
NOTEPAD_GLOBALS Globals
Definition: main.c:31
#define TRUE
Definition: types.h:120
#define SCAN_CODE_64
Definition: osk_res.h:121
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define SCAN_CODE_62
Definition: osk_res.h:120
void SaveSettings(void)
Definition: settings.c:115
#define SCAN_CODE_57
Definition: osk_res.h:116
#define SCAN_CODE_58
Definition: osk_res.h:117
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
BOOL OSK_ReleaseKey(WORD ScanCode)
Definition: main.c:469
#define SCAN_CODE_44
Definition: osk_res.h:104
HWND hMainWnd
Definition: main.h:56

Referenced by OSK_DlgProc().

◆ OSK_DlgCommand()

BOOL OSK_DlgCommand ( WPARAM  wCommand,
HWND  hWndControl 
)

Definition at line 360 of file main.c.

361 {
362  WORD ScanCode;
363  INPUT Input;
364  BOOL bExtendedKey;
365  BOOL bKeyDown;
366  BOOL bKeyUp;
367  LONG WindowStyle;
368  INT i;
369 
370  /* FIXME: To be deleted when ReactOS will support WS_EX_NOACTIVATE */
371  if (Globals.hActiveWnd)
372  {
373  MSG msg;
374 
375  SetForegroundWindow(Globals.hActiveWnd);
376  while (PeekMessageW(&msg, 0, 0, 0, PM_REMOVE))
377  {
380  }
381  }
382 
383  /* KeyDown and/or KeyUp ? */
384  WindowStyle = GetWindowLongW(hWndControl, GWL_STYLE);
385  if ((WindowStyle & BS_AUTOCHECKBOX) == BS_AUTOCHECKBOX)
386  {
387  /* 2-states key like Shift, Alt, Ctrl, ... */
388  if (SendMessageW(hWndControl, BM_GETCHECK, 0, 0) == BST_CHECKED)
389  {
390  bKeyDown = TRUE;
391  bKeyUp = FALSE;
392  }
393  else
394  {
395  bKeyDown = FALSE;
396  bKeyUp = TRUE;
397  }
398  }
399  else
400  {
401  /* Other key */
402  bKeyDown = TRUE;
403  bKeyUp = TRUE;
404  }
405 
406  /* Get the key from dialog control key command */
407  ScanCode = wCommand;
408 
409  /*
410  The user could've pushed one of the key buttons of the dialog that
411  can trigger particular function toggling (Caps Lock, Num Lock or Scroll Lock). Update
412  (invalidate) the LED icon resources accordingly.
413  */
414  for (i = 0; i < _countof(LedKey); i++)
415  {
416  if (LedKey[i].wScanCode == ScanCode)
417  {
419  }
420  }
421 
422  /* Extended key ? */
423  if (ScanCode & 0x0200)
424  bExtendedKey = TRUE;
425  else
426  bExtendedKey = FALSE;
427  ScanCode &= 0xFF;
428 
429  /* Press and release the key */
430  if (bKeyDown)
431  {
432  Input.type = INPUT_KEYBOARD;
433  Input.ki.wVk = 0;
434  Input.ki.wScan = ScanCode;
435  Input.ki.time = GetTickCount();
436  Input.ki.dwExtraInfo = GetMessageExtraInfo();
437  Input.ki.dwFlags = KEYEVENTF_SCANCODE;
438  if (bExtendedKey) Input.ki.dwFlags |= KEYEVENTF_EXTENDEDKEY;
439  SendInput(1, &Input, sizeof(Input));
440  }
441 
442  if (bKeyUp)
443  {
444  Input.type = INPUT_KEYBOARD;
445  Input.ki.wVk = 0;
446  Input.ki.wScan = ScanCode;
447  Input.ki.time = GetTickCount();
448  Input.ki.dwExtraInfo = GetMessageExtraInfo();
449  Input.ki.dwFlags = KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP;
450  if (bExtendedKey) Input.ki.dwFlags |= KEYEVENTF_EXTENDEDKEY;
451  SendInput(1, &Input, sizeof(Input));
452  }
453 
454  /* Play the sound during clicking event (only if "Use Click Sound" menu option is ticked) */
455  if (Globals.bSoundClick)
456  {
458  }
459 
460  return TRUE;
461 }
BOOL WINAPI TranslateMessage(_In_ const MSG *)
NOTEPAD_GLOBALS Globals
Definition: main.c:31
ULONG ScanCode
Definition: api.c:39
#define KEYEVENTF_KEYUP
Definition: winuser.h:1092
#define TRUE
Definition: types.h:120
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
Definition: arc.h:84
int32_t INT
Definition: typedefs.h:58
#define INPUT_KEYBOARD
Definition: winable.h:10
#define FALSE
Definition: types.h:117
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)
LPARAM WINAPI GetMessageExtraInfo(void)
Definition: message.c:1340
#define BS_AUTOCHECKBOX
Definition: pedump.c:654
#define BM_GETCHECK
Definition: winuser.h:1901
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define _countof(array)
Definition: sndvol32.h:68
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
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:11
#define GetModuleHandle
Definition: winbase.h:3683
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
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define NULL
Definition: types.h:112
OSK_KEYLEDINDICATOR LedKey[]
Definition: main.c:17
#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
HWND hMainWnd
Definition: main.h:56
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 144 of file main.c.

145 {
147  HMONITOR monitor;
149  POINT Pt;
150  RECT rcWindow, rcDlgIntersect;
151 
152  /* Save handle */
153  Globals.hMainWnd = hDlg;
154 
155  /* Check the checked menu item before displaying the modal box */
156  if (Globals.bIsEnhancedKeyboard)
157  {
158  /* Enhanced keyboard dialog chosen, set the respective menu item as checked */
161  }
162  else
163  {
164  /* Standard keyboard dialog chosen, set the respective menu item as checked */
167  }
168 
169  /* Check if the "Click Sound" option was chosen before (and if so, then tick the menu item) */
170  if (Globals.bSoundClick)
171  {
173  }
174 
175  /* Set the application's icon */
178  if (hIcon || hIconSm)
179  {
180  /* Set the window icons (they are deleted when the process terminates) */
183  }
184 
185  /* Get screen info */
186  memset(&Pt, 0, sizeof(Pt));
187  monitor = MonitorFromPoint(Pt, MONITOR_DEFAULTTOPRIMARY);
188  info.cbSize = sizeof(info);
189  GetMonitorInfoW(monitor, &info);
190  GetWindowRect(hDlg, &rcWindow);
191 
192  /*
193  If the coordination values are default then re-initialize using the specific formulas
194  to move the dialog at the bottom of the screen.
195  */
196  if (Globals.PosX == CW_USEDEFAULT && Globals.PosY == CW_USEDEFAULT)
197  {
198  Globals.PosX = (info.rcMonitor.left + info.rcMonitor.right - (rcWindow.right - rcWindow.left)) / 2;
199  Globals.PosY = info.rcMonitor.bottom - (rcWindow.bottom - rcWindow.top);
200  }
201 
202  /*
203  Calculate the intersection of two rectangle sources (dialog and work desktop area).
204  If such sources do not intersect, then the dialog is deemed as "off screen".
205  */
206  if (IntersectRect(&rcDlgIntersect, &rcWindow, &info.rcWork) == 0)
207  {
208  Globals.PosX = (info.rcMonitor.left + info.rcMonitor.right - (rcWindow.right - rcWindow.left)) / 2;
209  Globals.PosY = info.rcMonitor.bottom - (rcWindow.bottom - rcWindow.top);
210  }
211  else
212  {
213  /*
214  There's still some intersection but we're not for sure if it is sufficient (the dialog could also be partially hidden).
215  Therefore, check the remaining intersection if it's enough.
216  */
217  if (rcWindow.top < info.rcWork.top || rcWindow.left < info.rcWork.left || rcWindow.right > info.rcWork.right || rcWindow.bottom > info.rcWork.bottom)
218  {
219  Globals.PosX = (info.rcMonitor.left + info.rcMonitor.right - (rcWindow.right - rcWindow.left)) / 2;
220  Globals.PosY = info.rcMonitor.bottom - (rcWindow.bottom - rcWindow.top);
221  }
222  }
223 
224  /*
225  Place the window (with respective placement coordinates) as topmost, above
226  every window which are not on top or are at the bottom of the Z order.
227  */
228  if (Globals.bAlwaysOnTop)
229  {
231  SetWindowPos(hDlg, HWND_TOPMOST, Globals.PosX, Globals.PosY, 0, 0, SWP_NOSIZE);
232  }
233  else
234  {
236  SetWindowPos(hDlg, HWND_NOTOPMOST, Globals.PosX, Globals.PosY, 0, 0, SWP_NOSIZE);
237  }
238 
239  /* Set icon on visual buttons */
256 
257  /* Create a green brush for leds */
258  Globals.hBrushGreenLed = CreateSolidBrush(RGB(0, 255, 0));
259 
260  /* Set a timer for periodics tasks */
261  Globals.iTimer = SetTimer(hDlg, 0, 50, NULL);
262 
263  return TRUE;
264 }
#define SCAN_CODE_30
Definition: osk_res.h:90
HMONITOR WINAPI MonitorFromPoint(POINT, DWORD)
static HICON
Definition: imagelist.c:84
NOTEPAD_GLOBALS Globals
Definition: main.c:31
#define LR_SHARED
Definition: winuser.h:1090
#define IMAGE_ICON
Definition: winuser.h:212
#define MF_BYCOMMAND
Definition: winuser.h:202
#define RGB(r, g, b)
Definition: precomp.h:62
#define SCAN_CODE_128
Definition: osk_res.h:167
#define IDI_PG_UP
Definition: osk_res.h:27
#define TRUE
Definition: types.h:120
#define IDI_OSK
Definition: osk_res.h:18
LONG top
Definition: windef.h:307
#define IDI_RIGHT
Definition: osk_res.h:31
#define HWND_TOPMOST
Definition: winuser.h:1194
#define SM_CYSMICON
Definition: winuser.h:1003
#define SCAN_CODE_79
Definition: osk_res.h:124
#define IDI_TOP
Definition: osk_res.h:30
#define IDI_TAB
Definition: osk_res.h:20
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
#define IDI_SHIFT
Definition: osk_res.h:23
#define ICON_SMALL
Definition: tnclass.cpp:48
HINSTANCE hInstance
Definition: main.h:55
#define SCAN_CODE_80
Definition: osk_res.h:125
#define SCAN_CODE_16
Definition: osk_res.h:76
#define IDI_LEFT
Definition: osk_res.h:29
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:32
#define IDI_BACK
Definition: osk_res.h:19
#define SCAN_CODE_57
Definition: osk_res.h:116
HANDLE WINAPI CopyImage(_In_ HANDLE, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:1956
#define IDI_MENU
Definition: osk_res.h:25
#define CW_USEDEFAULT
Definition: winuser.h:225
#define IDI_HOME
Definition: osk_res.h:26
#define SCAN_CODE_86
Definition: osk_res.h:130
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define IDM_ON_TOP
Definition: osk_res.h:43
#define IDI_CAPS_LOCK
Definition: osk_res.h:21
#define IDM_STANDARD_KB
Definition: osk_res.h:36
#define MF_CHECKED
Definition: winuser.h:132
#define IDM_ENHANCED_KB
Definition: osk_res.h:37
#define LR_DEFAULTSIZE
Definition: winuser.h:1084
BOOL WINAPI GetMonitorInfoW(_In_ HMONITOR, _Inout_ LPMONITORINFO)
int WINAPI GetSystemMetrics(_In_ int)
DWORD WINAPI CheckMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define SM_CXSMICON
Definition: winuser.h:1002
struct _test_info info[]
Definition: SetCursorPos.c:19
#define IDI_REACTOS
Definition: osk_res.h:24
#define SCAN_CODE_89
Definition: osk_res.h:131
#define MF_UNCHECKED
Definition: winuser.h:204
#define SCAN_CODE_15
Definition: osk_res.h:75
BOOL WINAPI IntersectRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)
#define IDI_RETURN
Definition: osk_res.h:22
#define SWP_NOSIZE
Definition: winuser.h:1231
#define LR_COPYFROMRESOURCE
Definition: winuser.h:1089
#define SCAN_CODE_127
Definition: osk_res.h:166
HICON hIcon
Definition: msconfig.c:44
#define SCAN_CODE_84
Definition: osk_res.h:128
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define IDI_BOTTOM
Definition: osk_res.h:32
#define SCAN_CODE_43
Definition: osk_res.h:103
#define NULL
Definition: types.h:112
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
HICON hIconSm
Definition: msconfig.c:44
LONG bottom
Definition: windef.h:309
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 HWND_NOTOPMOST
Definition: winuser.h:1192
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define SCAN_CODE_85
Definition: osk_res.h:129
#define SCAN_CODE_44
Definition: osk_res.h:104
#define SCAN_CODE_83
Definition: osk_res.h:127
#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:28
#define IDM_CLICK_SOUND
Definition: osk_res.h:44
#define ICON_BIG
Definition: tnclass.cpp:51
#define SCAN_CODE_129
Definition: osk_res.h:168

Referenced by OSK_DlgProc().

◆ OSK_DlgProc()

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

Definition at line 586 of file main.c.

587 {
588  switch (msg)
589  {
590  case WM_INITDIALOG:
591  OSK_DlgInitDialog(hDlg);
592  return TRUE;
593 
594  case WM_TIMER:
595  OSK_DlgTimer();
596  return TRUE;
597 
598  case WM_NOTIFY:
599  return OSK_ThemeHandler(hDlg, (LPNMCUSTOMDRAW)lParam);
600 
601  case WM_CTLCOLORSTATIC:
602  if ((HWND)lParam == GetDlgItem(hDlg, IDC_LED_NUM))
603  {
604  if (GetKeyState(VK_NUMLOCK) & 0x0001)
605  return (INT_PTR)Globals.hBrushGreenLed;
606  else
608  }
609  if ((HWND)lParam == GetDlgItem(hDlg, IDC_LED_CAPS))
610  {
611  if (GetKeyState(VK_CAPITAL) & 0x0001)
612  return (INT_PTR)Globals.hBrushGreenLed;
613  else
615  }
616  if ((HWND)lParam == GetDlgItem(hDlg, IDC_LED_SCROLL))
617  {
618  if (GetKeyState(VK_SCROLL) & 0x0001)
619  return (INT_PTR)Globals.hBrushGreenLed;
620  else
622  }
623  break;
624 
625  case WM_COMMAND:
626  switch (LOWORD(wParam))
627  {
628  case IDCANCEL:
629  {
630  EndDialog(hDlg, FALSE);
631  break;
632  }
633 
634  case IDM_EXIT:
635  {
636  EndDialog(hDlg, FALSE);
637  break;
638  }
639 
640  case IDM_ENHANCED_KB:
641  {
642  if (!Globals.bIsEnhancedKeyboard)
643  {
644  /*
645  The user attempted to switch to enhanced keyboard dialog type.
646  Set the member value as TRUE, destroy the dialog and save the data configuration into the registry.
647  */
648  Globals.bIsEnhancedKeyboard = TRUE;
649  EndDialog(hDlg, FALSE);
650  SaveSettings();
651 
652  /* Change the condition of enhanced keyboard item menu to checked */
655 
656  /*
657  Before creating the dialog box restore the coordinates. The user can
658  move the dialog around before choosing a different dialog layout therefore
659  we must create the dialog with the new coordinates.
660  */
662 
663  /* Finally, display the dialog modal box with the enhanced keyboard dialog */
667  OSK_DlgProc);
668  }
669 
670  break;
671  }
672 
673  case IDM_STANDARD_KB:
674  {
675  if (Globals.bIsEnhancedKeyboard)
676  {
677  /*
678  The user attempted to switch to standard keyboard dialog type.
679  Set the member value as FALSE, destroy the dialog and save the data configuration into the registry.
680  */
681  Globals.bIsEnhancedKeyboard = FALSE;
682  EndDialog(hDlg, FALSE);
683  SaveSettings();
684 
685  /* Change the condition of standard keyboard item menu to checked */
688 
689  /*
690  Before creating the dialog box restore the coordinates. The user can
691  move the dialog around before choosing a different dialog layout therefore
692  we must create the dialog with the new coordinates.
693  */
695 
696  /* Finally, display the dialog modal box with the standard keyboard dialog */
700  OSK_DlgProc);
701  }
702 
703  break;
704  }
705 
706  case IDM_CLICK_SOUND:
707  {
708  /*
709  This case is triggered when the user attempts to click on the menu item. Before doing anything,
710  we must check the condition state of such menu item so that we can tick/untick the menu item accordingly.
711  */
712  if (!Globals.bSoundClick)
713  {
714  Globals.bSoundClick = TRUE;
716  }
717  else
718  {
719  Globals.bSoundClick = FALSE;
721  }
722 
723  break;
724  }
725 
726  case IDM_ON_TOP:
727  {
728  /*
729  Check the condition state before disabling/enabling the menu
730  item and change the topmost order.
731  */
732  if (!Globals.bAlwaysOnTop)
733  {
734  Globals.bAlwaysOnTop = TRUE;
736  SetWindowPos(hDlg, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
737  }
738  else
739  {
740  Globals.bAlwaysOnTop = FALSE;
742  SetWindowPos(hDlg, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
743  }
744 
745  break;
746  }
747 
748  case IDM_ABOUT:
749  {
750  OSK_About();
751  break;
752  }
753 
754  default:
756  break;
757  }
758  break;
759 
760  case WM_THEMECHANGED:
761  /* Redraw the dialog (and its control buttons) using the new theme */
762  InvalidateRect(hDlg, NULL, FALSE);
763  break;
764 
765  case WM_CLOSE:
766  OSK_DlgClose();
767  break;
768  }
769 
770  return 0;
771 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
INT_PTR APIENTRY OSK_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: main.c:586
int OSK_DlgClose(void)
Definition: main.c:284
NOTEPAD_GLOBALS Globals
Definition: main.c:31
#define MF_BYCOMMAND
Definition: winuser.h:202
#define IDM_ABOUT
Definition: resource.h:29
#define TRUE
Definition: types.h:120
#define WM_CTLCOLORSTATIC
Definition: winuser.h:1755
#define MAIN_DIALOG_STANDARD_KB
Definition: osk_res.h:9
#define HWND_TOPMOST
Definition: winuser.h:1194
int32_t INT_PTR
Definition: typedefs.h:64
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:144
void SaveSettings(void)
Definition: settings.c:115
#define IDC_LED_CAPS
Definition: osk_res.h:14
#define FALSE
Definition: types.h:117
LRESULT APIENTRY OSK_ThemeHandler(HWND hDlg, NMCUSTOMDRAW *pNmDraw)
Definition: main.c:510
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:656
#define IDM_ON_TOP
Definition: osk_res.h:43
#define DialogBoxW(i, t, p, f)
Definition: winuser.h:4375
SHORT WINAPI GetKeyState(_In_ int)
#define BLACK_BRUSH
Definition: wingdi.h:896
#define IDM_STANDARD_KB
Definition: osk_res.h:36
#define MF_CHECKED
Definition: winuser.h:132
BOOL OSK_DlgCommand(WPARAM wCommand, HWND hWndControl)
Definition: main.c:360
#define IDM_ENHANCED_KB
Definition: osk_res.h:37
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define WM_TIMER
Definition: winuser.h:1725
#define WM_CLOSE
Definition: winuser.h:1604
int OSK_DlgTimer(void)
Definition: main.c:334
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:15
#define WM_COMMAND
Definition: winuser.h:1723
#define MF_UNCHECKED
Definition: winuser.h:204
#define SWP_NOSIZE
Definition: winuser.h:1231
VOID OSK_About(VOID)
Definition: main.c:117
#define VK_SCROLL
Definition: winuser.h:2256
#define VK_NUMLOCK
Definition: winuser.h:2255
#define MAIN_DIALOG_ENHANCED_KB
Definition: osk_res.h:8
#define VK_CAPITAL
Definition: winuser.h:2182
#define NULL
Definition: types.h:112
#define IDM_EXIT
Definition: resource.h:27
#define msg(x)
Definition: auth_time.c:54
#define SWP_NOMOVE
Definition: winuser.h:1230
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define HWND_NOTOPMOST
Definition: winuser.h:1192
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define IDC_LED_NUM
Definition: osk_res.h:13
#define IDCANCEL
Definition: winuser.h:825
VOID OSK_RestoreDlgPlacement(HWND hDlg)
Definition: main.c:272
HMENU WINAPI GetMenu(_In_ HWND)
#define WM_INITDIALOG
Definition: winuser.h:1722
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:44

Referenced by OSK_DlgProc(), and wWinMain().

◆ OSK_DlgTimer()

int OSK_DlgTimer ( void  )

Definition at line 334 of file main.c.

335 {
336  /* FIXME: To be deleted when ReactOS will support WS_EX_NOACTIVATE */
337  HWND hWndActiveWindow;
338 
339  hWndActiveWindow = GetForegroundWindow();
340  if (hWndActiveWindow != NULL && hWndActiveWindow != Globals.hMainWnd)
341  {
342  Globals.hActiveWnd = hWndActiveWindow;
343  }
344 
345  /*
346  Update the LED key indicators accordingly to their state (if one
347  of the specific keys is held down).
348  */
350 
351  return TRUE;
352 }
NOTEPAD_GLOBALS Globals
Definition: main.c:31
#define TRUE
Definition: types.h:120
VOID OSK_RefreshLEDKeys(VOID)
Definition: main.c:312
#define NULL
Definition: types.h:112
HWND WINAPI GetForegroundWindow(void)
Definition: ntwrapper.h:392
HWND hMainWnd
Definition: main.h:56

Referenced by OSK_DlgProc().

◆ OSK_RefreshLEDKeys()

VOID OSK_RefreshLEDKeys ( VOID  )

Definition at line 312 of file main.c.

313 {
314  INT i;
315  BOOL bKeyIsPressed;
316 
317  for (i = 0; i < _countof(LedKey); i++)
318  {
319  bKeyIsPressed = (GetAsyncKeyState(LedKey[i].vKey) & 0x8000) != 0;
320  if (LedKey[i].bWasKeyPressed != bKeyIsPressed)
321  {
322  LedKey[i].bWasKeyPressed = bKeyIsPressed;
324  }
325  }
326 }
NOTEPAD_GLOBALS Globals
Definition: main.c:31
int32_t INT
Definition: typedefs.h:58
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define _countof(array)
Definition: sndvol32.h:68
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
SHORT WINAPI GetAsyncKeyState(_In_ int)
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 NULL
Definition: types.h:112
OSK_KEYLEDINDICATOR LedKey[]
Definition: main.c:17
HWND hMainWnd
Definition: main.h:56

Referenced by OSK_DlgTimer().

◆ OSK_ReleaseKey()

BOOL OSK_ReleaseKey ( WORD  ScanCode)

Definition at line 469 of file main.c.

470 {
471  INPUT Input;
472  BOOL bExtendedKey;
473  LONG WindowStyle;
474  HWND hWndControl;
475 
476  /* Is it a 2-states key ? */
477  hWndControl = GetDlgItem(Globals.hMainWnd, ScanCode);
478  WindowStyle = GetWindowLongW(hWndControl, GWL_STYLE);
479  if ((WindowStyle & BS_AUTOCHECKBOX) != BS_AUTOCHECKBOX) return FALSE;
480 
481  /* Is the key down ? */
482  if (SendMessageW(hWndControl, BM_GETCHECK, 0, 0) != BST_CHECKED) return TRUE;
483 
484  /* Extended key ? */
485  if (ScanCode & 0x0200)
486  bExtendedKey = TRUE;
487  else
488  bExtendedKey = FALSE;
489  ScanCode &= 0xFF;
490 
491  /* Release the key */
492  Input.type = INPUT_KEYBOARD;
493  Input.ki.wVk = 0;
494  Input.ki.wScan = ScanCode;
495  Input.ki.time = GetTickCount();
496  Input.ki.dwExtraInfo = GetMessageExtraInfo();
497  Input.ki.dwFlags = KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP;
498  if (bExtendedKey) Input.ki.dwFlags |= KEYEVENTF_EXTENDEDKEY;
499  SendInput(1, &Input, sizeof(Input));
500 
501  return TRUE;
502 }
NOTEPAD_GLOBALS Globals
Definition: main.c:31
ULONG ScanCode
Definition: api.c:39
#define KEYEVENTF_KEYUP
Definition: winuser.h:1092
#define TRUE
Definition: types.h:120
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
Definition: arc.h:84
#define INPUT_KEYBOARD
Definition: winable.h:10
#define FALSE
Definition: types.h:117
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:1340
#define BS_AUTOCHECKBOX
Definition: pedump.c:654
#define BM_GETCHECK
Definition: winuser.h:1901
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_RestoreDlgPlacement()

VOID OSK_RestoreDlgPlacement ( HWND  hDlg)

Definition at line 272 of file main.c.

273 {
274  LoadSettings();
275  SetWindowPos(hDlg, (Globals.bAlwaysOnTop ? HWND_TOPMOST : HWND_NOTOPMOST), Globals.PosX, Globals.PosY, 0, 0, SWP_NOSIZE);
276 }
NOTEPAD_GLOBALS Globals
Definition: main.c:31
#define HWND_TOPMOST
Definition: winuser.h:1194
void LoadSettings(void)
Definition: settings.c:53
#define SWP_NOSIZE
Definition: winuser.h:1231
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define HWND_NOTOPMOST
Definition: winuser.h:1192

Referenced by OSK_DlgProc().

◆ OSK_SetImage()

int OSK_SetImage ( int  IdDlgItem,
int  IdResource 
)

Definition at line 32 of file main.c.

33 {
34  HICON hIcon;
35  HWND hWndItem;
36 
38  IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
39  if (hIcon == NULL)
40  return FALSE;
41 
42  hWndItem = GetDlgItem(Globals.hMainWnd, IdDlgItem);
43  if (hWndItem == NULL)
44  {
46  return FALSE;
47  }
48 
50 
51  /* The system automatically deletes these resources when the process that created them terminates (MSDN) */
52 
53  return TRUE;
54 }
static HICON
Definition: imagelist.c:84
NOTEPAD_GLOBALS Globals
Definition: main.c:31
#define IMAGE_ICON
Definition: winuser.h:212
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
#define TRUE
Definition: types.h:120
UINT_PTR WPARAM
Definition: windef.h:207
#define BM_SETIMAGE
Definition: winuser.h:1905
HINSTANCE hInstance
Definition: main.h:55
#define FALSE
Definition: types.h:117
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
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 NULL
Definition: types.h:112
#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 510 of file main.c.

511 {
512  HTHEME hTheme;
513  HWND hDlgButtonCtrl;
514  LRESULT Ret;
515  INT iState = PBS_NORMAL;
516 
517  /* Retrieve the theme handle for the button controls */
518  hDlgButtonCtrl = pNmDraw->hdr.hwndFrom;
519  hTheme = GetWindowTheme(hDlgButtonCtrl);
520 
521  /*
522  Begin the painting procedures if we retrieved
523  the theme for control buttons of the dialog.
524  */
525  if (hTheme)
526  {
527  /* Obtain CDDS drawing stages */
528  switch (pNmDraw->dwDrawStage)
529  {
530  case CDDS_PREPAINT:
531  {
532  /*
533  The button could be either in normal state or pushed.
534  Retrieve its state and save to a variable.
535  */
536  if (pNmDraw->uItemState & CDIS_DEFAULT)
537  {
538  iState = PBS_DEFAULTED;
539  }
540  else if (pNmDraw->uItemState & CDIS_SELECTED)
541  {
542  iState = PBS_PRESSED;
543  }
544  else if (pNmDraw->uItemState & CDIS_HOT)
545  {
546  iState = PBS_HOT;
547  }
548 
550  {
551  /* Draw the application if the theme is transparent */
552  DrawThemeParentBackground(hDlgButtonCtrl, pNmDraw->hdc, &pNmDraw->rc);
553  }
554 
555  /* Draw it */
556  DrawThemeBackground(hTheme, pNmDraw->hdc, BP_PUSHBUTTON, iState, &pNmDraw->rc, NULL);
557 
558  Ret = CDRF_SKIPDEFAULT;
559  break;
560  }
561 
562  case CDDS_PREERASE:
563  {
564  Ret = CDRF_DODEFAULT;
565  break;
566  }
567 
568  default:
569  Ret = CDRF_SKIPDEFAULT;
570  break;
571  }
572  }
573  else
574  {
575  /* hTheme is NULL so bail right away */
576  Ret = CDRF_DODEFAULT;
577  }
578 
579  return Ret;
580 }
static HTHEME(WINAPI *pOpenThemeDataEx)(HWND
#define CDRF_SKIPDEFAULT
Definition: commctrl.h:270
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:58
BOOL WINAPI IsThemeBackgroundPartiallyTransparent(HTHEME hTheme, int iPartId, int iStateId)
Definition: draw.c:1883
#define CDIS_SELECTED
Definition: commctrl.h:291
HRESULT WINAPI DrawThemeParentBackground(HWND hwnd, HDC hdc, RECT *prc)
Definition: draw.c:72
#define CDIS_HOT
Definition: commctrl.h:297
#define CDRF_DODEFAULT
Definition: commctrl.h:268
HTHEME WINAPI GetWindowTheme(HWND hwnd)
Definition: system.c:851
#define CDDS_PREPAINT
Definition: commctrl.h:280
HWND hwndFrom
Definition: winuser.h:3133
#define NULL
Definition: types.h:112
LONG_PTR LRESULT
Definition: windef.h:209
#define CDIS_DEFAULT
Definition: commctrl.h:296
#define CDDS_PREERASE
Definition: commctrl.h:282

Referenced by OSK_DlgProc().

◆ OSK_WarningDlgThread()

DWORD WINAPI OSK_WarningDlgThread ( LPVOID  lpParameter)

Definition at line 103 of file main.c.

104 {
106 
108  return 0;
109 }
NOTEPAD_GLOBALS Globals
Definition: main.c:31
#define DialogBoxW(i, t, p, f)
Definition: winuser.h:4375
HINSTANCE hInstance
Definition: main.c:36
HANDLE HINSTANCE
Definition: typedefs.h:77
LPVOID lpParameter
Definition: kernel32.h:241
INT_PTR CALLBACK OSK_WarningProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: main.c:62
#define IDD_WARNINGDIALOG_OSK
Definition: osk_res.h:50
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
HWND hMainWnd
Definition: main.h:56

Referenced by wWinMain().

◆ OSK_WarningProc()

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

Definition at line 62 of file main.c.

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

Referenced by OSK_WarningDlgThread(), and 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 777 of file main.c.

781 {
782  HANDLE hMutex;
783  DWORD dwError;
784  INT LayoutResource;
785  INITCOMMONCONTROLSEX iccex;
786 
790 
791  /*
792  Obtain a mutex for the program. This will ensure that
793  the program is launched only once.
794  */
795  hMutex = CreateMutexW(NULL, FALSE, L"OSKRunning");
796 
797  if (hMutex)
798  {
799  /* Check if there's already a mutex for the program */
800  dwError = GetLastError();
801 
802  if (dwError == ERROR_ALREADY_EXISTS)
803  {
804  /*
805  A mutex with the object name has been created previously.
806  Therefore, another instance is already running.
807  */
808  DPRINT("wWinMain(): Failed to create a mutex! The program instance is already running.\n");
810  return 0;
811  }
812  }
813 
814  /* Load the common controls */
815  iccex.dwSize = sizeof(INITCOMMONCONTROLSEX);
817  InitCommonControlsEx(&iccex);
818 
819  ZeroMemory(&Globals, sizeof(Globals));
821 
822  /* Load the application's settings from the registry */
823  LoadSettings();
824 
825  /* If the member of the struct (bShowWarning) is set then display the dialog box */
826  if (Globals.bShowWarning)
827  {
828  /* If for whatever reason the thread fails to be created then handle the dialog box in main thread... */
830  {
832  }
833  }
834 
835  /* Before initializing the dialog execution, check if the chosen keyboard type is standard or enhanced */
836  if (Globals.bIsEnhancedKeyboard)
837  {
838  LayoutResource = MAIN_DIALOG_ENHANCED_KB;
839  }
840  else
841  {
842  LayoutResource = MAIN_DIALOG_STANDARD_KB;
843  }
844 
845  /* Create the modal box based on the configuration registry */
847  MAKEINTRESOURCEW(LayoutResource),
849  OSK_DlgProc);
850 
851  /* Delete the mutex */
852  if (hMutex)
853  {
855  }
856 
857  return 0;
858 }
INT_PTR APIENTRY OSK_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: main.c:586
#define CloseHandle
Definition: compat.h:598
NOTEPAD_GLOBALS Globals
Definition: main.c:31
DWORD WINAPI OSK_WarningDlgThread(LPVOID lpParameter)
Definition: main.c:103
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define MAIN_DIALOG_STANDARD_KB
Definition: osk_res.h:9
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
#define ZeroMemory
Definition: winbase.h:1664
TCHAR * cmdline
Definition: stretchblt.cpp:32
struct tagINITCOMMONCONTROLSEX INITCOMMONCONTROLSEX
int32_t INT
Definition: typedefs.h:58
HINSTANCE hInstance
Definition: main.h:55
#define ICC_WIN95_CLASSES
Definition: commctrl.h:66
void LoadSettings(void)
Definition: settings.c:53
#define FALSE
Definition: types.h:117
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:136
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:656
HANDLE hMutex
Definition: mutex.c:11
#define DialogBoxW(i, t, p, f)
Definition: winuser.h:4375
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:62
#define MAIN_DIALOG_ENHANCED_KB
Definition: osk_res.h:8
HANDLE WINAPI DECLSPEC_HOTPATCH CreateMutexW(IN LPSECURITY_ATTRIBUTES lpMutexAttributes OPTIONAL, IN BOOL bInitialOwner, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:576
#define NULL
Definition: types.h:112
#define IDD_WARNINGDIALOG_OSK
Definition: osk_res.h:50
#define ICC_STANDARD_CLASSES
Definition: commctrl.h:73
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
#define DPRINT
Definition: sndvol32.h:71
HWND hMainWnd
Definition: main.h:56

Variable Documentation

◆ Globals

OSK_GLOBALS Globals

Definition at line 15 of file main.c.

◆ LedKey

Initial value:
=
{
}
#define IDC_LED_CAPS
Definition: osk_res.h:14
#define FALSE
Definition: types.h:117
#define IDC_LED_SCROLL
Definition: osk_res.h:15
#define VK_SCROLL
Definition: winuser.h:2256
#define VK_NUMLOCK
Definition: winuser.h:2255
#define VK_CAPITAL
Definition: winuser.h:2182
#define IDC_LED_NUM
Definition: osk_res.h:13

Definition at line 17 of file main.c.

Referenced by OSK_DlgCommand(), and OSK_RefreshLEDKeys().