2014-12-05 21:43:00 +00:00
|
|
|
|
/*
|
2014-12-05 22:09:10 +00:00
|
|
|
|
* PROJECT: ReactOS On-Screen Keyboard
|
2014-12-05 21:43:00 +00:00
|
|
|
|
* LICENSE: GPL - See COPYING in the top level directory
|
|
|
|
|
* FILE: base/applications/osk/main.c
|
2014-12-05 22:09:10 +00:00
|
|
|
|
* PURPOSE: On-screen keyboard.
|
2014-12-05 21:43:00 +00:00
|
|
|
|
* PROGRAMMERS: Denis ROBERT
|
|
|
|
|
*/
|
|
|
|
|
|
2014-12-05 22:09:10 +00:00
|
|
|
|
/* INCLUDES *******************************************************************/
|
|
|
|
|
|
2014-12-05 21:43:00 +00:00
|
|
|
|
#include "osk.h"
|
2018-11-17 20:27:33 +00:00
|
|
|
|
#include "settings.h"
|
2014-12-05 21:43:00 +00:00
|
|
|
|
|
2014-12-05 22:09:10 +00:00
|
|
|
|
/* GLOBALS ********************************************************************/
|
|
|
|
|
|
2014-12-05 21:43:00 +00:00
|
|
|
|
OSK_GLOBALS Globals;
|
|
|
|
|
|
|
|
|
|
/* 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);
|
|
|
|
|
int WINAPI _tWinMain(HINSTANCE, HINSTANCE, LPTSTR, int);
|
|
|
|
|
|
2014-12-05 22:09:10 +00:00
|
|
|
|
/* FUNCTIONS ******************************************************************/
|
2014-12-05 21:43:00 +00:00
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
|
*
|
|
|
|
|
* OSK_SetImage
|
|
|
|
|
*
|
|
|
|
|
* Set an image on a button
|
|
|
|
|
*/
|
|
|
|
|
int OSK_SetImage(int IdDlgItem, int IdResource)
|
|
|
|
|
{
|
2014-12-05 22:09:10 +00:00
|
|
|
|
HICON hIcon;
|
|
|
|
|
HWND hWndItem;
|
2014-12-05 21:43:00 +00:00
|
|
|
|
|
2014-12-05 22:09:10 +00:00
|
|
|
|
hIcon = (HICON)LoadImage(Globals.hInstance, MAKEINTRESOURCE(IdResource),
|
|
|
|
|
IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
|
2015-09-03 09:33:58 +00:00
|
|
|
|
if (hIcon == NULL)
|
|
|
|
|
return FALSE;
|
2014-12-05 21:43:00 +00:00
|
|
|
|
|
2014-12-05 22:09:10 +00:00
|
|
|
|
hWndItem = GetDlgItem(Globals.hMainWnd, IdDlgItem);
|
2015-09-03 09:33:58 +00:00
|
|
|
|
if (hWndItem == NULL)
|
|
|
|
|
{
|
|
|
|
|
DestroyIcon(hIcon);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2014-12-05 21:43:00 +00:00
|
|
|
|
|
2014-12-05 22:09:10 +00:00
|
|
|
|
SendMessage(hWndItem, BM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)hIcon);
|
2014-12-05 21:43:00 +00:00
|
|
|
|
|
2014-12-05 22:09:10 +00:00
|
|
|
|
/* The system automatically deletes these resources when the process that created them terminates (MSDN) */
|
2014-12-05 21:43:00 +00:00
|
|
|
|
|
2014-12-05 22:09:10 +00:00
|
|
|
|
return TRUE;
|
2014-12-05 21:43:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-11-17 20:27:33 +00:00
|
|
|
|
/***********************************************************************
|
|
|
|
|
*
|
|
|
|
|
* OSK_WarningProc
|
|
|
|
|
*
|
|
|
|
|
* Function handler for the warning dialog box on startup
|
|
|
|
|
*/
|
|
|
|
|
INT_PTR CALLBACK OSK_WarningProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
|
{
|
|
|
|
|
UNREFERENCED_PARAMETER(lParam);
|
|
|
|
|
|
|
|
|
|
switch (Msg)
|
|
|
|
|
{
|
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
|
{
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case WM_COMMAND:
|
|
|
|
|
{
|
|
|
|
|
switch (LOWORD(wParam))
|
|
|
|
|
{
|
|
|
|
|
case IDC_SHOWWARNINGCHECK:
|
|
|
|
|
{
|
|
|
|
|
Globals.bShowWarning = !IsDlgButtonChecked(hDlg, IDC_SHOWWARNINGCHECK);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case IDOK:
|
|
|
|
|
case IDCANCEL:
|
|
|
|
|
{
|
|
|
|
|
EndDialog(hDlg, LOWORD(wParam));
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-05 21:43:00 +00:00
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
|
*
|
|
|
|
|
* OSK_DlgInitDialog
|
|
|
|
|
*
|
|
|
|
|
* Handling of WM_INITDIALOG
|
|
|
|
|
*/
|
|
|
|
|
int OSK_DlgInitDialog(HWND hDlg)
|
|
|
|
|
{
|
2014-12-05 22:09:10 +00:00
|
|
|
|
HMONITOR monitor;
|
|
|
|
|
MONITORINFO info;
|
|
|
|
|
POINT Pt;
|
|
|
|
|
RECT rcWindow;
|
|
|
|
|
|
|
|
|
|
/* Save handle */
|
|
|
|
|
Globals.hMainWnd = hDlg;
|
|
|
|
|
|
2018-11-17 20:27:33 +00:00
|
|
|
|
/* Load the settings from the registry hive */
|
|
|
|
|
LoadDataFromRegistry();
|
|
|
|
|
|
2014-12-05 22:09:10 +00:00
|
|
|
|
/* Get screen info */
|
|
|
|
|
memset(&Pt, 0, sizeof(Pt));
|
|
|
|
|
monitor = MonitorFromPoint(Pt, MONITOR_DEFAULTTOPRIMARY );
|
|
|
|
|
info.cbSize = sizeof(info);
|
|
|
|
|
GetMonitorInfoW(monitor, &info);
|
|
|
|
|
|
|
|
|
|
/* Move the dialog on the bottom of main screen */
|
|
|
|
|
GetWindowRect(hDlg, &rcWindow);
|
|
|
|
|
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
|
|
|
|
|
TRUE);
|
|
|
|
|
|
|
|
|
|
/* Set icon on visual buttons */
|
|
|
|
|
OSK_SetImage(SCAN_CODE_15, IDI_BACK);
|
|
|
|
|
OSK_SetImage(SCAN_CODE_16, IDI_TAB);
|
|
|
|
|
OSK_SetImage(SCAN_CODE_30, IDI_CAPS_LOCK);
|
|
|
|
|
OSK_SetImage(SCAN_CODE_43, IDI_RETURN);
|
|
|
|
|
OSK_SetImage(SCAN_CODE_44, IDI_SHIFT);
|
|
|
|
|
OSK_SetImage(SCAN_CODE_57, IDI_SHIFT);
|
|
|
|
|
OSK_SetImage(SCAN_CODE_127, IDI_REACTOS);
|
|
|
|
|
OSK_SetImage(SCAN_CODE_128, IDI_REACTOS);
|
|
|
|
|
OSK_SetImage(SCAN_CODE_129, IDI_MENU);
|
|
|
|
|
OSK_SetImage(SCAN_CODE_80, IDI_HOME);
|
|
|
|
|
OSK_SetImage(SCAN_CODE_85, IDI_PG_UP);
|
|
|
|
|
OSK_SetImage(SCAN_CODE_86, IDI_PG_DOWN);
|
|
|
|
|
OSK_SetImage(SCAN_CODE_79, IDI_LEFT);
|
|
|
|
|
OSK_SetImage(SCAN_CODE_83, IDI_TOP);
|
|
|
|
|
OSK_SetImage(SCAN_CODE_84, IDI_BOTTOM);
|
|
|
|
|
OSK_SetImage(SCAN_CODE_89, IDI_RIGHT);
|
|
|
|
|
|
|
|
|
|
/* Create a green brush for leds */
|
|
|
|
|
Globals.hBrushGreenLed = CreateSolidBrush(RGB(0, 255, 0));
|
|
|
|
|
|
|
|
|
|
/* Set a timer for periodics tasks */
|
|
|
|
|
Globals.iTimer = SetTimer(hDlg, 0, 200, NULL);
|
|
|
|
|
|
2018-11-17 20:27:33 +00:00
|
|
|
|
/* If the member of the struct (bShowWarning) is set then display the dialog box */
|
|
|
|
|
if (Globals.bShowWarning)
|
|
|
|
|
{
|
|
|
|
|
DialogBox(Globals.hInstance, MAKEINTRESOURCE(IDD_WARNINGDIALOG_OSK), Globals.hMainWnd, OSK_WarningProc);
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-05 22:09:10 +00:00
|
|
|
|
return TRUE;
|
2014-12-05 21:43:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
|
*
|
|
|
|
|
* OSK_DlgClose
|
|
|
|
|
*
|
|
|
|
|
* Handling of WM_CLOSE
|
|
|
|
|
*/
|
|
|
|
|
int OSK_DlgClose(void)
|
|
|
|
|
{
|
2014-12-05 22:09:10 +00:00
|
|
|
|
KillTimer(Globals.hMainWnd, Globals.iTimer);
|
2014-12-05 21:43:00 +00:00
|
|
|
|
|
2014-12-05 22:09:10 +00:00
|
|
|
|
/* 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
|
2014-12-05 21:43:00 +00:00
|
|
|
|
|
2014-12-05 22:09:10 +00:00
|
|
|
|
/* delete GDI objects */
|
|
|
|
|
if (Globals.hBrushGreenLed) DeleteObject(Globals.hBrushGreenLed);
|
2014-12-05 21:43:00 +00:00
|
|
|
|
|
2018-11-17 20:27:33 +00:00
|
|
|
|
/* Save the settings to the registry hive */
|
|
|
|
|
SaveDataToRegistry();
|
|
|
|
|
|
2014-12-05 22:09:10 +00:00
|
|
|
|
return TRUE;
|
2014-12-05 21:43:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
|
*
|
|
|
|
|
* OSK_DlgTimer
|
|
|
|
|
*
|
|
|
|
|
* Handling of WM_TIMER
|
|
|
|
|
*/
|
|
|
|
|
int OSK_DlgTimer(void)
|
|
|
|
|
{
|
2015-04-18 09:01:23 +00:00
|
|
|
|
/* FIXME: To be deleted when ReactOS will support WS_EX_NOACTIVATE */
|
2014-12-05 22:09:10 +00:00
|
|
|
|
HWND hWndActiveWindow;
|
2014-12-05 21:43:00 +00:00
|
|
|
|
|
2014-12-05 22:09:10 +00:00
|
|
|
|
hWndActiveWindow = GetForegroundWindow();
|
|
|
|
|
if (hWndActiveWindow != NULL && hWndActiveWindow != Globals.hMainWnd)
|
|
|
|
|
{
|
|
|
|
|
Globals.hActiveWnd = hWndActiveWindow;
|
|
|
|
|
}
|
2014-12-05 21:43:00 +00:00
|
|
|
|
|
2014-12-05 22:09:10 +00:00
|
|
|
|
/* 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_CAPS), NULL, TRUE);
|
|
|
|
|
InvalidateRect(GetDlgItem(Globals.hMainWnd, IDC_LED_SCROLL), NULL, TRUE);
|
2014-12-05 21:43:00 +00:00
|
|
|
|
|
2014-12-05 22:09:10 +00:00
|
|
|
|
return TRUE;
|
2014-12-05 21:43:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
|
*
|
|
|
|
|
* OSK_DlgCommand
|
|
|
|
|
*
|
|
|
|
|
* All handling of dialog command
|
|
|
|
|
*/
|
|
|
|
|
BOOL OSK_DlgCommand(WPARAM wCommand, HWND hWndControl)
|
|
|
|
|
{
|
2014-12-05 22:09:10 +00:00
|
|
|
|
WORD ScanCode;
|
|
|
|
|
INPUT Input;
|
|
|
|
|
BOOL bExtendedKey;
|
|
|
|
|
BOOL bKeyDown;
|
|
|
|
|
BOOL bKeyUp;
|
|
|
|
|
LONG WindowStyle;
|
|
|
|
|
|
2015-04-18 09:01:23 +00:00
|
|
|
|
/* FIXME: To be deleted when ReactOS will support WS_EX_NOACTIVATE */
|
2014-12-05 22:09:10 +00:00
|
|
|
|
if (Globals.hActiveWnd)
|
|
|
|
|
{
|
|
|
|
|
MSG msg;
|
|
|
|
|
|
|
|
|
|
SetForegroundWindow(Globals.hActiveWnd);
|
|
|
|
|
while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
|
|
|
|
|
{
|
|
|
|
|
TranslateMessage(&msg);
|
|
|
|
|
DispatchMessage(&msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-12-05 21:43:00 +00:00
|
|
|
|
|
2014-12-05 22:09:10 +00:00
|
|
|
|
/* KeyDown and/or KeyUp ? */
|
|
|
|
|
WindowStyle = GetWindowLong(hWndControl, GWL_STYLE);
|
|
|
|
|
if ((WindowStyle & BS_AUTOCHECKBOX) == BS_AUTOCHECKBOX)
|
2014-12-05 21:43:00 +00:00
|
|
|
|
{
|
2014-12-05 22:09:10 +00:00
|
|
|
|
/* 2-states key like Shift, Alt, Ctrl, ... */
|
|
|
|
|
if (SendMessage(hWndControl, BM_GETCHECK, 0, 0) == BST_CHECKED)
|
|
|
|
|
{
|
|
|
|
|
bKeyDown = TRUE;
|
|
|
|
|
bKeyUp = FALSE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
bKeyDown = FALSE;
|
|
|
|
|
bKeyUp = TRUE;
|
|
|
|
|
}
|
2014-12-05 21:43:00 +00:00
|
|
|
|
}
|
2014-12-05 22:09:10 +00:00
|
|
|
|
else
|
2014-12-05 21:43:00 +00:00
|
|
|
|
{
|
2014-12-05 22:09:10 +00:00
|
|
|
|
/* Other key */
|
|
|
|
|
bKeyDown = TRUE;
|
|
|
|
|
bKeyUp = TRUE;
|
2014-12-05 21:43:00 +00:00
|
|
|
|
}
|
2014-12-05 22:09:10 +00:00
|
|
|
|
|
|
|
|
|
/* Extended key ? */
|
|
|
|
|
ScanCode = wCommand;
|
|
|
|
|
if (ScanCode & 0x0200)
|
|
|
|
|
bExtendedKey = TRUE;
|
2014-12-05 21:43:00 +00:00
|
|
|
|
else
|
2014-12-05 22:09:10 +00:00
|
|
|
|
bExtendedKey = FALSE;
|
|
|
|
|
ScanCode &= 0xFF;
|
|
|
|
|
|
|
|
|
|
/* Press and release the key */
|
|
|
|
|
if (bKeyDown)
|
2014-12-05 21:43:00 +00:00
|
|
|
|
{
|
2014-12-05 22:09:10 +00:00
|
|
|
|
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;
|
|
|
|
|
if (bExtendedKey) Input.ki.dwFlags |= KEYEVENTF_EXTENDEDKEY;
|
|
|
|
|
SendInput(1, &Input, sizeof(Input));
|
2014-12-05 21:43:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-05 22:09:10 +00:00
|
|
|
|
if (bKeyUp)
|
|
|
|
|
{
|
|
|
|
|
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));
|
|
|
|
|
}
|
2014-12-05 21:43:00 +00:00
|
|
|
|
|
2014-12-05 22:09:10 +00:00
|
|
|
|
return TRUE;
|
2014-12-05 21:43:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
|
*
|
|
|
|
|
* OSK_ReleaseKey
|
|
|
|
|
*
|
|
|
|
|
* Release the key of ID wCommand
|
|
|
|
|
*/
|
|
|
|
|
BOOL OSK_ReleaseKey(WORD ScanCode)
|
|
|
|
|
{
|
2014-12-05 22:09:10 +00:00
|
|
|
|
INPUT Input;
|
|
|
|
|
BOOL bExtendedKey;
|
|
|
|
|
LONG WindowStyle;
|
|
|
|
|
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 the key down ? */
|
|
|
|
|
if (SendMessage(hWndControl, BM_GETCHECK, 0, 0) != BST_CHECKED) return TRUE;
|
|
|
|
|
|
|
|
|
|
/* Extended key ? */
|
|
|
|
|
if (ScanCode & 0x0200)
|
|
|
|
|
bExtendedKey = TRUE;
|
|
|
|
|
else
|
|
|
|
|
bExtendedKey = FALSE;
|
|
|
|
|
ScanCode &= 0xFF;
|
|
|
|
|
|
|
|
|
|
/* Release the key */
|
|
|
|
|
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;
|
2014-12-05 21:43:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
|
*
|
|
|
|
|
* OSK_DlgProc
|
|
|
|
|
*/
|
|
|
|
|
INT_PTR APIENTRY OSK_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
|
{
|
2014-12-05 22:09:10 +00:00
|
|
|
|
switch (msg)
|
2014-12-05 21:43:00 +00:00
|
|
|
|
{
|
2014-12-05 22:09:10 +00:00
|
|
|
|
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)
|
|
|
|
|
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);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case WM_CLOSE:
|
|
|
|
|
OSK_DlgClose();
|
|
|
|
|
break;
|
2014-12-05 21:43:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-05 22:09:10 +00:00
|
|
|
|
return 0;
|
2014-12-05 21:43:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
|
*
|
|
|
|
|
* WinMain
|
|
|
|
|
*/
|
2014-12-05 22:09:10 +00:00
|
|
|
|
int WINAPI _tWinMain(HINSTANCE hInstance,
|
|
|
|
|
HINSTANCE prev,
|
|
|
|
|
LPTSTR cmdline,
|
|
|
|
|
int show)
|
2014-12-05 21:43:00 +00:00
|
|
|
|
{
|
2014-12-05 22:09:10 +00:00
|
|
|
|
HANDLE hMutex;
|
2014-12-05 21:43:00 +00:00
|
|
|
|
|
2014-12-05 22:09:10 +00:00
|
|
|
|
UNREFERENCED_PARAMETER(prev);
|
|
|
|
|
UNREFERENCED_PARAMETER(cmdline);
|
|
|
|
|
UNREFERENCED_PARAMETER(show);
|
2014-12-05 21:43:00 +00:00
|
|
|
|
|
2014-12-05 22:09:10 +00:00
|
|
|
|
ZeroMemory(&Globals, sizeof(Globals));
|
|
|
|
|
Globals.hInstance = hInstance;
|
2014-12-05 21:43:00 +00:00
|
|
|
|
|
2014-12-05 22:09:10 +00:00
|
|
|
|
/* Rry to open a mutex for a single instance */
|
|
|
|
|
hMutex = OpenMutexA(MUTEX_ALL_ACCESS, FALSE, "osk");
|
2014-12-05 21:43:00 +00:00
|
|
|
|
|
2014-12-05 22:09:10 +00:00
|
|
|
|
if (!hMutex)
|
|
|
|
|
{
|
|
|
|
|
/* Mutex doesn<73>t exist. This is the first instance so create the mutex. */
|
|
|
|
|
hMutex = CreateMutexA(NULL, FALSE, "osk");
|
2014-12-05 21:43:00 +00:00
|
|
|
|
|
2014-12-05 22:09:10 +00:00
|
|
|
|
DialogBox(hInstance,
|
|
|
|
|
MAKEINTRESOURCE(MAIN_DIALOG),
|
|
|
|
|
GetDesktopWindow(),
|
|
|
|
|
OSK_DlgProc);
|
2014-12-05 21:43:00 +00:00
|
|
|
|
|
2014-12-05 22:09:10 +00:00
|
|
|
|
/* Delete the mutex */
|
|
|
|
|
if (hMutex) CloseHandle(hMutex);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Programme already launched */
|
2014-12-05 21:43:00 +00:00
|
|
|
|
|
2014-12-05 22:09:10 +00:00
|
|
|
|
/* Delete the mutex */
|
|
|
|
|
CloseHandle(hMutex);
|
2014-12-05 21:43:00 +00:00
|
|
|
|
|
2014-12-05 22:09:10 +00:00
|
|
|
|
ExitProcess(0);
|
|
|
|
|
}
|
2014-12-05 21:43:00 +00:00
|
|
|
|
|
2014-12-05 22:09:10 +00:00
|
|
|
|
return 0;
|
2014-12-05 21:43:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* EOF */
|