| [2] | 1 | /***
|
|---|
| 2 | This file belongs to the Gotcha! distribution.
|
|---|
| 3 | Copyright (C) 1998-2002 Thorsten Thielen <thth@c2226.de>
|
|---|
| 4 |
|
|---|
| 5 | This program is free software; you can redistribute it and/or modify
|
|---|
| 6 | it under the terms of the GNU General Public License as published by
|
|---|
| 7 | the Free Software Foundation; either version 2 of the License, or
|
|---|
| 8 | (at your option) any later version.
|
|---|
| 9 |
|
|---|
| 10 | This program is distributed in the hope that it will be useful,
|
|---|
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 13 | GNU General Public License for more details.
|
|---|
| 14 |
|
|---|
| 15 | You should have received a copy of the GNU General Public License
|
|---|
| 16 | along with this program; if not, write to the Free Software
|
|---|
| 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|---|
| 18 | ***/
|
|---|
| 19 |
|
|---|
| 20 | #define INCL_WIN
|
|---|
| 21 | #define INCL_DOS
|
|---|
| 22 | #include <os2.h>
|
|---|
| 23 | #include "../id.h"
|
|---|
| 24 |
|
|---|
| 25 | HAB habDLL;
|
|---|
| 26 | HWND hwndFrame;
|
|---|
| 27 | HMODULE hMod;
|
|---|
| 28 | PFN pfnInput;
|
|---|
| 29 |
|
|---|
| 30 | void EXPENTRY InitDLL (HAB hab, HWND hwnd)
|
|---|
| 31 | {
|
|---|
| 32 | habDLL = hab;
|
|---|
| 33 | hwndFrame = hwnd;
|
|---|
| 34 | DosLoadModule (NULL, 0, "GOTCHA", &hMod);
|
|---|
| 35 | DosQueryProcAddr (hMod, 0, "InputProc", &pfnInput);
|
|---|
| 36 | }
|
|---|
| 37 |
|
|---|
| 38 | void EXPENTRY StartInputHook (void)
|
|---|
| 39 | {
|
|---|
| 40 | WinSetHook (habDLL, NULLHANDLE, HK_INPUT, pfnInput, hMod);
|
|---|
| 41 | }
|
|---|
| 42 |
|
|---|
| 43 | void EXPENTRY StopInputHook (void)
|
|---|
| 44 | {
|
|---|
| 45 | WinReleaseHook (habDLL, NULLHANDLE, HK_INPUT, pfnInput, hMod);
|
|---|
| 46 | DosFreeModule (hMod);
|
|---|
| 47 | }
|
|---|
| 48 |
|
|---|
| 49 | BOOL EXPENTRY InputProc (HAB hab, PQMSG pqmsg, ULONG ul)
|
|---|
| 50 | {
|
|---|
| 51 | if (pqmsg->msg == WM_CHAR) {
|
|---|
| 52 | if ((SHORT1FROMMP (pqmsg->mp1) & KC_VIRTUALKEY) &&
|
|---|
| 53 | (SHORT2FROMMP (pqmsg->mp2) == VK_PRINTSCRN)) {
|
|---|
| 54 | if (SHORT1FROMMP (pqmsg->mp1) & KC_KEYUP) {
|
|---|
| 55 | WinPostMsg (hwndFrame, WM_COMMAND,
|
|---|
| 56 | MPFROM2SHORT (WID_PB_SCREENREGION,0), 0);
|
|---|
| 57 | /*DosBeep( 1000, 10 );
|
|---|
| 58 | DosBeep( 2000, 20 );
|
|---|
| 59 | DosBeep( 3000, 30 ); */
|
|---|
| 60 | return TRUE;
|
|---|
| 61 | } else {
|
|---|
| 62 | /*DosBeep( 3000, 30 );
|
|---|
| 63 | DosBeep( 2000, 20 );
|
|---|
| 64 | DosBeep( 1000, 10 ); */
|
|---|
| 65 | return TRUE;
|
|---|
| 66 | }
|
|---|
| 67 | }
|
|---|
| 68 | }
|
|---|
| 69 | return FALSE;
|
|---|
| 70 | }
|
|---|
| 71 |
|
|---|
| 72 | USHORT Version (VOID)
|
|---|
| 73 | {
|
|---|
| 74 | return 1;
|
|---|
| 75 | }
|
|---|