- Fix some coding style (whitespace): this is not win32k!!
- Remove unneeded headers.

svn path=/trunk/; revision=65569
This commit is contained in:
Hermès Bélusca-Maïto 2014-12-05 22:09:10 +00:00
parent e86551f057
commit a381da464a
4 changed files with 270 additions and 290 deletions

View file

@ -1,14 +1,17 @@
/*
* PROJECT: ReactOS Kernel
* PROJECT: ReactOS On-Screen Keyboard
* LICENSE: GPL - See COPYING in the top level directory
* FILE: base/applications/osk/main.c
* PURPOSE: On screen keyboard.
* PURPOSE: On-screen keyboard.
* PROGRAMMERS: Denis ROBERT
*/
/* INCLUDES ******************************************************************/
/* INCLUDES *******************************************************************/
#include "osk.h"
/* GLOBALS ********************************************************************/
OSK_GLOBALS Globals;
/* Functions */
@ -22,7 +25,7 @@ BOOL OSK_ReleaseKey(WORD ScanCode);
INT_PTR APIENTRY OSK_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
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);
/* 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;
}
@ -74,14 +77,13 @@ int OSK_DlgInitDialog(HWND hDlg)
/* Move the dialog on the bottom of main screen */
GetWindowRect(hDlg, &rcWindow);
MoveWindow(
hDlg,
MoveWindow(hDlg,
(info.rcMonitor.left + info.rcMonitor.right) / 2 - // Center of screen
(rcWindow.right - rcWindow.left) / 2, // - half size of dialog
info.rcMonitor.bottom - // Bottom of screen
(rcWindow.bottom - rcWindow.top), // - size of window
(rcWindow.right - rcWindow.left), // Width
(rcWindow.bottom - rcWindow.top), // Height
rcWindow.right - rcWindow.left, // Width
rcWindow.bottom - rcWindow.top, // Height
TRUE);
/* Set icon on visual buttons */
@ -119,10 +121,9 @@ int OSK_DlgInitDialog(HWND hDlg)
*/
int OSK_DlgClose(void)
{
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_57); // Right shift
OSK_ReleaseKey(SCAN_CODE_58); // Left ctrl
@ -144,7 +145,6 @@ int OSK_DlgClose(void)
*/
int OSK_DlgTimer(void)
{
/* FIXME: To be deleted when Reactos will support WS_EX_NOACTIVATE */
HWND hWndActiveWindow;
@ -153,7 +153,6 @@ int OSK_DlgTimer(void)
{
Globals.hActiveWnd = hWndActiveWindow;
}
/*******************************************************************/
/* Always redraw leds because it can be changed by the real keyboard) */
InvalidateRect(GetDlgItem(Globals.hMainWnd, IDC_LED_NUM), NULL, TRUE);
@ -178,7 +177,6 @@ BOOL OSK_DlgCommand(WPARAM wCommand, HWND hWndControl)
BOOL bKeyUp;
LONG WindowStyle;
/* FIXME: To be deleted when Reactos will support WS_EX_NOACTIVATE */
if (Globals.hActiveWnd)
{
@ -191,7 +189,6 @@ BOOL OSK_DlgCommand(WPARAM wCommand, HWND hWndControl)
DispatchMessage(&msg);
}
}
/*******************************************************************/
/* KeyDown and/or KeyUp ? */
WindowStyle = GetWindowLong(hWndControl, GWL_STYLE);
@ -218,8 +215,10 @@ BOOL OSK_DlgCommand(WPARAM wCommand, HWND hWndControl)
/* Extended key ? */
ScanCode = wCommand;
if (ScanCode & 0x0200) bExtendedKey = TRUE;
else bExtendedKey = FALSE;
if (ScanCode & 0x0200)
bExtendedKey = TRUE;
else
bExtendedKey = FALSE;
ScanCode &= 0xFF;
/* Press and release the key */
@ -263,7 +262,6 @@ BOOL OSK_ReleaseKey(WORD ScanCode)
LONG WindowStyle;
HWND hWndControl;
/* Is it a 2-states key ? */
hWndControl = GetDlgItem(Globals.hMainWnd, ScanCode);
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;
/* Extended key ? */
if (ScanCode & 0x0200) bExtendedKey = TRUE;
else bExtendedKey = FALSE;
if (ScanCode & 0x0200)
bExtendedKey = TRUE;
else
bExtendedKey = FALSE;
ScanCode &= 0xFF;
/* Release the key */
@ -298,7 +298,6 @@ INT_PTR APIENTRY OSK_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_INITDIALOG:
OSK_DlgInitDialog(hDlg);
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 (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:
if (wParam == IDCANCEL) EndDialog(hDlg, FALSE);
else if (wParam != IDC_STATIC) OSK_DlgCommand(wParam, (HWND) lParam);
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;
}
@ -360,8 +349,7 @@ INT_PTR APIENTRY OSK_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
*
* WinMain
*/
int WINAPI _tWinMain(
HINSTANCE hInstance,
int WINAPI _tWinMain(HINSTANCE hInstance,
HINSTANCE prev,
LPTSTR cmdline,
int show)
@ -375,30 +363,27 @@ int WINAPI _tWinMain(
ZeroMemory(&Globals, sizeof(Globals));
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");
if (!hMutex)
{
/* Mutex doesnt exist. This is
* the first instance so create
* the mutex. */
/* Mutex doesnt exist. This is the first instance so create the mutex. */
hMutex = CreateMutexA(NULL, FALSE, "osk");
DialogBox(
hInstance,
DialogBox(hInstance,
MAKEINTRESOURCE(MAIN_DIALOG),
GetDesktopWindow(),
OSK_DlgProc);
/* delete the mutex */
/* Delete the mutex */
if (hMutex) CloseHandle(hMutex);
}
else
{
/* Programme already launched */
/* delete the mutex */
/* Delete the mutex */
CloseHandle(hMutex);
ExitProcess(0);

View file

@ -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
* FILE: base/applications/osk/main.h
* PURPOSE: On screen keyboard.
* PROGRAMMERS: Denis ROBERT
*/
/* INCLUDES ******************************************************************/
#ifndef _OSKMAIN_H
#define _OSKMAIN_H
/* INCLUDES *******************************************************************/
#include "osk_res.h"
/* STRUCTURES ****************************************************************/
/* TYPES **********************************************************************/
typedef struct
{
@ -19,17 +21,16 @@ typedef struct
HWND hMainWnd;
HBRUSH hBrushGreenLed;
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;
/*******************************************************************/
} OSK_GLOBALS;
/* DEFINES *******************************************************************/
/* DEFINES ********************************************************************/
extern OSK_GLOBALS Globals;
#define countof(x) (sizeof(x) / sizeof((x)[0]))
#endif
/* EOF */

View file

@ -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
* FILE: base/applications/osk/osk.h
* PURPOSE: On screen keyboard.
* PROGRAMMERS: Denis ROBERT
*/
#ifndef STRSAFE_NO_DEPRECATE
#define STRSAFE_NO_DEPRECATE
#endif
#ifndef _OSK_H
#define _OSK_H
/* INCLUDES ******************************************************************/
#include <assert.h>
#include <stdio.h>
#include <windows.h>
#include <commdlg.h>
#include <commctrl.h>
#include <tchar.h>
#include <richedit.h>
#include <malloc.h>
#include <strsafe.h>
#include <windows.h>
#include "main.h"
#endif
/* EOF */

View file

@ -1,5 +1,5 @@
/*
* PROJECT: ReactOS Kernel
* PROJECT: ReactOS On-Screen Keyboard
* LICENSE: GPL - See COPYING in the top level directory
* FILE: base/applications/osk/osk_res.h
* PURPOSE: On screen keyboard.