source: trunk/dll/gotchdll.c@ 57

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

Add a -p command line switch to allow use of the default PM Print screen behavior (capture to printer)

  • Property svn:eol-style set to native
File size: 3.2 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;
[57]34BOOL usePMps;
[2]35
[57]36void EXPENTRY InitDLL (HAB hab, HWND hwnd, BOOL g_usePMps)
[2]37{
38 habDLL = hab;
39 hwndFrame = hwnd;
[57]40 usePMps = g_usePMps;
[27]41 DosLoadModule (NULL, 0, "GOTCHDLL", &hMod);
[2]42}
43
[27]44BOOL EXPENTRY InputProc (HAB hab, PQMSG pqmsg, ULONG ul)
45{
46 USHORT usFlags;
47 USHORT usScan;
48
49 if (pqmsg->msg != WM_CHAR
50 || (usFlags = SHORT1FROMMP(pqmsg->mp1), usScan =
51 SHORT2FROMMP (pqmsg->mp2), (usFlags & KC_SCANCODE)) == 0){
52 return FALSE;
53 }
54
55 if (CHAR4FROMMP(pqmsg->mp1) == 0x54 ) {
56 if (usFlags & KC_KEYUP) {
57 WinPostMsg (hwndFrame, WM_COMMAND,
58 MPFROM2SHORT (WID_PB_SETTINGS,0), 0);
59 /*DosBeep( 1000, 10 );
60 DosBeep( 2000, 20 );
61 DosBeep( 3000, 30 ); */
62 return TRUE;
63 } else {
64 /* DosBeep( 3000, 30 );
65 DosBeep( 2000, 20 );
66 DosBeep( 1000, 10 );*/
67 return TRUE;
68 }
69 }
[41]70 else if ((usScan == VK_PRINTSCRN || CHAR4FROMMP(pqmsg->mp1) == 93 ) &&
71 (usFlags & KC_CTRL)) {
[27]72 if (usFlags & KC_KEYUP) {
73 WinPostMsg (hwndFrame, WM_COMMAND,
[41]74 MPFROM2SHORT (WID_PB_SETCAPTURETYPE,0), MPFROMLONG(1));
75 return TRUE;
76 }
77
78 }
[57]79 else if ((usScan == VK_PRINTSCRN || CHAR4FROMMP(pqmsg->mp1) == 93 ) &&
80 (usFlags & KC_SHIFT)) {
[41]81 if (usFlags & KC_KEYUP) {
82 WinPostMsg (hwndFrame, WM_COMMAND,
[27]83 MPFROM2SHORT (WID_PB_SETCAPTURETYPE,0), 0);
84 return TRUE;
85 }
86 }
[57]87 else if (!usePMps && (usScan == VK_PRINTSCRN ||
88 CHAR4FROMMP(pqmsg->mp1) == 93 )) {
89 if (usFlags & KC_KEYUP) {
90 WinPostMsg (hwndFrame, WM_COMMAND,
91 MPFROM2SHORT (WID_PB_SETCAPTURETYPE,0), 0);
92 return TRUE;
93 }
94 }
[27]95 return FALSE;
96}
97
[2]98void EXPENTRY StartInputHook (void)
99{
[27]100 WinSetHook (habDLL, NULLHANDLE, HK_PREACCEL, (PFN) InputProc, hMod);
[2]101}
102
103void EXPENTRY StopInputHook (void)
104{
[27]105 WinReleaseHook (habDLL, NULLHANDLE, HK_PREACCEL, (PFN) InputProc, hMod);
[2]106 DosFreeModule (hMod);
107}
108
109USHORT Version (VOID)
110{
[50]111 return 2;
[2]112}
Note: See TracBrowser for help on using the repository browser.