ReactOS  0.4.15-dev-4874-g57c84dd
precomp.h File Reference
#include <stdio.h>
#include <windows.h>
#include <debug.h>
#include "commctrl.h"
#include "strsafe.h"
#include "osk_res.h"
Include dependency graph for precomp.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _KEY
 
struct  _KEYBOARD_STRUCT
 
struct  OSK_GLOBALS
 
struct  OSK_KEYLEDINDICATOR
 

Macros

#define SCANCODE_MASK   0xFF
 
#define OSK_CLASS   L"OSKMainWindow"
 
#define DEFAULT_FONTSIZE   15
 

Typedefs

typedef struct _KEY KEY
 
typedef struct _KEYPKEY
 
typedef struct _KEYBOARD_STRUCT KEYBOARD_STRUCT
 
typedef struct _KEYBOARD_STRUCTPKEYBOARD_STRUCT
 

Enumerations

enum  SetKeys_Reason { SETKEYS_INIT, SETKEYS_LAYOUT, SETKEYS_LANG }
 

Functions

int OSK_SetImage (int IdDlgItem, int IdResource)
 
LRESULT OSK_Create (HWND hwnd)
 
int OSK_Close (void)
 
int OSK_Timer (void)
 
BOOL OSK_Command (WPARAM wCommand, HWND hWndControl)
 
BOOL OSK_ReleaseKey (WORD ScanCode)
 
LRESULT APIENTRY OSK_WndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
DWORD WINAPI OSK_WarningDlgThread (LPVOID lpParameter)
 
int WINAPI wWinMain (HINSTANCE, HINSTANCE, LPWSTR, int)
 
VOID OSK_RestoreDlgPlacement (HWND hDlg)
 
VOID OSK_RefreshLEDKeys (VOID)
 
