mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 15:33:07 +00:00
[OSK]
- Fix some coding style (whitespace): this is not win32k!! - Remove unneeded headers. svn path=/trunk/; revision=65569
This commit is contained in:
parent
e86551f057
commit
a381da464a
4 changed files with 270 additions and 290 deletions
|
@ -1,14 +1,17 @@
|
||||||
/*
|
/*
|
||||||
* PROJECT: ReactOS Kernel
|
* PROJECT: ReactOS On-Screen Keyboard
|
||||||
* LICENSE: GPL - See COPYING in the top level directory
|
* LICENSE: GPL - See COPYING in the top level directory
|
||||||
* FILE: base/applications/osk/main.c
|
* FILE: base/applications/osk/main.c
|
||||||
* PURPOSE: On screen keyboard.
|
* PURPOSE: On-screen keyboard.
|
||||||
* PROGRAMMERS: Denis ROBERT
|
* PROGRAMMERS: Denis ROBERT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* INCLUDES ******************************************************************/
|
/* INCLUDES *******************************************************************/
|
||||||
|
|
||||||
#include "osk.h"
|
#include "osk.h"
|
||||||
|
|
||||||
|
/* GLOBALS ********************************************************************/
|
||||||
|
|
||||||
OSK_GLOBALS Globals;
|
OSK_GLOBALS Globals;
|
||||||
|
|
||||||
/* Functions */
|
/* Functions */
|
||||||
|
@ -22,7 +25,7 @@ BOOL OSK_ReleaseKey(WORD ScanCode);
|
||||||
INT_PTR APIENTRY OSK_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
|
INT_PTR APIENTRY OSK_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||||
int WINAPI _tWinMain(HINSTANCE, HINSTANCE, LPTSTR, int);
|
int WINAPI _tWinMain(HINSTANCE, HINSTANCE, LPTSTR, int);
|
||||||
|
|
||||||
|
/* FUNCTIONS ******************************************************************/
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
*
|
*
|
||||||
|
@ -32,21 +35,21 @@ int WINAPI _tWinMain(HINSTANCE, HINSTANCE, LPTSTR, int);
|
||||||
*/
|
*/
|
||||||
int OSK_SetImage(int IdDlgItem, int IdResource)
|
int OSK_SetImage(int IdDlgItem, int IdResource)
|
||||||
{
|
{
|
||||||
HICON hIcon;
|
HICON hIcon;
|
||||||
HWND hWndItem;
|
HWND hWndItem;
|
||||||
|
|
||||||
hIcon = (HICON) LoadImage(Globals.hInstance, MAKEINTRESOURCE(IdResource),
|
hIcon = (HICON)LoadImage(Globals.hInstance, MAKEINTRESOURCE(IdResource),
|
||||||
IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
|
IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
|
||||||
if (hIcon == NULL) return FALSE;
|
if (hIcon == NULL) return FALSE;
|
||||||
|
|
||||||
hWndItem = GetDlgItem(Globals.hMainWnd, IdDlgItem);
|
hWndItem = GetDlgItem(Globals.hMainWnd, IdDlgItem);
|
||||||
if (hWndItem == NULL) return FALSE;
|
if (hWndItem == NULL) return FALSE;
|
||||||
|
|
||||||
SendMessage(hWndItem, BM_SETIMAGE, (WPARAM) IMAGE_ICON, (LPARAM) hIcon );
|
SendMessage(hWndItem, BM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)hIcon);
|
||||||
|
|
||||||
/* The system automatically deletes these resources when the process that created them terminates (msdn) */
|
/* The system automatically deletes these resources when the process that created them terminates (MSDN) */
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -58,57 +61,56 @@ int OSK_SetImage(int IdDlgItem, int IdResource)
|
||||||
*/
|
*/
|
||||||
int OSK_DlgInitDialog(HWND hDlg)
|
int OSK_DlgInitDialog(HWND hDlg)
|
||||||
{
|
{
|
||||||
HMONITOR monitor;
|
HMONITOR monitor;
|
||||||
MONITORINFO info;
|
MONITORINFO info;
|
||||||
POINT Pt;
|
POINT Pt;
|
||||||
RECT rcWindow;
|
RECT rcWindow;
|
||||||
|
|
||||||
/* Save handle */
|
/* Save handle */
|
||||||
Globals.hMainWnd = hDlg;
|
Globals.hMainWnd = hDlg;
|
||||||
|
|
||||||
/* Get screen info */
|
/* Get screen info */
|
||||||
memset(&Pt, 0, sizeof(Pt));
|
memset(&Pt, 0, sizeof(Pt));
|
||||||
monitor = MonitorFromPoint(Pt, MONITOR_DEFAULTTOPRIMARY );
|
monitor = MonitorFromPoint(Pt, MONITOR_DEFAULTTOPRIMARY );
|
||||||
info.cbSize = sizeof(info);
|
info.cbSize = sizeof(info);
|
||||||
GetMonitorInfoW(monitor, &info);
|
GetMonitorInfoW(monitor, &info);
|
||||||
|
|
||||||
/* Move the dialog on the bottom of main screen */
|
/* Move the dialog on the bottom of main screen */
|
||||||
GetWindowRect(hDlg, &rcWindow);
|
GetWindowRect(hDlg, &rcWindow);
|
||||||
MoveWindow(
|
MoveWindow(hDlg,
|
||||||
hDlg,
|
(info.rcMonitor.left + info.rcMonitor.right) / 2 - // Center of screen
|
||||||
(info.rcMonitor.left + info.rcMonitor.right) / 2 - // Center of screen
|
(rcWindow.right - rcWindow.left) / 2, // - half size of dialog
|
||||||
(rcWindow.right - rcWindow.left) / 2, // - half size of dialog
|
info.rcMonitor.bottom - // Bottom of screen
|
||||||
info.rcMonitor.bottom - // Bottom of screen
|
(rcWindow.bottom - rcWindow.top), // - size of window
|
||||||
(rcWindow.bottom - rcWindow.top), // - size of window
|
rcWindow.right - rcWindow.left, // Width
|
||||||
(rcWindow.right - rcWindow.left), // Width
|
rcWindow.bottom - rcWindow.top, // Height
|
||||||
(rcWindow.bottom - rcWindow.top), // Height
|
TRUE);
|
||||||
TRUE);
|
|
||||||
|
|
||||||
/* Set icon on visual buttons */
|
/* Set icon on visual buttons */
|
||||||
OSK_SetImage(SCAN_CODE_15, IDI_BACK);
|
OSK_SetImage(SCAN_CODE_15, IDI_BACK);
|
||||||
OSK_SetImage(SCAN_CODE_16, IDI_TAB);
|
OSK_SetImage(SCAN_CODE_16, IDI_TAB);
|
||||||
OSK_SetImage(SCAN_CODE_30, IDI_CAPS_LOCK);
|
OSK_SetImage(SCAN_CODE_30, IDI_CAPS_LOCK);
|
||||||
OSK_SetImage(SCAN_CODE_43, IDI_RETURN);
|
OSK_SetImage(SCAN_CODE_43, IDI_RETURN);
|
||||||
OSK_SetImage(SCAN_CODE_44, IDI_SHIFT);
|
OSK_SetImage(SCAN_CODE_44, IDI_SHIFT);
|
||||||
OSK_SetImage(SCAN_CODE_57, IDI_SHIFT);
|
OSK_SetImage(SCAN_CODE_57, IDI_SHIFT);
|
||||||
OSK_SetImage(SCAN_CODE_127, IDI_REACTOS);
|
OSK_SetImage(SCAN_CODE_127, IDI_REACTOS);
|
||||||
OSK_SetImage(SCAN_CODE_128, IDI_REACTOS);
|
OSK_SetImage(SCAN_CODE_128, IDI_REACTOS);
|
||||||
OSK_SetImage(SCAN_CODE_129, IDI_MENU);
|
OSK_SetImage(SCAN_CODE_129, IDI_MENU);
|
||||||
OSK_SetImage(SCAN_CODE_80, IDI_HOME);
|
OSK_SetImage(SCAN_CODE_80, IDI_HOME);
|
||||||
OSK_SetImage(SCAN_CODE_85, IDI_PG_UP);
|
OSK_SetImage(SCAN_CODE_85, IDI_PG_UP);
|
||||||
OSK_SetImage(SCAN_CODE_86, IDI_PG_DOWN);
|
OSK_SetImage(SCAN_CODE_86, IDI_PG_DOWN);
|
||||||
OSK_SetImage(SCAN_CODE_79, IDI_LEFT);
|
OSK_SetImage(SCAN_CODE_79, IDI_LEFT);
|
||||||
OSK_SetImage(SCAN_CODE_83, IDI_TOP);
|
OSK_SetImage(SCAN_CODE_83, IDI_TOP);
|
||||||
OSK_SetImage(SCAN_CODE_84, IDI_BOTTOM);
|
OSK_SetImage(SCAN_CODE_84, IDI_BOTTOM);
|
||||||
OSK_SetImage(SCAN_CODE_89, IDI_RIGHT);
|
OSK_SetImage(SCAN_CODE_89, IDI_RIGHT);
|
||||||
|
|
||||||
/* Create a green brush for leds */
|
/* Create a green brush for leds */
|
||||||
Globals.hBrushGreenLed = CreateSolidBrush(RGB(0, 255, 0));
|
Globals.hBrushGreenLed = CreateSolidBrush(RGB(0, 255, 0));
|
||||||
|
|
||||||
/* Set a timer for periodics tasks */
|
/* Set a timer for periodics tasks */
|
||||||
Globals.iTimer = SetTimer(hDlg, 0, 200, NULL);
|
Globals.iTimer = SetTimer(hDlg, 0, 200, NULL);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
@ -119,21 +121,20 @@ int OSK_DlgInitDialog(HWND hDlg)
|
||||||
*/
|
*/
|
||||||
int OSK_DlgClose(void)
|
int OSK_DlgClose(void)
|
||||||
{
|
{
|
||||||
|
KillTimer(Globals.hMainWnd, Globals.iTimer);
|
||||||
|
|
||||||
KillTimer(Globals.hMainWnd, Globals.iTimer);
|
/* Release Ctrl, Shift, Alt keys */
|
||||||
|
OSK_ReleaseKey(SCAN_CODE_44); // Left shift
|
||||||
|
OSK_ReleaseKey(SCAN_CODE_57); // Right shift
|
||||||
|
OSK_ReleaseKey(SCAN_CODE_58); // Left ctrl
|
||||||
|
OSK_ReleaseKey(SCAN_CODE_60); // Left alt
|
||||||
|
OSK_ReleaseKey(SCAN_CODE_62); // Right alt
|
||||||
|
OSK_ReleaseKey(SCAN_CODE_64); // Right ctrl
|
||||||
|
|
||||||
/* Release ctrl, shift, alt keys */
|
/* delete GDI objects */
|
||||||
OSK_ReleaseKey(SCAN_CODE_44); // Left shift
|
if (Globals.hBrushGreenLed) DeleteObject(Globals.hBrushGreenLed);
|
||||||
OSK_ReleaseKey(SCAN_CODE_57); // Right shift
|
|
||||||
OSK_ReleaseKey(SCAN_CODE_58); // Left ctrl
|
|
||||||
OSK_ReleaseKey(SCAN_CODE_60); // Left alt
|
|
||||||
OSK_ReleaseKey(SCAN_CODE_62); // Right alt
|
|
||||||
OSK_ReleaseKey(SCAN_CODE_64); // Right ctrl
|
|
||||||
|
|
||||||
/* delete GDI objects */
|
return TRUE;
|
||||||
if (Globals.hBrushGreenLed) DeleteObject(Globals.hBrushGreenLed);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
@ -144,23 +145,21 @@ int OSK_DlgClose(void)
|
||||||
*/
|
*/
|
||||||
int OSK_DlgTimer(void)
|
int OSK_DlgTimer(void)
|
||||||
{
|
{
|
||||||
|
/* FIXME: To be deleted when Reactos will support WS_EX_NOACTIVATE */
|
||||||
|
HWND hWndActiveWindow;
|
||||||
|
|
||||||
/* FIXME: To be deleted when Reactos will support WS_EX_NOACTIVATE */
|
hWndActiveWindow = GetForegroundWindow();
|
||||||
HWND hWndActiveWindow;
|
if (hWndActiveWindow != NULL && hWndActiveWindow != Globals.hMainWnd)
|
||||||
|
{
|
||||||
|
Globals.hActiveWnd = hWndActiveWindow;
|
||||||
|
}
|
||||||
|
|
||||||
hWndActiveWindow = GetForegroundWindow();
|
/* Always redraw leds because it can be changed by the real keyboard) */
|
||||||
if (hWndActiveWindow != NULL && hWndActiveWindow != Globals.hMainWnd)
|
InvalidateRect(GetDlgItem(Globals.hMainWnd, IDC_LED_NUM), NULL, TRUE);
|
||||||
{
|
InvalidateRect(GetDlgItem(Globals.hMainWnd, IDC_LED_CAPS), NULL, TRUE);
|
||||||
Globals.hActiveWnd = hWndActiveWindow;
|
InvalidateRect(GetDlgItem(Globals.hMainWnd, IDC_LED_SCROLL), NULL, TRUE);
|
||||||
}
|
|
||||||
/*******************************************************************/
|
|
||||||
|
|
||||||
/* Always redraw leds because it can be changed by the real keyboard) */
|
return TRUE;
|
||||||
InvalidateRect(GetDlgItem(Globals.hMainWnd, IDC_LED_NUM), NULL, TRUE);
|
|
||||||
InvalidateRect(GetDlgItem(Globals.hMainWnd, IDC_LED_CAPS), NULL, TRUE);
|
|
||||||
InvalidateRect(GetDlgItem(Globals.hMainWnd, IDC_LED_SCROLL), NULL, TRUE);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
@ -171,83 +170,83 @@ int OSK_DlgTimer(void)
|
||||||
*/
|
*/
|
||||||
BOOL OSK_DlgCommand(WPARAM wCommand, HWND hWndControl)
|
BOOL OSK_DlgCommand(WPARAM wCommand, HWND hWndControl)
|
||||||
{
|
{
|
||||||
WORD ScanCode;
|
WORD ScanCode;
|
||||||
INPUT Input;
|
INPUT Input;
|
||||||
BOOL bExtendedKey;
|
BOOL bExtendedKey;
|
||||||
BOOL bKeyDown;
|
BOOL bKeyDown;
|
||||||
BOOL bKeyUp;
|
BOOL bKeyUp;
|
||||||
LONG WindowStyle;
|
LONG WindowStyle;
|
||||||
|
|
||||||
|
/* FIXME: To be deleted when Reactos will support WS_EX_NOACTIVATE */
|
||||||
/* FIXME: To be deleted when Reactos will support WS_EX_NOACTIVATE */
|
if (Globals.hActiveWnd)
|
||||||
if (Globals.hActiveWnd)
|
|
||||||
{
|
|
||||||
MSG msg;
|
|
||||||
|
|
||||||
SetForegroundWindow(Globals.hActiveWnd);
|
|
||||||
while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
|
|
||||||
{
|
{
|
||||||
TranslateMessage(&msg);
|
MSG msg;
|
||||||
DispatchMessage(&msg);
|
|
||||||
|
SetForegroundWindow(Globals.hActiveWnd);
|
||||||
|
while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
|
||||||
|
{
|
||||||
|
TranslateMessage(&msg);
|
||||||
|
DispatchMessage(&msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
/*******************************************************************/
|
|
||||||
|
|
||||||
/* KeyDown and/or KeyUp ? */
|
/* KeyDown and/or KeyUp ? */
|
||||||
WindowStyle = GetWindowLong(hWndControl, GWL_STYLE);
|
WindowStyle = GetWindowLong(hWndControl, GWL_STYLE);
|
||||||
if ((WindowStyle & BS_AUTOCHECKBOX) == BS_AUTOCHECKBOX)
|
if ((WindowStyle & BS_AUTOCHECKBOX) == BS_AUTOCHECKBOX)
|
||||||
{
|
|
||||||
/* 2-states key like Shift, Alt, Ctrl, ... */
|
|
||||||
if (SendMessage(hWndControl, BM_GETCHECK, 0, 0) == BST_CHECKED)
|
|
||||||
{
|
{
|
||||||
bKeyDown = TRUE;
|
/* 2-states key like Shift, Alt, Ctrl, ... */
|
||||||
bKeyUp = FALSE;
|
if (SendMessage(hWndControl, BM_GETCHECK, 0, 0) == BST_CHECKED)
|
||||||
|
{
|
||||||
|
bKeyDown = TRUE;
|
||||||
|
bKeyUp = FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bKeyDown = FALSE;
|
||||||
|
bKeyUp = TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bKeyDown = FALSE;
|
/* Other key */
|
||||||
bKeyUp = TRUE;
|
bKeyDown = TRUE;
|
||||||
|
bKeyUp = TRUE;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Other key */
|
|
||||||
bKeyDown = TRUE;
|
|
||||||
bKeyUp = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Extended key ? */
|
/* Extended key ? */
|
||||||
ScanCode = wCommand;
|
ScanCode = wCommand;
|
||||||
if (ScanCode & 0x0200) bExtendedKey = TRUE;
|
if (ScanCode & 0x0200)
|
||||||
else bExtendedKey = FALSE;
|
bExtendedKey = TRUE;
|
||||||
ScanCode &= 0xFF;
|
else
|
||||||
|
bExtendedKey = FALSE;
|
||||||
|
ScanCode &= 0xFF;
|
||||||
|
|
||||||
/* Press and release the key */
|
/* Press and release the key */
|
||||||
if (bKeyDown)
|
if (bKeyDown)
|
||||||
{
|
{
|
||||||
Input.type = INPUT_KEYBOARD;
|
Input.type = INPUT_KEYBOARD;
|
||||||
Input.ki.wVk = 0;
|
Input.ki.wVk = 0;
|
||||||
Input.ki.wScan = ScanCode;
|
Input.ki.wScan = ScanCode;
|
||||||
Input.ki.time = GetTickCount();
|
Input.ki.time = GetTickCount();
|
||||||
Input.ki.dwExtraInfo = GetMessageExtraInfo();
|
Input.ki.dwExtraInfo = GetMessageExtraInfo();
|
||||||
Input.ki.dwFlags = KEYEVENTF_SCANCODE;
|
Input.ki.dwFlags = KEYEVENTF_SCANCODE;
|
||||||
if (bExtendedKey) Input.ki.dwFlags |= KEYEVENTF_EXTENDEDKEY;
|
if (bExtendedKey) Input.ki.dwFlags |= KEYEVENTF_EXTENDEDKEY;
|
||||||
SendInput(1, &Input, sizeof(Input));
|
SendInput(1, &Input, sizeof(Input));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bKeyUp)
|
if (bKeyUp)
|
||||||
{
|
{
|
||||||
Input.type = INPUT_KEYBOARD;
|
Input.type = INPUT_KEYBOARD;
|
||||||
Input.ki.wVk = 0;
|
Input.ki.wVk = 0;
|
||||||
Input.ki.wScan = ScanCode;
|
Input.ki.wScan = ScanCode;
|
||||||
Input.ki.time = GetTickCount();
|
Input.ki.time = GetTickCount();
|
||||||
Input.ki.dwExtraInfo = GetMessageExtraInfo();
|
Input.ki.dwExtraInfo = GetMessageExtraInfo();
|
||||||
Input.ki.dwFlags = KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP;
|
Input.ki.dwFlags = KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP;
|
||||||
if (bExtendedKey) Input.ki.dwFlags |= KEYEVENTF_EXTENDEDKEY;
|
if (bExtendedKey) Input.ki.dwFlags |= KEYEVENTF_EXTENDEDKEY;
|
||||||
SendInput(1, &Input, sizeof(Input));
|
SendInput(1, &Input, sizeof(Input));
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
@ -258,36 +257,37 @@ BOOL OSK_DlgCommand(WPARAM wCommand, HWND hWndControl)
|
||||||
*/
|
*/
|
||||||
BOOL OSK_ReleaseKey(WORD ScanCode)
|
BOOL OSK_ReleaseKey(WORD ScanCode)
|
||||||
{
|
{
|
||||||
INPUT Input;
|
INPUT Input;
|
||||||
BOOL bExtendedKey;
|
BOOL bExtendedKey;
|
||||||
LONG WindowStyle;
|
LONG WindowStyle;
|
||||||
HWND hWndControl;
|
HWND hWndControl;
|
||||||
|
|
||||||
|
/* Is it a 2-states key ? */
|
||||||
|
hWndControl = GetDlgItem(Globals.hMainWnd, ScanCode);
|
||||||
|
WindowStyle = GetWindowLong(hWndControl, GWL_STYLE);
|
||||||
|
if ((WindowStyle & BS_AUTOCHECKBOX) != BS_AUTOCHECKBOX) return FALSE;
|
||||||
|
|
||||||
/* Is it a 2-states key ? */
|
/* Is the key down ? */
|
||||||
hWndControl = GetDlgItem(Globals.hMainWnd, ScanCode);
|
if (SendMessage(hWndControl, BM_GETCHECK, 0, 0) != BST_CHECKED) return TRUE;
|
||||||
WindowStyle = GetWindowLong(hWndControl, GWL_STYLE);
|
|
||||||
if ((WindowStyle & BS_AUTOCHECKBOX) != BS_AUTOCHECKBOX) return FALSE;
|
|
||||||
|
|
||||||
/* Is the key down ? */
|
/* Extended key ? */
|
||||||
if (SendMessage(hWndControl, BM_GETCHECK, 0, 0) != BST_CHECKED) return TRUE;
|
if (ScanCode & 0x0200)
|
||||||
|
bExtendedKey = TRUE;
|
||||||
|
else
|
||||||
|
bExtendedKey = FALSE;
|
||||||
|
ScanCode &= 0xFF;
|
||||||
|
|
||||||
/* Extended key ? */
|
/* Release the key */
|
||||||
if (ScanCode & 0x0200) bExtendedKey = TRUE;
|
Input.type = INPUT_KEYBOARD;
|
||||||
else bExtendedKey = FALSE;
|
Input.ki.wVk = 0;
|
||||||
ScanCode &= 0xFF;
|
Input.ki.wScan = ScanCode;
|
||||||
|
Input.ki.time = GetTickCount();
|
||||||
|
Input.ki.dwExtraInfo = GetMessageExtraInfo();
|
||||||
|
Input.ki.dwFlags = KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP;
|
||||||
|
if (bExtendedKey) Input.ki.dwFlags |= KEYEVENTF_EXTENDEDKEY;
|
||||||
|
SendInput(1, &Input, sizeof(Input));
|
||||||
|
|
||||||
/* Release the key */
|
return TRUE;
|
||||||
Input.type = INPUT_KEYBOARD;
|
|
||||||
Input.ki.wVk = 0;
|
|
||||||
Input.ki.wScan = ScanCode;
|
|
||||||
Input.ki.time = GetTickCount();
|
|
||||||
Input.ki.dwExtraInfo = GetMessageExtraInfo();
|
|
||||||
Input.ki.dwFlags = KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP;
|
|
||||||
if (bExtendedKey) Input.ki.dwFlags |= KEYEVENTF_EXTENDEDKEY;
|
|
||||||
SendInput(1, &Input, sizeof(Input));
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
@ -296,115 +296,100 @@ BOOL OSK_ReleaseKey(WORD ScanCode)
|
||||||
*/
|
*/
|
||||||
INT_PTR APIENTRY OSK_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
INT_PTR APIENTRY OSK_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
switch (msg)
|
switch (msg)
|
||||||
{
|
|
||||||
|
|
||||||
case WM_INITDIALOG:
|
|
||||||
OSK_DlgInitDialog(hDlg);
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
case WM_TIMER:
|
|
||||||
OSK_DlgTimer();
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
case WM_CTLCOLORSTATIC:
|
|
||||||
if ((HWND) lParam == GetDlgItem(hDlg, IDC_LED_NUM))
|
|
||||||
{
|
{
|
||||||
if (GetKeyState(VK_NUMLOCK) & 0x0001)
|
case WM_INITDIALOG:
|
||||||
{
|
OSK_DlgInitDialog(hDlg);
|
||||||
return (INT_PTR) Globals.hBrushGreenLed;
|
return TRUE;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return (INT_PTR) GetStockObject(BLACK_BRUSH);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ((HWND) lParam == GetDlgItem(hDlg, IDC_LED_CAPS))
|
|
||||||
{
|
|
||||||
if (GetKeyState(VK_CAPITAL) & 0x0001)
|
|
||||||
{
|
|
||||||
return (INT_PTR) Globals.hBrushGreenLed;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return (INT_PTR) GetStockObject(BLACK_BRUSH);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ((HWND) lParam == GetDlgItem(hDlg, IDC_LED_SCROLL))
|
|
||||||
{
|
|
||||||
if (GetKeyState(VK_SCROLL) & 0x0001)
|
|
||||||
{
|
|
||||||
return (INT_PTR) Globals.hBrushGreenLed;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return (INT_PTR) GetStockObject(BLACK_BRUSH);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_COMMAND:
|
case WM_TIMER:
|
||||||
if (wParam == IDCANCEL) EndDialog(hDlg, FALSE);
|
OSK_DlgTimer();
|
||||||
else if (wParam != IDC_STATIC) OSK_DlgCommand(wParam, (HWND) lParam);
|
return TRUE;
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_CLOSE:
|
case WM_CTLCOLORSTATIC:
|
||||||
OSK_DlgClose();
|
if ((HWND)lParam == GetDlgItem(hDlg, IDC_LED_NUM))
|
||||||
break;
|
{
|
||||||
|
if (GetKeyState(VK_NUMLOCK) & 0x0001)
|
||||||
|
return (INT_PTR)Globals.hBrushGreenLed;
|
||||||
|
else
|
||||||
|
return (INT_PTR)GetStockObject(BLACK_BRUSH);
|
||||||
|
}
|
||||||
|
if ((HWND)lParam == GetDlgItem(hDlg, IDC_LED_CAPS))
|
||||||
|
{
|
||||||
|
if (GetKeyState(VK_CAPITAL) & 0x0001)
|
||||||
|
return (INT_PTR)Globals.hBrushGreenLed;
|
||||||
|
else
|
||||||
|
return (INT_PTR)GetStockObject(BLACK_BRUSH);
|
||||||
|
}
|
||||||
|
if ((HWND)lParam == GetDlgItem(hDlg, IDC_LED_SCROLL))
|
||||||
|
{
|
||||||
|
if (GetKeyState(VK_SCROLL) & 0x0001)
|
||||||
|
return (INT_PTR)Globals.hBrushGreenLed;
|
||||||
|
else
|
||||||
|
return (INT_PTR)GetStockObject(BLACK_BRUSH);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
case WM_COMMAND:
|
||||||
return 0;
|
if (wParam == IDCANCEL)
|
||||||
|
EndDialog(hDlg, FALSE);
|
||||||
|
else if (wParam != IDC_STATIC)
|
||||||
|
OSK_DlgCommand(wParam, (HWND) lParam);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_CLOSE:
|
||||||
|
OSK_DlgClose();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
*
|
*
|
||||||
* WinMain
|
* WinMain
|
||||||
*/
|
*/
|
||||||
int WINAPI _tWinMain(
|
int WINAPI _tWinMain(HINSTANCE hInstance,
|
||||||
HINSTANCE hInstance,
|
HINSTANCE prev,
|
||||||
HINSTANCE prev,
|
LPTSTR cmdline,
|
||||||
LPTSTR cmdline,
|
int show)
|
||||||
int show)
|
|
||||||
{
|
{
|
||||||
HANDLE hMutex;
|
HANDLE hMutex;
|
||||||
|
|
||||||
UNREFERENCED_PARAMETER(prev);
|
UNREFERENCED_PARAMETER(prev);
|
||||||
UNREFERENCED_PARAMETER(cmdline);
|
UNREFERENCED_PARAMETER(cmdline);
|
||||||
UNREFERENCED_PARAMETER(show);
|
UNREFERENCED_PARAMETER(show);
|
||||||
|
|
||||||
ZeroMemory(&Globals, sizeof(Globals));
|
ZeroMemory(&Globals, sizeof(Globals));
|
||||||
Globals.hInstance = hInstance;
|
Globals.hInstance = hInstance;
|
||||||
|
|
||||||
/* try to open a mutex for a single instance */
|
/* Rry to open a mutex for a single instance */
|
||||||
hMutex = OpenMutexA(MUTEX_ALL_ACCESS, FALSE, "osk");
|
hMutex = OpenMutexA(MUTEX_ALL_ACCESS, FALSE, "osk");
|
||||||
|
|
||||||
if (!hMutex)
|
if (!hMutex)
|
||||||
{
|
{
|
||||||
/* Mutex doesn’t exist. This is
|
/* Mutex doesn’t exist. This is the first instance so create the mutex. */
|
||||||
* the first instance so create
|
hMutex = CreateMutexA(NULL, FALSE, "osk");
|
||||||
* the mutex. */
|
|
||||||
hMutex = CreateMutexA(NULL, FALSE, "osk");
|
|
||||||
|
|
||||||
DialogBox(
|
DialogBox(hInstance,
|
||||||
hInstance,
|
MAKEINTRESOURCE(MAIN_DIALOG),
|
||||||
MAKEINTRESOURCE(MAIN_DIALOG),
|
GetDesktopWindow(),
|
||||||
GetDesktopWindow(),
|
OSK_DlgProc);
|
||||||
OSK_DlgProc);
|
|
||||||
|
|
||||||
/* delete the mutex */
|
/* Delete the mutex */
|
||||||
if (hMutex) CloseHandle(hMutex);
|
if (hMutex) CloseHandle(hMutex);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Programme already launched */
|
/* Programme already launched */
|
||||||
|
|
||||||
/* delete the mutex */
|
/* Delete the mutex */
|
||||||
CloseHandle(hMutex);
|
CloseHandle(hMutex);
|
||||||
|
|
||||||
ExitProcess(0);
|
ExitProcess(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -1,35 +1,36 @@
|
||||||
#ifndef _OSKMAIN_H
|
|
||||||
#define _OSKMAIN_H
|
|
||||||
/*
|
/*
|
||||||
* PROJECT: ReactOS Kernel
|
* PROJECT: ReactOS On-Screen Keyboard
|
||||||
* LICENSE: GPL - See COPYING in the top level directory
|
* LICENSE: GPL - See COPYING in the top level directory
|
||||||
* FILE: base/applications/osk/main.h
|
* FILE: base/applications/osk/main.h
|
||||||
* PURPOSE: On screen keyboard.
|
* PURPOSE: On screen keyboard.
|
||||||
* PROGRAMMERS: Denis ROBERT
|
* PROGRAMMERS: Denis ROBERT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* INCLUDES ******************************************************************/
|
#ifndef _OSKMAIN_H
|
||||||
|
#define _OSKMAIN_H
|
||||||
|
|
||||||
|
/* INCLUDES *******************************************************************/
|
||||||
|
|
||||||
#include "osk_res.h"
|
#include "osk_res.h"
|
||||||
|
|
||||||
/* STRUCTURES ****************************************************************/
|
/* TYPES **********************************************************************/
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
HINSTANCE hInstance;
|
HINSTANCE hInstance;
|
||||||
HWND hMainWnd;
|
HWND hMainWnd;
|
||||||
HBRUSH hBrushGreenLed;
|
HBRUSH hBrushGreenLed;
|
||||||
UINT_PTR iTimer;
|
UINT_PTR iTimer;
|
||||||
/* FIXME: To be deleted when Reactos will support WS_EX_NOACTIVATE */
|
/* FIXME: To be deleted when ReactOS will support WS_EX_NOACTIVATE */
|
||||||
HWND hActiveWnd;
|
HWND hActiveWnd;
|
||||||
/*******************************************************************/
|
|
||||||
} OSK_GLOBALS;
|
} OSK_GLOBALS;
|
||||||
|
|
||||||
/* DEFINES *******************************************************************/
|
/* DEFINES ********************************************************************/
|
||||||
|
|
||||||
extern OSK_GLOBALS Globals;
|
extern OSK_GLOBALS Globals;
|
||||||
|
|
||||||
#define countof(x) (sizeof(x) / sizeof((x)[0]))
|
#define countof(x) (sizeof(x) / sizeof((x)[0]))
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -1,29 +1,23 @@
|
||||||
#ifndef _OSK_H
|
|
||||||
#define _OSK_H
|
|
||||||
/*
|
/*
|
||||||
* PROJECT: ReactOS Kernel
|
* PROJECT: ReactOS On-Screen Keyboard
|
||||||
* LICENSE: GPL - See COPYING in the top level directory
|
* LICENSE: GPL - See COPYING in the top level directory
|
||||||
* FILE: base/applications/osk/osk.h
|
* FILE: base/applications/osk/osk.h
|
||||||
* PURPOSE: On screen keyboard.
|
* PURPOSE: On screen keyboard.
|
||||||
* PROGRAMMERS: Denis ROBERT
|
* PROGRAMMERS: Denis ROBERT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef STRSAFE_NO_DEPRECATE
|
#ifndef _OSK_H
|
||||||
#define STRSAFE_NO_DEPRECATE
|
#define _OSK_H
|
||||||
#endif
|
|
||||||
|
|
||||||
/* INCLUDES ******************************************************************/
|
/* INCLUDES ******************************************************************/
|
||||||
#include <assert.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <windows.h>
|
|
||||||
#include <commdlg.h>
|
|
||||||
#include <commctrl.h>
|
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <richedit.h>
|
|
||||||
#include <malloc.h>
|
#include <windows.h>
|
||||||
#include <strsafe.h>
|
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* PROJECT: ReactOS Kernel
|
* PROJECT: ReactOS On-Screen Keyboard
|
||||||
* LICENSE: GPL - See COPYING in the top level directory
|
* LICENSE: GPL - See COPYING in the top level directory
|
||||||
* FILE: base/applications/osk/osk_res.h
|
* FILE: base/applications/osk/osk_res.h
|
||||||
* PURPOSE: On screen keyboard.
|
* PURPOSE: On screen keyboard.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue