no message
[wxWidgets.git] / src / msw / penwin.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: penwin.cpp
3 // Purpose: PenWindows code
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 04/01/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation
14 #endif
15
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
18
19 #ifdef __BORLANDC__
20 #pragma hdrstop
21 #endif
22
23 #ifndef WX_PRECOMP
24 #include "wx/setup.h"
25 #endif
26
27 #include "wx/msw/private.h"
28
29 #if wxUSE_PENWINDOWS
30
31 #ifdef __BORLANDC__
32 #define RPA_DEFAULT 1
33 #else
34 #include <penwin.h>
35 #endif
36
37 HANDLE g_hPenWin = (HANDLE)NULL;
38 typedef void (CALLBACK * PENREGPROC)(WORD,BOOL);
39
40 // The routine below allows Windows applications (binaries) to
41 // support Pen input when running under Microsoft Windows for
42 // Pen Computing 1.0 without need of the PenPalete.
43 //
44 // Should masked edit functions be added to wxWindows we would
45 // be a new class of functions to support BEDIT controls.
46 //
47 // (The function is a NOOP for native Windows-NT)
48 #ifndef __WIN32__
49 static void (CALLBACK * RegPenApp) (WORD, BOOL) = NULL;
50 #endif
51
52 // Where is this called??
53 void wxEnablePenAppHooks (bool hook)
54 {
55 #ifndef __WIN32__
56 if (hook)
57 {
58 if (g_hPenWin)
59 return;
60
61 ///////////////////////////////////////////////////////////////////////
62 // If running on a Pen Windows system, register this app so all
63 // EDIT controls in dialogs are replaced by HEDIT controls.
64 if ((g_hPenWin = (HANDLE)GetSystemMetrics (SM_PENWINDOWS)) != (HANDLE) NULL)
65 {
66 // We do this fancy GetProcAddress simply because we don't
67 // know if we're running Pen Windows.
68 if ((RegPenApp = (PENREGPROC)GetProcAddress (g_hPenWin, "RegisterPenApp")) != NULL)
69 (*RegPenApp) (RPA_DEFAULT, TRUE);
70 }
71 }
72 else
73 {
74 ///////////////////////////////////////////////////////////////////////
75 // If running on a Pen Windows system, unregister
76 if (g_hPenWin)
77 {
78 // Unregister this app
79 if (RegPenApp != NULL)
80 (*RegPenApp) (RPA_DEFAULT, FALSE);
81 g_hPenWin = (HANDLE) NULL;
82 }
83 }
84 #endif /* ! Windows-NT */
85 }
86
87 #endif
88 // End wxUSE_PENWINDOWS
89
90 void wxRegisterPenWin(void)
91 {
92 #if wxUSE_PENWINDOWS
93 ///////////////////////////////////////////////////////////////////////
94 // If running on a Pen Windows system, register this app so all
95 // EDIT controls in dialogs are replaced by HEDIT controls.
96 // (Notice the CONTROL statement in the RC file is "EDIT",
97 // RegisterPenApp will automatically change that control to
98 // an HEDIT.
99 if ((g_hPenWin = (HANDLE)GetSystemMetrics(SM_PENWINDOWS)) != (HANDLE)NULL) {
100 // We do this fancy GetProcAddress simply because we don't
101 // know if we're running Pen Windows.
102 if ( (RegPenApp = (void (CALLBACK *)(WORD, BOOL))GetProcAddress(g_hPenWin, "RegisterPenApp"))!= NULL)
103 (*RegPenApp)(RPA_DEFAULT, TRUE);
104 }
105 ///////////////////////////////////////////////////////////////////////
106 #endif
107 }
108
109 void wxCleanUpPenWin(void)
110 {
111 #if wxUSE_PENWINDOWS
112 if (g_hPenWin) {
113 // Unregister this app
114 if (RegPenApp != NULL)
115 (*RegPenApp)(RPA_DEFAULT, FALSE);
116 }
117 #endif
118 }
119