ReactOS  0.4.14-dev-1276-g8aa58c1
precomp.h File Reference
#include <stdio.h>
#include <windows.h>
#include <commctrl.h>
#include <debug.h>
#include <uxtheme.h>
#include <vsstyle.h>
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "winnls.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  OSK_GLOBALS
 
struct  OSK_KEYLEDINDICATOR
 

Macros

#define countof(x)   (sizeof(x) / sizeof((x)[0]))
 
#define MAX_BUFF   256
 

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)
 
VOID OSK_RestoreDlgPlacement (HWND hDlg)
 
VOID OSK_RefreshLEDKeys (VOID)
 
INT_PTR CALLBACK OSK_WarningProc (HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
 
LONG LoadDataFromRegistry (IN LPCWSTR lpValueDataName, OUT PDWORD pdwValueData)
 
LONG SaveDataToRegistry (IN LPCWSTR lpValueDataName, IN DWORD dwValueData)
 
VOID LoadSettings (VOID)
 
VOID SaveSettings (VOID)
 

Variables

OSK_GLOBALS Globals
 

Macro Definition Documentation

◆ countof

#define countof (   x)    (sizeof(x) / sizeof((x)[0]))

Definition at line 87 of file precomp.h.

◆ MAX_BUFF

#define MAX_BUFF   256

Definition at line 88 of file precomp.h.

Function Documentation

◆ LoadDataFromRegistry()

LONG LoadDataFromRegistry ( IN LPCWSTR  lpValueDataName,
OUT PDWORD  pdwValueData 
)

Definition at line 14 of file settings.c.

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

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 
99  RegCloseKey(hKey);
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
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define SendDlgItemMessage
Definition: winuser.h:5817
#define IDC_COMBO_CHARSET
Definition: resource.h:21
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define ComboBox_FindStringExact(hwndCtl, indexStart, lpszFind)
Definition: windowsx.h:22
unsigned char * LPBYTE
Definition: typedefs.h:53
const TCHAR g_szGeneralRegKey[]
Definition: settings.c:16
smooth NULL
Definition: ftsmooth.c:416
#define CB_ERR
Definition: winuser.h:2410
#define MF_CHECKED
Definition: winuser.h:132
char TCHAR
Definition: xmlstorage.h:189
#define BM_CLICK
Definition: winuser.h:1899
#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:26
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:113
LONG QueryStringValue(HKEY hKey, LPCTSTR lpSubKey, LPCTSTR lpValueName, LPTSTR pszBuffer, DWORD dwBufferLen)
Definition: settings.c:19
#define RegOpenKeyEx
Definition: winreg.h:520
HWND hCharmapDlg
Definition: charmap.c:22
#define REG_DWORD
Definition: sdbapi.c:596

◆ OSK_DlgClose()

int OSK_DlgClose ( void  )

Definition at line 270 of file main.c.

271 {
273 
274  /* Release Ctrl, Shift, Alt keys */
275  OSK_ReleaseKey(SCAN_CODE_44); // Left shift
276  OSK_ReleaseKey(SCAN_CODE_57); // Right shift
277  OSK_ReleaseKey(SCAN_CODE_58); // Left ctrl
278  OSK_ReleaseKey(SCAN_CODE_60); // Left alt
279  OSK_ReleaseKey(SCAN_CODE_62); // Right alt
280  OSK_ReleaseKey(SCAN_CODE_64); // Right ctrl
281 
282  /* delete GDI objects */
283  if (Globals.hBrushGreenLed) DeleteObject(Globals.hBrushGreenLed);
284 
285  /* Save the application's settings on registry */
286  SaveSettings();
287 
288  return TRUE;
289 }
#define TRUE
Definition: types.h:120
#define SCAN_CODE_60
Definition: osk_res.h:118
NOTEPAD_GLOBALS Globals
Definition: main.c:31
#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:455
#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 346 of file main.c.

347 {
348  WORD ScanCode;
349  INPUT Input;
350  BOOL bExtendedKey;
351  BOOL bKeyDown;
352  BOOL bKeyUp;
353  LONG WindowStyle;
354  INT i;
355 
356  /* FIXME: To be deleted when ReactOS will support WS_EX_NOACTIVATE */
357  if (Globals.hActiveWnd)
358  {
359  MSG msg;
360 
361  SetForegroundWindow(Globals.hActiveWnd);
362  while (PeekMessageW(&msg, 0, 0, 0, PM_REMOVE))
363  {
366  }
367  }
368 
369  /* KeyDown and/or KeyUp ? */
370  WindowStyle = GetWindowLongW(hWndControl, GWL_STYLE);
371  if ((WindowStyle & BS_AUTOCHECKBOX) == BS_AUTOCHECKBOX)
372  {
373  /* 2-states key like Shift, Alt, Ctrl, ... */
374  if (SendMessageW(hWndControl, BM_GETCHECK, 0, 0) == BST_CHECKED)
375  {
376  bKeyDown = TRUE;
377  bKeyUp = FALSE;
378  }
379  else
380  {
381  bKeyDown = FALSE;
382  bKeyUp = TRUE;
383  }
384  }
385  else
386  {
387  /* Other key */
388  bKeyDown = TRUE;
389  bKeyUp = TRUE;
390  }
391 
392  /* Get the key from dialog control key command */
393  ScanCode = wCommand;
394 
395  /*
396  The user could've pushed one of the key buttons of the dialog that
397  can trigger particular function toggling (Caps Lock, Num Lock or Scroll Lock). Update
398  (invalidate) the LED icon resources accordingly.
399  */
400  for (i = 0; i < _countof(LedKey); i++)
401  {
402  if (LedKey[i].wScanCode == ScanCode)
403  {
405  }
406  }
407 
408  /* Extended key ? */
409  if (ScanCode & 0x0200)
410  bExtendedKey = TRUE;
411  else
412  bExtendedKey = FALSE;
413  ScanCode &= 0xFF;
414 
415  /* Press and release the key */
416  if (bKeyDown)
417  {
418  Input.type = INPUT_KEYBOARD;
419  Input.ki.wVk = 0;
420  Input.ki.wScan = ScanCode;
421  Input.ki.time = GetTickCount();
422  Input.ki.dwExtraInfo = GetMessageExtraInfo();
423  Input.ki.dwFlags = KEYEVENTF_SCANCODE;
424  if (bExtendedKey) Input.ki.dwFlags |= KEYEVENTF_EXTENDEDKEY;
425  SendInput(1, &Input, sizeof(Input));
426  }
427 
428  if (bKeyUp)
429  {
430  Input.type = INPUT_KEYBOARD;
431  Input.ki.wVk = 0;
432  Input.ki.wScan = ScanCode;
433  Input.ki.time = GetTickCount();
434  Input.ki.dwExtraInfo = GetMessageExtraInfo();
435  Input.ki.dwFlags = KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP;
436  if (bExtendedKey) Input.ki.dwFlags |= KEYEVENTF_EXTENDEDKEY;
437  SendInput(1, &Input, sizeof(Input));
438  }
439 
440  /* Play the sound during clicking event (only if "Use Click Sound" menu option is ticked) */
441  if (Globals.bSoundClick)
442  {
444  }
445 
446  return TRUE;
447 }
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define TRUE
Definition: types.h:120
NOTEPAD_GLOBALS Globals
Definition: main.c:31
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:455
Definition: arc.h:84
int32_t INT
Definition: typedefs.h:57
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 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:1900
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:3667
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
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 130 of file main.c.

131 {
133  HMONITOR monitor;
135  POINT Pt;
136  RECT rcWindow, rcDlgIntersect;
137 
138  /* Save handle */
139  Globals.hMainWnd = hDlg;
140 
141  /* Check the checked menu item before displaying the modal box */
142  if (Globals.bIsEnhancedKeyboard)
143  {
144  /* Enhanced keyboard dialog chosen, set the respective menu item as checked */
147  }
148  else
149  {
150  /* Standard keyboard dialog chosen, set the respective menu item as checked */
153  }
154 
155  /* Check if the "Click Sound" option was chosen before (and if so, then tick the menu item) */
156  if (Globals.bSoundClick)
157  {
159  }
160 
161  /* Set the application's icon */
164  if (hIcon || hIconSm)
165  {
166  /* Set the window icons (they are deleted when the process terminates) */
169  }
170 
171  /* Get screen info */
172  memset(&Pt, 0, sizeof(Pt));
173  monitor = MonitorFromPoint(Pt, MONITOR_DEFAULTTOPRIMARY);
174  info.cbSize = sizeof(info);
175  GetMonitorInfoW(monitor, &info);
176  GetWindowRect(hDlg, &rcWindow);
177 
178  /*
179  If the coordination values are default then re-initialize using the specific formulas
180  to move the dialog at the bottom of the screen.
181  */
182  if (Globals.PosX == CW_USEDEFAULT && Globals.PosY == CW_USEDEFAULT)
183  {
184  Globals.PosX = (info.rcMonitor.left + info.rcMonitor.right - (rcWindow.right - rcWindow.left)) / 2;
185  Globals.PosY = info.rcMonitor.bottom - (rcWindow.bottom - rcWindow.top);
186  }
187 
188  /*
189  Calculate the intersection of two rectangle sources (dialog and work desktop area).
190  If such sources do not intersect, then the dialog is deemed as "off screen".
191  */
192  if (IntersectRect(&rcDlgIntersect, &rcWindow, &info.rcWork) == 0)
193  {
194  Globals.PosX = (info.rcMonitor.left + info.rcMonitor.right - (rcWindow.right - rcWindow.left)) / 2;
195  Globals.PosY = info.rcMonitor.bottom - (rcWindow.bottom - rcWindow.top);
196  }
197  else
198  {
199  /*
200  There's still some intersection but we're not for sure if it is sufficient (the dialog could also be partially hidden).
201  Therefore, check the remaining intersection if it's enough.
202  */
203  if (rcWindow.top < info.rcWork.top || rcWindow.left < info.rcWork.left || rcWindow.right > info.rcWork.right || rcWindow.bottom > info.rcWork.bottom)
204  {
205  Globals.PosX = (info.rcMonitor.left + info.rcMonitor.right - (rcWindow.right - rcWindow.left)) / 2;
206  Globals.PosY = info.rcMonitor.bottom - (rcWindow.bottom - rcWindow.top);
207  }
208  }
209 
210  /*
211  Place the window (with respective placement coordinates) as topmost, above
212  every window which are not on top or are at the bottom of the Z order.
213  */
214  if (Globals.bAlwaysOnTop)
215  {
217  SetWindowPos(hDlg, HWND_TOPMOST, Globals.PosX, Globals.PosY, 0, 0, SWP_NOSIZE);
218  }
219  else
220  {
222  SetWindowPos(hDlg, HWND_NOTOPMOST, Globals.PosX, Globals.PosY, 0, 0, SWP_NOSIZE);
223  }
224 
225  /* Set icon on visual buttons */
242 
243  /* Create a green brush for leds */
244  Globals.hBrushGreenLed = CreateSolidBrush(RGB(0, 255, 0));
245 
246  /* Set a timer for periodics tasks */
247  Globals.iTimer = SetTimer(hDlg, 0, 50, NULL);
248 
249  return TRUE;
250 }
#define SCAN_CODE_30
Definition: osk_res.h:90
HMONITOR WINAPI MonitorFromPoint(POINT, DWORD)
static HICON
Definition: imagelist.c:84
#define TRUE
Definition: types.h:120
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 SCAN_CODE_128
Definition: osk_res.h:167
#define IDI_PG_UP
Definition: osk_res.h:27
#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
struct _test_info info[]
Definition: SetCursorPos.c:19
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
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 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)
#define RGB(r, g, b)
Definition: wingdi.h:2939
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: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:1230
#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
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 572 of file main.c.