INT_PTR CALLBACK OSK_WarningProc (HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
 
LONG LoadDWORDFromRegistry (IN LPCWSTR lpValueDataName, OUT PDWORD pdwValueData)
 
LONG LoadStringFromRegistry (IN LPCWSTR lpValueDataName, OUT LPWSTR lpValueData, IN OUT LPUINT cchCount)
 
LONG SaveDWORDToRegistry (IN LPCWSTR lpValueDataName, IN DWORD dwValueData)
 
LONG SaveStringToRegistry (IN LPCWSTR lpValueDataName, IN LPCWSTR lpValueData, IN UINT cchCount)
 
VOID LoadSettings (VOID)
 
VOID SaveSettings (VOID)
 

Variables

KEYBOARD_STRUCT StandardKeyboard
 
KEYBOARD_STRUCT EnhancedKeyboard
 
OSK_GLOBALS Globals
 

Macro Definition Documentation

◆ DEFAULT_FONTSIZE

#define DEFAULT_FONTSIZE   15

Definition at line 127 of file precomp.h.

◆ OSK_CLASS

#define OSK_CLASS   L"OSKMainWindow"

Definition at line 126 of file precomp.h.

◆ SCANCODE_MASK

#define SCANCODE_MASK   0xFF

Definition at line 122 of file precomp.h.

Typedef Documentation

◆ KEY

typedef struct _KEY KEY

◆ KEYBOARD_STRUCT

◆ PKEY

typedef struct _KEY * PKEY

◆ PKEYBOARD_STRUCT

Enumeration Type Documentation

◆ SetKeys_Reason

Enumerator
SETKEYS_INIT 
SETKEYS_LAYOUT 
SETKEYS_LANG 

Definition at line 130 of file precomp.h.

131 {
132  SETKEYS_INIT,
135 };

Function Documentation

◆ LoadDWORDFromRegistry()

LONG LoadDWORDFromRegistry ( IN LPCWSTR  lpValueDataName,
OUT PDWORD  pdwValueData 
)

Definition at line 15 of file settings.c.

17 {
18  HKEY hKey;
19  LONG lResult;
20  DWORD dwValue;
21  DWORD cbData = sizeof(dwValue);
22 
23  /* Initialize the pointer parameter to default */
24  *pdwValueData = 0;
25 
26  /* Open our application's key in order to load its configuration data */
28  L"Software\\Microsoft\\Osk",
29  0,
30  KEY_READ,
31  &hKey);
32 
33  if (lResult != ERROR_SUCCESS)
34  {
35  /* Bail out */
36  DPRINT("LoadDWORDFromRegistry(): Failed to open the application's key! (Error - %li)\n", lResult);
37  return lResult;
38  }
39 
40  /* Load the specific value based on the parameter caller, lpValueDataName */
41  lResult = RegQueryValueExW(hKey,
42  lpValueDataName,
43  0,
44  0,
45  (BYTE *)&dwValue,
46  &cbData);
47 
48  if (lResult != ERROR_SUCCESS)
49  {
50 
51  /* Bail out */
52  DPRINT("LoadDWORDFromRegistry(): Failed to load the following value - \"%S\". (Error - %li)\n", lpValueDataName, lResult);
54  return lResult;
55  }
56 
57  /* Is the buffer's size too small to query the required data? */
58  if (cbData != sizeof(dwValue))
59  {
60  /* It is therefore bail out */
61  DPRINT("LoadDWORDFromRegistry(): The buffer is too small to hold the data!\n");
63  return ERROR_MORE_DATA;
64  }
65 
66  *pdwValueData = dwValue;
68  return lResult;
69 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4120
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ERROR_MORE_DATA
Definition: dderror.h:13
unsigned char BYTE
Definition: xxhash.c:193
FxAutoRegKey hKey
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3356
#define DPRINT
Definition: sndvol32.h:71
#define RegCloseKey(hKey)
Definition: registry.h:47

Referenced by LoadSettings().

◆ LoadSettings()

VOID LoadSettings ( VOID  )

Definition at line 53 of file settings.c.

54 {
55  HKEY hKey = NULL;
56  int iItemIndex = -1;
57 
59  {
60  TCHAR szBuffer[MAX_PATH];
61  DWORD dwAdvancedChecked;
62  DWORD type, size = sizeof(dwAdvancedChecked);
63  LSTATUS lstatus;
64 
65  /* Restore last selected font */
66  if (QueryStringValue(HKEY_CURRENT_USER, g_szGeneralRegKey, _T("Font"), szBuffer, (sizeof(szBuffer)/sizeof(szBuffer[0]))) == ERROR_SUCCESS)
67  {
68  //Get combobox handle
70 
71  //Search for match and return index if match found
72  iItemIndex = ComboBox_FindStringExact(hWnd, -1, szBuffer);
73  if(iItemIndex != CB_ERR)
74  {
75  ComboBox_SetCurSel(hWnd, iItemIndex);
77  }
78  }
79 
80  /* Restore last selected character set */
81  if (QueryStringValue(HKEY_CURRENT_USER, g_szGeneralRegKey, _T("CodePage"), szBuffer, (sizeof(szBuffer)/sizeof(szBuffer[0]))) == ERROR_SUCCESS)
82  {
83  //Get combobox handle
85 
86  iItemIndex = ComboBox_FindStringExact(hWnd, -1, szBuffer);
87  if(iItemIndex != CB_ERR)
88  {
89  ComboBox_SetCurSel(hWnd, iItemIndex);
90  }
91  }
92 
93  lstatus = RegQueryValueEx(hKey, _T("Advanced"), NULL, &type, (LPBYTE)&dwAdvancedChecked, &size);
94  if (lstatus == ERROR_SUCCESS && type == REG_DWORD && dwAdvancedChecked != FALSE)
95  {
97  }
98 
100  }
101  else
102  {
103  /* Default font seems to be Arial */
105 
106  iItemIndex = ComboBox_FindStringExact(hWnd, -1, _T("Arial"));
107  if(iItemIndex != CB_ERR)
108  {
109  ComboBox_SetCurSel(hWnd, iItemIndex);
111  }
112  }
113 }
#define RegQueryValueEx
Definition: winreg.h:524
#define ERROR_SUCCESS
Definition: deptool.c:10
#define IDC_CHECK_ADVANCED
Definition: resource.h:26
#define KEY_READ
Definition: nt_native.h:1023
#define HKEY_CURRENT_USER
Definition: winreg.h:11
HWND hWnd
Definition: settings.c:17
#define SendDlgItemMessage
Definition: winuser.h:5822
#define IDC_COMBO_CHARSET
Definition: resource.h:21
#define ComboBox_FindStringExact(hwndCtl, indexStart, lpszFind)
Definition: windowsx.h:22
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
const TCHAR g_szGeneralRegKey[]
Definition: settings.c:16
#define CB_ERR
Definition: winuser.h:2415
#define MF_CHECKED
Definition: winuser.h:132
char TCHAR
Definition: xmlstorage.h:189
#define BM_CLICK
Definition: winuser.h:1904
#define _T(x)
Definition: vfdio.h:22
GLsizeiptr size
Definition: glext.h:5919
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
#define ComboBox_SetCurSel(hwndCtl, index)
Definition: windowsx.h:41
#define IDC_FONTCOMBO
Definition: resource.h:12
VOID ChangeMapFont(HWND hDlg)
Definition: charmap.c:162
LONG QueryStringValue(HKEY hKey, LPCTSTR lpSubKey, LPCTSTR lpValueName, LPTSTR pszBuffer, DWORD dwBufferLen)
Definition: settings.c:19
#define RegOpenKeyEx
Definition: winreg.h:520
FxAutoRegKey hKey
#define NULL
Definition: types.h:112
HWND hCharmapDlg
Definition: charmap.c:22
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define REG_DWORD
Definition: sdbapi.c:596
#define RegCloseKey(hKey)
Definition: registry.h:47

◆ LoadStringFromRegistry()

LONG LoadStringFromRegistry ( IN LPCWSTR  lpValueDataName,
OUT LPWSTR  lpValueData,
IN OUT LPUINT  cchCount 
)

Definition at line 73 of file settings.c.

76 {
77  HKEY hKey;
78  LONG lResult;
79  UINT cbCount;
80 
81  cbCount = (*cchCount) * sizeof(WCHAR);
82 
83  /* Open our application's key in order to load its configuration data */
85  L"Software\\Microsoft\\Osk",
86  0,
87  KEY_READ,
88  &hKey);
89 
90  if (lResult != ERROR_SUCCESS)
91  {
92  /* Bail out */
93  DPRINT("LoadStringFromRegistry(): Failed to open the application's key! (Error - %li)\n", lResult);
94  return lResult;
95  }
96 
97  /* Load the specific value based on the parameter caller, lpValueDataName */
98  lResult = RegQueryValueExW(hKey,
99  lpValueDataName,
100  0,
101  0,
102  (BYTE *)lpValueData,
103  (LPDWORD)&cbCount);
104 
105 
106  if (lResult != ERROR_SUCCESS)
107  {
108 
109  /* Bail out */
110  DPRINT("LoadStringFromRegistry(): Failed to load the following value - \"%S\". (Error - %li)\n", lpValueDataName, lResult);
111  RegCloseKey(hKey);
112  return lResult;
113  }
114 
115  *cchCount = cbCount / sizeof(WCHAR);
116 
117  RegCloseKey(hKey);
118  return lResult;
119 }
#define ERROR_SUCCESS
Definition: deptool.c:10
static int cbCount
Definition: fiber.c:42
#define KEY_READ
Definition: nt_native.h:1023
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4120
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned char BYTE
Definition: xxhash.c:193
FxAutoRegKey hKey
unsigned int UINT
Definition: ndis.h:50
uint32_t * LPDWORD
Definition: typedefs.h:59
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3356
#define DPRINT
Definition: sndvol32.h:71
#define RegCloseKey(hKey)
Definition: registry.h:47

Referenced by LoadSettings().

◆ OSK_Close()

int OSK_Close ( void  )

Definition at line 490 of file main.c.

491 {
493 
494  /* Release Ctrl, Shift, Alt keys */
495  OSK_ReleaseKey(SCAN_CODE_44); // Left shift
496  OSK_ReleaseKey(SCAN_CODE_57); // Right shift
497  OSK_ReleaseKey(SCAN_CODE_58); // Left ctrl
498  OSK_ReleaseKey(SCAN_CODE_60); // Left alt
499  OSK_ReleaseKey(SCAN_CODE_62); // Right alt
500  OSK_ReleaseKey(SCAN_CODE_64); // Right ctrl
501 
502  /* Destroy child controls */
503  OSK_DestroyKeys();
504 
505  /* delete GDI objects */
506  if (Globals.hBrushGreenLed) DeleteObject(Globals.hBrushGreenLed);
508 
509  /* Save the application's settings on registry */
510  SaveSettings();
511 
512  return TRUE;
513 }
#define SCAN_CODE_60
Definition: osk_res.h:131
NOTEPAD_GLOBALS Globals
Definition: main.c:31
#define TRUE
Definition: types.h:120
#define SCAN_CODE_64
Definition: osk_res.h:134
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define SCAN_CODE_62
Definition: osk_res.h:133
void SaveSettings(void)
Definition: settings.c:115
#define SCAN_CODE_57
Definition: osk_res.h:129
#define SCAN_CODE_58
Definition: osk_res.h:130
HFONT hFont
Definition: main.h:60
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
VOID OSK_DestroyKeys(VOID)
Definition: main.c:162
BOOL OSK_ReleaseKey(WORD ScanCode)
Definition: main.c:731
#define SCAN_CODE_44
Definition: osk_res.h:117
HWND hMainWnd
Definition: main.h:56

Referenced by OSK_WndProc().

◆ OSK_Command()

BOOL OSK_Command ( WPARAM  wCommand,
HWND  hWndControl 
)

Definition at line 622 of file main.c.

623 {
624  WORD ScanCode;
625  INPUT Input;
626  BOOL bExtendedKey;
627  BOOL bKeyDown;
628  BOOL bKeyUp;
629  LONG WindowStyle;
630  INT i;
631 
632  /* FIXME: To be deleted when ReactOS will support WS_EX_NOACTIVATE */
633  if (Globals.hActiveWnd)
634  {
635  MSG msg;
636 
637  SetForegroundWindow(Globals.hActiveWnd);
638  while (PeekMessageW(&msg, 0, 0, 0, PM_REMOVE))
639  {
642  }
643  }
644 
645  /* KeyDown and/or KeyUp ? */
646  WindowStyle = GetWindowLongW(hWndControl, GWL_STYLE);
647  if ((WindowStyle & BS_AUTOCHECKBOX) == BS_AUTOCHECKBOX)
648  {
649  /* 2-states key like Shift, Alt, Ctrl, ... */
650  if (SendMessageW(hWndControl, BM_GETCHECK, 0, 0) == BST_CHECKED)
651  {
652  bKeyDown = TRUE;
653  bKeyUp = FALSE;
654  }
655  else
656  {
657  bKeyDown = FALSE;
658  bKeyUp = TRUE;
659  }
660  }
661  else
662  {
663  /* Other key */
664  bKeyDown = TRUE;
665  bKeyUp = TRUE;
666  }
667 
668  /* Get the key from dialog control key command */
669  ScanCode = wCommand;
670 
671  /*
672  The user could've pushed one of the key buttons of the dialog that
673  can trigger particular function toggling (Caps Lock, Num Lock or Scroll Lock). Update
674  (invalidate) the LED icon resources accordingly.
675  */
676  for (i = 0; i < _countof(LedKey); i++)
677  {
678  if (LedKey[i].wScanCode == ScanCode)
679  {
681  }
682  }
683 
684  /* Extended key ? */
685  if (ScanCode & 0x0200)
686  bExtendedKey = TRUE;
687  else
688  bExtendedKey = FALSE;
690 
691  /* Press and release the key */
692  if (bKeyDown)
693  {
694  Input.type = INPUT_KEYBOARD;
695  Input.ki.wVk = 0;
696  Input.ki.wScan = ScanCode;
697  Input.ki.time = GetTickCount();
698  Input.ki.dwExtraInfo = GetMessageExtraInfo();
699  Input.ki.dwFlags = KEYEVENTF_SCANCODE;
700  if (bExtendedKey) Input.ki.dwFlags |= KEYEVENTF_EXTENDEDKEY;
701  SendInput(1, &Input, sizeof(Input));
702  }
703 
704  if (bKeyUp)
705  {
706  Input.type = INPUT_KEYBOARD;
707  Input.ki.wVk = 0;
708  Input.ki.wScan = ScanCode;
709  Input.ki.time = GetTickCount();
710  Input.ki.dwExtraInfo = GetMessageExtraInfo();
711  Input.ki.dwFlags = KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP;
712  if (bExtendedKey) Input.ki.dwFlags |= KEYEVENTF_EXTENDEDKEY;
713  SendInput(1, &Input, sizeof(Input));
714  }
715 
716  /* Play the sound during clicking event (only if "Use Click Sound" menu option is ticked) */
717  if (Globals.bSoundClick)
718  {
720  }
721 
722  return TRUE;
723 }
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:1096
#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:1905
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:8
#define GetModuleHandle
Definition: winbase.h:3688
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:18
#define KEYEVENTF_EXTENDEDKEY
Definition: winuser.h:1095
#define BST_CHECKED
Definition: winuser.h:197
#define msg(x)
Definition: auth_time.c:54
BOOL WINAPI SetForegroundWindow(_In_ HWND)
#define SCANCODE_MASK
Definition: precomp.h:122
#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:1186
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_WndProc().

