mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 08:23:01 +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 ******************************************************************/
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
*
|
*
|
||||||
|
@ -44,7 +47,7 @@ int OSK_SetImage(int IdDlgItem, int IdResource)
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -74,14 +77,13 @@ int OSK_DlgInitDialog(HWND hDlg)
|
||||||
|
|
||||||
/* 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 */
|
||||||
|
@ -119,10 +121,9 @@ 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 */
|
/* Release Ctrl, Shift, Alt keys */
|
||||||
OSK_ReleaseKey(SCAN_CODE_44); // Left shift
|
OSK_ReleaseKey(SCAN_CODE_44); // Left shift
|
||||||
OSK_ReleaseKey(SCAN_CODE_57); // Right shift
|
OSK_ReleaseKey(SCAN_CODE_57); // Right shift
|
||||||
OSK_ReleaseKey(SCAN_CODE_58); // Left ctrl
|
OSK_ReleaseKey(SCAN_CODE_58); // Left ctrl
|
||||||
|
@ -144,7 +145,6 @@ int OSK_DlgClose(void)
|
||||||
*/
|
*/
|
||||||
int OSK_DlgTimer(void)
|
int OSK_DlgTimer(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* FIXME: To be deleted when Reactos will support WS_EX_NOACTIVATE */
|
/* FIXME: To be deleted when Reactos will support WS_EX_NOACTIVATE */
|
||||||
HWND hWndActiveWindow;
|
HWND hWndActiveWindow;
|
||||||
|
|
||||||
|
@ -153,7 +153,6 @@ int OSK_DlgTimer(void)
|
||||||
{
|
{
|
||||||
Globals.hActiveWnd = hWndActiveWindow;
|
Globals.hActiveWnd = hWndActiveWindow;
|
||||||
}
|
}
|
||||||
/*******************************************************************/
|
|
||||||
|
|
||||||
/* Always redraw leds because it can be changed by the real keyboard) */
|
/* Always redraw leds because it can be changed by the real keyboard) */
|
||||||
InvalidateRect(GetDlgItem(Globals.hMainWnd, IDC_LED_NUM), NULL, TRUE);
|
InvalidateRect(GetDlgItem(Globals.hMainWnd, IDC_LED_NUM), NULL, TRUE);
|
||||||
|
@ -178,7 +177,6 @@ BOOL OSK_DlgCommand(WPARAM wCommand, HWND hWndControl)
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
@ -191,7 +189,6 @@ BOOL OSK_DlgCommand(WPARAM wCommand, HWND hWndControl)
|
||||||
DispatchMessage(&msg);
|
DispatchMessage(&msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*******************************************************************/
|
|
||||||
|
|
||||||
/* KeyDown and/or KeyUp ? */
|
/* KeyDown and/or KeyUp ? */
|
||||||
WindowStyle = GetWindowLong(hWndControl, GWL_STYLE);
|
WindowStyle = GetWindowLong(hWndControl, GWL_STYLE);
|
||||||
|
@ -218,8 +215,10 @@ BOOL OSK_DlgCommand(WPARAM wCommand, HWND hWndControl)
|
||||||
|
|
||||||
/* Extended key ? */
|
/* Extended key ? */
|
||||||
ScanCode = wCommand;
|
ScanCode = wCommand;
|
||||||
if (ScanCode & 0x0200) bExtendedKey = TRUE;
|
if (ScanCode & 0x0200)
|
||||||
else bExtendedKey = FALSE;
|
bExtendedKey = TRUE;
|
||||||
|
else
|
||||||
|
bExtendedKey = FALSE;
|
||||||
ScanCode &= 0xFF;
|
ScanCode &= 0xFF;
|
||||||
|
|
||||||
/* Press and release the key */
|
/* Press and release the key */
|
||||||
|
@ -263,7 +262,6 @@ BOOL OSK_ReleaseKey(WORD ScanCode)
|
||||||
LONG WindowStyle;
|
LONG WindowStyle;
|
||||||
HWND hWndControl;
|
HWND hWndControl;
|
||||||
|
|
||||||
|
|
||||||
/* Is it a 2-states key ? */
|
/* Is it a 2-states key ? */
|
||||||
hWndControl = GetDlgItem(Globals.hMainWnd, ScanCode);
|
hWndControl = GetDlgItem(Globals.hMainWnd, ScanCode);
|
||||||
WindowStyle = GetWindowLong(hWndControl, GWL_STYLE);
|
WindowStyle = GetWindowLong(hWndControl, GWL_STYLE);
|
||||||
|
@ -273,8 +271,10 @@ BOOL OSK_ReleaseKey(WORD ScanCode)
|
||||||
if (SendMessage(hWndControl, BM_GETCHECK, 0, 0) != BST_CHECKED) return TRUE;
|
if (SendMessage(hWndControl, BM_GETCHECK, 0, 0) != BST_CHECKED) return TRUE;
|
||||||
|
|
||||||
/* Extended key ? */
|
/* Extended key ? */
|
||||||
if (ScanCode & 0x0200) bExtendedKey = TRUE;
|
if (ScanCode & 0x0200)
|
||||||
else bExtendedKey = FALSE;
|
bExtendedKey = TRUE;
|
||||||
|
else
|
||||||
|
bExtendedKey = FALSE;
|
||||||
ScanCode &= 0xFF;
|
ScanCode &= 0xFF;
|
||||||
|
|
||||||
/* Release the key */
|
/* Release the key */
|
||||||
|
@ -298,7 +298,6 @@ INT_PTR APIENTRY OSK_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
switch (msg)
|
switch (msg)
|
||||||
{
|
{
|
||||||
|
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
OSK_DlgInitDialog(hDlg);
|
OSK_DlgInitDialog(hDlg);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -311,48 +310,38 @@ INT_PTR APIENTRY OSK_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
if ((HWND)lParam == GetDlgItem(hDlg, IDC_LED_NUM))
|
if ((HWND)lParam == GetDlgItem(hDlg, IDC_LED_NUM))
|
||||||
{
|
{
|
||||||
if (GetKeyState(VK_NUMLOCK) & 0x0001)
|
if (GetKeyState(VK_NUMLOCK) & 0x0001)
|
||||||
{
|
|
||||||
return (INT_PTR)Globals.hBrushGreenLed;
|
return (INT_PTR)Globals.hBrushGreenLed;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
return (INT_PTR)GetStockObject(BLACK_BRUSH);
|
return (INT_PTR)GetStockObject(BLACK_BRUSH);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if ((HWND)lParam == GetDlgItem(hDlg, IDC_LED_CAPS))
|
if ((HWND)lParam == GetDlgItem(hDlg, IDC_LED_CAPS))
|
||||||
{
|
{
|
||||||
if (GetKeyState(VK_CAPITAL) & 0x0001)
|
if (GetKeyState(VK_CAPITAL) & 0x0001)
|
||||||
{
|
|
||||||
return (INT_PTR)Globals.hBrushGreenLed;
|
return (INT_PTR)Globals.hBrushGreenLed;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
return (INT_PTR)GetStockObject(BLACK_BRUSH);
|
return (INT_PTR)GetStockObject(BLACK_BRUSH);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if ((HWND)lParam == GetDlgItem(hDlg, IDC_LED_SCROLL))
|
if ((HWND)lParam == GetDlgItem(hDlg, IDC_LED_SCROLL))
|
||||||
{
|
{
|
||||||
if (GetKeyState(VK_SCROLL) & 0x0001)
|
if (GetKeyState(VK_SCROLL) & 0x0001)
|
||||||
{
|
|
||||||
return (INT_PTR)Globals.hBrushGreenLed;
|
return (INT_PTR)Globals.hBrushGreenLed;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
return (INT_PTR)GetStockObject(BLACK_BRUSH);
|
return (INT_PTR)GetStockObject(BLACK_BRUSH);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
if (wParam == IDCANCEL) EndDialog(hDlg, FALSE);
|
if (wParam == IDCANCEL)
|
||||||
else if (wParam != IDC_STATIC) OSK_DlgCommand(wParam, (HWND) lParam);
|
EndDialog(hDlg, FALSE);
|
||||||
|
else if (wParam != IDC_STATIC)
|
||||||
|
OSK_DlgCommand(wParam, (HWND) lParam);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
OSK_DlgClose();
|
OSK_DlgClose();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,8 +349,7 @@ INT_PTR APIENTRY OSK_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
*
|
*
|
||||||
* WinMain
|
* WinMain
|
||||||
*/
|
*/
|
||||||
int WINAPI _tWinMain(
|
int WINAPI _tWinMain(HINSTANCE hInstance,
|
||||||
HINSTANCE hInstance,
|
|
||||||
HINSTANCE prev,
|
HINSTANCE prev,
|
||||||
LPTSTR cmdline,
|
LPTSTR cmdline,
|
||||||
int show)
|
int show)
|
||||||
|
@ -375,30 +363,27 @@ int WINAPI _tWinMain(
|
||||||
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
|
|
||||||
* the mutex. */
|
|
||||||
hMutex = CreateMutexA(NULL, FALSE, "osk");
|
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);
|
||||||
|
|
|
@ -1,17 +1,19 @@
|
||||||
#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
|
||||||
{
|
{
|
||||||
|
@ -19,17 +21,16 @@ typedef struct
|
||||||
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