source: trunk/dll/gotchdll.c@ 50

Last change on this file since 50 was 50, checked in by Gregg Young, 7 years ago

Only allow single instance of Gotcha Quiet; Disable PM print screen setting on opening Gotcha Quiet and restore it to what ever it was set to on exit. Update the hook version.

  • Property svn:eol-style set to native
File size: 2.8 KB
RevLine 
[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
[27]25//#define __PMPRINTF__
26//#include "PMPRINTF.H"
27
28/* pre-accelerator input hook, undocumented, */
29#define HK_PREACCEL 17
30
[2]31HAB habDLL;
32HWND hwndFrame;
33HMODULE hMod;
34
35void EXPENTRY InitDLL (HAB hab, HWND hwnd)
36{
37 habDLL = hab;
38 hwndFrame = hwnd;
[27]39 DosLoadModule (NULL, 0, "GOTCHDLL", &hMod);
[2]40}
41
[27]42BOOL EXPENTRY InputProc (HAB hab, PQMSG pqmsg, ULONG ul)
43{
44 USHORT usFlags;
45 USHORT usScan;
46
47 if (pqmsg->msg != WM_CHAR
48 || (usFlags = SHORT1FROMMP(pqmsg->mp1), usScan =
49 SHORT2FROMMP (pqmsg->mp2), (usFlags & KC_SCANCODE)) == 0){
50 return FALSE;
51 }
52
53 if (CHAR4FROMMP(pqmsg->mp1) == 0x54 ) {
54 if (usFlags & KC_KEYUP) {
55 WinPostMsg (hwndFrame, WM_COMMAND,
56 MPFROM2SHORT (WID_PB_SETTINGS,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 }
[41]68 else if ((usScan == VK_PRINTSCRN || CHAR4FROMMP(pqmsg->mp1) == 93 ) &&
69 (usFlags & KC_CTRL)) {
[27]70 if (usFlags & KC_KEYUP) {
71 WinPostMsg (hwndFrame, WM_COMMAND,
[41]72 MPFROM2SHORT (WID_PB_SETCAPTURETYPE,0), MPFROMLONG(1));
73 return TRUE;
74 }
75
76 }
77 else if ((usScan == VK_PRINTSCRN || CHAR4FROMMP(pqmsg->mp1) == 93 )) {
78 if (usFlags & KC_KEYUP) {
79 WinPostMsg (hwndFrame, WM_COMMAND,
[27]80 MPFROM2SHORT (WID_PB_SETCAPTURETYPE,0), 0);
81 return TRUE;
82 }
83
84 }
85 return FALSE;
86}
87
[2]88void EXPENTRY StartInputHook (void)
89{
[27]90 WinSetHook (habDLL, NULLHANDLE, HK_PREACCEL, (PFN) InputProc, hMod);
[2]91}
92
93void EXPENTRY StopInputHook (void)
94{
[27]95 WinReleaseHook (habDLL, NULLHANDLE, HK_PREACCEL, (PFN) InputProc, hMod);
[2]96 DosFreeModule (hMod);
97}
98
99USHORT Version (VOID)
100{
[50]101 return 2;
[2]102}
Note: See TracBrowser for help on using the repository browser.