◆ OSK_Create()

LRESULT OSK_Create ( HWND  hwnd)

Definition at line 372 of file main.c.

373 {
374  HMONITOR monitor;
376  POINT Pt;
377  RECT rcWindow, rcDlgIntersect;
378  LOGFONTW lf = {0};
379 
380  /* Save handle */
382 
383  /* Init Font */
384  lf.lfHeight = Globals.FontHeight;
385  StringCchCopyW(lf.lfFaceName, _countof(Globals.FontFaceName), Globals.FontFaceName);
387 
388  if (OSK_SetKeys(SETKEYS_INIT) == -1)
389  return -1;
390 
391  /* Check the checked menu item before displaying the window */
392  if (Globals.bIsEnhancedKeyboard)
393  {
394  /* Enhanced keyboard dialog chosen, set the respective menu item as checked */
397  }
398  else
399  {
400  /* Standard keyboard dialog chosen, set the respective menu item as checked */
403  }
404 
405  /* Check if the "Click Sound" option was chosen before (and if so, then tick the menu item) */
406  if (Globals.bSoundClick)
407  {
409  }
410 
411  /* Get screen info */
412  memset(&Pt, 0, sizeof(Pt));
413  monitor = MonitorFromPoint(Pt, MONITOR_DEFAULTTOPRIMARY);
414  info.cbSize = sizeof(info);
415  GetMonitorInfoW(monitor, &info);
416  GetWindowRect(hwnd, &rcWindow);
417 
418  /*
419  If the coordination values are default then re-initialize using the specific formulas
420  to move the dialog at the bottom of the screen.
421  */
422  if (Globals.PosX == CW_USEDEFAULT && Globals.PosY == CW_USEDEFAULT)
423  {
424  Globals.PosX = (info.rcMonitor.left + info.rcMonitor.right - (rcWindow.right - rcWindow.left)) / 2;
425  Globals.PosY = info.rcMonitor.bottom - (rcWindow.bottom - rcWindow.top);
426  }
427 
428  /*
429  Calculate the intersection of two rectangle sources (dialog and work desktop area).
430  If such sources do not intersect, then the dialog is deemed as "off screen".
431  */
432  if (IntersectRect(&rcDlgIntersect, &rcWindow, &info.rcWork) == 0)
433  {
434  Globals.PosX = (info.rcMonitor.left + info.rcMonitor.right - (rcWindow.right - rcWindow.left)) / 2;
435  Globals.PosY = info.rcMonitor.bottom - (rcWindow.bottom - rcWindow.top);
436  }
437  else
438  {
439  /*
440  There's still some intersection but we're not for sure if it is sufficient (the dialog could also be partially hidden).
441  Therefore, check the remaining intersection if it's enough.
442  */
443  if (rcWindow.top < info.rcWork.top || rcWindow.left < info.rcWork.left || rcWindow.right > info.rcWork.right || rcWindow.bottom > info.rcWork.bottom)
444  {
445  Globals.PosX = (info.rcMonitor.left + info.rcMonitor.right - (rcWindow.right - rcWindow.left)) / 2;
446  Globals.PosY = info.rcMonitor.bottom - (rcWindow.bottom - rcWindow.top);
447  }
448  }
449 
450  /*
451  Place the window (with respective placement coordinates) as topmost, above
452  every window which are not on top or are at the bottom of the Z order.
453  */
454  if (Globals.bAlwaysOnTop)
455  {
458  }
459  else
460  {
463  }
464 
465  /* Create a green brush for leds */
466  Globals.hBrushGreenLed = CreateSolidBrush(RGB(0, 255, 0));
467 
468  /* Set a timer for periodic tasks */
469  Globals.iTimer = SetTimer(hwnd, 0, 100, NULL);
470 
471  /* If the member of the struct (bShowWarning) is set then display the dialog box */
472  if (Globals.bShowWarning)
473  {
474  /* If for whatever reason the thread fails to be created then handle the dialog box in main thread... */
476  {
478  }
479  }
480 
481  return 0;
482 }
HMONITOR WINAPI MonitorFromPoint(POINT, DWORD)
NOTEPAD_GLOBALS Globals
Definition: main.c:31
DWORD WINAPI OSK_WarningDlgThread(LPVOID lpParameter)
Definition: main.c:124
#define MF_BYCOMMAND
Definition: winuser.h:202
#define RGB(r, g, b)
Definition: precomp.h:62
LONG lfHeight
Definition: dimm.idl:59
LONG top
Definition: windef.h:307
#define HWND_TOPMOST
Definition: winuser.h:1198
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
HINSTANCE hInstance
Definition: main.h:55
static struct _test_info info[]
Definition: SetCursorPos.c:19
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
#define CW_USEDEFAULT
Definition: winuser.h:225
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:137
HFONT WINAPI CreateFontIndirectW(_In_ const LOGFONTW *)
HFONT hFont
Definition: main.h:60
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define IDM_ON_TOP
Definition: osk_res.h:40
#define DialogBoxW(i, t, p, f)
Definition: winuser.h:4379
#define IDM_STANDARD_KB
Definition: osk_res.h:33
#define MF_CHECKED
Definition: winuser.h:132
#define IDM_ENHANCED_KB
Definition: osk_res.h:34
BOOL WINAPI GetMonitorInfoW(_In_ HMONITOR, _Inout_ LPMONITORINFO)
#define _countof(array)
Definition: sndvol32.h:68
LRESULT OSK_SetKeys(int reason)
Definition: main.c:188
DWORD WINAPI CheckMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
INT_PTR CALLBACK OSK_WarningProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: main.c:83
#define MF_UNCHECKED
Definition: winuser.h:204
BOOL WINAPI IntersectRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)
#define SWP_NOSIZE
Definition: winuser.h:1235
#define NULL
Definition: types.h:112
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
#define IDD_WARNINGDIALOG_OSK
Definition: osk_res.h:47
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
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:1196
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4022
#define memset(x, y, z)
Definition: compat.h:39
HMENU WINAPI GetMenu(_In_ HWND)
HWND hMainWnd
Definition: main.h:56
#define IDM_CLICK_SOUND
Definition: osk_res.h:41

