|
|
1.1 root 1: Microsoft Foundation Classes Microsoft Corporation
2: Technical Notes
3:
4: #15 : Windows for Pen interface to MFC
5:
6: This note describes the extra interfaces in 'afxpen.h' that
7: provide a C++ interface to the Windows for Pen environment.
8:
9: =============================================================================
10: What is Windows for Pen ?
11: =========================
12:
13: Windows for Pen is an extension to Windows 3.1 that provides
14: a new input paradigm that uses a pen or stylus for hand writing input.
15:
16: If you already have Windows for Pen running on your system, then
17: you don't need any more description. If you don't have it running
18: already, please read on, because you can try Pen for Windows
19: without having to buy any extra hardware.
20:
21: Installing the driver:
22: ----------------------
23: The Windows SDK includes a sample driver and associated DLLs for a subset
24: of the Pen Windows environment. The Microsoft Mouse can be used to get
25: a rough idea of how recognition and a pen will work.
26:
27: The file \windev\pen\readme.txt describes the steps needed to
28: install the Pen driver for either a mouse or tablet based system.
29:
30: MFC Samples:
31: ------------
32: All the the MFC samples, and all MFC applications automatically
33: are pen aware. That means that all standard edit controls will
34: respond to handwriting.
35:
36: Two of the MFC samples support specialized Windows for Pen features.
37:
38: CTRLTEST (\c700\mfc\samples\ctrltest) is a general control test applet,
39: that includes tests for the extra Pen controls (described below). If
40: CTRLTEST is run without Windows for Pen installed, the "Pen" test menu
41: will be disabled.
42:
43: SPEAKN (\c700\mfc\samples\speakn) is a sample that uses multimedia
44: sound output and the pen input for a simple spelling test. This
45: sample requires a sound capable machine (eg: a full MPC machine
46: is not required) and the Window for Pen drivers and DLLs.
47:
48: =============================================================================
49: Being Pen Aware:
50: ================
51:
52: There are various degrees of support for pen. MFC gives your
53: applications the first level of support for free. All MFC
54: applications are pen aware, so that normal EDIT/CEdit edit items
55: will recognize handwriting automatically.
56:
57: With work on your part, you can make your application exploit more of
58: the features of pen.
59:
60: Pen only apps:
61: --------------
62: If you want to write a pen-only application, an application that
63: requires features of the pen API or the special pen edit controls,
64: you must do an extra test in your application's InitInstance
65: to make sure that the current running system supports pen input
66: (and the PENWIN.DLL is loaded).
67:
68: The SPEAKN example shows such a test (using ::GetSystemMetrics for
69: SM_PENWINDOWS), and a reasonable MessageBox to alert the user that
70: Windows for Pen is required to run this application.
71:
72: Pen-only applications should be marked as Win3.1 only applications
73: as well (i.e. pass '/31' to the second pass RC command line, see SPEAKN for
74: an example).
75:
76: Pen Edit controls:
77: ------------------
78: There are two special handwriting input edit controls supported
79: by Windows for Pen and MFC. HEdit is for handwriting edit input,
80: and BEdit is like HEdit, but is for boxed input (those little boxes
81: or combs that show where the letters should go).
82: These controls and the C++ class interfaces to them provide many
83: ways to customize visuals, recognition and so on.
84:
85: Handling Writing:
86: -----------------
87: Another way of exploiting the pen is to actually process writing
88: in your client area of your application.
89: The complete C Pen API is available to you. Please refer to
90: the Windows for Pen documentation in the WIndows SDK for more
91: details.
92:
93: =============================================================================
94: Two special controls:
95: =====================
96:
97: The header file AFXPEN.H includes two C++ classes that interface
98: with the Windows for Pen controls HEDIT and BEDIT.
99:
100: HEDIT is the general handwriting edit item that you can place in
101: dialogs or wherever you would place a normal edit item. The
102: C++ class CHEdit gives you a C++ interface to this control
103: (just as CEdit gives you a C++ interface to the Windows EDIT control).
104:
105: BEDIT provides additional functionality for boxed edits.
106: The C++ class CBEdit gives you a C++ interface to this control.
107:
108: For more details on these functions and the behaviour of these
109: two edit controls, please refer to the Pen SDK documentation
110: (\BIN\PENAPIWH.HLP or \HELP\PENAPIQH.HLP).
111: Most of the HEDIT and BEDIT behavior is documented in the topic for
112: WM_HEDITCTL.
113:
114:
115: CHEdit member functions:
116: ------------------------
117: GetInflate/SetInflate Get/set the inflation size
118: GetRC/SetRC Get/set the local recognition context
119: GetUnderline/SetUnderline Get/set the HEdit underline mode
120:
121: GetInkHandle Get the current captured ink (can be NULL)
122: SetInkMode Start capturing ink
123: StopInkMode Stop capturing ink
124:
125: CBEdit member functions:
126: ------------------------
127: CharOffset Get byte offset from logical position
128: CharPosition Get logical position from byte offset
129: Get/SetBoxLayout Get/set the BOXLAYOUT structure
130: DefaultFont Set back to default font
131:
132: =============================================================================
133: Pen samples:
134: ============
135:
136: Along with the samples in the Win SDK (\SAMPLES\...) there are two
137: MFC specific sample applications that illustrate the use of Pen.
138:
139: CTRLTEST (\C700\MFC\SAMPLES\CTRLTEST) provides several custom control
140: examples, including samples of CHEdit and CBEdit controls. This shows
141: you both how to create them from C++ code, as well as creating them
142: from dialog templates.
143:
144: =============================================================================
145: Other Pen APIs:
146: ===============
147:
148: If you start using some of the more sophisticated features of Windows
149: for Pen, some of these interfaces require HWNDs or Windows callbacks.
150:
151: You can use the extensible message map architecture to handle the
152: new pen windows messages.
153:
154: New Pen specific windows messages:
155: ON_MESSAGE(WM_RCRESULT, OnRcResult)
156: // notification of recognition result
157: ON_MESSAGE(WM_GLOBALRCCHANGE, OnGlobalRcChange)
158: // notification of global recongnition parameter changes
159: ON_MESSAGE(WM_SKB, OnSystemKeyboardChange)
160: // notification of system keyboard change
161:
162: New Pen specific HEDIT control notifications:
163: ON_CONTROL(HN_ENDREC, IDC_???, OnEndRec)
164: ON_CONTROL(HN_DELAYEDRECOGFAIL, IDC_???, OnDelayedRecogFail)
165: ON_CONTROL(HN_ENDREC, IDC_???, OnRcResult)
166: // where IDC_??? is the control ID of an HEDIT control
167:
168: New Pen specific combo-box control notifications:
169: ON_CONTROL(CBN_ENDREC, IDC_???, OnEndRec)
170: ON_CONTROL(CBN_DELAYEDRECOGFAIL, IDC_???, OnDelayedRecogFail)
171: ON_CONTROL(CBN_ENDREC, IDC_???, OnRcResult)
172: // where IDC_??? is the control ID of a combobox control
173:
174: =============================================================================
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.