573 {
574  switch (msg)
575  {
576  case WM_INITDIALOG:
577  OSK_DlgInitDialog(hDlg);
578  return TRUE;
579 
580  case WM_TIMER:
581  OSK_DlgTimer();
582  return TRUE;
583 
584  case WM_NOTIFY:
585  return OSK_ThemeHandler(hDlg, (LPNMCUSTOMDRAW)lParam);
586 
587  case WM_CTLCOLORSTATIC:
588  if ((HWND)lParam == GetDlgItem(hDlg, IDC_LED_NUM))
589  {
590  if (GetKeyState(VK_NUMLOCK) & 0x0001)
591  return (INT_PTR)Globals.hBrushGreenLed;
592  else
594  }
595  if ((HWND)lParam == GetDlgItem(hDlg, IDC_LED_CAPS))
596  {
597  if (GetKeyState(VK_CAPITAL) & 0x0001)
598  return (INT_PTR)Globals.hBrushGreenLed;
599  else
601  }
602  if ((HWND)lParam == GetDlgItem(hDlg, IDC_LED_SCROLL))
603  {
604  if (GetKeyState(VK_SCROLL) & 0x0001)
605  return (INT_PTR)Globals.hBrushGreenLed;
606  else
608  }
609  break;
610 
611  case WM_COMMAND:
612  switch (LOWORD(wParam))
613  {
614  case IDCANCEL:
615  {
616  EndDialog(hDlg, FALSE);
617  break;
618  }
619 
620  case IDM_EXIT:
621  {
622  EndDialog(hDlg, FALSE);
623  break;
624  }
625 
626  case IDM_ENHANCED_KB:
627  {
628  if (!Globals.bIsEnhancedKeyboard)
629  {
630  /*
631  The user attempted to switch to enhanced keyboard dialog type.
632  Set the member value as TRUE, destroy the dialog and save the data configuration into the registry.
633  */
634  Globals.bIsEnhancedKeyboard = TRUE;
635  EndDialog(hDlg, FALSE);
636  SaveSettings();
637 
638  /* Change the condition of enhanced keyboard item menu to checked */
641 
642  /*
643  Before creating the dialog box restore the coordinates. The user can
644  move the dialog around before choosing a different dialog layout therefore
645  we must create the dialog with the new coordinates.
646  */
648 
649  /* Finally, display the dialog modal box with the enhanced keyboard dialog */
653  OSK_DlgProc);
654  }
655 
656  break;
657  }
658 
659  case IDM_STANDARD_KB:
660  {
661  if (Globals.bIsEnhancedKeyboard)
662  {
663  /*
664  The user attempted to switch to standard keyboard dialog type.
665  Set the member value as FALSE, destroy the dialog and save the data configuration into the registry.
666  */
667  Globals.bIsEnhancedKeyboard = FALSE;
668  EndDialog(hDlg, FALSE);
669  SaveSettings();
670 
671  /* Change the condition of standard keyboard item menu to checked */
674 
675  /*
676  Before creating the dialog box restore the coordinates. The user can
677  move the dialog around before choosing a different dialog layout therefore
678  we must create the dialog with the new coordinates.
679  */
681 
682  /* Finally, display the dialog modal box with the standard keyboard dialog */
686  OSK_DlgProc);
687  }
688 
689  break;
690  }
691 
692  case IDM_CLICK_SOUND:
693  {
694  /*
695  This case is triggered when the user attempts to click on the menu item. Before doing anything,
696  we must check the condition state of such menu item so that we can tick/untick the menu item accordingly.
697  */
698  if (!Globals.bSoundClick)
699  {
700  Globals.bSoundClick = TRUE;
702  }
703  else
704  {
705  Globals.bSoundClick = FALSE;
707  }
708 
709  break;
710  }
711 
712  case IDM_ON_TOP:
713  {
714  /*
715  Check the condition state before disabling/enabling the menu
716  item and change the topmost order.
717  */
718  if (!Globals.bAlwaysOnTop)
719  {
720  Globals.bAlwaysOnTop = TRUE;
722  SetWindowPos(hDlg, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
723  }
724  else
725  {
726  Globals.bAlwaysOnTop = FALSE;
728  SetWindowPos(hDlg, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
729  }
730 
731  break;
732  }
733 
734  case IDM_ABOUT:
735  {
736  OSK_About();
737  break;
738  }
739 
740  default:
742  break;
743  }
744  break;
745 
746  case WM_THEMECHANGED:
747  /* Redraw the dialog (and its control buttons) using the new theme */
748  InvalidateRect(hDlg, NULL, FALSE);
749  break;
750 
751  case WM_CLOSE:
752  OSK_DlgClose();
753  break;
754  }
755 
756  return 0;
757 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
INT_PTR APIENTRY OSK_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: main.c:572
int OSK_DlgClose(void)
Definition: main.c:270
#define TRUE
Definition: types.h:120
NOTEPAD_GLOBALS Globals
Definition: main.c:31
#define MF_BYCOMMAND
Definition: winuser.h:202
#define IDM_ABOUT
Definition: resource.h:29
#define WM_CTLCOLORSTATIC
Definition: winuser.h:1754
#define MAIN_DIALOG_STANDARD_KB
Definition: osk_res.h:9
#define HWND_TOPMOST
Definition: winuser.h:1194
int32_t INT_PTR
Definition: typedefs.h:63
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:130
void SaveSettings(void)
Definition: settings.c:115
#define IDC_LED_CAPS
Definition: osk_res.h:14
LRESULT APIENTRY OSK_ThemeHandler(HWND hDlg, NMCUSTOMDRAW *pNmDraw)
Definition: main.c:496
smooth NULL
Definition: ftsmooth.c:416
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:4374
SHORT WINAPI GetKeyState(_In_ int)
#define BLACK_BRUSH
Definition: wingdi.h:895
#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:346
#define IDM_ENHANCED_KB
Definition: osk_res.h:37
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define WM_TIMER
Definition: winuser.h:1724
#define WM_CLOSE
Definition: winuser.h:1603
int OSK_DlgTimer(void)
Definition: main.c:320
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:1722
#define MF_UNCHECKED
Definition: winuser.h:204
#define SWP_NOSIZE
Definition: winuser.h:1230
VOID OSK_About(VOID)
Definition: main.c:103
#define VK_SCROLL
Definition: winuser.h:2255
#define VK_NUMLOCK
Definition: winuser.h:2254
#define MAIN_DIALOG_ENHANCED_KB
Definition: osk_res.h:8
#define VK_CAPITAL
Definition: winuser.h:2181
#define IDM_EXIT
Definition: resource.h:27
#define msg(x)
Definition: auth_time.c:54
#define SWP_NOMOVE
Definition: winuser.h:1229
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:258
HMENU WINAPI GetMenu(_In_ HWND)
#define WM_INITDIALOG
Definition: winuser.h:1721
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 320 of file main.c.

321 {
322  /* FIXME: To be deleted when ReactOS will support WS_EX_NOACTIVATE */
323  HWND hWndActiveWindow;
324 
325  hWndActiveWindow = GetForegroundWindow();
326  if (hWndActiveWindow != NULL && hWndActiveWindow != Globals.hMainWnd)
327  {
328  Globals.hActiveWnd = hWndActiveWindow;
329  }
330 
331  /*
332  Update the LED key indicators accordingly to their state (if one
333  of the specific keys is held down).
334  */
336 
337  return TRUE;
338 }
#define TRUE
Definition: types.h:120
NOTEPAD_GLOBALS Globals
Definition: main.c:31
smooth NULL
Definition: ftsmooth.c:416
VOID OSK_RefreshLEDKeys(VOID)
Definition: main.c:298
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 298 of file main.c.

299 {
300  INT i;
301  BOOL bKeyIsPressed;
302 
303  for (i = 0; i < _countof(LedKey); i++)
304  {
305  bKeyIsPressed = (GetAsyncKeyState(LedKey[i].vKey) & 0x8000) != 0;
306  if (LedKey[i].bWasKeyPressed != bKeyIsPressed)
307  {
308  LedKey[i].bWasKeyPressed = bKeyIsPressed;
310  }
311  }
312 }
NOTEPAD_GLOBALS Globals
Definition: main.c:31
int32_t INT
Definition: typedefs.h:57
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
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
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)
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 455 of file main.c.