Referenced by OSK_WndProc().

◆ OSK_RefreshLEDKeys()

VOID OSK_RefreshLEDKeys ( VOID  )

Definition at line 522 of file main.c.

523 {
524  INT i;
525  BOOL bKeyIsPressed;
526 
527  for (i = 0; i < _countof(LedKey); i++)
528  {
529  bKeyIsPressed = (GetAsyncKeyState(LedKey[i].vKey) & 0x8000) != 0;
530  if (LedKey[i].bWasKeyPressed != bKeyIsPressed)
531  {
532  LedKey[i].bWasKeyPressed = bKeyIsPressed;
534  }
535  }
536 }
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:18
HWND hMainWnd
Definition: main.h:56

Referenced by OSK_Timer().

◆ OSK_ReleaseKey()

BOOL OSK_ReleaseKey ( WORD  ScanCode)

Definition at line 731 of file main.c.

732 {
733  INPUT Input;
734  BOOL bExtendedKey;
735  LONG WindowStyle;
736  HWND hWndControl;
737 
738  /* Is it a 2-states key ? */
739  hWndControl = GetDlgItem(Globals.hMainWnd, ScanCode);
740  WindowStyle = GetWindowLongW(hWndControl, GWL_STYLE);
741  if ((WindowStyle & BS_AUTOCHECKBOX) != BS_AUTOCHECKBOX) return FALSE;
742 
743  /* Is the key down ? */
744  if (SendMessageW(hWndControl, BM_GETCHECK, 0, 0) != BST_CHECKED) return TRUE;
745 
746  /* Extended key ? */
747  if (ScanCode & 0x0200)
748  bExtendedKey = TRUE;
749  else
750  bExtendedKey = FALSE;
752 
753  /* Release the key */
754  Input.type = INPUT_KEYBOARD;
755  Input.ki.wVk = 0;
756  Input.ki.wScan = ScanCode;
757  Input.ki.time = GetTickCount();
758  Input.ki.dwExtraInfo = GetMessageExtraInfo();
759  Input.ki.dwFlags = KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP;
760  if (bExtendedKey) Input.ki.dwFlags |= KEYEVENTF_EXTENDEDKEY;
761  SendInput(1, &Input, sizeof(Input));
762 
763  return TRUE;
764 }
NOTEPAD_GLOBALS Globals
Definition: main.c:31
ULONG ScanCode
Definition: api.c:39
#define KEYEVENTF_KEYUP
Definition: winuser.h:1096
#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:1905
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:1095
#define BST_CHECKED
Definition: winuser.h:197
#define SCANCODE_MASK
Definition: precomp.h:122
HWND hMainWnd
Definition: main.h:56
UINT WINAPI SendInput(UINT, LPINPUT, int)
Definition: ntwrapper.h:344

Referenced by OSK_Close().

◆ OSK_RestoreDlgPlacement()

VOID OSK_RestoreDlgPlacement ( HWND  hDlg)

◆ OSK_SetImage()

int OSK_SetImage ( int  IdDlgItem,
int  IdResource 
)

Definition at line 33 of file main.c.

34 {
35  HICON hIcon;
36  HWND hWndItem;
37 
39  IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
40  if (hIcon == NULL)
41  return FALSE;
42 
43  hWndItem = GetDlgItem(Globals.hMainWnd, IdDlgItem);
44  if (hWndItem == NULL)
45  {
47  return FALSE;
48  }
49 
51 
52  /* The system automatically deletes these resources when the process that created them terminates (MSDN) */
53 
54  return TRUE;
55 }
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:1909
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:1081
HWND hMainWnd
Definition: main.h:56

Referenced by OSK_SetKeys().

◆ OSK_Timer()

int OSK_Timer ( void  )

Definition at line 544 of file main.c.

545 {
546  HWND hWndActiveWindow;
547  DWORD dwThread;
548  HKL hKeyboardLayout;
549 
550  hWndActiveWindow = GetForegroundWindow();
551  if (hWndActiveWindow != NULL && hWndActiveWindow != Globals.hMainWnd)
552  {
553  /* FIXME: To be deleted when ReactOS will support WS_EX_NOACTIVATE */
554  Globals.hActiveWnd = hWndActiveWindow;
555 
556  /* Grab the current keyboard layout from the foreground window */
557  dwThread = GetWindowThreadProcessId(hWndActiveWindow, NULL);
558  hKeyboardLayout = GetKeyboardLayout(dwThread);
559  /* Activate the layout */
560  ActivateKeyboardLayout(hKeyboardLayout, 0);
561  }
562 
563  /*
564  Update the LED key indicators accordingly to their state (if one
565  of the specific keys is held down).
566  */
568  /* Update the buttons */
570 
571  return TRUE;
572 }
HKL WINAPI ActivateKeyboardLayout(_In_ HKL, _In_ UINT)
NOTEPAD_GLOBALS Globals
Definition: main.c:31
DWORD WINAPI GetWindowThreadProcessId(HWND hWnd, PDWORD lpdwProcessId)
#define TRUE
Definition: types.h:120
VOID OSK_RefreshLEDKeys(VOID)
Definition: main.c:522
unsigned long DWORD
Definition: ntddk_ex.h:95
LRESULT OSK_SetKeys(int reason)
Definition: main.c:188
UINT_PTR HKL
Definition: msctf.idl:101
PKEYBOARD_LAYOUT GetKeyboardLayout()
Definition: utils.c:194
#define NULL
Definition: types.h:112
HWND WINAPI GetForegroundWindow(void)
Definition: ntwrapper.h:392
HWND hMainWnd
Definition: main.h:56

