advapi32: Implement LsaSetSecret stub.
[wine/wine-kai.git] / dlls / user32 / tests / edit.c
blobb70dae53c316908a9b225092d0e6c31b6b05ba65
1 /* Unit test suite for edit control.
3 * Copyright 2004 Vitaliy Margolen
4 * Copyright 2005 C. Scott Ananian
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <assert.h>
22 #include <windows.h>
23 #include <commctrl.h>
25 #include "wine/test.h"
27 #ifndef ES_COMBO
28 #define ES_COMBO 0x200
29 #endif
31 #define ID_EDITTEST2 99
32 #define MAXLEN 200
34 struct edit_notify {
35 int en_change, en_maxtext, en_update;
38 static struct edit_notify notifications;
40 static INT_PTR CALLBACK multi_edit_dialog_proc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
42 static int num_ok_commands = 0;
43 switch (msg)
45 case WM_INITDIALOG:
47 HWND hedit = GetDlgItem(hdlg, 1000);
48 SetFocus(hedit);
49 switch (lparam)
51 /* test cases related to bug 12319 */
52 case 0:
53 PostMessage(hedit, WM_KEYDOWN, VK_TAB, 0xf0001);
54 PostMessage(hdlg, WM_USER, 0xdeadbeef, 0);
55 break;
56 case 1:
57 PostMessage(hedit, WM_CHAR, VK_TAB, 0xf0001);
58 PostMessage(hdlg, WM_USER, 0xdeadbeef, 0);
59 break;
60 case 2:
61 PostMessage(hedit, WM_KEYDOWN, VK_TAB, 0xf0001);
62 PostMessage(hedit, WM_CHAR, VK_TAB, 0xf0001);
63 PostMessage(hdlg, WM_USER, 0xdeadbeef, 0);
64 break;
66 /* test cases for pressing enter */
67 case 3:
68 num_ok_commands = 0;
69 PostMessage(hedit, WM_KEYDOWN, VK_RETURN, 0x1c0001);
70 PostMessage(hdlg, WM_USER, 0xdeadbeef, 1);
71 break;
73 default:
74 break;
76 break;
79 case WM_COMMAND:
80 if (HIWORD(wparam) != BN_CLICKED)
81 break;
83 switch (LOWORD(wparam))
85 case IDOK:
86 num_ok_commands++;
87 break;
89 default:
90 break;
92 break;
94 case WM_USER:
96 HWND hfocus = GetFocus();
97 HWND hedit = GetDlgItem(hdlg, 1000);
98 HWND hedit2 = GetDlgItem(hdlg, 1001);
99 HWND hedit3 = GetDlgItem(hdlg, 1002);
101 if (wparam != 0xdeadbeef)
102 break;
104 switch (lparam)
106 case 0:
107 if (hfocus == hedit)
108 EndDialog(hdlg, 1111);
109 else if (hfocus == hedit2)
110 EndDialog(hdlg, 2222);
111 else if (hfocus == hedit3)
112 EndDialog(hdlg, 3333);
113 else
114 EndDialog(hdlg, 4444);
115 break;
116 case 1:
117 if ((hfocus == hedit) && (num_ok_commands == 0))
118 EndDialog(hdlg, 11);
119 else
120 EndDialog(hdlg, 22);
121 break;
122 default:
123 EndDialog(hdlg, 5555);
125 break;
128 case WM_CLOSE:
129 EndDialog(hdlg, 333);
130 break;
132 default:
133 break;
136 return FALSE;
139 static INT_PTR CALLBACK edit_dialog_proc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
141 switch (msg)
143 case WM_INITDIALOG:
145 HWND hedit = GetDlgItem(hdlg, 1000);
146 SetFocus(hedit);
147 switch (lparam)
149 /* from bug 11841 */
150 case 0:
151 PostMessage(hedit, WM_KEYDOWN, VK_ESCAPE, 0x10001);
152 break;
153 case 1:
154 PostMessage(hedit, WM_KEYDOWN, VK_RETURN, 0x1c0001);
155 break;
156 case 2:
157 PostMessage(hedit, WM_KEYDOWN, VK_TAB, 0xf0001);
158 PostMessage(hdlg, WM_USER, 0xdeadbeef, 1);
159 break;
161 /* more test cases for WM_CHAR */
162 case 3:
163 PostMessage(hedit, WM_CHAR, VK_ESCAPE, 0x10001);
164 PostMessage(hdlg, WM_USER, 0xdeadbeef, 0);
165 break;
166 case 4:
167 PostMessage(hedit, WM_CHAR, VK_RETURN, 0x1c0001);
168 PostMessage(hdlg, WM_USER, 0xdeadbeef, 0);
169 break;
170 case 5:
171 PostMessage(hedit, WM_CHAR, VK_TAB, 0xf0001);
172 PostMessage(hdlg, WM_USER, 0xdeadbeef, 0);
173 break;
175 /* more test cases for WM_KEYDOWN + WM_CHAR */
176 case 6:
177 PostMessage(hedit, WM_KEYDOWN, VK_ESCAPE, 0x10001);
178 PostMessage(hedit, WM_CHAR, VK_ESCAPE, 0x10001);
179 PostMessage(hdlg, WM_USER, 0xdeadbeef, 0);
180 break;
181 case 7:
182 PostMessage(hedit, WM_KEYDOWN, VK_RETURN, 0x1c0001);
183 PostMessage(hedit, WM_CHAR, VK_RETURN, 0x1c0001);
184 PostMessage(hdlg, WM_USER, 0xdeadbeef, 1);
185 break;
186 case 8:
187 PostMessage(hedit, WM_KEYDOWN, VK_TAB, 0xf0001);
188 PostMessage(hedit, WM_CHAR, VK_TAB, 0xf0001);
189 PostMessage(hdlg, WM_USER, 0xdeadbeef, 1);
190 break;
192 /* multiple tab tests */
193 case 9:
194 PostMessage(hedit, WM_KEYDOWN, VK_TAB, 0xf0001);
195 PostMessage(hedit, WM_KEYDOWN, VK_TAB, 0xf0001);
196 PostMessage(hdlg, WM_USER, 0xdeadbeef, 2);
197 break;
198 case 10:
199 PostMessage(hedit, WM_KEYDOWN, VK_TAB, 0xf0001);
200 PostMessage(hedit, WM_KEYDOWN, VK_TAB, 0xf0001);
201 PostMessage(hedit, WM_KEYDOWN, VK_TAB, 0xf0001);
202 PostMessage(hdlg, WM_USER, 0xdeadbeef, 2);
203 break;
205 default:
206 break;
208 break;
211 case WM_COMMAND:
212 if (HIWORD(wparam) != BN_CLICKED)
213 break;
215 switch (LOWORD(wparam))
217 case IDOK:
218 EndDialog(hdlg, 111);
219 break;
221 case IDCANCEL:
222 EndDialog(hdlg, 222);
223 break;
225 default:
226 break;
228 break;
230 case WM_USER:
232 int len;
233 HWND hok = GetDlgItem(hdlg, IDOK);
234 HWND hcancel = GetDlgItem(hdlg, IDCANCEL);
235 HWND hedit = GetDlgItem(hdlg, 1000);
236 HWND hfocus = GetFocus();
238 if (wparam != 0xdeadbeef)
239 break;
241 switch (lparam)
243 case 0:
244 len = SendMessage(hedit, WM_GETTEXTLENGTH, 0, 0);
245 if (len == 0)
246 EndDialog(hdlg, 444);
247 else
248 EndDialog(hdlg, 555);
249 break;
251 case 1:
252 len = SendMessage(hedit, WM_GETTEXTLENGTH, 0, 0);
253 if ((hfocus == hok) && len == 0)
254 EndDialog(hdlg, 444);
255 else
256 EndDialog(hdlg, 555);
257 break;
259 case 2:
260 if (hfocus == hok)
261 EndDialog(hdlg, 11);
262 else if (hfocus == hcancel)
263 EndDialog(hdlg, 22);
264 else if (hfocus == hedit)
265 EndDialog(hdlg, 33);
266 else
267 EndDialog(hdlg, 44);
268 break;
270 default:
271 EndDialog(hdlg, 555);
273 break;
276 case WM_CLOSE:
277 EndDialog(hdlg, 333);
278 break;
280 default:
281 break;
284 return FALSE;
287 static INT_PTR CALLBACK edit_singleline_dialog_proc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
289 switch (msg)
291 case WM_INITDIALOG:
293 HWND hedit = GetDlgItem(hdlg, 1000);
294 SetFocus(hedit);
295 switch (lparam)
297 /* test cases for WM_KEYDOWN */
298 case 0:
299 PostMessage(hedit, WM_KEYDOWN, VK_ESCAPE, 0x10001);
300 break;
301 case 1:
302 PostMessage(hedit, WM_KEYDOWN, VK_RETURN, 0x1c0001);
303 break;
304 case 2:
305 PostMessage(hedit, WM_KEYDOWN, VK_TAB, 0xf0001);
306 PostMessage(hdlg, WM_USER, 0xdeadbeef, 1);
307 break;
309 /* test cases for WM_CHAR */
310 case 3:
311 PostMessage(hedit, WM_CHAR, VK_ESCAPE, 0x10001);
312 PostMessage(hdlg, WM_USER, 0xdeadbeef, 0);
313 break;
314 case 4:
315 PostMessage(hedit, WM_CHAR, VK_RETURN, 0x1c0001);
316 PostMessage(hdlg, WM_USER, 0xdeadbeef, 0);
317 break;
318 case 5:
319 PostMessage(hedit, WM_CHAR, VK_TAB, 0xf0001);
320 PostMessage(hdlg, WM_USER, 0xdeadbeef, 0);
321 break;
323 /* test cases for WM_KEYDOWN + WM_CHAR */
324 case 6:
325 PostMessage(hedit, WM_KEYDOWN, VK_ESCAPE, 0x10001);
326 PostMessage(hedit, WM_CHAR, VK_ESCAPE, 0x10001);
327 break;
328 case 7:
329 PostMessage(hedit, WM_KEYDOWN, VK_RETURN, 0x1c0001);
330 PostMessage(hedit, WM_CHAR, VK_RETURN, 0x1c0001);
331 break;
332 case 8:
333 PostMessage(hedit, WM_KEYDOWN, VK_TAB, 0xf0001);
334 PostMessage(hedit, WM_CHAR, VK_TAB, 0xf0001);
335 PostMessage(hdlg, WM_USER, 0xdeadbeef, 1);
336 break;
338 default:
339 break;
341 break;
344 case WM_COMMAND:
345 if (HIWORD(wparam) != BN_CLICKED)
346 break;
348 switch (LOWORD(wparam))
350 case IDOK:
351 EndDialog(hdlg, 111);
352 break;
354 case IDCANCEL:
355 EndDialog(hdlg, 222);
356 break;
358 default:
359 break;
361 break;
363 case WM_USER:
365 HWND hok = GetDlgItem(hdlg, IDOK);
366 HWND hedit = GetDlgItem(hdlg, 1000);
367 HWND hfocus = GetFocus();
368 int len = SendMessage(hedit, WM_GETTEXTLENGTH, 0, 0);
370 if (wparam != 0xdeadbeef)
371 break;
373 switch (lparam)
375 case 0:
376 if ((hfocus == hedit) && len == 0)
377 EndDialog(hdlg, 444);
378 else
379 EndDialog(hdlg, 555);
380 break;
382 case 1:
383 if ((hfocus == hok) && len == 0)
384 EndDialog(hdlg, 444);
385 else
386 EndDialog(hdlg, 555);
387 break;
389 default:
390 EndDialog(hdlg, 55);
392 break;
395 case WM_CLOSE:
396 EndDialog(hdlg, 333);
397 break;
399 default:
400 break;
403 return FALSE;
406 static INT_PTR CALLBACK edit_wantreturn_dialog_proc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
408 switch (msg)
410 case WM_INITDIALOG:
412 HWND hedit = GetDlgItem(hdlg, 1000);
413 SetFocus(hedit);
414 switch (lparam)
416 /* test cases for WM_KEYDOWN */
417 case 0:
418 PostMessage(hedit, WM_KEYDOWN, VK_ESCAPE, 0x10001);
419 break;
420 case 1:
421 PostMessage(hedit, WM_KEYDOWN, VK_RETURN, 0x1c0001);
422 PostMessage(hdlg, WM_USER, 0xdeadbeef, 0);
423 break;
424 case 2:
425 PostMessage(hedit, WM_KEYDOWN, VK_TAB, 0xf0001);
426 PostMessage(hdlg, WM_USER, 0xdeadbeef, 1);
427 break;
429 /* test cases for WM_CHAR */
430 case 3:
431 PostMessage(hedit, WM_CHAR, VK_ESCAPE, 0x10001);
432 PostMessage(hdlg, WM_USER, 0xdeadbeef, 0);
433 break;
434 case 4:
435 PostMessage(hedit, WM_CHAR, VK_RETURN, 0x1c0001);
436 PostMessage(hdlg, WM_USER, 0xdeadbeef, 2);
437 break;
438 case 5:
439 PostMessage(hedit, WM_CHAR, VK_TAB, 0xf0001);
440 PostMessage(hdlg, WM_USER, 0xdeadbeef, 0);
441 break;
443 /* test cases for WM_KEYDOWN + WM_CHAR */
444 case 6:
445 PostMessage(hedit, WM_KEYDOWN, VK_ESCAPE, 0x10001);
446 PostMessage(hedit, WM_CHAR, VK_ESCAPE, 0x10001);
447 PostMessage(hdlg, WM_USER, 0xdeadbeef, 0);
448 break;
449 case 7:
450 PostMessage(hedit, WM_KEYDOWN, VK_RETURN, 0x1c0001);
451 PostMessage(hedit, WM_CHAR, VK_RETURN, 0x1c0001);
452 PostMessage(hdlg, WM_USER, 0xdeadbeef, 2);
453 break;
454 case 8:
455 PostMessage(hedit, WM_KEYDOWN, VK_TAB, 0xf0001);
456 PostMessage(hedit, WM_CHAR, VK_TAB, 0xf0001);
457 PostMessage(hdlg, WM_USER, 0xdeadbeef, 1);
458 break;
460 default:
461 break;
463 break;
466 case WM_COMMAND:
467 if (HIWORD(wparam) != BN_CLICKED)
468 break;
470 switch (LOWORD(wparam))
472 case IDOK:
473 EndDialog(hdlg, 111);
474 break;
476 case IDCANCEL:
477 EndDialog(hdlg, 222);
478 break;
480 default:
481 break;
483 break;
485 case WM_USER:
487 HWND hok = GetDlgItem(hdlg, IDOK);
488 HWND hedit = GetDlgItem(hdlg, 1000);
489 HWND hfocus = GetFocus();
490 int len = SendMessage(hedit, WM_GETTEXTLENGTH, 0, 0);
492 if (wparam != 0xdeadbeef)
493 break;
495 switch (lparam)
497 case 0:
498 if ((hfocus == hedit) && len == 0)
499 EndDialog(hdlg, 444);
500 else
501 EndDialog(hdlg, 555);
502 break;
504 case 1:
505 if ((hfocus == hok) && len == 0)
506 EndDialog(hdlg, 444);
507 else
508 EndDialog(hdlg, 555);
509 break;
511 case 2:
512 if ((hfocus == hedit) && len == 2)
513 EndDialog(hdlg, 444);
514 else
515 EndDialog(hdlg, 555);
516 break;
518 default:
519 EndDialog(hdlg, 55);
521 break;
524 case WM_CLOSE:
525 EndDialog(hdlg, 333);
526 break;
528 default:
529 break;
532 return FALSE;
535 static HINSTANCE hinst;
536 static HWND hwndET2;
537 static const char szEditTest2Class[] = "EditTest2Class";
538 static const char szEditTest3Class[] = "EditTest3Class";
539 static const char szEditTextPositionClass[] = "EditTextPositionWindowClass";
541 static HWND create_editcontrol (DWORD style, DWORD exstyle)
543 HWND handle;
545 handle = CreateWindowEx(exstyle,
546 "EDIT",
547 "Test Text",
548 style,
549 10, 10, 300, 300,
550 NULL, NULL, hinst, NULL);
551 assert (handle);
552 if (winetest_interactive)
553 ShowWindow (handle, SW_SHOW);
554 return handle;
557 static HWND create_child_editcontrol (DWORD style, DWORD exstyle)
559 HWND parentWnd;
560 HWND editWnd;
561 RECT rect;
563 rect.left = 0;
564 rect.top = 0;
565 rect.right = 300;
566 rect.bottom = 300;
567 assert(AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE));
569 parentWnd = CreateWindowEx(0,
570 szEditTextPositionClass,
571 "Edit Test",
572 WS_OVERLAPPEDWINDOW,
573 CW_USEDEFAULT, CW_USEDEFAULT,
574 rect.right - rect.left, rect.bottom - rect.top,
575 NULL, NULL, hinst, NULL);
576 assert(parentWnd);
578 editWnd = CreateWindowEx(exstyle,
579 "EDIT",
580 "Test Text",
581 WS_CHILD | style,
582 0, 0, 300, 300,
583 parentWnd, NULL, hinst, NULL);
584 assert(editWnd);
585 if (winetest_interactive)
586 ShowWindow (parentWnd, SW_SHOW);
587 return editWnd;
590 static void destroy_child_editcontrol (HWND hwndEdit)
592 if (GetParent(hwndEdit))
593 DestroyWindow(GetParent(hwndEdit));
594 else {
595 trace("Edit control has no parent!\n");
596 DestroyWindow(hwndEdit);
600 static LONG get_edit_style (HWND hwnd)
602 return GetWindowLongA( hwnd, GWL_STYLE ) & (
603 ES_LEFT |
604 /* FIXME: not implemented
605 ES_CENTER |
606 ES_RIGHT |
607 ES_OEMCONVERT |
609 ES_MULTILINE |
610 ES_UPPERCASE |
611 ES_LOWERCASE |
612 ES_PASSWORD |
613 ES_AUTOVSCROLL |
614 ES_AUTOHSCROLL |
615 ES_NOHIDESEL |
616 ES_COMBO |
617 ES_READONLY |
618 ES_WANTRETURN |
619 ES_NUMBER
623 static void set_client_height(HWND Wnd, unsigned Height)
625 RECT ClientRect, WindowRect;
627 GetWindowRect(Wnd, &WindowRect);
628 GetClientRect(Wnd, &ClientRect);
629 SetWindowPos(Wnd, NULL, 0, 0,
630 WindowRect.right - WindowRect.left,
631 Height + (WindowRect.bottom - WindowRect.top) -
632 (ClientRect.bottom - ClientRect.top),
633 SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);
635 /* Workaround for a bug in Windows' edit control
636 (multi-line mode) */
637 GetWindowRect(Wnd, &WindowRect);
638 SetWindowPos(Wnd, NULL, 0, 0,
639 WindowRect.right - WindowRect.left + 1,
640 WindowRect.bottom - WindowRect.top + 1,
641 SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);
642 SetWindowPos(Wnd, NULL, 0, 0,
643 WindowRect.right - WindowRect.left,
644 WindowRect.bottom - WindowRect.top,
645 SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);
647 GetClientRect(Wnd, &ClientRect);
648 ok(ClientRect.bottom - ClientRect.top == Height,
649 "The client height should be %ld, but is %ld\n",
650 (long)Height, (long)(ClientRect.bottom - ClientRect.top));
653 static void test_edit_control_1(void)
655 HWND hwEdit;
656 MSG msMessage;
657 int i;
658 LONG r;
660 msMessage.message = WM_KEYDOWN;
662 trace("EDIT: Single line\n");
663 hwEdit = create_editcontrol(ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0);
664 r = get_edit_style(hwEdit);
665 ok(r == (ES_AUTOVSCROLL | ES_AUTOHSCROLL), "Wrong style expected 0xc0 got: 0x%x\n", r);
666 for (i=0;i<65535;i++)
668 msMessage.wParam = i;
669 r = SendMessage(hwEdit, WM_GETDLGCODE, 0, (LPARAM) &msMessage);
670 ok(r == (DLGC_WANTCHARS | DLGC_HASSETSEL | DLGC_WANTARROWS),
671 "Expected DLGC_WANTCHARS | DLGC_HASSETSEL | DLGC_WANTARROWS got %x\n", r);
673 DestroyWindow (hwEdit);
675 trace("EDIT: Single line want returns\n");
676 hwEdit = create_editcontrol(ES_WANTRETURN | ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0);
677 r = get_edit_style(hwEdit);
678 ok(r == (ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN), "Wrong style expected 0x10c0 got: 0x%x\n", r);
679 for (i=0;i<65535;i++)
681 msMessage.wParam = i;
682 r = SendMessage(hwEdit, WM_GETDLGCODE, 0, (LPARAM) &msMessage);
683 ok(r == (DLGC_WANTCHARS | DLGC_HASSETSEL | DLGC_WANTARROWS),
684 "Expected DLGC_WANTCHARS | DLGC_HASSETSEL | DLGC_WANTARROWS got %x\n", r);
686 DestroyWindow (hwEdit);
688 trace("EDIT: Multiline line\n");
689 hwEdit = create_editcontrol(ES_MULTILINE | WS_VSCROLL | ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0);
690 r = get_edit_style(hwEdit);
691 ok(r == (ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_MULTILINE), "Wrong style expected 0xc4 got: 0x%x\n", r);
692 for (i=0;i<65535;i++)
694 msMessage.wParam = i;
695 r = SendMessage(hwEdit, WM_GETDLGCODE, 0, (LPARAM) &msMessage);
696 ok(r == (DLGC_WANTCHARS | DLGC_HASSETSEL | DLGC_WANTALLKEYS | DLGC_WANTARROWS),
697 "Expected DLGC_WANTCHARS | DLGC_HASSETSEL | DLGC_WANTALLKEYS | DLGC_WANTARROWS got %x\n", r);
699 DestroyWindow (hwEdit);
701 trace("EDIT: Multi line want returns\n");
702 hwEdit = create_editcontrol(ES_MULTILINE | WS_VSCROLL | ES_WANTRETURN | ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0);
703 r = get_edit_style(hwEdit);
704 ok(r == (ES_WANTRETURN | ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_MULTILINE), "Wrong style expected 0x10c4 got: 0x%x\n", r);
705 for (i=0;i<65535;i++)
707 msMessage.wParam = i;
708 r = SendMessage(hwEdit, WM_GETDLGCODE, 0, (LPARAM) &msMessage);
709 ok(r == (DLGC_WANTCHARS | DLGC_HASSETSEL | DLGC_WANTALLKEYS | DLGC_WANTARROWS),
710 "Expected DLGC_WANTCHARS | DLGC_HASSETSEL | DLGC_WANTALLKEYS | DLGC_WANTARROWS got %x\n", r);
712 DestroyWindow (hwEdit);
715 /* WM_SETTEXT is implemented by selecting all text, and then replacing the
716 * selection. This test checks that the first 'select all' doesn't generate
717 * an UPDATE message which can escape and (via a handler) change the
718 * selection, which would cause WM_SETTEXT to break. This old bug
719 * was fixed 18-Mar-2005; we check here to ensure it doesn't regress.
721 static void test_edit_control_2(void)
723 HWND hwndMain;
724 char szLocalString[MAXLEN];
725 LONG r;
727 /* Create main and edit windows. */
728 hwndMain = CreateWindow(szEditTest2Class, "ET2", WS_OVERLAPPEDWINDOW,
729 0, 0, 200, 200, NULL, NULL, hinst, NULL);
730 assert(hwndMain);
731 if (winetest_interactive)
732 ShowWindow (hwndMain, SW_SHOW);
734 hwndET2 = CreateWindow("EDIT", NULL,
735 WS_CHILD|WS_BORDER|ES_LEFT|ES_AUTOHSCROLL,
736 0, 0, 150, 50, /* important this not be 0 size. */
737 hwndMain, (HMENU) ID_EDITTEST2, hinst, NULL);
738 assert(hwndET2);
739 if (winetest_interactive)
740 ShowWindow (hwndET2, SW_SHOW);
742 trace("EDIT: SETTEXT atomicity\n");
743 /* Send messages to "type" in the word 'foo'. */
744 r = SendMessage(hwndET2, WM_CHAR, 'f', 1);
745 ok(1 == r, "Expected: %d, got: %d\n", 1, r);
746 r = SendMessage(hwndET2, WM_CHAR, 'o', 1);
747 ok(1 == r, "Expected: %d, got: %d\n", 1, r);
748 r = SendMessage(hwndET2, WM_CHAR, 'o', 1);
749 ok(1 == r, "Expected: %d, got: %d\n", 1, r);
750 /* 'foo' should have been changed to 'bar' by the UPDATE handler. */
751 GetWindowText(hwndET2, szLocalString, MAXLEN);
752 ok(lstrcmp(szLocalString, "bar")==0,
753 "Wrong contents of edit: %s\n", szLocalString);
755 /* OK, done! */
756 DestroyWindow (hwndET2);
757 DestroyWindow (hwndMain);
760 static void ET2_check_change(void) {
761 char szLocalString[MAXLEN];
762 /* This EN_UPDATE handler changes any 'foo' to 'bar'. */
763 GetWindowText(hwndET2, szLocalString, MAXLEN);
764 if (lstrcmp(szLocalString, "foo")==0) {
765 lstrcpy(szLocalString, "bar");
766 SendMessage(hwndET2, WM_SETTEXT, 0, (LPARAM) szLocalString);
768 /* always leave the cursor at the end. */
769 SendMessage(hwndET2, EM_SETSEL, MAXLEN - 1, MAXLEN - 1);
771 static void ET2_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
773 if (id==ID_EDITTEST2 && codeNotify == EN_UPDATE)
774 ET2_check_change();
776 static LRESULT CALLBACK ET2_WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
778 switch (iMsg) {
779 case WM_COMMAND:
780 ET2_OnCommand(hwnd, LOWORD(wParam), (HWND)lParam, HIWORD(wParam));
781 break;
783 return DefWindowProc(hwnd, iMsg, wParam, lParam);
786 static void zero_notify(void)
788 notifications.en_change = 0;
789 notifications.en_maxtext = 0;
790 notifications.en_update = 0;
793 #define test_notify(enchange, enmaxtext, enupdate) \
794 ok(notifications.en_change == enchange, "expected %d EN_CHANGE notifications, " \
795 "got %d\n", enchange, notifications.en_change); \
796 ok(notifications.en_maxtext == enmaxtext, "expected %d EN_MAXTEXT notifications, " \
797 "got %d\n", enmaxtext, notifications.en_maxtext); \
798 ok(notifications.en_update == enupdate, "expected %d EN_UPDATE notifications, " \
799 "got %d\n", enupdate, notifications.en_update)
802 static LRESULT CALLBACK edit3_wnd_procA(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
804 switch (msg) {
805 case WM_COMMAND:
806 switch (HIWORD(wParam)) {
807 case EN_MAXTEXT:
808 notifications.en_maxtext++;
809 break;
810 case EN_UPDATE:
811 notifications.en_update++;
812 break;
813 case EN_CHANGE:
814 notifications.en_change++;
815 break;
817 break;
819 return DefWindowProcA(hWnd, msg, wParam, lParam);
822 /* Test behaviour of WM_SETTEXT, WM_REPLACESEL and notificatisons sent in response
823 * to these messages.
825 static void test_edit_control_3(void)
827 HWND hWnd;
828 HWND hParent;
829 int len;
830 static const char *str = "this is a long string.";
831 static const char *str2 = "this is a long string.\r\nthis is a long string.\r\nthis is a long string.\r\nthis is a long string.";
833 trace("EDIT: Test notifications\n");
835 hParent = CreateWindowExA(0,
836 szEditTest3Class,
837 NULL,
839 CW_USEDEFAULT, CW_USEDEFAULT, 10, 10,
840 NULL, NULL, NULL, NULL);
841 assert(hParent);
843 trace("EDIT: Single line, no ES_AUTOHSCROLL\n");
844 hWnd = CreateWindowExA(0,
845 "EDIT",
846 NULL,
848 10, 10, 50, 50,
849 hParent, NULL, NULL, NULL);
850 assert(hWnd);
852 zero_notify();
853 SendMessageA(hWnd, EM_REPLACESEL, 0, (LPARAM)str);
854 len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
855 ok(lstrlenA(str) > len, "text should have been truncated\n");
856 test_notify(1, 1, 1);
858 SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)"");
859 zero_notify();
860 SendMessageA(hWnd, EM_REPLACESEL, 0, (LPARAM)"a");
861 len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
862 ok(1 == len, "wrong text length, expected 1, got %d\n", len);
863 test_notify(1, 0, 1);
865 zero_notify();
866 SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)str);
867 len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
868 ok(lstrlenA(str) == len, "text shouldn't have been truncated\n");
869 test_notify(1, 0, 1);
871 SendMessageA(hWnd, EM_SETLIMITTEXT, 5, 0);
873 SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)"");
874 zero_notify();
875 SendMessageA(hWnd, EM_REPLACESEL, 0, (LPARAM)str);
876 len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
877 ok(5 == len, "text should have been truncated to limit, expected 5, got %d\n", len);
878 test_notify(1, 1, 1);
880 zero_notify();
881 SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)str);
882 len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
883 ok(lstrlenA(str) == len, "text shouldn't have been truncated\n");
884 test_notify(1, 0, 1);
886 DestroyWindow(hWnd);
888 trace("EDIT: Single line, ES_AUTOHSCROLL\n");
889 hWnd = CreateWindowExA(0,
890 "EDIT",
891 NULL,
892 ES_AUTOHSCROLL,
893 10, 10, 50, 50,
894 hParent, NULL, NULL, NULL);
895 assert(hWnd);
897 zero_notify();
898 SendMessageA(hWnd, EM_REPLACESEL, 0, (LPARAM)str);
899 len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
900 ok(lstrlenA(str) == len, "text shouldn't have been truncated\n");
901 test_notify(1, 0, 1);
903 zero_notify();
904 SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)str);
905 len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
906 ok(lstrlenA(str) == len, "text shouldn't have been truncated\n");
907 test_notify(1, 0, 1);
909 SendMessageA(hWnd, EM_SETLIMITTEXT, 5, 0);
911 SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)"");
912 zero_notify();
913 SendMessageA(hWnd, EM_REPLACESEL, 0, (LPARAM)str);
914 len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
915 ok(5 == len, "text should have been truncated to limit, expected 5, got %d\n", len);
916 test_notify(1, 1, 1);
918 zero_notify();
919 SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)str);
920 len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
921 ok(lstrlenA(str) == len, "text shouldn't have been truncated\n");
922 test_notify(1, 0, 1);
924 DestroyWindow(hWnd);
926 trace("EDIT: Multline, no ES_AUTOHSCROLL, no ES_AUTOVSCROLL\n");
927 hWnd = CreateWindowExA(0,
928 "EDIT",
929 NULL,
930 ES_MULTILINE,
931 10, 10, 50, 50,
932 hParent, NULL, NULL, NULL);
933 assert(hWnd);
935 zero_notify();
936 SendMessageA(hWnd, EM_REPLACESEL, 0, (LPARAM)str);
937 len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
938 ok(0 == len, "text should have been truncated, expected 0, got %d\n", len);
939 test_notify(1, 1, 1);
941 SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)"");
942 zero_notify();
943 SendMessageA(hWnd, EM_REPLACESEL, 0, (LPARAM)"a");
944 len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
945 ok(1 == SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0), "wrong text length, expected 1, got %d\n", len);
946 test_notify(1, 0, 1);
948 zero_notify();
949 SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)str);
950 len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
951 ok(lstrlenA(str) == len, "text shouldn't have been truncated\n");
952 test_notify(0, 0, 0);
954 SendMessageA(hWnd, EM_SETLIMITTEXT, 5, 0);
956 SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)"");
957 zero_notify();
958 SendMessageA(hWnd, EM_REPLACESEL, 0, (LPARAM)str);
959 len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
960 ok(5 == len, "text should have been truncated to limit, expected 5, got %d\n", len);
961 test_notify(1, 1, 1);
963 zero_notify();
964 SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)str);
965 len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
966 ok(lstrlenA(str) == len, "text shouldn't have been truncated\n");
967 test_notify(0, 0, 0);
969 DestroyWindow(hWnd);
971 trace("EDIT: Multline, ES_AUTOHSCROLL, no ES_AUTOVSCROLL\n");
972 hWnd = CreateWindowExA(0,
973 "EDIT",
974 NULL,
975 ES_MULTILINE | ES_AUTOHSCROLL,
976 10, 10, 50, 50,
977 hParent, NULL, NULL, NULL);
978 assert(hWnd);
980 zero_notify();
981 SendMessageA(hWnd, EM_REPLACESEL, 0, (LPARAM)str2);
982 len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
983 ok(0 == len, "text should have been truncated, expected 0, got %d\n", len);
984 test_notify(1, 1, 1);
986 SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)"");
987 zero_notify();
988 SendMessageA(hWnd, EM_REPLACESEL, 0, (LPARAM)"a");
989 len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
990 ok(1 == SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0), "wrong text length, expected 1, got %d\n", len);
991 test_notify(1, 0, 1);
993 zero_notify();
994 SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)str2);
995 len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
996 ok(lstrlenA(str2) == len, "text shouldn't have been truncated\n");
997 test_notify(0, 0, 0);
999 SendMessageA(hWnd, EM_SETLIMITTEXT, 5, 0);
1001 SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)"");
1002 zero_notify();
1003 SendMessageA(hWnd, EM_REPLACESEL, 0, (LPARAM)str2);
1004 len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
1005 ok(5 == len, "text should have been truncated to limit, expected 5, got %d\n", len);
1006 test_notify(1, 1, 1);
1008 zero_notify();
1009 SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)str2);
1010 len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
1011 ok(lstrlenA(str2) == len, "text shouldn't have been truncated\n");
1012 test_notify(0, 0, 0);
1014 DestroyWindow(hWnd);
1016 trace("EDIT: Multline, ES_AUTOHSCROLL and ES_AUTOVSCROLL\n");
1017 hWnd = CreateWindowExA(0,
1018 "EDIT",
1019 NULL,
1020 ES_MULTILINE | ES_AUTOHSCROLL | ES_AUTOVSCROLL,
1021 10, 10, 50, 50,
1022 hParent, NULL, NULL, NULL);
1023 assert(hWnd);
1025 zero_notify();
1026 SendMessageA(hWnd, EM_REPLACESEL, 0, (LPARAM)str2);
1027 len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
1028 ok(lstrlenA(str2) == len, "text shouldn't have been truncated\n");
1029 test_notify(1, 0, 1);
1031 zero_notify();
1032 SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)str2);
1033 len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
1034 ok(lstrlenA(str2) == len, "text shouldn't have been truncated\n");
1035 test_notify(0, 0, 0);
1037 SendMessageA(hWnd, EM_SETLIMITTEXT, 5, 0);
1039 SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)"");
1040 zero_notify();
1041 SendMessageA(hWnd, EM_REPLACESEL, 0, (LPARAM)str2);
1042 len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
1043 ok(5 == len, "text should have been truncated to limit, expected 5, got %d\n", len);
1044 test_notify(1, 1, 1);
1046 zero_notify();
1047 SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)str2);
1048 len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
1049 ok(lstrlenA(str2) == len, "text shouldn't have been truncated\n");
1050 test_notify(0, 0, 0);
1052 DestroyWindow(hWnd);
1055 /* Test EM_CHARFROMPOS and EM_POSFROMCHAR
1057 static void test_edit_control_4(void)
1059 HWND hwEdit;
1060 int lo, hi, mid;
1061 int ret;
1062 int i;
1064 trace("EDIT: Test EM_CHARFROMPOS and EM_POSFROMCHAR\n");
1065 hwEdit = create_editcontrol(ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0);
1066 SendMessage(hwEdit, WM_SETTEXT, 0, (LPARAM) "aa");
1067 lo = LOWORD(SendMessage(hwEdit, EM_POSFROMCHAR, 0, 0));
1068 hi = LOWORD(SendMessage(hwEdit, EM_POSFROMCHAR, 1, 0));
1069 mid = lo + (hi - lo) / 2;
1071 for (i = lo; i < mid; i++) {
1072 ret = LOWORD(SendMessage(hwEdit, EM_CHARFROMPOS, 0, (LPARAM) i));
1073 ok(0 == ret, "expected 0 got %d\n", ret);
1075 for (i = mid; i <= hi; i++) {
1076 ret = LOWORD(SendMessage(hwEdit, EM_CHARFROMPOS, 0, (LPARAM) i));
1077 ok(1 == ret, "expected 1 got %d\n", ret);
1079 ret = SendMessage(hwEdit, EM_POSFROMCHAR, 2, 0);
1080 ok(-1 == ret, "expected -1 got %d\n", ret);
1081 DestroyWindow(hwEdit);
1083 hwEdit = create_editcontrol(ES_RIGHT | ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0);
1084 SendMessage(hwEdit, WM_SETTEXT, 0, (LPARAM) "aa");
1085 lo = LOWORD(SendMessage(hwEdit, EM_POSFROMCHAR, 0, 0));
1086 hi = LOWORD(SendMessage(hwEdit, EM_POSFROMCHAR, 1, 0));
1087 mid = lo + (hi - lo) / 2;
1089 for (i = lo; i < mid; i++) {
1090 ret = LOWORD(SendMessage(hwEdit, EM_CHARFROMPOS, 0, (LPARAM) i));
1091 ok(0 == ret, "expected 0 got %d\n", ret);
1093 for (i = mid; i <= hi; i++) {
1094 ret = LOWORD(SendMessage(hwEdit, EM_CHARFROMPOS, 0, (LPARAM) i));
1095 ok(1 == ret, "expected 1 got %d\n", ret);
1097 ret = SendMessage(hwEdit, EM_POSFROMCHAR, 2, 0);
1098 ok(-1 == ret, "expected -1 got %d\n", ret);
1099 DestroyWindow(hwEdit);
1101 hwEdit = create_editcontrol(ES_CENTER | ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0);
1102 SendMessage(hwEdit, WM_SETTEXT, 0, (LPARAM) "aa");
1103 lo = LOWORD(SendMessage(hwEdit, EM_POSFROMCHAR, 0, 0));
1104 hi = LOWORD(SendMessage(hwEdit, EM_POSFROMCHAR, 1, 0));
1105 mid = lo + (hi - lo) / 2;
1107 for (i = lo; i < mid; i++) {
1108 ret = LOWORD(SendMessage(hwEdit, EM_CHARFROMPOS, 0, (LPARAM) i));
1109 ok(0 == ret, "expected 0 got %d\n", ret);
1111 for (i = mid; i <= hi; i++) {
1112 ret = LOWORD(SendMessage(hwEdit, EM_CHARFROMPOS, 0, (LPARAM) i));
1113 ok(1 == ret, "expected 1 got %d\n", ret);
1115 ret = SendMessage(hwEdit, EM_POSFROMCHAR, 2, 0);
1116 ok(-1 == ret, "expected -1 got %d\n", ret);
1117 DestroyWindow(hwEdit);
1119 hwEdit = create_editcontrol(ES_MULTILINE | ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0);
1120 SendMessage(hwEdit, WM_SETTEXT, 0, (LPARAM) "aa");
1121 lo = LOWORD(SendMessage(hwEdit, EM_POSFROMCHAR, 0, 0));
1122 hi = LOWORD(SendMessage(hwEdit, EM_POSFROMCHAR, 1, 0));
1123 mid = lo + (hi - lo) / 2 +1;
1125 for (i = lo; i < mid; i++) {
1126 ret = LOWORD(SendMessage(hwEdit, EM_CHARFROMPOS, 0, (LPARAM) i));
1127 ok((0 == ret || 1 == ret /* Vista */), "expected 0 or 1 got %d\n", ret);
1129 for (i = mid; i <= hi; i++) {
1130 ret = LOWORD(SendMessage(hwEdit, EM_CHARFROMPOS, 0, (LPARAM) i));
1131 ok(1 == ret, "expected 1 got %d\n", ret);
1133 ret = SendMessage(hwEdit, EM_POSFROMCHAR, 2, 0);
1134 ok(-1 == ret, "expected -1 got %d\n", ret);
1135 DestroyWindow(hwEdit);
1137 hwEdit = create_editcontrol(ES_MULTILINE | ES_RIGHT | ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0);
1138 SendMessage(hwEdit, WM_SETTEXT, 0, (LPARAM) "aa");
1139 lo = LOWORD(SendMessage(hwEdit, EM_POSFROMCHAR, 0, 0));
1140 hi = LOWORD(SendMessage(hwEdit, EM_POSFROMCHAR, 1, 0));
1141 mid = lo + (hi - lo) / 2 +1;
1143 for (i = lo; i < mid; i++) {
1144 ret = LOWORD(SendMessage(hwEdit, EM_CHARFROMPOS, 0, (LPARAM) i));
1145 ok((0 == ret || 1 == ret /* Vista */), "expected 0 or 1 got %d\n", ret);
1147 for (i = mid; i <= hi; i++) {
1148 ret = LOWORD(SendMessage(hwEdit, EM_CHARFROMPOS, 0, (LPARAM) i));
1149 ok(1 == ret, "expected 1 got %d\n", ret);
1151 ret = SendMessage(hwEdit, EM_POSFROMCHAR, 2, 0);
1152 ok(-1 == ret, "expected -1 got %d\n", ret);
1153 DestroyWindow(hwEdit);
1155 hwEdit = create_editcontrol(ES_MULTILINE | ES_CENTER | ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0);
1156 SendMessage(hwEdit, WM_SETTEXT, 0, (LPARAM) "aa");
1157 lo = LOWORD(SendMessage(hwEdit, EM_POSFROMCHAR, 0, 0));
1158 hi = LOWORD(SendMessage(hwEdit, EM_POSFROMCHAR, 1, 0));
1159 mid = lo + (hi - lo) / 2 +1;
1161 for (i = lo; i < mid; i++) {
1162 ret = LOWORD(SendMessage(hwEdit, EM_CHARFROMPOS, 0, (LPARAM) i));
1163 ok((0 == ret || 1 == ret /* Vista */), "expected 0 or 1 got %d\n", ret);
1165 for (i = mid; i <= hi; i++) {
1166 ret = LOWORD(SendMessage(hwEdit, EM_CHARFROMPOS, 0, (LPARAM) i));
1167 ok(1 == ret, "expected 1 got %d\n", ret);
1169 ret = SendMessage(hwEdit, EM_POSFROMCHAR, 2, 0);
1170 ok(-1 == ret, "expected -1 got %d\n", ret);
1171 DestroyWindow(hwEdit);
1174 /* Test if creating edit control without ES_AUTOHSCROLL and ES_AUTOVSCROLL
1175 * truncates text that doesn't fit.
1177 static void test_edit_control_5(void)
1179 static const char *str = "test\r\ntest";
1180 HWND hWnd;
1181 int len;
1183 hWnd = CreateWindowEx(0,
1184 "EDIT",
1185 str,
1187 10, 10, 1, 1,
1188 NULL, NULL, NULL, NULL);
1189 assert(hWnd);
1191 len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
1192 ok(lstrlenA(str) == len, "text shouldn't have been truncated\n");
1193 DestroyWindow(hWnd);
1195 hWnd = CreateWindowEx(0,
1196 "EDIT",
1197 str,
1198 ES_MULTILINE,
1199 10, 10, 1, 1,
1200 NULL, NULL, NULL, NULL);
1201 assert(hWnd);
1203 len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
1204 ok(lstrlenA(str) == len, "text shouldn't have been truncated\n");
1205 DestroyWindow(hWnd);
1208 static void test_edit_control_limittext(void)
1210 HWND hwEdit;
1211 DWORD r;
1213 /* Test default limit for single-line control */
1214 trace("EDIT: buffer limit for single-line\n");
1215 hwEdit = create_editcontrol(ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0);
1216 r = SendMessage(hwEdit, EM_GETLIMITTEXT, 0, 0);
1217 ok(r == 30000, "Incorrect default text limit, expected 30000 got %u\n", r);
1218 SendMessage(hwEdit, EM_SETLIMITTEXT, 0, 0);
1219 r = SendMessage(hwEdit, EM_GETLIMITTEXT, 0, 0);
1220 /* Win9x+ME: 32766; WinNT: 2147483646UL */
1221 ok( (r == 32766) || (r == 2147483646UL),
1222 "got limit %u (expected 32766 or 2147483646)\n", r);
1223 DestroyWindow(hwEdit);
1225 /* Test default limit for multi-line control */
1226 trace("EDIT: buffer limit for multi-line\n");
1227 hwEdit = create_editcontrol(ES_MULTILINE | WS_VSCROLL | ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0);
1228 r = SendMessage(hwEdit, EM_GETLIMITTEXT, 0, 0);
1229 ok(r == 30000, "Incorrect default text limit, expected 30000 got %u\n", r);
1230 SendMessage(hwEdit, EM_SETLIMITTEXT, 0, 0);
1231 r = SendMessage(hwEdit, EM_GETLIMITTEXT, 0, 0);
1232 /* Win9x+ME: 65535; WinNT: 4294967295UL */
1233 ok( (r == 65535) || (r == 4294967295UL),
1234 "got limit %u (expected 65535 or 4294967295)\n", r);
1235 DestroyWindow(hwEdit);
1238 static void test_margins(void)
1240 HWND hwEdit;
1241 RECT old_rect, new_rect;
1242 INT old_left_margin, old_right_margin;
1243 DWORD old_margins, new_margins;
1245 hwEdit = create_editcontrol(WS_BORDER | ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0);
1247 old_margins = SendMessage(hwEdit, EM_GETMARGINS, 0, 0);
1248 old_left_margin = LOWORD(old_margins);
1249 old_right_margin = HIWORD(old_margins);
1251 /* Check if setting the margins works */
1253 SendMessage(hwEdit, EM_SETMARGINS, EC_LEFTMARGIN, MAKELONG(10, 0));
1254 new_margins = SendMessage(hwEdit, EM_GETMARGINS, 0, 0);
1255 ok(LOWORD(new_margins) == 10, "Wrong left margin: %d\n", LOWORD(new_margins));
1256 ok(HIWORD(new_margins) == old_right_margin, "Wrong right margin: %d\n", HIWORD(new_margins));
1258 SendMessage(hwEdit, EM_SETMARGINS, EC_RIGHTMARGIN, MAKELONG(0, 10));
1259 new_margins = SendMessage(hwEdit, EM_GETMARGINS, 0, 0);
1260 ok(LOWORD(new_margins) == 10, "Wrong left margin: %d\n", LOWORD(new_margins));
1261 ok(HIWORD(new_margins) == 10, "Wrong right margin: %d\n", HIWORD(new_margins));
1264 /* The size of the rectangle must decrease if we increase the margin */
1266 SendMessage(hwEdit, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(5, 5));
1267 SendMessage(hwEdit, EM_GETRECT, 0, (LPARAM)&old_rect);
1268 SendMessage(hwEdit, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(15, 20));
1269 SendMessage(hwEdit, EM_GETRECT, 0, (LPARAM)&new_rect);
1270 ok(new_rect.left == old_rect.left + 10, "The left border of the rectangle is wrong\n");
1271 ok(new_rect.right == old_rect.right - 15, "The right border of the rectangle is wrong\n");
1272 ok(new_rect.top == old_rect.top, "The top border of the rectangle must not change\n");
1273 ok(new_rect.bottom == old_rect.bottom, "The bottom border of the rectangle must not change\n");
1276 /* If we set the margin to same value as the current margin,
1277 the rectangle must not change */
1279 SendMessage(hwEdit, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(10, 10));
1280 old_rect.left = 1;
1281 old_rect.right = 99;
1282 old_rect.top = 1;
1283 old_rect.bottom = 99;
1284 SendMessage(hwEdit, EM_SETRECT, 0, (LPARAM)&old_rect);
1285 SendMessage(hwEdit, EM_GETRECT, 0, (LPARAM)&old_rect);
1286 SendMessage(hwEdit, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(10, 10));
1287 SendMessage(hwEdit, EM_GETRECT, 0, (LPARAM)&new_rect);
1288 ok(new_rect.left == old_rect.left, "The left border of the rectangle has changed\n");
1289 ok(new_rect.right == old_rect.right, "The right border of the rectangle has changed\n");
1290 ok(new_rect.top == old_rect.top, "The top border of the rectangle has changed\n");
1291 ok(new_rect.bottom == old_rect.bottom, "The bottom border of the rectangle has changed\n");
1293 DestroyWindow (hwEdit);
1296 static INT CALLBACK find_font_proc(const LOGFONT *elf, const TEXTMETRIC *ntm, DWORD type, LPARAM lParam)
1298 return 0;
1301 static void test_margins_font_change(void)
1303 HWND hwEdit;
1304 DWORD margins, font_margins;
1305 LOGFONT lf;
1306 HFONT hfont, hfont2;
1307 HDC hdc = GetDC(0);
1309 if(EnumFontFamiliesA(hdc, "Arial", find_font_proc, 0))
1311 trace("Arial not found - skipping font change margin tests\n");
1312 ReleaseDC(0, hdc);
1313 return;
1315 ReleaseDC(0, hdc);
1317 hwEdit = create_child_editcontrol(0, 0);
1319 SetWindowPos(hwEdit, NULL, 10, 10, 1000, 100, SWP_NOZORDER | SWP_NOACTIVATE);
1321 memset(&lf, 0, sizeof(lf));
1322 strcpy(lf.lfFaceName, "Arial");
1323 lf.lfHeight = 16;
1324 lf.lfCharSet = DEFAULT_CHARSET;
1325 hfont = CreateFontIndirectA(&lf);
1326 lf.lfHeight = 30;
1327 hfont2 = CreateFontIndirectA(&lf);
1329 SendMessageA(hwEdit, WM_SETFONT, (WPARAM)hfont, 0);
1330 font_margins = SendMessage(hwEdit, EM_GETMARGINS, 0, 0);
1331 ok(LOWORD(font_margins) != 0, "got %d\n", LOWORD(font_margins));
1332 ok(HIWORD(font_margins) != 0, "got %d\n", HIWORD(font_margins));
1334 /* With 'small' edit controls, test that the margin doesn't get set */
1335 SetWindowPos(hwEdit, NULL, 10, 10, 16, 100, SWP_NOZORDER | SWP_NOACTIVATE);
1336 SendMessageA(hwEdit, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(0,0));
1337 SendMessageA(hwEdit, WM_SETFONT, (WPARAM)hfont, 0);
1338 margins = SendMessage(hwEdit, EM_GETMARGINS, 0, 0);
1339 ok(LOWORD(margins) == 0, "got %d\n", LOWORD(margins));
1340 ok(HIWORD(margins) == 0, "got %d\n", HIWORD(margins));
1342 SendMessageA(hwEdit, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(1,0));
1343 SendMessageA(hwEdit, WM_SETFONT, (WPARAM)hfont, 0);
1344 margins = SendMessage(hwEdit, EM_GETMARGINS, 0, 0);
1345 ok(LOWORD(margins) == 1, "got %d\n", LOWORD(margins));
1346 ok(HIWORD(margins) == 0, "got %d\n", HIWORD(margins));
1348 SendMessageA(hwEdit, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(1,1));
1349 SendMessageA(hwEdit, WM_SETFONT, (WPARAM)hfont, 0);
1350 margins = SendMessage(hwEdit, EM_GETMARGINS, 0, 0);
1351 ok(LOWORD(margins) == 1, "got %d\n", LOWORD(margins));
1352 ok(HIWORD(margins) == 1, "got %d\n", HIWORD(margins));
1354 SendMessageA(hwEdit, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(EC_USEFONTINFO,EC_USEFONTINFO));
1355 margins = SendMessage(hwEdit, EM_GETMARGINS, 0, 0);
1356 ok(LOWORD(margins) == 1, "got %d\n", LOWORD(margins));
1357 ok(HIWORD(margins) == 1, "got %d\n", HIWORD(margins));
1358 SendMessageA(hwEdit, WM_SETFONT, (WPARAM)hfont2, 0);
1359 margins = SendMessage(hwEdit, EM_GETMARGINS, 0, 0);
1360 ok(LOWORD(margins) == 1, "got %d\n", LOWORD(margins));
1361 ok(HIWORD(margins) == 1, "got %d\n", HIWORD(margins));
1363 /* Above a certain size threshold then the margin is updated */
1364 SetWindowPos(hwEdit, NULL, 10, 10, 1000, 100, SWP_NOZORDER | SWP_NOACTIVATE);
1365 SendMessageA(hwEdit, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(1,0));
1366 SendMessageA(hwEdit, WM_SETFONT, (WPARAM)hfont, 0);
1367 margins = SendMessage(hwEdit, EM_GETMARGINS, 0, 0);
1368 ok(LOWORD(margins) == LOWORD(font_margins), "got %d\n", LOWORD(margins));
1369 ok(HIWORD(margins) == HIWORD(font_margins), "got %d\n", HIWORD(margins));
1371 SendMessageA(hwEdit, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(1,1));
1372 SendMessageA(hwEdit, WM_SETFONT, (WPARAM)hfont, 0);
1373 margins = SendMessage(hwEdit, EM_GETMARGINS, 0, 0);
1374 ok(LOWORD(margins) == LOWORD(font_margins), "got %d\n", LOWORD(margins));
1375 ok(HIWORD(margins) == HIWORD(font_margins), "got %d\n", HIWORD(margins));
1377 SendMessageA(hwEdit, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(EC_USEFONTINFO,EC_USEFONTINFO));
1378 margins = SendMessage(hwEdit, EM_GETMARGINS, 0, 0);
1379 ok(LOWORD(margins) == LOWORD(font_margins), "got %d\n", LOWORD(margins));
1380 ok(HIWORD(margins) == HIWORD(font_margins), "got %d\n", HIWORD(margins));
1381 SendMessageA(hwEdit, WM_SETFONT, (WPARAM)hfont2, 0);
1382 margins = SendMessage(hwEdit, EM_GETMARGINS, 0, 0);
1383 ok(LOWORD(margins) != LOWORD(font_margins), "got %d\n", LOWORD(margins));
1384 ok(HIWORD(margins) != HIWORD(font_margins), "got %d\n", HIWORD(margins));
1386 SendMessageA(hwEdit, WM_SETFONT, 0, 0);
1388 DeleteObject(hfont2);
1389 DeleteObject(hfont);
1390 destroy_child_editcontrol(hwEdit);
1394 #define edit_pos_ok(exp, got, txt) \
1395 ok(exp == got, "wrong " #txt " expected %d got %d\n", exp, got);
1397 #define check_pos(hwEdit, set_height, test_top, test_height, test_left) \
1398 do { \
1399 RECT format_rect; \
1400 int left_margin; \
1401 set_client_height(hwEdit, set_height); \
1402 SendMessage(hwEdit, EM_GETRECT, 0, (LPARAM) &format_rect); \
1403 left_margin = LOWORD(SendMessage(hwEdit, EM_GETMARGINS, 0, 0)); \
1404 edit_pos_ok(test_top, format_rect.top, vertical position); \
1405 edit_pos_ok((int)test_height, format_rect.bottom - format_rect.top, height); \
1406 edit_pos_ok(test_left, format_rect.left - left_margin, left); \
1407 } while(0)
1409 static void test_text_position_style(DWORD style)
1411 HWND hwEdit;
1412 HFONT font, oldFont;
1413 HDC dc;
1414 TEXTMETRIC metrics;
1415 INT b, bm, b2, b3;
1416 BOOL single_line = !(style & ES_MULTILINE);
1418 b = GetSystemMetrics(SM_CYBORDER) + 1;
1419 b2 = 2 * b;
1420 b3 = 3 * b;
1421 bm = b2 - 1;
1423 /* Get a stock font for which we can determine the metrics */
1424 assert(font = GetStockObject(SYSTEM_FONT));
1425 assert(dc = GetDC(NULL));
1426 oldFont = SelectObject(dc, font);
1427 assert(GetTextMetrics(dc, &metrics));
1428 SelectObject(dc, oldFont);
1429 ReleaseDC(NULL, dc);
1431 /* Windows' edit control has some bugs in multi-line mode:
1432 * - Sometimes the format rectangle doesn't get updated
1433 * (see workaround in set_client_height())
1434 * - If the height of the control is smaller than the height of a text
1435 * line, the format rectangle is still as high as a text line
1436 * (higher than the client rectangle) and the caret is not shown
1439 /* Edit controls that are in a parent window */
1441 hwEdit = create_child_editcontrol(style | WS_VISIBLE, 0);
1442 SendMessage(hwEdit, WM_SETFONT, (WPARAM) font, (LPARAM) FALSE);
1443 if (single_line)
1444 check_pos(hwEdit, metrics.tmHeight - 1, 0, metrics.tmHeight - 1, 0);
1445 check_pos(hwEdit, metrics.tmHeight , 0, metrics.tmHeight , 0);
1446 check_pos(hwEdit, metrics.tmHeight + 1, 0, metrics.tmHeight , 0);
1447 check_pos(hwEdit, metrics.tmHeight + 2, 0, metrics.tmHeight , 0);
1448 check_pos(hwEdit, metrics.tmHeight + 10, 0, metrics.tmHeight , 0);
1449 destroy_child_editcontrol(hwEdit);
1451 hwEdit = create_child_editcontrol(style | WS_BORDER | WS_VISIBLE, 0);
1452 SendMessage(hwEdit, WM_SETFONT, (WPARAM) font, (LPARAM) FALSE);
1453 if (single_line)
1454 check_pos(hwEdit, metrics.tmHeight - 1, 0, metrics.tmHeight - 1, b);
1455 check_pos(hwEdit, metrics.tmHeight , 0, metrics.tmHeight , b);
1456 check_pos(hwEdit, metrics.tmHeight + 1, 0, metrics.tmHeight , b);
1457 check_pos(hwEdit, metrics.tmHeight + bm, 0, metrics.tmHeight , b);
1458 check_pos(hwEdit, metrics.tmHeight + b2, b, metrics.tmHeight , b);
1459 check_pos(hwEdit, metrics.tmHeight + b3, b, metrics.tmHeight , b);
1460 destroy_child_editcontrol(hwEdit);
1462 hwEdit = create_child_editcontrol(style | WS_VISIBLE, WS_EX_CLIENTEDGE);
1463 SendMessage(hwEdit, WM_SETFONT, (WPARAM) font, (LPARAM) FALSE);
1464 if (single_line)
1465 check_pos(hwEdit, metrics.tmHeight - 1, 0, metrics.tmHeight - 1, 1);
1466 check_pos(hwEdit, metrics.tmHeight , 0, metrics.tmHeight , 1);
1467 check_pos(hwEdit, metrics.tmHeight + 1, 0, metrics.tmHeight , 1);
1468 check_pos(hwEdit, metrics.tmHeight + 2, 1, metrics.tmHeight , 1);
1469 check_pos(hwEdit, metrics.tmHeight + 10, 1, metrics.tmHeight , 1);
1470 destroy_child_editcontrol(hwEdit);
1472 hwEdit = create_child_editcontrol(style | WS_BORDER | WS_VISIBLE, WS_EX_CLIENTEDGE);
1473 SendMessage(hwEdit, WM_SETFONT, (WPARAM) font, (LPARAM) FALSE);
1474 if (single_line)
1475 check_pos(hwEdit, metrics.tmHeight - 1, 0, metrics.tmHeight - 1, 1);
1476 check_pos(hwEdit, metrics.tmHeight , 0, metrics.tmHeight , 1);
1477 check_pos(hwEdit, metrics.tmHeight + 1, 0, metrics.tmHeight , 1);
1478 check_pos(hwEdit, metrics.tmHeight + 2, 1, metrics.tmHeight , 1);
1479 check_pos(hwEdit, metrics.tmHeight + 10, 1, metrics.tmHeight , 1);
1480 destroy_child_editcontrol(hwEdit);
1483 /* Edit controls that are popup windows */
1485 hwEdit = create_editcontrol(style | WS_POPUP, 0);
1486 SendMessage(hwEdit, WM_SETFONT, (WPARAM) font, (LPARAM) FALSE);
1487 if (single_line)
1488 check_pos(hwEdit, metrics.tmHeight - 1, 0, metrics.tmHeight - 1, 0);
1489 check_pos(hwEdit, metrics.tmHeight , 0, metrics.tmHeight , 0);
1490 check_pos(hwEdit, metrics.tmHeight + 1, 0, metrics.tmHeight , 0);
1491 check_pos(hwEdit, metrics.tmHeight + 2, 0, metrics.tmHeight , 0);
1492 check_pos(hwEdit, metrics.tmHeight + 10, 0, metrics.tmHeight , 0);
1493 DestroyWindow(hwEdit);
1495 hwEdit = create_editcontrol(style | WS_POPUP | WS_BORDER, 0);
1496 SendMessage(hwEdit, WM_SETFONT, (WPARAM) font, (LPARAM) FALSE);
1497 if (single_line)
1498 check_pos(hwEdit, metrics.tmHeight - 1, 0, metrics.tmHeight - 1, b);
1499 check_pos(hwEdit, metrics.tmHeight , 0, metrics.tmHeight , b);
1500 check_pos(hwEdit, metrics.tmHeight + 1, 0, metrics.tmHeight , b);
1501 check_pos(hwEdit, metrics.tmHeight + bm, 0, metrics.tmHeight , b);
1502 check_pos(hwEdit, metrics.tmHeight + b2, b, metrics.tmHeight , b);
1503 check_pos(hwEdit, metrics.tmHeight + b3, b, metrics.tmHeight , b);
1504 DestroyWindow(hwEdit);
1506 hwEdit = create_editcontrol(style | WS_POPUP, WS_EX_CLIENTEDGE);
1507 SendMessage(hwEdit, WM_SETFONT, (WPARAM) font, (LPARAM) FALSE);
1508 if (single_line)
1509 check_pos(hwEdit, metrics.tmHeight - 1, 0, metrics.tmHeight - 1, 1);
1510 check_pos(hwEdit, metrics.tmHeight , 0, metrics.tmHeight , 1);
1511 check_pos(hwEdit, metrics.tmHeight + 1, 0, metrics.tmHeight , 1);
1512 check_pos(hwEdit, metrics.tmHeight + 2, 1, metrics.tmHeight , 1);
1513 check_pos(hwEdit, metrics.tmHeight + 10, 1, metrics.tmHeight , 1);
1514 DestroyWindow(hwEdit);
1516 hwEdit = create_editcontrol(style | WS_POPUP | WS_BORDER, WS_EX_CLIENTEDGE);
1517 SendMessage(hwEdit, WM_SETFONT, (WPARAM) font, (LPARAM) FALSE);
1518 if (single_line)
1519 check_pos(hwEdit, metrics.tmHeight - 1, 0, metrics.tmHeight - 1, 1);
1520 check_pos(hwEdit, metrics.tmHeight , 0, metrics.tmHeight , 1);
1521 check_pos(hwEdit, metrics.tmHeight + 1, 0, metrics.tmHeight , 1);
1522 check_pos(hwEdit, metrics.tmHeight + 2, 1, metrics.tmHeight , 1);
1523 check_pos(hwEdit, metrics.tmHeight + 10, 1, metrics.tmHeight , 1);
1524 DestroyWindow(hwEdit);
1527 static void test_text_position(void)
1529 trace("EDIT: Text position (Single line)\n");
1530 test_text_position_style(ES_AUTOHSCROLL | ES_AUTOVSCROLL);
1531 trace("EDIT: Text position (Multi line)\n");
1532 test_text_position_style(ES_MULTILINE | ES_AUTOHSCROLL | ES_AUTOVSCROLL);
1535 static void test_espassword(void)
1537 HWND hwEdit;
1538 LONG r;
1539 char buffer[1024];
1540 const char* password = "secret";
1542 hwEdit = create_editcontrol(ES_PASSWORD, 0);
1543 r = get_edit_style(hwEdit);
1544 ok(r == ES_PASSWORD, "Wrong style expected 0x%x got: 0x%x\n", ES_PASSWORD, r);
1545 /* set text */
1546 r = SendMessage(hwEdit , WM_SETTEXT, 0, (LPARAM) password);
1547 ok(r == TRUE, "Expected: %d, got: %d\n", TRUE, r);
1549 /* select all, cut (ctrl-x) */
1550 SendMessage(hwEdit, EM_SETSEL, 0, -1);
1551 r = SendMessage(hwEdit, WM_CHAR, 24, 0);
1552 ok(1 == r, "Expected: %d, got: %d\n", 1, r);
1554 /* get text */
1555 r = SendMessage(hwEdit, WM_GETTEXT, 1024, (LPARAM) buffer);
1556 ok(r == strlen(password), "Expected: %s, got len %d\n", password, r);
1557 ok(strcmp(buffer, password) == 0, "expected %s, got %s\n", password, buffer);
1559 r = OpenClipboard(hwEdit);
1560 ok(r == TRUE, "expected %d, got %d\n", TRUE, r);
1561 r = EmptyClipboard();
1562 ok(r == TRUE, "expected %d, got %d\n", TRUE, r);
1563 r = CloseClipboard();
1564 ok(r == TRUE, "expected %d, got %d\n", TRUE, r);
1566 /* select all, copy (ctrl-c) and paste (ctrl-v) */
1567 SendMessage(hwEdit, EM_SETSEL, 0, -1);
1568 r = SendMessage(hwEdit, WM_CHAR, 3, 0);
1569 ok(1 == r, "Expected: %d, got: %d\n", 1, r);
1570 r = SendMessage(hwEdit, WM_CHAR, 22, 0);
1571 ok(1 == r, "Expected: %d, got: %d\n", 1, r);
1573 /* get text */
1574 buffer[0] = 0;
1575 r = SendMessage(hwEdit, WM_GETTEXT, 1024, (LPARAM) buffer);
1576 ok(r == 0, "Expected: 0, got: %d\n", r);
1577 ok(strcmp(buffer, "") == 0, "expected empty string, got %s\n", buffer);
1579 DestroyWindow (hwEdit);
1582 static void test_undo(void)
1584 HWND hwEdit;
1585 LONG r;
1586 DWORD cpMin, cpMax;
1587 char buffer[1024];
1588 const char* text = "undo this";
1590 hwEdit = create_editcontrol(0, 0);
1591 r = get_edit_style(hwEdit);
1592 ok(0 == r, "Wrong style expected 0x%x got: 0x%x\n", 0, r);
1594 /* set text */
1595 r = SendMessage(hwEdit , WM_SETTEXT, 0, (LPARAM) text);
1596 ok(TRUE == r, "Expected: %d, got: %d\n", TRUE, r);
1598 /* select all, */
1599 cpMin = cpMax = 0xdeadbeef;
1600 SendMessage(hwEdit, EM_SETSEL, 0, -1);
1601 r = SendMessage(hwEdit, EM_GETSEL, (WPARAM) &cpMin, (LPARAM) &cpMax);
1602 ok((strlen(text) << 16) == r, "Unexpected length %d\n", r);
1603 ok(0 == cpMin, "Expected: %d, got %d\n", 0, cpMin);
1604 ok(9 == cpMax, "Expected: %d, got %d\n", 9, cpMax);
1606 /* cut (ctrl-x) */
1607 r = SendMessage(hwEdit, WM_CHAR, 24, 0);
1608 ok(1 == r, "Expected: %d, got: %d\n", 1, r);
1610 /* get text */
1611 buffer[0] = 0;
1612 r = SendMessage(hwEdit, WM_GETTEXT, 1024, (LPARAM) buffer);
1613 ok(0 == r, "Expected: %d, got len %d\n", 0, r);
1614 ok(0 == strcmp(buffer, ""), "expected %s, got %s\n", "", buffer);
1616 /* undo (ctrl-z) */
1617 r = SendMessage(hwEdit, WM_CHAR, 26, 0);
1618 ok(1 == r, "Expected: %d, got: %d\n", 1, r);
1620 /* get text */
1621 buffer[0] = 0;
1622 r = SendMessage(hwEdit, WM_GETTEXT, 1024, (LPARAM) buffer);
1623 ok(strlen(text) == r, "Unexpected length %d\n", r);
1624 ok(0 == strcmp(buffer, text), "expected %s, got %s\n", text, buffer);
1626 /* undo again (ctrl-z) */
1627 r = SendMessage(hwEdit, WM_CHAR, 26, 0);
1628 ok(1 == r, "Expected: %d, got: %d\n", 1, r);
1630 /* get text */
1631 buffer[0] = 0;
1632 r = SendMessage(hwEdit, WM_GETTEXT, 1024, (LPARAM) buffer);
1633 ok(r == 0, "Expected: %d, got len %d\n", 0, r);
1634 ok(0 == strcmp(buffer, ""), "expected %s, got %s\n", "", buffer);
1636 DestroyWindow (hwEdit);
1639 static void test_enter(void)
1641 HWND hwEdit;
1642 LONG r;
1643 char buffer[16];
1645 /* multiline */
1646 hwEdit = create_editcontrol(ES_MULTILINE, 0);
1647 r = get_edit_style(hwEdit);
1648 ok(ES_MULTILINE == r, "Wrong style expected 0x%x got: 0x%x\n", ES_MULTILINE, r);
1650 /* set text */
1651 r = SendMessage(hwEdit , WM_SETTEXT, 0, (LPARAM) "");
1652 ok(TRUE == r, "Expected: %d, got: %d\n", TRUE, r);
1654 r = SendMessage(hwEdit, WM_CHAR, VK_RETURN, 0);
1655 ok(1 == r, "Expected: %d, got: %d\n", 1, r);
1657 /* get text */
1658 buffer[0] = 0;
1659 r = SendMessage(hwEdit, WM_GETTEXT, 16, (LPARAM) buffer);
1660 ok(2 == r, "Expected: %d, got len %d\n", 2, r);
1661 ok(0 == strcmp(buffer, "\r\n"), "expected \"\\r\\n\", got \"%s\"\n", buffer);
1663 DestroyWindow (hwEdit);
1665 /* single line */
1666 hwEdit = create_editcontrol(0, 0);
1667 r = get_edit_style(hwEdit);
1668 ok(0 == r, "Wrong style expected 0x%x got: 0x%x\n", 0, r);
1670 /* set text */
1671 r = SendMessage(hwEdit , WM_SETTEXT, 0, (LPARAM) "");
1672 ok(TRUE == r, "Expected: %d, got: %d\n", TRUE, r);
1674 r = SendMessage(hwEdit, WM_CHAR, VK_RETURN, 0);
1675 ok(1 == r, "Expected: %d, got: %d\n", 1, r);
1677 /* get text */
1678 buffer[0] = 0;
1679 r = SendMessage(hwEdit, WM_GETTEXT, 16, (LPARAM) buffer);
1680 ok(0 == r, "Expected: %d, got len %d\n", 0, r);
1681 ok(0 == strcmp(buffer, ""), "expected \"\", got \"%s\"\n", buffer);
1683 DestroyWindow (hwEdit);
1685 /* single line with ES_WANTRETURN */
1686 hwEdit = create_editcontrol(ES_WANTRETURN, 0);
1687 r = get_edit_style(hwEdit);
1688 ok(ES_WANTRETURN == r, "Wrong style expected 0x%x got: 0x%x\n", ES_WANTRETURN, r);
1690 /* set text */
1691 r = SendMessage(hwEdit , WM_SETTEXT, 0, (LPARAM) "");
1692 ok(TRUE == r, "Expected: %d, got: %d\n", TRUE, r);
1694 r = SendMessage(hwEdit, WM_CHAR, VK_RETURN, 0);
1695 ok(1 == r, "Expected: %d, got: %d\n", 1, r);
1697 /* get text */
1698 buffer[0] = 0;
1699 r = SendMessage(hwEdit, WM_GETTEXT, 16, (LPARAM) buffer);
1700 ok(0 == r, "Expected: %d, got len %d\n", 0, r);
1701 ok(0 == strcmp(buffer, ""), "expected \"\", got \"%s\"\n", buffer);
1703 DestroyWindow (hwEdit);
1706 static void test_tab(void)
1708 HWND hwEdit;
1709 LONG r;
1710 char buffer[16];
1712 /* multiline */
1713 hwEdit = create_editcontrol(ES_MULTILINE, 0);
1714 r = get_edit_style(hwEdit);
1715 ok(ES_MULTILINE == r, "Wrong style expected 0x%x got: 0x%x\n", ES_MULTILINE, r);
1717 /* set text */
1718 r = SendMessage(hwEdit , WM_SETTEXT, 0, (LPARAM) "");
1719 ok(TRUE == r, "Expected: %d, got: %d\n", TRUE, r);
1721 r = SendMessage(hwEdit, WM_CHAR, VK_TAB, 0);
1722 ok(1 == r, "Expected: %d, got: %d\n", 1, r);
1724 /* get text */
1725 buffer[0] = 0;
1726 r = SendMessage(hwEdit, WM_GETTEXT, 16, (LPARAM) buffer);
1727 ok(1 == r, "Expected: %d, got len %d\n", 1, r);
1728 ok(0 == strcmp(buffer, "\t"), "expected \"\\t\", got \"%s\"\n", buffer);
1730 DestroyWindow (hwEdit);
1732 /* single line */
1733 hwEdit = create_editcontrol(0, 0);
1734 r = get_edit_style(hwEdit);
1735 ok(0 == r, "Wrong style expected 0x%x got: 0x%x\n", 0, r);
1737 /* set text */
1738 r = SendMessage(hwEdit , WM_SETTEXT, 0, (LPARAM) "");
1739 ok(TRUE == r, "Expected: %d, got: %d\n", TRUE, r);
1741 r = SendMessage(hwEdit, WM_CHAR, VK_TAB, 0);
1742 ok(1 == r, "Expected: %d, got: %d\n", 1, r);
1744 /* get text */
1745 buffer[0] = 0;
1746 r = SendMessage(hwEdit, WM_GETTEXT, 16, (LPARAM) buffer);
1747 ok(0 == r, "Expected: %d, got len %d\n", 0, r);
1748 ok(0 == strcmp(buffer, ""), "expected \"\", got \"%s\"\n", buffer);
1750 DestroyWindow (hwEdit);
1753 static void test_edit_dialog(void)
1755 int r;
1757 /* from bug 11841 */
1758 r = DialogBoxParam(hinst, "EDIT_READONLY_DIALOG", NULL, (DLGPROC)edit_dialog_proc, 0);
1759 ok(333 == r, "Expected %d, got %d\n", 333, r);
1760 r = DialogBoxParam(hinst, "EDIT_READONLY_DIALOG", NULL, (DLGPROC)edit_dialog_proc, 1);
1761 ok(111 == r, "Expected %d, got %d\n", 111, r);
1762 r = DialogBoxParam(hinst, "EDIT_READONLY_DIALOG", NULL, (DLGPROC)edit_dialog_proc, 2);
1763 ok(444 == r, "Expected %d, got %d\n", 444, r);
1765 /* more tests for WM_CHAR */
1766 r = DialogBoxParam(hinst, "EDIT_READONLY_DIALOG", NULL, (DLGPROC)edit_dialog_proc, 3);
1767 ok(444 == r, "Expected %d, got %d\n", 444, r);
1768 r = DialogBoxParam(hinst, "EDIT_READONLY_DIALOG", NULL, (DLGPROC)edit_dialog_proc, 4);
1769 ok(444 == r, "Expected %d, got %d\n", 444, r);
1770 r = DialogBoxParam(hinst, "EDIT_READONLY_DIALOG", NULL, (DLGPROC)edit_dialog_proc, 5);
1771 ok(444 == r, "Expected %d, got %d\n", 444, r);
1773 /* more tests for WM_KEYDOWN + WM_CHAR */
1774 r = DialogBoxParam(hinst, "EDIT_READONLY_DIALOG", NULL, (DLGPROC)edit_dialog_proc, 6);
1775 todo_wine ok(444 == r, "Expected %d, got %d\n", 444, r);
1776 r = DialogBoxParam(hinst, "EDIT_READONLY_DIALOG", NULL, (DLGPROC)edit_dialog_proc, 7);
1777 todo_wine ok(444 == r, "Expected %d, got %d\n", 444, r);
1778 r = DialogBoxParam(hinst, "EDIT_READONLY_DIALOG", NULL, (DLGPROC)edit_dialog_proc, 8);
1779 ok(444 == r, "Expected %d, got %d\n", 444, r);
1781 /* tests with an editable edit control */
1782 r = DialogBoxParam(hinst, "EDIT_DIALOG", NULL, (DLGPROC)edit_dialog_proc, 0);
1783 ok(333 == r, "Expected %d, got %d\n", 333, r);
1784 r = DialogBoxParam(hinst, "EDIT_DIALOG", NULL, (DLGPROC)edit_dialog_proc, 1);
1785 ok(111 == r, "Expected %d, got %d\n", 111, r);
1786 r = DialogBoxParam(hinst, "EDIT_DIALOG", NULL, (DLGPROC)edit_dialog_proc, 2);
1787 ok(444 == r, "Expected %d, got %d\n", 444, r);
1789 /* tests for WM_CHAR */
1790 r = DialogBoxParam(hinst, "EDIT_DIALOG", NULL, (DLGPROC)edit_dialog_proc, 3);
1791 ok(444 == r, "Expected %d, got %d\n", 444, r);
1792 r = DialogBoxParam(hinst, "EDIT_DIALOG", NULL, (DLGPROC)edit_dialog_proc, 4);
1793 ok(444 == r, "Expected %d, got %d\n", 444, r);
1794 r = DialogBoxParam(hinst, "EDIT_DIALOG", NULL, (DLGPROC)edit_dialog_proc, 5);
1795 ok(444 == r, "Expected %d, got %d\n", 444, r);
1797 /* tests for WM_KEYDOWN + WM_CHAR */
1798 r = DialogBoxParam(hinst, "EDIT_DIALOG", NULL, (DLGPROC)edit_dialog_proc, 6);
1799 todo_wine ok(444 == r, "Expected %d, got %d\n", 444, r);
1800 r = DialogBoxParam(hinst, "EDIT_DIALOG", NULL, (DLGPROC)edit_dialog_proc, 7);
1801 todo_wine ok(444 == r, "Expected %d, got %d\n", 444, r);
1802 r = DialogBoxParam(hinst, "EDIT_DIALOG", NULL, (DLGPROC)edit_dialog_proc, 8);
1803 ok(444 == r, "Expected %d, got %d\n", 444, r);
1805 /* multiple tab tests */
1806 r = DialogBoxParam(hinst, "EDIT_DIALOG", NULL, (DLGPROC)edit_dialog_proc, 9);
1807 ok(22 == r, "Expected %d, got %d\n", 22, r);
1808 r = DialogBoxParam(hinst, "EDIT_DIALOG", NULL, (DLGPROC)edit_dialog_proc, 10);
1809 ok(33 == r, "Expected %d, got %d\n", 33, r);
1812 static void test_multi_edit_dialog(void)
1814 int r;
1816 /* test for multiple edit dialogs (bug 12319) */
1817 r = DialogBoxParam(hinst, "MULTI_EDIT_DIALOG", NULL, (DLGPROC)multi_edit_dialog_proc, 0);
1818 ok(2222 == r, "Expected %d, got %d\n", 2222, r);
1819 r = DialogBoxParam(hinst, "MULTI_EDIT_DIALOG", NULL, (DLGPROC)multi_edit_dialog_proc, 1);
1820 ok(1111 == r, "Expected %d, got %d\n", 1111, r);
1821 r = DialogBoxParam(hinst, "MULTI_EDIT_DIALOG", NULL, (DLGPROC)multi_edit_dialog_proc, 2);
1822 ok(2222 == r, "Expected %d, got %d\n", 2222, r);
1823 r = DialogBoxParam(hinst, "MULTI_EDIT_DIALOG", NULL, (DLGPROC)multi_edit_dialog_proc, 3);
1824 ok(11 == r, "Expected %d, got %d\n", 11, r);
1827 static void test_wantreturn_edit_dialog(void)
1829 int r;
1831 /* tests for WM_KEYDOWN */
1832 r = DialogBoxParam(hinst, "EDIT_WANTRETURN_DIALOG", NULL, (DLGPROC)edit_wantreturn_dialog_proc, 0);
1833 ok(333 == r, "Expected %d, got %d\n", 333, r);
1834 r = DialogBoxParam(hinst, "EDIT_WANTRETURN_DIALOG", NULL, (DLGPROC)edit_wantreturn_dialog_proc, 1);
1835 ok(444 == r, "Expected %d, got %d\n", 444, r);
1836 r = DialogBoxParam(hinst, "EDIT_WANTRETURN_DIALOG", NULL, (DLGPROC)edit_wantreturn_dialog_proc, 2);
1837 ok(444 == r, "Expected %d, got %d\n", 444, r);
1839 /* tests for WM_CHAR */
1840 r = DialogBoxParam(hinst, "EDIT_WANTRETURN_DIALOG", NULL, (DLGPROC)edit_wantreturn_dialog_proc, 3);
1841 ok(444 == r, "Expected %d, got %d\n", 444, r);
1842 r = DialogBoxParam(hinst, "EDIT_WANTRETURN_DIALOG", NULL, (DLGPROC)edit_wantreturn_dialog_proc, 4);
1843 ok(444 == r, "Expected %d, got %d\n", 444, r);
1844 r = DialogBoxParam(hinst, "EDIT_WANTRETURN_DIALOG", NULL, (DLGPROC)edit_wantreturn_dialog_proc, 5);
1845 ok(444 == r, "Expected %d, got %d\n", 444, r);
1847 /* tests for WM_KEYDOWN + WM_CHAR */
1848 r = DialogBoxParam(hinst, "EDIT_WANTRETURN_DIALOG", NULL, (DLGPROC)edit_wantreturn_dialog_proc, 6);
1849 todo_wine ok(444 == r, "Expected %d, got %d\n", 444, r);
1850 r = DialogBoxParam(hinst, "EDIT_WANTRETURN_DIALOG", NULL, (DLGPROC)edit_wantreturn_dialog_proc, 7);
1851 ok(444 == r, "Expected %d, got %d\n", 444, r);
1852 r = DialogBoxParam(hinst, "EDIT_WANTRETURN_DIALOG", NULL, (DLGPROC)edit_wantreturn_dialog_proc, 8);
1853 ok(444 == r, "Expected %d, got %d\n", 444, r);
1856 static void test_singleline_wantreturn_edit_dialog(void)
1858 int r;
1860 /* tests for WM_KEYDOWN */
1861 r = DialogBoxParam(hinst, "EDIT_SINGLELINE_DIALOG", NULL, (DLGPROC)edit_singleline_dialog_proc, 0);
1862 ok(222 == r, "Expected %d, got %d\n", 222, r);
1863 r = DialogBoxParam(hinst, "EDIT_SINGLELINE_DIALOG", NULL, (DLGPROC)edit_singleline_dialog_proc, 1);
1864 ok(111 == r, "Expected %d, got %d\n", 111, r);
1865 r = DialogBoxParam(hinst, "EDIT_SINGLELINE_DIALOG", NULL, (DLGPROC)edit_singleline_dialog_proc, 2);
1866 ok(444 == r, "Expected %d, got %d\n", 444, r);
1868 /* tests for WM_CHAR */
1869 r = DialogBoxParam(hinst, "EDIT_SINGLELINE_DIALOG", NULL, (DLGPROC)edit_singleline_dialog_proc, 3);
1870 ok(444 == r, "Expected %d, got %d\n", 444, r);
1871 r = DialogBoxParam(hinst, "EDIT_SINGLELINE_DIALOG", NULL, (DLGPROC)edit_singleline_dialog_proc, 4);
1872 ok(444 == r, "Expected %d, got %d\n", 444, r);
1873 r = DialogBoxParam(hinst, "EDIT_SINGLELINE_DIALOG", NULL, (DLGPROC)edit_singleline_dialog_proc, 5);
1874 ok(444 == r, "Expected %d, got %d\n", 444, r);
1876 /* tests for WM_KEYDOWN + WM_CHAR */
1877 r = DialogBoxParam(hinst, "EDIT_SINGLELINE_DIALOG", NULL, (DLGPROC)edit_singleline_dialog_proc, 6);
1878 ok(222 == r, "Expected %d, got %d\n", 222, r);
1879 r = DialogBoxParam(hinst, "EDIT_SINGLELINE_DIALOG", NULL, (DLGPROC)edit_singleline_dialog_proc, 7);
1880 ok(111 == r, "Expected %d, got %d\n", 111, r);
1881 r = DialogBoxParam(hinst, "EDIT_SINGLELINE_DIALOG", NULL, (DLGPROC)edit_singleline_dialog_proc, 8);
1882 ok(444 == r, "Expected %d, got %d\n", 444, r);
1884 /* tests for WM_KEYDOWN */
1885 r = DialogBoxParam(hinst, "EDIT_SINGLELINE_WANTRETURN_DIALOG", NULL, (DLGPROC)edit_singleline_dialog_proc, 0);
1886 ok(222 == r, "Expected %d, got %d\n", 222, r);
1887 r = DialogBoxParam(hinst, "EDIT_SINGLELINE_WANTRETURN_DIALOG", NULL, (DLGPROC)edit_singleline_dialog_proc, 1);
1888 ok(111 == r, "Expected %d, got %d\n", 111, r);
1889 r = DialogBoxParam(hinst, "EDIT_SINGLELINE_WANTRETURN_DIALOG", NULL, (DLGPROC)edit_singleline_dialog_proc, 2);
1890 ok(444 == r, "Expected %d, got %d\n", 444, r);
1892 /* tests for WM_CHAR */
1893 r = DialogBoxParam(hinst, "EDIT_SINGLELINE_WANTRETURN_DIALOG", NULL, (DLGPROC)edit_singleline_dialog_proc, 3);
1894 ok(444 == r, "Expected %d, got %d\n", 444, r);
1895 r = DialogBoxParam(hinst, "EDIT_SINGLELINE_WANTRETURN_DIALOG", NULL, (DLGPROC)edit_singleline_dialog_proc, 4);
1896 ok(444 == r, "Expected %d, got %d\n", 444, r);
1897 r = DialogBoxParam(hinst, "EDIT_SINGLELINE_WANTRETURN_DIALOG", NULL, (DLGPROC)edit_singleline_dialog_proc, 5);
1898 ok(444 == r, "Expected %d, got %d\n", 444, r);
1900 /* tests for WM_KEYDOWN + WM_CHAR */
1901 r = DialogBoxParam(hinst, "EDIT_SINGLELINE_WANTRETURN_DIALOG", NULL, (DLGPROC)edit_singleline_dialog_proc, 6);
1902 ok(222 == r, "Expected %d, got %d\n", 222, r);
1903 r = DialogBoxParam(hinst, "EDIT_SINGLELINE_WANTRETURN_DIALOG", NULL, (DLGPROC)edit_singleline_dialog_proc, 7);
1904 ok(111 == r, "Expected %d, got %d\n", 111, r);
1905 r = DialogBoxParam(hinst, "EDIT_SINGLELINE_WANTRETURN_DIALOG", NULL, (DLGPROC)edit_singleline_dialog_proc, 8);
1906 ok(444 == r, "Expected %d, got %d\n", 444, r);
1909 static int child_edit_wmkeydown_num_messages = 0;
1910 static INT_PTR CALLBACK child_edit_wmkeydown_proc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
1912 switch (msg)
1914 case WM_DESTROY:
1915 case WM_NCDESTROY:
1916 break;
1918 default:
1919 child_edit_wmkeydown_num_messages++;
1920 break;
1923 return FALSE;
1926 static void test_child_edit_wmkeydown(void)
1928 HWND hwEdit, hwParent;
1929 int r;
1931 hwEdit = create_child_editcontrol(0, 0);
1932 hwParent = GetParent(hwEdit);
1933 SetWindowLongPtr(hwParent, GWLP_WNDPROC, (LONG_PTR)child_edit_wmkeydown_proc);
1934 r = SendMessage(hwEdit, WM_KEYDOWN, VK_RETURN, 0x1c0001);
1935 ok(1 == r, "expected 1, got %d\n", r);
1936 ok(0 == child_edit_wmkeydown_num_messages, "expected 0, got %d\n", child_edit_wmkeydown_num_messages);
1937 destroy_child_editcontrol(hwEdit);
1940 static BOOL RegisterWindowClasses (void)
1942 WNDCLASSA test2;
1943 WNDCLASSA test3;
1944 WNDCLASSA text_position;
1946 test2.style = 0;
1947 test2.lpfnWndProc = ET2_WndProc;
1948 test2.cbClsExtra = 0;
1949 test2.cbWndExtra = 0;
1950 test2.hInstance = hinst;
1951 test2.hIcon = NULL;
1952 test2.hCursor = LoadCursorA (NULL, IDC_ARROW);
1953 test2.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
1954 test2.lpszMenuName = NULL;
1955 test2.lpszClassName = szEditTest2Class;
1956 if (!RegisterClassA(&test2)) return FALSE;
1958 test3.style = 0;
1959 test3.lpfnWndProc = edit3_wnd_procA;
1960 test3.cbClsExtra = 0;
1961 test3.cbWndExtra = 0;
1962 test3.hInstance = hinst;
1963 test3.hIcon = 0;
1964 test3.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW);
1965 test3.hbrBackground = GetStockObject(WHITE_BRUSH);
1966 test3.lpszMenuName = NULL;
1967 test3.lpszClassName = szEditTest3Class;
1968 if (!RegisterClassA(&test3)) return FALSE;
1970 text_position.style = CS_HREDRAW | CS_VREDRAW;
1971 text_position.cbClsExtra = 0;
1972 text_position.cbWndExtra = 0;
1973 text_position.hInstance = hinst;
1974 text_position.hIcon = NULL;
1975 text_position.hCursor = LoadCursorA(NULL, IDC_ARROW);
1976 text_position.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
1977 text_position.lpszMenuName = NULL;
1978 text_position.lpszClassName = szEditTextPositionClass;
1979 text_position.lpfnWndProc = DefWindowProc;
1980 if (!RegisterClassA(&text_position)) return FALSE;
1982 return TRUE;
1985 static void UnregisterWindowClasses (void)
1987 UnregisterClassA(szEditTest2Class, hinst);
1988 UnregisterClassA(szEditTest3Class, hinst);
1989 UnregisterClassA(szEditTextPositionClass, hinst);
1992 void test_fontsize(void)
1994 HWND hwEdit;
1995 HFONT hfont;
1996 LOGFONT lf;
1997 LONG r;
1998 char szLocalString[MAXLEN];
2000 memset(&lf,0,sizeof(LOGFONTA));
2001 strcpy(lf.lfFaceName,"Arial");
2002 lf.lfHeight = -300; /* taller than the edit box */
2003 lf.lfWeight = 500;
2004 hfont = CreateFontIndirect(&lf);
2006 trace("EDIT: Oversized font (Multi line)\n");
2007 hwEdit= CreateWindow("EDIT", NULL, ES_MULTILINE|ES_AUTOHSCROLL,
2008 0, 0, 150, 50, NULL, NULL, hinst, NULL);
2010 SendMessage(hwEdit,WM_SETFONT,(WPARAM)hfont,0);
2012 if (winetest_interactive)
2013 ShowWindow (hwEdit, SW_SHOW);
2015 r = SendMessage(hwEdit, WM_CHAR, 'A', 1);
2016 ok(1 == r, "Expected: %d, got: %d\n", 1, r);
2017 r = SendMessage(hwEdit, WM_CHAR, 'B', 1);
2018 ok(1 == r, "Expected: %d, got: %d\n", 1, r);
2019 r = SendMessage(hwEdit, WM_CHAR, 'C', 1);
2020 ok(1 == r, "Expected: %d, got: %d\n", 1, r);
2022 GetWindowText(hwEdit, szLocalString, MAXLEN);
2023 ok(lstrcmp(szLocalString, "ABC")==0,
2024 "Wrong contents of edit: %s\n", szLocalString);
2026 r = SendMessage(hwEdit, EM_POSFROMCHAR,0,0);
2027 ok(r != -1,"EM_POSFROMCHAR failed index 0\n");
2028 r = SendMessage(hwEdit, EM_POSFROMCHAR,1,0);
2029 ok(r != -1,"EM_POSFROMCHAR failed index 1\n");
2030 r = SendMessage(hwEdit, EM_POSFROMCHAR,2,0);
2031 ok(r != -1,"EM_POSFROMCHAR failed index 2\n");
2032 r = SendMessage(hwEdit, EM_POSFROMCHAR,3,0);
2033 ok(r == -1,"EM_POSFROMCHAR succeeded index 3\n");
2035 DestroyWindow (hwEdit);
2036 DeleteObject(hfont);
2039 START_TEST(edit)
2041 hinst = GetModuleHandleA(NULL);
2042 assert(RegisterWindowClasses());
2044 test_edit_control_1();
2045 test_edit_control_2();
2046 test_edit_control_3();
2047 test_edit_control_4();
2048 test_edit_control_5();
2049 test_edit_control_limittext();
2050 test_margins();
2051 test_margins_font_change();
2052 test_text_position();
2053 test_espassword();
2054 test_undo();
2055 test_enter();
2056 test_tab();
2057 test_edit_dialog();
2058 test_multi_edit_dialog();
2059 test_wantreturn_edit_dialog();
2060 test_singleline_wantreturn_edit_dialog();
2061 test_child_edit_wmkeydown();
2062 test_fontsize();
2064 UnregisterWindowClasses();