456 {
457  INPUT Input;
458  BOOL bExtendedKey;
459  LONG WindowStyle;
460  HWND hWndControl;
461 
462  /* Is it a 2-states key ? */
463  hWndControl = GetDlgItem(Globals.hMainWnd, ScanCode);
464  WindowStyle = GetWindowLongW(hWndControl, GWL_STYLE);
465  if ((WindowStyle & BS_AUTOCHECKBOX) != BS_AUTOCHECKBOX) return FALSE;
466 
467  /* Is the key down ? */
468  if (SendMessageW(hWndControl, BM_GETCHECK, 0, 0) != BST_CHECKED) return TRUE;
469 
470  /* Extended key ? */
471  if (ScanCode & 0x0200)
472  bExtendedKey = TRUE;
473  else
474  bExtendedKey = FALSE;
475  ScanCode &= 0xFF;
476 
477  /* Release the key */
478  Input.type = INPUT_KEYBOARD;
479  Input.ki.wVk = 0;
480  Input.ki.wScan = ScanCode;
481  Input.ki.time = GetTickCount();
482  Input.ki.dwExtraInfo = GetMessageExtraInfo();
483  Input.ki.dwFlags = KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP;
484  if (bExtendedKey) Input.ki.dwFlags |= KEYEVENTF_EXTENDEDKEY;
485  SendInput(1, &Input, sizeof(Input));
486 
487  return TRUE;
488 }
#define TRUE
Definition: types.h:120
NOTEPAD_GLOBALS Globals
Definition: main.c:31
ULONG ScanCode
Definition: api.c:39
#define KEYEVENTF_KEYUP
Definition: winuser.h:1092
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
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:1900
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 258 of file main.c.