Referenced by OSK_WndProc().

◆ OSK_WarningDlgThread()

DWORD WINAPI OSK_WarningDlgThread ( LPVOID  lpParameter)

Definition at line 124 of file main.c.

125 {
126  HINSTANCE hInstance = (HINSTANCE)lpParameter;
127 
129  return 0;
130 }
NOTEPAD_GLOBALS Globals
Definition: main.c:31
#define DialogBoxW(i, t, p, f)
Definition: winuser.h:4379
HINSTANCE hInstance
Definition: main.c:36
HANDLE HINSTANCE
Definition: typedefs.h:77
INT_PTR CALLBACK OSK_WarningProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: main.c:83
#define IDD_WARNINGDIALOG_OSK
Definition: osk_res.h:47
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
HWND hMainWnd
Definition: main.h:56

Referenced by OSK_Create().

◆ OSK_WarningProc()

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

Definition at line 83 of file main.c.

84 {
86 
87  switch (Msg)
88  {
89  case WM_INITDIALOG:
90  {
91  return TRUE;
92  }
93 
94  case WM_COMMAND:
95  {
96  switch (LOWORD(wParam))
97  {
99  {
100  Globals.bShowWarning = !IsDlgButtonChecked(hDlg, IDC_SHOWWARNINGCHECK);
101  return TRUE;
102  }
103 
104  case IDOK:
105  case IDCANCEL:
106  {
107  EndDialog(hDlg, LOWORD(wParam));
108  return TRUE;
109  }
110  }
111  break;
112  }
113  }
114 
115  return FALSE;
116 }
#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:1727
struct @1589 Msg[]
#define IDCANCEL
Definition: winuser.h:825
#define WM_INITDIALOG
Definition: winuser.h:1726
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82

Referenced by OSK_Create(), and OSK_WarningDlgThread().

◆ OSK_WndProc()

