58 if (IS_WINVISTA && cr.cpMin == cr.cpMax) {
59 ::InvalidateRect(GetHWnd(), NULL, TRUE);
60 }
61
62 }
63
64 LRESULT AwtTextField::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
65 {
66 if (message == WM_UNDO || message == EM_UNDO || message == EM_CANUNDO) {
67 if (GetWindowLong(GetHWnd(), GWL_STYLE) & ES_READONLY) {
68 return FALSE;
69 }
70 }
71 return AwtTextComponent::WindowProc(message, wParam, lParam);
72 }
73
74 MsgRouting
75 AwtTextField::HandleEvent(MSG *msg, BOOL synthetic)
76 {
77 MsgRouting returnVal;
78 /*
79 * RichEdit 1.0 control starts internal message loop if the
80 * left mouse button is pressed while the cursor is not over
81 * the current selection or the current selection is empty.
82 * Because of this we don't receive WM_MOUSEMOVE messages
83 * while the left mouse button is pressed. To work around
84 * this behavior we process the relevant mouse messages
85 * by ourselves.
86 * By consuming WM_MOUSEMOVE messages we also don't give
87 * the RichEdit control a chance to recognize a drag gesture
88 * and initiate its own drag-n-drop operation.
89 *
90 * The workaround also allows us to implement synthetic focus mechanism.
91 */
92 if (IsFocusingMouseMessage(msg)) {
93
94 LONG lCurPos = EditGetCharFromPos(msg->pt);
95
96 /*
97 * NOTE: Plain EDIT control always clears selection on mouse
200 si.fMask = SIF_PAGE | SIF_POS | SIF_RANGE;
201
202 VERIFY(::GetScrollInfo(GetHWnd(), SB_HORZ, &si));
203 if (bScrollLeft == TRUE) {
204 si.nPos = si.nPos - si.nPage / 2;
205 si.nPos = max(si.nMin, si.nPos);
206 } else if (bScrollRight == TRUE) {
207 si.nPos = si.nPos + si.nPage / 2;
208 si.nPos = min(si.nPos, si.nMax);
209 }
210 /*
211 * Okay to use 16-bit position since RichEdit control adjusts
212 * its scrollbars so that their range is always 16-bit.
213 */
214 DASSERT(abs(si.nPos) < 0x8000);
215 SendMessage(WM_HSCROLL,
216 MAKEWPARAM(SB_THUMBPOSITION, LOWORD(si.nPos)));
217 }
218 delete msg;
219 return mrConsume;
220 }
221 /*
222 * Store the 'synthetic' parameter so that the WM_PASTE security check
223 * happens only for synthetic events.
224 */
225 m_synthetic = synthetic;
226 returnVal = AwtComponent::HandleEvent(msg, synthetic);
227 m_synthetic = FALSE;
228
229 return returnVal;
230 }
231
232 void AwtTextField::_SetEchoChar(void *param)
233 {
234 JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
235
236 SetEchoCharStruct *secs = (SetEchoCharStruct *)param;
237 jobject self = secs->textfield;
238 jchar echo = secs->echoChar;
239
240 AwtTextField *c = NULL;
241
242 PDATA pData;
243 JNI_CHECK_PEER_GOTO(self, ret);
244 c = (AwtTextField *)pData;
245 if (::IsWindow(c->GetHWnd()))
246 {
247 c->SendMessage(EM_SETPASSWORDCHAR, echo);
|
58 if (IS_WINVISTA && cr.cpMin == cr.cpMax) {
59 ::InvalidateRect(GetHWnd(), NULL, TRUE);
60 }
61
62 }
63
64 LRESULT AwtTextField::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
65 {
66 if (message == WM_UNDO || message == EM_UNDO || message == EM_CANUNDO) {
67 if (GetWindowLong(GetHWnd(), GWL_STYLE) & ES_READONLY) {
68 return FALSE;
69 }
70 }
71 return AwtTextComponent::WindowProc(message, wParam, lParam);
72 }
73
74 MsgRouting
75 AwtTextField::HandleEvent(MSG *msg, BOOL synthetic)
76 {
77 MsgRouting returnVal;
78 BOOL systemBeeperEnabled = FALSE;
79 /*
80 * RichEdit 1.0 control starts internal message loop if the
81 * left mouse button is pressed while the cursor is not over
82 * the current selection or the current selection is empty.
83 * Because of this we don't receive WM_MOUSEMOVE messages
84 * while the left mouse button is pressed. To work around
85 * this behavior we process the relevant mouse messages
86 * by ourselves.
87 * By consuming WM_MOUSEMOVE messages we also don't give
88 * the RichEdit control a chance to recognize a drag gesture
89 * and initiate its own drag-n-drop operation.
90 *
91 * The workaround also allows us to implement synthetic focus mechanism.
92 */
93 if (IsFocusingMouseMessage(msg)) {
94
95 LONG lCurPos = EditGetCharFromPos(msg->pt);
96
97 /*
98 * NOTE: Plain EDIT control always clears selection on mouse
201 si.fMask = SIF_PAGE | SIF_POS | SIF_RANGE;
202
203 VERIFY(::GetScrollInfo(GetHWnd(), SB_HORZ, &si));
204 if (bScrollLeft == TRUE) {
205 si.nPos = si.nPos - si.nPage / 2;
206 si.nPos = max(si.nMin, si.nPos);
207 } else if (bScrollRight == TRUE) {
208 si.nPos = si.nPos + si.nPage / 2;
209 si.nPos = min(si.nPos, si.nMax);
210 }
211 /*
212 * Okay to use 16-bit position since RichEdit control adjusts
213 * its scrollbars so that their range is always 16-bit.
214 */
215 DASSERT(abs(si.nPos) < 0x8000);
216 SendMessage(WM_HSCROLL,
217 MAKEWPARAM(SB_THUMBPOSITION, LOWORD(si.nPos)));
218 }
219 delete msg;
220 return mrConsume;
221 } else if (msg->message == WM_KEYDOWN) {
222 UINT virtualKey = (UINT) msg->wParam;
223
224 switch(virtualKey){
225 case VK_RETURN:
226 case VK_UP:
227 case VK_DOWN:
228 case VK_LEFT:
229 case VK_RIGHT:
230 case VK_DELETE:
231 case VK_BACK:
232 SystemParametersInfo(SPI_GETBEEP, 0, &systemBeeperEnabled, 0);
233 if(systemBeeperEnabled){
234 // disable system beeper for the RICHEDIT control to be compatible
235 // with the EDIT control behaviour
236 SystemParametersInfo(SPI_SETBEEP, 0, NULL, 0);
237 }
238 break;
239 }
240 }
241 /*
242 * Store the 'synthetic' parameter so that the WM_PASTE security check
243 * happens only for synthetic events.
244 */
245 m_synthetic = synthetic;
246 returnVal = AwtComponent::HandleEvent(msg, synthetic);
247 m_synthetic = FALSE;
248
249 if(systemBeeperEnabled){
250 SystemParametersInfo(SPI_SETBEEP, 1, NULL, 0);
251 }
252
253 return returnVal;
254 }
255
256 void AwtTextField::_SetEchoChar(void *param)
257 {
258 JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
259
260 SetEchoCharStruct *secs = (SetEchoCharStruct *)param;
261 jobject self = secs->textfield;
262 jchar echo = secs->echoChar;
263
264 AwtTextField *c = NULL;
265
266 PDATA pData;
267 JNI_CHECK_PEER_GOTO(self, ret);
268 c = (AwtTextField *)pData;
269 if (::IsWindow(c->GetHWnd()))
270 {
271 c->SendMessage(EM_SETPASSWORDCHAR, echo);
|