259 {
260  LoadSettings();
261  SetWindowPos(hDlg, (Globals.bAlwaysOnTop ? HWND_TOPMOST : HWND_NOTOPMOST), Globals.PosX, Globals.PosY, 0, 0, SWP_NOSIZE);
262 }
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: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

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
#define TRUE
Definition: types.h:120
NOTEPAD_GLOBALS Globals
Definition: main.c:31
#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:1904
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 496 of file main.c.

497 {
498  HTHEME hTheme;
499  HWND hDlgButtonCtrl;
500  LRESULT Ret;
501  INT iState = PBS_NORMAL;
502 
503  /* Retrieve the theme handle for the button controls */
504  hDlgButtonCtrl = pNmDraw->hdr.hwndFrom;
505  hTheme = GetWindowTheme(hDlgButtonCtrl);
506 
507  /*
508  Begin the painting procedures if we retrieved
509  the theme for control buttons of the dialog.
510  */
511  if (hTheme)
512  {
513  /* Obtain CDDS drawing stages */
514  switch (pNmDraw->dwDrawStage)
515  {
516  case CDDS_PREPAINT:
517  {
518  /*
519  The button could be either in normal state or pushed.
520  Retrieve its state and save to a variable.
521  */
522  if (pNmDraw->uItemState & CDIS_DEFAULT)
523  {
524  iState = PBS_DEFAULTED;
525  }
526  else if (pNmDraw->uItemState & CDIS_SELECTED)
527  {
528  iState = PBS_PRESSED;
529  }
530  else if (pNmDraw->uItemState & CDIS_HOT)
531  {
532  iState = PBS_HOT;
533  }
534 
536  {
537  /* Draw the application if the theme is transparent */
538  DrawThemeParentBackground(hDlgButtonCtrl, pNmDraw->hdc, &pNmDraw->rc);
539  }
540 
541  /* Draw it */
542  DrawThemeBackground(hTheme, pNmDraw->hdc, BP_PUSHBUTTON, iState, &pNmDraw->rc, NULL);
543 
544  Ret = CDRF_SKIPDEFAULT;
545  break;
546  }
547 
548  case CDDS_PREERASE:
549  {
550  Ret = CDRF_DODEFAULT;
551  break;
552  }
553 
554  default:
555  Ret = CDRF_SKIPDEFAULT;
556  break;
557  }
558  }
559  else
560  {
561  /* hTheme is NULL so bail right away */
562  Ret = CDRF_DODEFAULT;
563  }
564 
565  return Ret;
566 }
static HTHEME(WINAPI *pOpenThemeDataEx)(HWND
#define CDRF_SKIPDEFAULT
Definition: commctrl.h:266
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:57
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:287
HRESULT WINAPI DrawThemeParentBackground(HWND hwnd, HDC hdc, RECT *prc)
Definition: draw.c:72
#define CDIS_HOT
Definition: commctrl.h:293
#define CDRF_DODEFAULT
Definition: commctrl.h:264
HTHEME WINAPI GetWindowTheme(HWND hwnd)
Definition: system.c:851
#define CDDS_PREPAINT
Definition: commctrl.h:276
HWND hwndFrom
Definition: winuser.h:3132
LONG_PTR LRESULT
Definition: windef.h:209
#define CDIS_DEFAULT
Definition: commctrl.h:292
#define CDDS_PREERASE
Definition: commctrl.h:278

Referenced by OSK_DlgProc().

◆ 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 TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
NOTEPAD_GLOBALS Globals
Definition: main.c:31
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define IDC_SHOWWARNINGCHECK
Definition: resource.h:25
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
UINT WINAPI IsDlgButtonChecked(_In_ HWND, _In_ int)
#define WM_COMMAND
Definition: winuser.h:1722
struct @1587 Msg[]
#define IDCANCEL
Definition: winuser.h:825
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82

Referenced by wWinMain().

◆ SaveDataToRegistry()

LONG SaveDataToRegistry ( IN LPCWSTR  lpValueDataName,
IN DWORD  dwValueData 
)

Definition at line 70 of file settings.c.

72 {
73  HKEY hKey;
74  LONG lResult;
75 
76  /* Set up the application's key in case it has not been made yet */
78  L"Software\\Microsoft\\Osk",
79  0,
80  NULL,
81  0,
82  KEY_WRITE,
83  NULL,
84  &hKey,
85  NULL);
86 
87  if (lResult != ERROR_SUCCESS)
88  {
89  /* Bail out */
90  DPRINT("SaveDataToRegistry(): Failed to create the application's key! (Error - %li)\n", lResult);
91  return lResult;
92  }
93 
94  /* Save the data into the registry value */
95  lResult = RegSetValueExW(hKey,
96  lpValueDataName,
97  0,
98  REG_DWORD,
99  (BYTE *)&dwValueData,
100  sizeof(dwValueData));
101 
102  if (lResult != ERROR_SUCCESS)
103  {
104  /* Bail out */
105  DPRINT("SaveDataToRegistry(): Failed to save the following value - \"%S\". (Error - %li)\n", lpValueDataName, lResult);
106  RegCloseKey(hKey);
107  return lResult;
108  }
109 
110  RegCloseKey(hKey);
111  return lResult;
112 }
#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
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#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:4895
static const WCHAR L[]
Definition: oid.c:1250
unsigned char BYTE
Definition: mem.h:68
#define REG_DWORD
Definition: sdbapi.c:596

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
SSSTARS Settings
Definition: settings.c:33
#define IDC_COMBO_CHARSET
Definition: resource.h:21
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
const TCHAR g_szGeneralRegKey[]
Definition: settings.c:16
smooth NULL
Definition: ftsmooth.c:416
#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:26
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IDC_FONTCOMBO
Definition: resource.h:12
HWND hCharmapDlg
Definition: charmap.c:22
#define REG_DWORD
Definition: sdbapi.c:596
#define RegSetValueEx
Definition: winreg.h:533
#define RegCreateKeyEx
Definition: winreg.h:501
#define REG_SZ
Definition: layer.c:22