LRESULT APIENTRY OSK_WndProc ( HWND  hwnd,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 813 of file main.c.

814 {
815  switch (msg)
816  {
817  case WM_CREATE:
818  return OSK_Create(hwnd);
819 
820  case WM_PAINT:
821  return OSK_Paint(hwnd);
822 
823  case WM_TIMER:
824  return OSK_Timer();
825 
826  case WM_CTLCOLORSTATIC:
828  {
829  if (GetKeyState(VK_NUMLOCK) & 0x0001)
830  return (LRESULT)Globals.hBrushGreenLed;
831  else
833  }
835  {
836  if (GetKeyState(VK_CAPITAL) & 0x0001)
837  return (LRESULT)Globals.hBrushGreenLed;
838  else
840  }
842  {
843  if (GetKeyState(VK_SCROLL) & 0x0001)
844  return (LRESULT)Globals.hBrushGreenLed;
845  else
847  }
848  break;
849 
850  case WM_COMMAND:
851  switch (LOWORD(wParam))
852  {
853  case IDM_EXIT:
854  {
855  PostMessageW(hwnd, WM_CLOSE, 0, 0);
856  break;
857  }
858 
859  case IDM_ENHANCED_KB:
860  {
861  if (!Globals.bIsEnhancedKeyboard)
862  {
863  /*
864  The user attempted to switch to enhanced keyboard dialog type.
865  Set the member value as TRUE, destroy the dialog and save the data configuration into the registry.
866  */
867  Globals.bIsEnhancedKeyboard = TRUE;
868  SaveSettings();
869 
870  /* Change the condition of enhanced keyboard item menu to checked */
873 
874  /* Finally, update the key layout */
875  LoadSettings();
877  }
878 
879  break;
880  }
881 
882  case IDM_STANDARD_KB:
883  {
884  if (Globals.bIsEnhancedKeyboard)
885  {
886  /*
887  The user attempted to switch to standard keyboard dialog type.
888  Set the member value as FALSE, destroy the dialog and save the data configuration into the registry.
889  */
890  Globals.bIsEnhancedKeyboard = FALSE;
891  SaveSettings();
892 
893  /* Change the condition of standard keyboard item menu to checked */
896 
897  /* Finally, update the key layout */
898  LoadSettings();
900  }
901 
902  break;
903  }
904 
905  case IDM_CLICK_SOUND:
906  {
907  /*
908  This case is triggered when the user attempts to click on the menu item. Before doing anything,
909  we must check the condition state of such menu item so that we can tick/untick the menu item accordingly.
910  */
911  if (!Globals.bSoundClick)
912  {
913  Globals.bSoundClick = TRUE;
915  }
916  else
917  {
918  Globals.bSoundClick = FALSE;
920  }
921 
922  break;
923  }
924 
925  case IDM_ON_TOP:
926  {
927  /*
928  Check the condition state before disabling/enabling the menu
929  item and change the topmost order.
930  */
931  if (!Globals.bAlwaysOnTop)
932  {
933  Globals.bAlwaysOnTop = TRUE;
936  }
937  else
938  {
939  Globals.bAlwaysOnTop = FALSE;
942  }
943 
944  break;
945  }
946 
947  case IDM_FONT:
948  {
949  OSK_ChooseFont();
950  break;
951  }
952 
953  case IDM_ABOUT:
954  {
955  OSK_About();
956  break;
957  }
958 
959  default:
961  break;
962  }
963  return 0;
964 
965  case WM_THEMECHANGED:
966  /* Redraw the dialog (and its control buttons) using the new theme */
968  return 0;
969 
970  case WM_CLOSE:
971  OSK_Close();
972  PostQuitMessage(0);
973  return 0;
974  }
975  return DefWindowProcW(hwnd, msg, wParam, lParam);
976 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
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
BOOL OSK_Command(WPARAM wCommand, HWND hWndControl)
Definition: main.c:622
#define WM_CTLCOLORSTATIC
Definition: winuser.h:1759
#define HWND_TOPMOST
Definition: winuser.h:1198
WPARAM wParam
Definition: combotst.c:138
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
void SaveSettings(void)
Definition: settings.c:115
#define IDC_LED_CAPS
Definition: osk_res.h:11
void LoadSettings(void)
Definition: settings.c:53
#define FALSE
Definition: types.h:117
#define IDM_FONT
Definition: osk_res.h:43
int OSK_Close(void)
Definition: main.c:490
#define IDM_ON_TOP
Definition: osk_res.h:40
SHORT WINAPI GetKeyState(_In_ int)
#define BLACK_BRUSH
Definition: wingdi.h:896
#define IDM_STANDARD_KB
Definition: osk_res.h:33
#define MF_CHECKED
Definition: winuser.h:132
VOID OSK_ChooseFont(VOID)
Definition: main.c:580
#define IDM_ENHANCED_KB
Definition: osk_res.h:34
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define WM_TIMER
Definition: winuser.h:1729
int OSK_Timer(void)
Definition: main.c:544
#define WM_CLOSE
Definition: winuser.h:1608
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
LRESULT OSK_SetKeys(int reason)
Definition: main.c:188
DWORD WINAPI CheckMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define WM_PAINT
Definition: winuser.h:1607
#define IDC_LED_SCROLL
Definition: osk_res.h:12
LRESULT OSK_Paint(HWND hwnd)
Definition: main.c:772
LRESULT OSK_Create(HWND hwnd)
Definition: main.c:372
#define WM_COMMAND
Definition: winuser.h:1727
#define MF_UNCHECKED
Definition: winuser.h:204
#define SWP_NOSIZE
Definition: winuser.h:1235
VOID OSK_About(VOID)
Definition: main.c:138
#define VK_SCROLL
Definition: winuser.h:2260
#define VK_NUMLOCK
Definition: winuser.h:2259
#define VK_CAPITAL
Definition: winuser.h:2186
#define NULL
Definition: types.h:112
#define IDM_EXIT
Definition: resource.h:27
#define msg(x)
Definition: auth_time.c:54
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_CREATE
Definition: winuser.h:1595
#define SWP_NOMOVE
Definition: winuser.h:1234
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define HWND_NOTOPMOST
Definition: winuser.h:1196
#define IDC_LED_NUM
Definition: osk_res.h:10
LONG_PTR LRESULT
Definition: windef.h:209
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4022
HMENU WINAPI GetMenu(_In_ HWND)
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define IDM_CLICK_SOUND
Definition: osk_res.h:41

Referenced by wWinMain().

◆ SaveDWORDToRegistry()

LONG SaveDWORDToRegistry ( IN LPCWSTR  lpValueDataName,
IN DWORD  dwValueData 
)

Definition at line 121 of file settings.c.

123 {
124  HKEY hKey;
125  LONG lResult;
126 
127  /* Set up the application's key in case it has not been made yet */
129  L"Software\\Microsoft\\Osk",
130  0,
131  NULL,
132  0,
133  KEY_WRITE,
134  NULL,
135  &hKey,
136  NULL);
137 
138  if (lResult != ERROR_SUCCESS)
139  {
140  /* Bail out */
141  DPRINT("SaveDWORDToRegistry(): Failed to create the application's key! (Error - %li)\n", lResult);
142  return lResult;
143  }
144 
145  /* Save the data into the registry value */
146  lResult = RegSetValueExW(hKey,
147  lpValueDataName,
148  0,
149  REG_DWORD,
150  (BYTE *)&dwValueData,
151  sizeof(dwValueData));
152 
153  if (lResult != ERROR_SUCCESS)
154  {
155  /* Bail out */
156  DPRINT("SaveDWORDToRegistry(): Failed to save the following value - \"%S\". (Error - %li)\n", lpValueDataName, lResult);
157  RegCloseKey(hKey);
158  return lResult;
159  }
160 
161  RegCloseKey(hKey);
162  return lResult;
163 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define HKEY_CURRENT_USER
Definition: winreg.h:11
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1091
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
#define KEY_WRITE
Definition: nt_native.h:1031
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4899
unsigned char BYTE
Definition: xxhash.c:193
FxAutoRegKey hKey
#define NULL
Definition: types.h:112
#define DPRINT
Definition: sndvol32.h:71
#define REG_DWORD
Definition: sdbapi.c:596
#define RegCloseKey(hKey)
Definition: registry.h:47

Referenced by SaveSettings().

◆ SaveSettings()

VOID SaveSettings ( VOID  )

Definition at line 115 of file settings.c.

116 {
117  HKEY hKey = NULL;
118 
120  {
121  TCHAR szBuffer[MAX_PATH];
122 
124  ComboBox_GetText(hWnd, szBuffer, MAX_PATH);
125 
126  if(*szBuffer != '\0')
127  RegSetValueEx(hKey, _T("Font"), 0, REG_SZ, (LPBYTE) szBuffer, (DWORD) MAX_PATH);
128 
130  ComboBox_GetText(hWnd, szBuffer, MAX_PATH);
131 
132  if(*szBuffer != '\0')
133  RegSetValueEx(hKey, _T("CodePage"), 0, REG_SZ, (LPBYTE) szBuffer, (DWORD) MAX_PATH);
134 
135  RegSetValueEx(hKey, _T("Advanced"), 0, REG_DWORD, (LPBYTE)&Settings.IsAdvancedView, (DWORD) sizeof(DWORD));
136 
137  RegCloseKey(hKey);
138  }
139 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define HKEY_CURRENT_USER
Definition: winreg.h:11
HWND hWnd
Definition: settings.c:17
#define ComboBox_GetText(hwndCtl, lpch, cchMax)
Definition: windowsx.h:33
#define IDC_COMBO_CHARSET
Definition: resource.h:21
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_POWER_POLICY_IDLE_SETTINGS Settings
Definition: wdfdevice.h:2592
unsigned char * LPBYTE
Definition: typedefs.h:53
const TCHAR g_szGeneralRegKey[]
Definition: settings.c:16
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IDC_FONTCOMBO
Definition: resource.h:12
FxAutoRegKey hKey
#define NULL
Definition: types.h:112
HWND hCharmapDlg
Definition: charmap.c:22
#define REG_DWORD
Definition: sdbapi.c:596
#define RegCloseKey(hKey)
Definition: registry.h:47
#define RegSetValueEx
Definition: winreg.h:533
#define RegCreateKeyEx
Definition: winreg.h:501
#define REG_SZ
Definition: layer.c:22

◆ SaveStringToRegistry()

LONG SaveStringToRegistry ( IN LPCWSTR  lpValueDataName,
IN LPCWSTR  lpValueData,
IN UINT  cchCount 
)

Definition at line 165 of file settings.c.

168 {
169  HKEY hKey;
170  LONG lResult;
171 
172  /* Set up the application's key in case it has not been made yet */
174  L"Software\\Microsoft\\Osk",
175  0,
176  NULL,
177  0,
178  KEY_WRITE,
179  NULL,
180  &hKey,
181  NULL);
182 
183  if (lResult != ERROR_SUCCESS)
184  {
185  /* Bail out */
186  DPRINT("SaveStringToRegistry(): Failed to create the application's key! (Error - %li)\n", lResult);
187  return lResult;
188  }
189 
190  /* Save the data into the registry value */
191  lResult = RegSetValueExW(hKey,
192  lpValueDataName,
193  0,
194  REG_SZ,
195  (BYTE *)lpValueData,
196  cchCount * sizeof(WCHAR));
197 
198  if (lResult != ERROR_SUCCESS)
199  {
200  /* Bail out */
201  DPRINT("SaveStringToRegistry(): Failed to save the following value - \"%S\". (Error - %li)\n", lpValueDataName, lResult);
202  RegCloseKey(hKey);
203  return lResult;
204  }
205 
206  RegCloseKey(hKey);
207  return lResult;
208 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define HKEY_CURRENT_USER
Definition: winreg.h:11
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1091
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
#define KEY_WRITE
Definition: nt_native.h:1031
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4899
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned char BYTE
Definition: xxhash.c:193
FxAutoRegKey hKey
#define NULL
Definition: types.h:112
#define DPRINT
Definition: sndvol32.h:71
#define RegCloseKey(hKey)
Definition: registry.h:47
#define REG_SZ
Definition: layer.c:22

Referenced by SaveSettings().

◆ wWinMain()

int WINAPI wWinMain ( HINSTANCE  ,
HINSTANCE  ,
LPWSTR  ,
int   
)

Definition at line 670 of file charmap.c.

674 {
676  INT Ret = 1;
677  HMODULE hRichEd20;
678  MSG Msg;
679 
680  hInstance = hInst;
681 
682  /* Mirroring code for the titlebar */
683  switch (GetUserDefaultUILanguage())
684  {
687  break;
688 
689  default:
690  break;
691  }
692 
693  iccx.dwSize = sizeof(INITCOMMONCONTROLSEX);
694  iccx.dwICC = ICC_TAB_CLASSES;
695  InitCommonControlsEx(&iccx);
696 
698  {
699  hRichEd20 = LoadLibraryW(L"RICHED20.DLL");
700 
701  if (hRichEd20 != NULL)
702  {
704 
705  for (;;)
706  {
707  if (GetMessage(&Msg, NULL, 0, 0) <= 0)
708  {
709  Ret = Msg.wParam;
710  break;
711  }
712 
715  }
716 
717  FreeLibrary(hRichEd20);
718  }
720  }
721 
722  return Ret;
723 }
#define DispatchMessage
Definition: winuser.h:5745
LANGID WINAPI GetUserDefaultUILanguage(void)
Definition: lang.c:810
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define LAYOUT_RTL
Definition: wingdi.h:1371
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define SUBLANG_DEFAULT
Definition: nls.h:168
struct tagINITCOMMONCONTROLSEX INITCOMMONCONTROLSEX
int32_t INT
Definition: typedefs.h:58
#define LANG_HEBREW
Definition: nls.h:67
static HWND InitInstance(HINSTANCE hInst)
Definition: charmap.c:607
HINSTANCE hInstance
Definition: charmap.c:20
#define L(x)
Definition: ntvdm.h:50
VOID UnregisterMapClasses(HINSTANCE hInstance)
Definition: map.c:741
#define LoadLibraryW(x)
Definition: compat.h:606
BOOL WINAPI SetProcessDefaultLayout(DWORD dwDefaultLayout)
Definition: window.c:1720
#define FreeLibrary(x)
Definition: compat.h:607
BOOL WINAPI InitCommonControlsEx(const INITCOMMONCONTROLSEX *lpInitCtrls)
Definition: commctrl.c:893
BOOL RegisterMapClasses(HINSTANCE hInstance)
Definition: map.c:715
HINSTANCE hInst
Definition: dxdiag.c:13
#define NULL
Definition: types.h:112
#define GetMessage
Definition: winuser.h:5770
struct @1589 Msg[]
#define MAKELANGID(p, s)
Definition: nls.h:15
#define ICC_TAB_CLASSES
Definition: commctrl.h:61

Variable Documentation

◆ EnhancedKeyboard

KEYBOARD_STRUCT EnhancedKeyboard

Definition at line 227 of file keyboard.c.

Referenced by OSK_SetKeys().

◆ Globals

OSK_GLOBALS Globals

Definition at line 13 of file clipbrd.c.

◆ StandardKeyboard

KEYBOARD_STRUCT StandardKeyboard

Definition at line 240 of file keyboard.c.

Referenced by OSK_SetKeys().