◆ wWinMain()

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

Definition at line 580 of file charmap.c.

584 {
586  INT Ret = 1;
587  HMODULE hRichEd20;
588  MSG Msg;
589 
590  hInstance = hInst;
591 
592  /* Mirroring code for the titlebar */
593  switch (GetUserDefaultUILanguage())
594  {
597  break;
598 
599  default:
600  break;
601  }
602 
603  iccx.dwSize = sizeof(INITCOMMONCONTROLSEX);
604  iccx.dwICC = ICC_TAB_CLASSES;
605  InitCommonControlsEx(&iccx);
606 
608  {
609  hRichEd20 = LoadLibraryW(L"RICHED20.DLL");
610 
611  if (hRichEd20 != NULL)
612  {
614 
615  for (;;)
616  {
617  if (GetMessage(&Msg, NULL, 0, 0) <= 0)
618  {
619  Ret = Msg.wParam;
620  break;
621  }
622 
625  }
626 
627  FreeLibrary(hRichEd20);
628  }
630  }
631 
632  return Ret;
633 }
#define DispatchMessage
Definition: winuser.h:5740
LANGID WINAPI GetUserDefaultUILanguage(void)
Definition: lang.c:806
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define LAYOUT_RTL
Definition: wingdi.h:1370
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:57
#define LANG_HEBREW
Definition: nls.h:67
static HWND InitInstance(HINSTANCE hInst)
Definition: charmap.c:517
HINSTANCE hInstance
Definition: charmap.c:20
VOID UnregisterMapClasses(HINSTANCE hInstance)
Definition: map.c:672
#define LoadLibraryW(x)
Definition: compat.h:412
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI SetProcessDefaultLayout(DWORD dwDefaultLayout)
Definition: window.c:1720
#define FreeLibrary(x)
Definition: compat.h:413
static const WCHAR L[]
Definition: oid.c:1250
BOOL WINAPI InitCommonControlsEx(const INITCOMMONCONTROLSEX *lpInitCtrls)
Definition: commctrl.c:893
BOOL RegisterMapClasses(HINSTANCE hInstance)
Definition: map.c:646
HINSTANCE hInst
Definition: dxdiag.c:13
#define GetMessage
Definition: winuser.h:5765
struct @1587 Msg[]
#define MAKELANGID(p, s)
Definition: nls.h:15
#define ICC_TAB_CLASSES
Definition: commctrl.h:61

Variable Documentation

◆ Globals

OSK_GLOBALS Globals

Definition at line 13 of file clipbrd.c.