2004-11-08 23:10:05 +01:00
|
|
|
/* Unit test suite for edit control.
|
|
|
|
*
|
|
|
|
* Copyright 2004 Vitaliy Margolen
|
2005-03-22 17:40:36 +01:00
|
|
|
* Copyright 2005 C. Scott Ananian
|
2004-11-08 23:10:05 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-11-08 23:10:05 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <windows.h>
|
|
|
|
#include <commctrl.h>
|
|
|
|
|
|
|
|
#include "wine/test.h"
|
|
|
|
|
2005-02-14 12:02:06 +01:00
|
|
|
#ifndef ES_COMBO
|
|
|
|
#define ES_COMBO 0x200
|
|
|
|
#endif
|
|
|
|
|
2009-08-25 17:01:05 +02:00
|
|
|
#define ID_EDITTESTDBUTTON 0x123
|
2005-03-22 17:40:36 +01:00
|
|
|
#define ID_EDITTEST2 99
|
|
|
|
#define MAXLEN 200
|
|
|
|
|
2005-06-05 21:19:11 +02:00
|
|
|
struct edit_notify {
|
|
|
|
int en_change, en_maxtext, en_update;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct edit_notify notifications;
|
|
|
|
|
2008-04-02 20:04:23 +02:00
|
|
|
static INT_PTR CALLBACK multi_edit_dialog_proc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
|
|
|
|
{
|
2008-04-02 20:33:19 +02:00
|
|
|
static int num_ok_commands = 0;
|
2008-04-02 20:04:23 +02:00
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
{
|
|
|
|
HWND hedit = GetDlgItem(hdlg, 1000);
|
|
|
|
SetFocus(hedit);
|
|
|
|
switch (lparam)
|
|
|
|
{
|
|
|
|
/* test cases related to bug 12319 */
|
|
|
|
case 0:
|
2013-10-23 07:53:42 +02:00
|
|
|
PostMessageA(hedit, WM_KEYDOWN, VK_TAB, 0xf0001);
|
|
|
|
PostMessageA(hdlg, WM_USER, 0xdeadbeef, 0);
|
2008-04-02 20:04:23 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
2013-10-23 07:53:42 +02:00
|
|
|
PostMessageA(hedit, WM_CHAR, VK_TAB, 0xf0001);
|
|
|
|
PostMessageA(hdlg, WM_USER, 0xdeadbeef, 0);
|
2008-04-02 20:04:23 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
2013-10-23 07:53:42 +02:00
|
|
|
PostMessageA(hedit, WM_KEYDOWN, VK_TAB, 0xf0001);
|
|
|
|
PostMessageA(hedit, WM_CHAR, VK_TAB, 0xf0001);
|
|
|
|
PostMessageA(hdlg, WM_USER, 0xdeadbeef, 0);
|
2008-04-02 20:04:23 +02:00
|
|
|
break;
|
|
|
|
|
2008-04-02 20:33:19 +02:00
|
|
|
/* test cases for pressing enter */
|
|
|
|
case 3:
|
|
|
|
num_ok_commands = 0;
|
2013-10-23 07:53:42 +02:00
|
|
|
PostMessageA(hedit, WM_KEYDOWN, VK_RETURN, 0x1c0001);
|
|
|
|
PostMessageA(hdlg, WM_USER, 0xdeadbeef, 1);
|
2008-04-02 20:33:19 +02:00
|
|
|
break;
|
|
|
|
|
2008-04-02 20:04:23 +02:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case WM_COMMAND:
|
|
|
|
if (HIWORD(wparam) != BN_CLICKED)
|
|
|
|
break;
|
|
|
|
|
|
|
|
switch (LOWORD(wparam))
|
|
|
|
{
|
|
|
|
case IDOK:
|
2008-04-02 20:33:19 +02:00
|
|
|
num_ok_commands++;
|
2008-04-02 20:04:23 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_USER:
|
|
|
|
{
|
|
|
|
HWND hfocus = GetFocus();
|
|
|
|
HWND hedit = GetDlgItem(hdlg, 1000);
|
|
|
|
HWND hedit2 = GetDlgItem(hdlg, 1001);
|
|
|
|
HWND hedit3 = GetDlgItem(hdlg, 1002);
|
|
|
|
|
|
|
|
if (wparam != 0xdeadbeef)
|
|
|
|
break;
|
|
|
|
|
|
|
|
switch (lparam)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
if (hfocus == hedit)
|
|
|
|
EndDialog(hdlg, 1111);
|
|
|
|
else if (hfocus == hedit2)
|
|
|
|
EndDialog(hdlg, 2222);
|
|
|
|
else if (hfocus == hedit3)
|
|
|
|
EndDialog(hdlg, 3333);
|
|
|
|
else
|
|
|
|
EndDialog(hdlg, 4444);
|
|
|
|
break;
|
2008-04-02 20:33:19 +02:00
|
|
|
case 1:
|
|
|
|
if ((hfocus == hedit) && (num_ok_commands == 0))
|
|
|
|
EndDialog(hdlg, 11);
|
|
|
|
else
|
|
|
|
EndDialog(hdlg, 22);
|
|
|
|
break;
|
2008-04-02 20:04:23 +02:00
|
|
|
default:
|
|
|
|
EndDialog(hdlg, 5555);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case WM_CLOSE:
|
|
|
|
EndDialog(hdlg, 333);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-03-27 19:48:44 +01:00
|
|
|
static INT_PTR CALLBACK edit_dialog_proc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
|
2008-03-26 03:09:38 +01:00
|
|
|
{
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
{
|
2008-03-27 19:48:44 +01:00
|
|
|
HWND hedit = GetDlgItem(hdlg, 1000);
|
|
|
|
SetFocus(hedit);
|
2008-03-26 03:09:38 +01:00
|
|
|
switch (lparam)
|
|
|
|
{
|
2008-03-27 20:17:23 +01:00
|
|
|
/* from bug 11841 */
|
2008-03-26 03:09:38 +01:00
|
|
|
case 0:
|
2013-10-23 07:53:42 +02:00
|
|
|
PostMessageA(hedit, WM_KEYDOWN, VK_ESCAPE, 0x10001);
|
2008-03-26 03:09:38 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2013-10-23 07:53:42 +02:00
|
|
|
PostMessageA(hedit, WM_KEYDOWN, VK_RETURN, 0x1c0001);
|
2008-03-26 03:09:38 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
2013-10-23 07:53:42 +02:00
|
|
|
PostMessageA(hedit, WM_KEYDOWN, VK_TAB, 0xf0001);
|
|
|
|
PostMessageA(hdlg, WM_USER, 0xdeadbeef, 1);
|
2008-03-26 03:09:38 +01:00
|
|
|
break;
|
2008-03-27 20:17:23 +01:00
|
|
|
|
|
|
|
/* more test cases for WM_CHAR */
|
|
|
|
case 3:
|
2013-10-23 07:53:42 +02:00
|
|
|
PostMessageA(hedit, WM_CHAR, VK_ESCAPE, 0x10001);
|
|
|
|
PostMessageA(hdlg, WM_USER, 0xdeadbeef, 0);
|
2008-03-27 20:17:23 +01:00
|
|
|
break;
|
|
|
|
case 4:
|
2013-10-23 07:53:42 +02:00
|
|
|
PostMessageA(hedit, WM_CHAR, VK_RETURN, 0x1c0001);
|
|
|
|
PostMessageA(hdlg, WM_USER, 0xdeadbeef, 0);
|
2008-03-27 20:17:23 +01:00
|
|
|
break;
|
|
|
|
case 5:
|
2013-10-23 07:53:42 +02:00
|
|
|
PostMessageA(hedit, WM_CHAR, VK_TAB, 0xf0001);
|
|
|
|
PostMessageA(hdlg, WM_USER, 0xdeadbeef, 0);
|
2008-03-27 20:17:23 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* more test cases for WM_KEYDOWN + WM_CHAR */
|
|
|
|
case 6:
|
2013-10-23 07:53:42 +02:00
|
|
|
PostMessageA(hedit, WM_KEYDOWN, VK_ESCAPE, 0x10001);
|
|
|
|
PostMessageA(hedit, WM_CHAR, VK_ESCAPE, 0x10001);
|
|
|
|
PostMessageA(hdlg, WM_USER, 0xdeadbeef, 0);
|
2008-03-27 20:17:23 +01:00
|
|
|
break;
|
|
|
|
case 7:
|
2013-10-23 07:53:42 +02:00
|
|
|
PostMessageA(hedit, WM_KEYDOWN, VK_RETURN, 0x1c0001);
|
|
|
|
PostMessageA(hedit, WM_CHAR, VK_RETURN, 0x1c0001);
|
|
|
|
PostMessageA(hdlg, WM_USER, 0xdeadbeef, 1);
|
2008-03-27 20:17:23 +01:00
|
|
|
break;
|
|
|
|
case 8:
|
2013-10-23 07:53:42 +02:00
|
|
|
PostMessageA(hedit, WM_KEYDOWN, VK_TAB, 0xf0001);
|
|
|
|
PostMessageA(hedit, WM_CHAR, VK_TAB, 0xf0001);
|
|
|
|
PostMessageA(hdlg, WM_USER, 0xdeadbeef, 1);
|
2008-03-27 20:17:23 +01:00
|
|
|
break;
|
|
|
|
|
2008-04-02 19:50:09 +02:00
|
|
|
/* multiple tab tests */
|
|
|
|
case 9:
|
2013-10-23 07:53:42 +02:00
|
|
|
PostMessageA(hedit, WM_KEYDOWN, VK_TAB, 0xf0001);
|
|
|
|
PostMessageA(hedit, WM_KEYDOWN, VK_TAB, 0xf0001);
|
|
|
|
PostMessageA(hdlg, WM_USER, 0xdeadbeef, 2);
|
2008-04-02 19:50:09 +02:00
|
|
|
break;
|
|
|
|
case 10:
|
2013-10-23 07:53:42 +02:00
|
|
|
PostMessageA(hedit, WM_KEYDOWN, VK_TAB, 0xf0001);
|
|
|
|
PostMessageA(hedit, WM_KEYDOWN, VK_TAB, 0xf0001);
|
|
|
|
PostMessageA(hedit, WM_KEYDOWN, VK_TAB, 0xf0001);
|
|
|
|
PostMessageA(hdlg, WM_USER, 0xdeadbeef, 2);
|
2008-04-02 19:50:09 +02:00
|
|
|
break;
|
|
|
|
|
2008-03-26 03:09:38 +01:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case WM_COMMAND:
|
|
|
|
if (HIWORD(wparam) != BN_CLICKED)
|
|
|
|
break;
|
|
|
|
|
|
|
|
switch (LOWORD(wparam))
|
|
|
|
{
|
|
|
|
case IDOK:
|
|
|
|
EndDialog(hdlg, 111);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDCANCEL:
|
|
|
|
EndDialog(hdlg, 222);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_USER:
|
2008-03-27 20:17:23 +01:00
|
|
|
{
|
|
|
|
int len;
|
|
|
|
HWND hok = GetDlgItem(hdlg, IDOK);
|
2008-04-02 19:50:09 +02:00
|
|
|
HWND hcancel = GetDlgItem(hdlg, IDCANCEL);
|
2008-03-27 20:17:23 +01:00
|
|
|
HWND hedit = GetDlgItem(hdlg, 1000);
|
2008-04-02 19:50:09 +02:00
|
|
|
HWND hfocus = GetFocus();
|
2008-03-27 20:17:23 +01:00
|
|
|
|
|
|
|
if (wparam != 0xdeadbeef)
|
2008-03-26 03:09:38 +01:00
|
|
|
break;
|
2008-03-27 20:17:23 +01:00
|
|
|
|
|
|
|
switch (lparam)
|
|
|
|
{
|
|
|
|
case 0:
|
2013-10-23 07:53:42 +02:00
|
|
|
len = SendMessageA(hedit, WM_GETTEXTLENGTH, 0, 0);
|
2008-03-27 20:17:23 +01:00
|
|
|
if (len == 0)
|
|
|
|
EndDialog(hdlg, 444);
|
|
|
|
else
|
|
|
|
EndDialog(hdlg, 555);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
2013-10-23 07:53:42 +02:00
|
|
|
len = SendMessageA(hedit, WM_GETTEXTLENGTH, 0, 0);
|
2008-04-02 19:50:09 +02:00
|
|
|
if ((hfocus == hok) && len == 0)
|
2008-03-27 20:17:23 +01:00
|
|
|
EndDialog(hdlg, 444);
|
|
|
|
else
|
|
|
|
EndDialog(hdlg, 555);
|
|
|
|
break;
|
|
|
|
|
2008-04-02 19:50:09 +02:00
|
|
|
case 2:
|
|
|
|
if (hfocus == hok)
|
|
|
|
EndDialog(hdlg, 11);
|
|
|
|
else if (hfocus == hcancel)
|
|
|
|
EndDialog(hdlg, 22);
|
|
|
|
else if (hfocus == hedit)
|
|
|
|
EndDialog(hdlg, 33);
|
|
|
|
else
|
|
|
|
EndDialog(hdlg, 44);
|
|
|
|
break;
|
|
|
|
|
2008-03-27 20:17:23 +01:00
|
|
|
default:
|
|
|
|
EndDialog(hdlg, 555);
|
|
|
|
}
|
2008-03-26 03:09:38 +01:00
|
|
|
break;
|
2008-03-27 20:17:23 +01:00
|
|
|
}
|
2008-03-26 03:09:38 +01:00
|
|
|
|
|
|
|
case WM_CLOSE:
|
|
|
|
EndDialog(hdlg, 333);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-04-07 22:32:36 +02:00
|
|
|
static INT_PTR CALLBACK edit_singleline_dialog_proc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
|
|
|
|
{
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
{
|
|
|
|
HWND hedit = GetDlgItem(hdlg, 1000);
|
|
|
|
SetFocus(hedit);
|
|
|
|
switch (lparam)
|
|
|
|
{
|
|
|
|
/* test cases for WM_KEYDOWN */
|
|
|
|
case 0:
|
2013-10-23 07:53:42 +02:00
|
|
|
PostMessageA(hedit, WM_KEYDOWN, VK_ESCAPE, 0x10001);
|
2008-04-07 22:32:36 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
2013-10-23 07:53:42 +02:00
|
|
|
PostMessageA(hedit, WM_KEYDOWN, VK_RETURN, 0x1c0001);
|
2008-04-07 22:32:36 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
2013-10-23 07:53:42 +02:00
|
|
|
PostMessageA(hedit, WM_KEYDOWN, VK_TAB, 0xf0001);
|
|
|
|
PostMessageA(hdlg, WM_USER, 0xdeadbeef, 1);
|
2008-04-07 22:32:36 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* test cases for WM_CHAR */
|
|
|
|
case 3:
|
2013-10-23 07:53:42 +02:00
|
|
|
PostMessageA(hedit, WM_CHAR, VK_ESCAPE, 0x10001);
|
|
|
|
PostMessageA(hdlg, WM_USER, 0xdeadbeef, 0);
|
2008-04-07 22:32:36 +02:00
|
|
|
break;
|
|
|
|
case 4:
|
2013-10-23 07:53:42 +02:00
|
|
|
PostMessageA(hedit, WM_CHAR, VK_RETURN, 0x1c0001);
|
|
|
|
PostMessageA(hdlg, WM_USER, 0xdeadbeef, 0);
|
2008-04-07 22:32:36 +02:00
|
|
|
break;
|
|
|
|
case 5:
|
2013-10-23 07:53:42 +02:00
|
|
|
PostMessageA(hedit, WM_CHAR, VK_TAB, 0xf0001);
|
|
|
|
PostMessageA(hdlg, WM_USER, 0xdeadbeef, 0);
|
2008-04-07 22:32:36 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* test cases for WM_KEYDOWN + WM_CHAR */
|
|
|
|
case 6:
|
2013-10-23 07:53:42 +02:00
|
|
|
PostMessageA(hedit, WM_KEYDOWN, VK_ESCAPE, 0x10001);
|
|
|
|
PostMessageA(hedit, WM_CHAR, VK_ESCAPE, 0x10001);
|
2008-04-07 22:32:36 +02:00
|
|
|
break;
|
|
|
|
case 7:
|
2013-10-23 07:53:42 +02:00
|
|
|
PostMessageA(hedit, WM_KEYDOWN, VK_RETURN, 0x1c0001);
|
|
|
|
PostMessageA(hedit, WM_CHAR, VK_RETURN, 0x1c0001);
|
2008-04-07 22:32:36 +02:00
|
|
|
break;
|
|
|
|
case 8:
|
2013-10-23 07:53:42 +02:00
|
|
|
PostMessageA(hedit, WM_KEYDOWN, VK_TAB, 0xf0001);
|
|
|
|
PostMessageA(hedit, WM_CHAR, VK_TAB, 0xf0001);
|
|
|
|
PostMessageA(hdlg, WM_USER, 0xdeadbeef, 1);
|
2008-04-07 22:32:36 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case WM_COMMAND:
|
|
|
|
if (HIWORD(wparam) != BN_CLICKED)
|
|
|
|
break;
|
|
|
|
|
|
|
|
switch (LOWORD(wparam))
|
|
|
|
{
|
|
|
|
case IDOK:
|
|
|
|
EndDialog(hdlg, 111);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDCANCEL:
|
|
|
|
EndDialog(hdlg, 222);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_USER:
|
|
|
|
{
|
|
|
|
HWND hok = GetDlgItem(hdlg, IDOK);
|
|
|
|
HWND hedit = GetDlgItem(hdlg, 1000);
|
|
|
|
HWND hfocus = GetFocus();
|
2013-10-23 07:53:42 +02:00
|
|
|
int len = SendMessageA(hedit, WM_GETTEXTLENGTH, 0, 0);
|
2008-04-07 22:32:36 +02:00
|
|
|
|
|
|
|
if (wparam != 0xdeadbeef)
|
|
|
|
break;
|
|
|
|
|
|
|
|
switch (lparam)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
if ((hfocus == hedit) && len == 0)
|
|
|
|
EndDialog(hdlg, 444);
|
|
|
|
else
|
|
|
|
EndDialog(hdlg, 555);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
if ((hfocus == hok) && len == 0)
|
|
|
|
EndDialog(hdlg, 444);
|
|
|
|
else
|
|
|
|
EndDialog(hdlg, 555);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
EndDialog(hdlg, 55);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case WM_CLOSE:
|
|
|
|
EndDialog(hdlg, 333);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-04-07 22:32:20 +02:00
|
|
|
static INT_PTR CALLBACK edit_wantreturn_dialog_proc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
|
|
|
|
{
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
{
|
|
|
|
HWND hedit = GetDlgItem(hdlg, 1000);
|
|
|
|
SetFocus(hedit);
|
|
|
|
switch (lparam)
|
|
|
|
{
|
|
|
|
/* test cases for WM_KEYDOWN */
|
|
|
|
case 0:
|
2013-10-23 07:53:42 +02:00
|
|
|
PostMessageA(hedit, WM_KEYDOWN, VK_ESCAPE, 0x10001);
|
2008-04-07 22:32:20 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
2013-10-23 07:53:42 +02:00
|
|
|
PostMessageA(hedit, WM_KEYDOWN, VK_RETURN, 0x1c0001);
|
|
|
|
PostMessageA(hdlg, WM_USER, 0xdeadbeef, 0);
|
2008-04-07 22:32:20 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
2013-10-23 07:53:42 +02:00
|
|
|
PostMessageA(hedit, WM_KEYDOWN, VK_TAB, 0xf0001);
|
|
|
|
PostMessageA(hdlg, WM_USER, 0xdeadbeef, 1);
|
2008-04-07 22:32:20 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* test cases for WM_CHAR */
|
|
|
|
case 3:
|
2013-10-23 07:53:42 +02:00
|
|
|
PostMessageA(hedit, WM_CHAR, VK_ESCAPE, 0x10001);
|
|
|
|
PostMessageA(hdlg, WM_USER, 0xdeadbeef, 0);
|
2008-04-07 22:32:20 +02:00
|
|
|
break;
|
|
|
|
case 4:
|
2013-10-23 07:53:42 +02:00
|
|
|
PostMessageA(hedit, WM_CHAR, VK_RETURN, 0x1c0001);
|
|
|
|
PostMessageA(hdlg, WM_USER, 0xdeadbeef, 2);
|
2008-04-07 22:32:20 +02:00
|
|
|
break;
|
|
|
|
case 5:
|
2013-10-23 07:53:42 +02:00
|
|
|
PostMessageA(hedit, WM_CHAR, VK_TAB, 0xf0001);
|
|
|
|
PostMessageA(hdlg, WM_USER, 0xdeadbeef, 0);
|
2008-04-07 22:32:20 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* test cases for WM_KEYDOWN + WM_CHAR */
|
|
|
|
case 6:
|
2013-10-23 07:53:42 +02:00
|
|
|
PostMessageA(hedit, WM_KEYDOWN, VK_ESCAPE, 0x10001);
|
|
|
|
PostMessageA(hedit, WM_CHAR, VK_ESCAPE, 0x10001);
|
|
|
|
PostMessageA(hdlg, WM_USER, 0xdeadbeef, 0);
|
2008-04-07 22:32:20 +02:00
|
|
|
break;
|
|
|
|
case 7:
|
2013-10-23 07:53:42 +02:00
|
|
|
PostMessageA(hedit, WM_KEYDOWN, VK_RETURN, 0x1c0001);
|
|
|
|
PostMessageA(hedit, WM_CHAR, VK_RETURN, 0x1c0001);
|
|
|
|
PostMessageA(hdlg, WM_USER, 0xdeadbeef, 2);
|
2008-04-07 22:32:20 +02:00
|
|
|
break;
|
|
|
|
case 8:
|
2013-10-23 07:53:42 +02:00
|
|
|
PostMessageA(hedit, WM_KEYDOWN, VK_TAB, 0xf0001);
|
|
|
|
PostMessageA(hedit, WM_CHAR, VK_TAB, 0xf0001);
|
|
|
|
PostMessageA(hdlg, WM_USER, 0xdeadbeef, 1);
|
2008-04-07 22:32:20 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case WM_COMMAND:
|
|
|
|
if (HIWORD(wparam) != BN_CLICKED)
|
|
|
|
break;
|
|
|
|
|
|
|
|
switch (LOWORD(wparam))
|
|
|
|
{
|
|
|
|
case IDOK:
|
|
|
|
EndDialog(hdlg, 111);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDCANCEL:
|
|
|
|
EndDialog(hdlg, 222);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_USER:
|
|
|
|
{
|
|
|
|
HWND hok = GetDlgItem(hdlg, IDOK);
|
|
|
|
HWND hedit = GetDlgItem(hdlg, 1000);
|
|
|
|
HWND hfocus = GetFocus();
|
2013-10-23 07:53:42 +02:00
|
|
|
int len = SendMessageA(hedit, WM_GETTEXTLENGTH, 0, 0);
|
2008-04-07 22:32:20 +02:00
|
|
|
|
|
|
|
if (wparam != 0xdeadbeef)
|
|
|
|
break;
|
|
|
|
|
|
|
|
switch (lparam)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
if ((hfocus == hedit) && len == 0)
|
|
|
|
EndDialog(hdlg, 444);
|
|
|
|
else
|
|
|
|
EndDialog(hdlg, 555);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
if ((hfocus == hok) && len == 0)
|
|
|
|
EndDialog(hdlg, 444);
|
|
|
|
else
|
|
|
|
EndDialog(hdlg, 555);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
if ((hfocus == hedit) && len == 2)
|
|
|
|
EndDialog(hdlg, 444);
|
|
|
|
else
|
|
|
|
EndDialog(hdlg, 555);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
EndDialog(hdlg, 55);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case WM_CLOSE:
|
|
|
|
EndDialog(hdlg, 333);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2005-03-22 17:40:36 +01:00
|
|
|
static HINSTANCE hinst;
|
|
|
|
static HWND hwndET2;
|
2006-01-24 14:00:32 +01:00
|
|
|
static const char szEditTest2Class[] = "EditTest2Class";
|
|
|
|
static const char szEditTest3Class[] = "EditTest3Class";
|
2010-04-24 21:33:00 +02:00
|
|
|
static const char szEditTest4Class[] = "EditTest4Class";
|
2006-01-24 14:00:32 +01:00
|
|
|
static const char szEditTextPositionClass[] = "EditTextPositionWindowClass";
|
2005-02-14 12:02:06 +01:00
|
|
|
|
2005-06-15 12:20:53 +02:00
|
|
|
static HWND create_editcontrol (DWORD style, DWORD exstyle)
|
2004-11-08 23:10:05 +01:00
|
|
|
{
|
|
|
|
HWND handle;
|
|
|
|
|
2013-10-23 07:53:42 +02:00
|
|
|
handle = CreateWindowExA(exstyle,
|
2004-11-28 15:55:42 +01:00
|
|
|
"EDIT",
|
2005-09-06 13:40:01 +02:00
|
|
|
"Test Text",
|
2006-01-27 15:47:32 +01:00
|
|
|
style,
|
2004-11-08 23:10:05 +01:00
|
|
|
10, 10, 300, 300,
|
2005-09-06 13:40:01 +02:00
|
|
|
NULL, NULL, hinst, NULL);
|
2011-02-24 17:53:16 +01:00
|
|
|
ok (handle != NULL, "CreateWindow EDIT Control failed\n");
|
2004-11-08 23:10:05 +01:00
|
|
|
assert (handle);
|
|
|
|
if (winetest_interactive)
|
|
|
|
ShowWindow (handle, SW_SHOW);
|
|
|
|
return handle;
|
|
|
|
}
|
|
|
|
|
2018-01-12 12:26:51 +01:00
|
|
|
static HWND create_editcontrolW(DWORD style, DWORD exstyle)
|
|
|
|
{
|
|
|
|
static const WCHAR testtextW[] = {'T','e','s','t',' ','t','e','x','t',0};
|
|
|
|
static const WCHAR editW[] = {'E','d','i','t',0};
|
|
|
|
HWND handle;
|
|
|
|
|
|
|
|
handle = CreateWindowExW(exstyle, editW, testtextW, style, 10, 10, 300, 300,
|
|
|
|
NULL, NULL, hinst, NULL);
|
|
|
|
ok(handle != NULL, "Failed to create Edit control.\n");
|
|
|
|
return handle;
|
|
|
|
}
|
|
|
|
|
2005-09-06 13:40:01 +02:00
|
|
|
static HWND create_child_editcontrol (DWORD style, DWORD exstyle)
|
|
|
|
{
|
|
|
|
HWND parentWnd;
|
|
|
|
HWND editWnd;
|
|
|
|
RECT rect;
|
2011-02-24 17:53:16 +01:00
|
|
|
BOOL b;
|
2016-04-18 10:12:23 +02:00
|
|
|
SetRect(&rect, 0, 0, 300, 300);
|
2011-02-24 17:53:16 +01:00
|
|
|
b = AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE);
|
|
|
|
ok(b, "AdjustWindowRect failed\n");
|
2005-09-06 13:40:01 +02:00
|
|
|
|
2013-10-23 07:53:42 +02:00
|
|
|
parentWnd = CreateWindowExA(0,
|
2005-09-06 13:40:01 +02:00
|
|
|
szEditTextPositionClass,
|
|
|
|
"Edit Test",
|
|
|
|
WS_OVERLAPPEDWINDOW,
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
rect.right - rect.left, rect.bottom - rect.top,
|
|
|
|
NULL, NULL, hinst, NULL);
|
2011-02-24 17:53:16 +01:00
|
|
|
ok (parentWnd != NULL, "CreateWindow EDIT Test failed\n");
|
2005-09-06 13:40:01 +02:00
|
|
|
assert(parentWnd);
|
|
|
|
|
2013-10-23 07:53:42 +02:00
|
|
|
editWnd = CreateWindowExA(exstyle,
|
2005-09-06 13:40:01 +02:00
|
|
|
"EDIT",
|
|
|
|
"Test Text",
|
2006-01-27 15:47:32 +01:00
|
|
|
WS_CHILD | style,
|
2005-09-06 13:40:01 +02:00
|
|
|
0, 0, 300, 300,
|
|
|
|
parentWnd, NULL, hinst, NULL);
|
2011-02-24 17:53:16 +01:00
|
|
|
ok (editWnd != NULL, "CreateWindow EDIT Test Text failed\n");
|
2005-09-06 13:40:01 +02:00
|
|
|
assert(editWnd);
|
|
|
|
if (winetest_interactive)
|
|
|
|
ShowWindow (parentWnd, SW_SHOW);
|
|
|
|
return editWnd;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void destroy_child_editcontrol (HWND hwndEdit)
|
|
|
|
{
|
|
|
|
if (GetParent(hwndEdit))
|
|
|
|
DestroyWindow(GetParent(hwndEdit));
|
|
|
|
else {
|
|
|
|
trace("Edit control has no parent!\n");
|
|
|
|
DestroyWindow(hwndEdit);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-11-08 23:10:05 +01:00
|
|
|
static LONG get_edit_style (HWND hwnd)
|
|
|
|
{
|
|
|
|
return GetWindowLongA( hwnd, GWL_STYLE ) & (
|
|
|
|
ES_LEFT |
|
|
|
|
/* FIXME: not implemented
|
|
|
|
ES_CENTER |
|
|
|
|
ES_RIGHT |
|
|
|
|
ES_OEMCONVERT |
|
|
|
|
*/
|
|
|
|
ES_MULTILINE |
|
|
|
|
ES_UPPERCASE |
|
|
|
|
ES_LOWERCASE |
|
|
|
|
ES_PASSWORD |
|
|
|
|
ES_AUTOVSCROLL |
|
|
|
|
ES_AUTOHSCROLL |
|
|
|
|
ES_NOHIDESEL |
|
|
|
|
ES_COMBO |
|
|
|
|
ES_READONLY |
|
|
|
|
ES_WANTRETURN |
|
|
|
|
ES_NUMBER
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2004-11-28 15:55:42 +01:00
|
|
|
static void set_client_height(HWND Wnd, unsigned Height)
|
|
|
|
{
|
|
|
|
RECT ClientRect, WindowRect;
|
|
|
|
|
|
|
|
GetWindowRect(Wnd, &WindowRect);
|
|
|
|
GetClientRect(Wnd, &ClientRect);
|
2005-09-06 13:40:01 +02:00
|
|
|
SetWindowPos(Wnd, NULL, 0, 0,
|
2004-11-28 15:55:42 +01:00
|
|
|
WindowRect.right - WindowRect.left,
|
2005-09-06 13:40:01 +02:00
|
|
|
Height + (WindowRect.bottom - WindowRect.top) -
|
|
|
|
(ClientRect.bottom - ClientRect.top),
|
|
|
|
SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);
|
|
|
|
|
|
|
|
/* Workaround for a bug in Windows' edit control
|
|
|
|
(multi-line mode) */
|
|
|
|
GetWindowRect(Wnd, &WindowRect);
|
|
|
|
SetWindowPos(Wnd, NULL, 0, 0,
|
|
|
|
WindowRect.right - WindowRect.left + 1,
|
|
|
|
WindowRect.bottom - WindowRect.top + 1,
|
|
|
|
SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);
|
|
|
|
SetWindowPos(Wnd, NULL, 0, 0,
|
|
|
|
WindowRect.right - WindowRect.left,
|
|
|
|
WindowRect.bottom - WindowRect.top,
|
|
|
|
SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);
|
2005-06-09 22:32:32 +02:00
|
|
|
|
2005-09-06 13:40:01 +02:00
|
|
|
GetClientRect(Wnd, &ClientRect);
|
|
|
|
ok(ClientRect.bottom - ClientRect.top == Height,
|
2009-04-22 10:25:30 +02:00
|
|
|
"The client height should be %d, but is %d\n",
|
|
|
|
Height, ClientRect.bottom - ClientRect.top);
|
2005-09-06 13:40:01 +02:00
|
|
|
}
|
2005-06-09 22:32:32 +02:00
|
|
|
|
2005-03-22 17:40:36 +01:00
|
|
|
static void test_edit_control_1(void)
|
2004-11-08 23:10:05 +01:00
|
|
|
{
|
|
|
|
HWND hwEdit;
|
|
|
|
MSG msMessage;
|
|
|
|
int i;
|
|
|
|
LONG r;
|
|
|
|
|
|
|
|
msMessage.message = WM_KEYDOWN;
|
|
|
|
|
|
|
|
trace("EDIT: Single line\n");
|
2006-01-27 15:47:32 +01:00
|
|
|
hwEdit = create_editcontrol(ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0);
|
2004-11-08 23:10:05 +01:00
|
|
|
r = get_edit_style(hwEdit);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok(r == (ES_AUTOVSCROLL | ES_AUTOHSCROLL), "Wrong style expected 0xc0 got: 0x%x\n", r);
|
2004-11-08 23:10:05 +01:00
|
|
|
for (i=0;i<65535;i++)
|
|
|
|
{
|
|
|
|
msMessage.wParam = i;
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, WM_GETDLGCODE, 0, (LPARAM) &msMessage);
|
2004-11-08 23:10:05 +01:00
|
|
|
ok(r == (DLGC_WANTCHARS | DLGC_HASSETSEL | DLGC_WANTARROWS),
|
2006-10-07 21:45:11 +02:00
|
|
|
"Expected DLGC_WANTCHARS | DLGC_HASSETSEL | DLGC_WANTARROWS got %x\n", r);
|
2004-11-08 23:10:05 +01:00
|
|
|
}
|
|
|
|
DestroyWindow (hwEdit);
|
|
|
|
|
|
|
|
trace("EDIT: Single line want returns\n");
|
2006-01-27 15:47:32 +01:00
|
|
|
hwEdit = create_editcontrol(ES_WANTRETURN | ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0);
|
2004-11-08 23:10:05 +01:00
|
|
|
r = get_edit_style(hwEdit);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok(r == (ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN), "Wrong style expected 0x10c0 got: 0x%x\n", r);
|
2004-11-08 23:10:05 +01:00
|
|
|
for (i=0;i<65535;i++)
|
|
|
|
{
|
|
|
|
msMessage.wParam = i;
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, WM_GETDLGCODE, 0, (LPARAM) &msMessage);
|
2004-11-08 23:10:05 +01:00
|
|
|
ok(r == (DLGC_WANTCHARS | DLGC_HASSETSEL | DLGC_WANTARROWS),
|
2006-10-07 21:45:11 +02:00
|
|
|
"Expected DLGC_WANTCHARS | DLGC_HASSETSEL | DLGC_WANTARROWS got %x\n", r);
|
2004-11-08 23:10:05 +01:00
|
|
|
}
|
|
|
|
DestroyWindow (hwEdit);
|
|
|
|
|
|
|
|
trace("EDIT: Multiline line\n");
|
2006-01-27 15:47:32 +01:00
|
|
|
hwEdit = create_editcontrol(ES_MULTILINE | WS_VSCROLL | ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0);
|
2004-11-08 23:10:05 +01:00
|
|
|
r = get_edit_style(hwEdit);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok(r == (ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_MULTILINE), "Wrong style expected 0xc4 got: 0x%x\n", r);
|
2004-11-08 23:10:05 +01:00
|
|
|
for (i=0;i<65535;i++)
|
|
|
|
{
|
|
|
|
msMessage.wParam = i;
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, WM_GETDLGCODE, 0, (LPARAM) &msMessage);
|
2004-11-08 23:10:05 +01:00
|
|
|
ok(r == (DLGC_WANTCHARS | DLGC_HASSETSEL | DLGC_WANTALLKEYS | DLGC_WANTARROWS),
|
2006-10-07 21:45:11 +02:00
|
|
|
"Expected DLGC_WANTCHARS | DLGC_HASSETSEL | DLGC_WANTALLKEYS | DLGC_WANTARROWS got %x\n", r);
|
2004-11-08 23:10:05 +01:00
|
|
|
}
|
|
|
|
DestroyWindow (hwEdit);
|
|
|
|
|
|
|
|
trace("EDIT: Multi line want returns\n");
|
2006-01-27 15:47:32 +01:00
|
|
|
hwEdit = create_editcontrol(ES_MULTILINE | WS_VSCROLL | ES_WANTRETURN | ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0);
|
2004-11-08 23:10:05 +01:00
|
|
|
r = get_edit_style(hwEdit);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok(r == (ES_WANTRETURN | ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_MULTILINE), "Wrong style expected 0x10c4 got: 0x%x\n", r);
|
2004-11-08 23:10:05 +01:00
|
|
|
for (i=0;i<65535;i++)
|
|
|
|
{
|
|
|
|
msMessage.wParam = i;
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, WM_GETDLGCODE, 0, (LPARAM) &msMessage);
|
2004-11-08 23:10:05 +01:00
|
|
|
ok(r == (DLGC_WANTCHARS | DLGC_HASSETSEL | DLGC_WANTALLKEYS | DLGC_WANTARROWS),
|
2006-10-07 21:45:11 +02:00
|
|
|
"Expected DLGC_WANTCHARS | DLGC_HASSETSEL | DLGC_WANTALLKEYS | DLGC_WANTARROWS got %x\n", r);
|
2004-11-08 23:10:05 +01:00
|
|
|
}
|
|
|
|
DestroyWindow (hwEdit);
|
|
|
|
}
|
|
|
|
|
2005-03-22 17:40:36 +01:00
|
|
|
/* WM_SETTEXT is implemented by selecting all text, and then replacing the
|
|
|
|
* selection. This test checks that the first 'select all' doesn't generate
|
|
|
|
* an UPDATE message which can escape and (via a handler) change the
|
|
|
|
* selection, which would cause WM_SETTEXT to break. This old bug
|
|
|
|
* was fixed 18-Mar-2005; we check here to ensure it doesn't regress.
|
|
|
|
*/
|
|
|
|
static void test_edit_control_2(void)
|
|
|
|
{
|
2011-09-08 04:59:10 +02:00
|
|
|
HWND hwndMain, phwnd;
|
2005-03-22 17:40:36 +01:00
|
|
|
char szLocalString[MAXLEN];
|
2011-09-08 04:59:10 +02:00
|
|
|
LONG r, w = 150, h = 50;
|
|
|
|
POINT cpos;
|
2005-03-22 17:40:36 +01:00
|
|
|
|
|
|
|
/* Create main and edit windows. */
|
2013-10-23 07:53:42 +02:00
|
|
|
hwndMain = CreateWindowA(szEditTest2Class, "ET2", WS_OVERLAPPEDWINDOW,
|
2005-03-22 17:40:36 +01:00
|
|
|
0, 0, 200, 200, NULL, NULL, hinst, NULL);
|
|
|
|
assert(hwndMain);
|
|
|
|
if (winetest_interactive)
|
|
|
|
ShowWindow (hwndMain, SW_SHOW);
|
|
|
|
|
2013-10-23 07:53:42 +02:00
|
|
|
hwndET2 = CreateWindowA("EDIT", NULL,
|
2005-03-22 17:40:36 +01:00
|
|
|
WS_CHILD|WS_BORDER|ES_LEFT|ES_AUTOHSCROLL,
|
2011-09-08 04:59:10 +02:00
|
|
|
0, 0, w, h, /* important this not be 0 size. */
|
2005-03-22 17:40:36 +01:00
|
|
|
hwndMain, (HMENU) ID_EDITTEST2, hinst, NULL);
|
|
|
|
assert(hwndET2);
|
|
|
|
if (winetest_interactive)
|
|
|
|
ShowWindow (hwndET2, SW_SHOW);
|
|
|
|
|
|
|
|
trace("EDIT: SETTEXT atomicity\n");
|
|
|
|
/* Send messages to "type" in the word 'foo'. */
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwndET2, WM_CHAR, 'f', 1);
|
2008-04-07 23:11:58 +02:00
|
|
|
ok(1 == r, "Expected: %d, got: %d\n", 1, r);
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwndET2, WM_CHAR, 'o', 1);
|
2008-04-07 23:11:58 +02:00
|
|
|
ok(1 == r, "Expected: %d, got: %d\n", 1, r);
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwndET2, WM_CHAR, 'o', 1);
|
2008-04-07 23:11:58 +02:00
|
|
|
ok(1 == r, "Expected: %d, got: %d\n", 1, r);
|
2005-03-22 17:40:36 +01:00
|
|
|
/* 'foo' should have been changed to 'bar' by the UPDATE handler. */
|
2013-10-23 07:53:42 +02:00
|
|
|
GetWindowTextA(hwndET2, szLocalString, MAXLEN);
|
|
|
|
ok(strcmp(szLocalString, "bar")==0,
|
2005-03-22 17:40:36 +01:00
|
|
|
"Wrong contents of edit: %s\n", szLocalString);
|
|
|
|
|
2011-09-08 04:59:10 +02:00
|
|
|
/* try setting the caret before it's visible */
|
|
|
|
r = SetCaretPos(0, 0);
|
|
|
|
todo_wine ok(0 == r, "SetCaretPos succeeded unexpectedly, expected: 0, got: %d\n", r);
|
|
|
|
phwnd = SetFocus(hwndET2);
|
2011-09-09 12:49:44 +02:00
|
|
|
ok(phwnd != NULL, "SetFocus failed unexpectedly, expected non-zero, got NULL\n");
|
2011-09-08 04:59:10 +02:00
|
|
|
r = SetCaretPos(0, 0);
|
|
|
|
ok(1 == r, "SetCaretPos failed unexpectedly, expected: 1, got: %d\n", r);
|
|
|
|
r = GetCaretPos(&cpos);
|
|
|
|
ok(1 == r, "GetCaretPos failed unexpectedly, expected: 1, got: %d\n", r);
|
|
|
|
ok(cpos.x == 0 && cpos.y == 0, "Wrong caret position, expected: (0,0), got: (%d,%d)\n", cpos.x, cpos.y);
|
|
|
|
r = SetCaretPos(-1, -1);
|
|
|
|
ok(1 == r, "SetCaretPos failed unexpectedly, expected: 1, got: %d\n", r);
|
|
|
|
r = GetCaretPos(&cpos);
|
|
|
|
ok(1 == r, "GetCaretPos failed unexpectedly, expected: 1, got: %d\n", r);
|
|
|
|
ok(cpos.x == -1 && cpos.y == -1, "Wrong caret position, expected: (-1,-1), got: (%d,%d)\n", cpos.x, cpos.y);
|
|
|
|
r = SetCaretPos(w << 1, h << 1);
|
|
|
|
ok(1 == r, "SetCaretPos failed unexpectedly, expected: 1, got: %d\n", r);
|
|
|
|
r = GetCaretPos(&cpos);
|
|
|
|
ok(1 == r, "GetCaretPos failed unexpectedly, expected: 1, got: %d\n", r);
|
|
|
|
ok(cpos.x == (w << 1) && cpos.y == (h << 1), "Wrong caret position, expected: (%d,%d), got: (%d,%d)\n", w << 1, h << 1, cpos.x, cpos.y);
|
|
|
|
r = SetCaretPos(w, h);
|
|
|
|
ok(1 == r, "SetCaretPos failed unexpectedly, expected: 1, got: %d\n", r);
|
|
|
|
r = GetCaretPos(&cpos);
|
|
|
|
ok(1 == r, "GetCaretPos failed unexpectedly, expected: 1, got: %d\n", r);
|
|
|
|
ok(cpos.x == w && cpos.y == h, "Wrong caret position, expected: (%d,%d), got: (%d,%d)\n", w, h, cpos.x, cpos.y);
|
|
|
|
r = SetCaretPos(w - 1, h - 1);
|
|
|
|
ok(1 == r, "SetCaretPos failed unexpectedly, expected: 1, got: %d\n", r);
|
|
|
|
r = GetCaretPos(&cpos);
|
|
|
|
ok(1 == r, "GetCaretPos failed unexpectedly, expected: 1, got: %d\n", r);
|
|
|
|
ok(cpos.x == (w - 1) && cpos.y == (h - 1), "Wrong caret position, expected: (%d,%d), got: (%d,%d)\n", w - 1, h - 1, cpos.x, cpos.y);
|
|
|
|
|
2005-03-22 17:40:36 +01:00
|
|
|
/* OK, done! */
|
|
|
|
DestroyWindow (hwndET2);
|
|
|
|
DestroyWindow (hwndMain);
|
|
|
|
}
|
|
|
|
|
2005-06-20 16:18:03 +02:00
|
|
|
static void ET2_check_change(void) {
|
2005-03-22 17:40:36 +01:00
|
|
|
char szLocalString[MAXLEN];
|
|
|
|
/* This EN_UPDATE handler changes any 'foo' to 'bar'. */
|
2013-10-23 07:53:42 +02:00
|
|
|
GetWindowTextA(hwndET2, szLocalString, MAXLEN);
|
|
|
|
if (strcmp(szLocalString, "foo")==0) {
|
|
|
|
strcpy(szLocalString, "bar");
|
|
|
|
SendMessageA(hwndET2, WM_SETTEXT, 0, (LPARAM) szLocalString);
|
2005-03-22 17:40:36 +01:00
|
|
|
}
|
|
|
|
/* always leave the cursor at the end. */
|
2013-10-23 07:53:42 +02:00
|
|
|
SendMessageA(hwndET2, EM_SETSEL, MAXLEN - 1, MAXLEN - 1);
|
2005-03-22 17:40:36 +01:00
|
|
|
}
|
|
|
|
static void ET2_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
|
|
|
|
{
|
|
|
|
if (id==ID_EDITTEST2 && codeNotify == EN_UPDATE)
|
|
|
|
ET2_check_change();
|
|
|
|
}
|
|
|
|
static LRESULT CALLBACK ET2_WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
switch (iMsg) {
|
2006-03-17 15:26:20 +01:00
|
|
|
case WM_COMMAND:
|
|
|
|
ET2_OnCommand(hwnd, LOWORD(wParam), (HWND)lParam, HIWORD(wParam));
|
|
|
|
break;
|
2005-03-22 17:40:36 +01:00
|
|
|
}
|
2013-10-23 07:53:42 +02:00
|
|
|
return DefWindowProcA(hwnd, iMsg, wParam, lParam);
|
2005-03-22 17:40:36 +01:00
|
|
|
}
|
|
|
|
|
2005-06-05 21:19:11 +02:00
|
|
|
static void zero_notify(void)
|
|
|
|
{
|
|
|
|
notifications.en_change = 0;
|
|
|
|
notifications.en_maxtext = 0;
|
|
|
|
notifications.en_update = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define test_notify(enchange, enmaxtext, enupdate) \
|
2015-05-19 17:15:13 +02:00
|
|
|
do { \
|
2005-06-05 21:19:11 +02:00
|
|
|
ok(notifications.en_change == enchange, "expected %d EN_CHANGE notifications, " \
|
|
|
|
"got %d\n", enchange, notifications.en_change); \
|
|
|
|
ok(notifications.en_maxtext == enmaxtext, "expected %d EN_MAXTEXT notifications, " \
|
|
|
|
"got %d\n", enmaxtext, notifications.en_maxtext); \
|
|
|
|
ok(notifications.en_update == enupdate, "expected %d EN_UPDATE notifications, " \
|
2015-05-19 17:15:13 +02:00
|
|
|
"got %d\n", enupdate, notifications.en_update); \
|
|
|
|
} while(0)
|
2005-06-05 21:19:11 +02:00
|
|
|
|
|
|
|
|
|
|
|
static LRESULT CALLBACK edit3_wnd_procA(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
switch (msg) {
|
|
|
|
case WM_COMMAND:
|
|
|
|
switch (HIWORD(wParam)) {
|
|
|
|
case EN_MAXTEXT:
|
|
|
|
notifications.en_maxtext++;
|
|
|
|
break;
|
|
|
|
case EN_UPDATE:
|
|
|
|
notifications.en_update++;
|
|
|
|
break;
|
|
|
|
case EN_CHANGE:
|
|
|
|
notifications.en_change++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return DefWindowProcA(hWnd, msg, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
2017-11-05 19:28:38 +01:00
|
|
|
/* Test behaviour of WM_SETTEXT, WM_REPLACESEL and notifications sent in response
|
2005-06-05 21:19:11 +02:00
|
|
|
* to these messages.
|
|
|
|
*/
|
|
|
|
static void test_edit_control_3(void)
|
|
|
|
{
|
|
|
|
HWND hWnd;
|
|
|
|
HWND hParent;
|
2011-01-24 00:56:10 +01:00
|
|
|
HDC hDC;
|
|
|
|
int len, dpi;
|
2005-06-05 21:19:11 +02:00
|
|
|
static const char *str = "this is a long string.";
|
|
|
|
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.";
|
|
|
|
|
2011-01-24 00:56:10 +01:00
|
|
|
hDC = GetDC(NULL);
|
|
|
|
dpi = GetDeviceCaps(hDC, LOGPIXELSY);
|
|
|
|
ReleaseDC(NULL, hDC);
|
|
|
|
|
2005-06-05 21:19:11 +02:00
|
|
|
trace("EDIT: Test notifications\n");
|
|
|
|
|
|
|
|
hParent = CreateWindowExA(0,
|
2005-09-06 13:40:01 +02:00
|
|
|
szEditTest3Class,
|
2005-06-05 21:19:11 +02:00
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT, 10, 10,
|
|
|
|
NULL, NULL, NULL, NULL);
|
|
|
|
assert(hParent);
|
|
|
|
|
|
|
|
trace("EDIT: Single line, no ES_AUTOHSCROLL\n");
|
|
|
|
hWnd = CreateWindowExA(0,
|
|
|
|
"EDIT",
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
10, 10, 50, 50,
|
|
|
|
hParent, NULL, NULL, NULL);
|
|
|
|
assert(hWnd);
|
|
|
|
|
|
|
|
zero_notify();
|
|
|
|
SendMessageA(hWnd, EM_REPLACESEL, 0, (LPARAM)str);
|
|
|
|
len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
|
2015-05-19 17:15:13 +02:00
|
|
|
if (len == lstrlenA(str)) /* Win 8 */
|
|
|
|
test_notify(1, 0, 1);
|
|
|
|
else
|
|
|
|
test_notify(1, 1, 1);
|
2005-06-05 21:19:11 +02:00
|
|
|
|
|
|
|
SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)"");
|
|
|
|
zero_notify();
|
|
|
|
SendMessageA(hWnd, EM_REPLACESEL, 0, (LPARAM)"a");
|
|
|
|
len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
|
|
|
|
ok(1 == len, "wrong text length, expected 1, got %d\n", len);
|
|
|
|
test_notify(1, 0, 1);
|
|
|
|
|
|
|
|
zero_notify();
|
|
|
|
SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)str);
|
|
|
|
len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
|
|
|
|
ok(lstrlenA(str) == len, "text shouldn't have been truncated\n");
|
|
|
|
test_notify(1, 0, 1);
|
|
|
|
|
2010-01-24 21:37:59 +01:00
|
|
|
len = SendMessageA(hWnd, EM_GETSEL, 0, 0);
|
|
|
|
ok(LOWORD(len)==0, "Unexpected start position for selection %d\n", LOWORD(len));
|
|
|
|
ok(HIWORD(len)==0, "Unexpected end position for selection %d\n", HIWORD(len));
|
2013-10-23 07:53:42 +02:00
|
|
|
SendMessageA(hParent, WM_SETFOCUS, 0, (LPARAM)hWnd);
|
2010-01-24 21:37:59 +01:00
|
|
|
len = SendMessageA(hWnd, EM_GETSEL, 0, 0);
|
|
|
|
ok(LOWORD(len)==0, "Unexpected start position for selection %d\n", LOWORD(len));
|
|
|
|
ok(HIWORD(len)==0, "Unexpected end position for selection %d\n", HIWORD(len));
|
|
|
|
|
2005-06-05 21:19:11 +02:00
|
|
|
SendMessageA(hWnd, EM_SETLIMITTEXT, 5, 0);
|
|
|
|
|
|
|
|
SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)"");
|
|
|
|
zero_notify();
|
|
|
|
SendMessageA(hWnd, EM_REPLACESEL, 0, (LPARAM)str);
|
|
|
|
len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
|
|
|
|
ok(5 == len, "text should have been truncated to limit, expected 5, got %d\n", len);
|
|
|
|
test_notify(1, 1, 1);
|
|
|
|
|
|
|
|
zero_notify();
|
|
|
|
SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)str);
|
|
|
|
len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
|
|
|
|
ok(lstrlenA(str) == len, "text shouldn't have been truncated\n");
|
|
|
|
test_notify(1, 0, 1);
|
|
|
|
|
|
|
|
DestroyWindow(hWnd);
|
|
|
|
|
|
|
|
trace("EDIT: Single line, ES_AUTOHSCROLL\n");
|
|
|
|
hWnd = CreateWindowExA(0,
|
|
|
|
"EDIT",
|
|
|
|
NULL,
|
|
|
|
ES_AUTOHSCROLL,
|
|
|
|
10, 10, 50, 50,
|
|
|
|
hParent, NULL, NULL, NULL);
|
|
|
|
assert(hWnd);
|
|
|
|
|
|
|
|
zero_notify();
|
|
|
|
SendMessageA(hWnd, EM_REPLACESEL, 0, (LPARAM)str);
|
|
|
|
len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
|
|
|
|
ok(lstrlenA(str) == len, "text shouldn't have been truncated\n");
|
|
|
|
test_notify(1, 0, 1);
|
|
|
|
|
|
|
|
zero_notify();
|
|
|
|
SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)str);
|
|
|
|
len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
|
|
|
|
ok(lstrlenA(str) == len, "text shouldn't have been truncated\n");
|
|
|
|
test_notify(1, 0, 1);
|
|
|
|
|
2017-11-05 19:28:38 +01:00
|
|
|
SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)"");
|
|
|
|
zero_notify();
|
|
|
|
SendMessageA(hWnd, EM_REPLACESEL, 0, (LPARAM)str2);
|
|
|
|
len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
|
|
|
|
ok(lstrlenA(str2) == len, "text shouldn't have been truncated\n");
|
|
|
|
test_notify(1, 0, 1);
|
|
|
|
|
|
|
|
zero_notify();
|
|
|
|
SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)str2);
|
|
|
|
len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
|
|
|
|
ok(lstrlenA(str2) == len, "text shouldn't have been truncated\n");
|
|
|
|
test_notify(1, 0, 1);
|
|
|
|
|
2005-06-05 21:19:11 +02:00
|
|
|
SendMessageA(hWnd, EM_SETLIMITTEXT, 5, 0);
|
|
|
|
|
|
|
|
SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)"");
|
|
|
|
zero_notify();
|
|
|
|
SendMessageA(hWnd, EM_REPLACESEL, 0, (LPARAM)str);
|
|
|
|
len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
|
|
|
|
ok(5 == len, "text should have been truncated to limit, expected 5, got %d\n", len);
|
|
|
|
test_notify(1, 1, 1);
|
|
|
|
|
|
|
|
zero_notify();
|
|
|
|
SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)str);
|
|
|
|
len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
|
|
|
|
ok(lstrlenA(str) == len, "text shouldn't have been truncated\n");
|
|
|
|
test_notify(1, 0, 1);
|
|
|
|
|
|
|
|
DestroyWindow(hWnd);
|
|
|
|
|
|
|
|
trace("EDIT: Multline, no ES_AUTOHSCROLL, no ES_AUTOVSCROLL\n");
|
|
|
|
hWnd = CreateWindowExA(0,
|
|
|
|
"EDIT",
|
|
|
|
NULL,
|
|
|
|
ES_MULTILINE,
|
2011-01-24 00:56:10 +01:00
|
|
|
10, 10, (50 * dpi) / 96, (50 * dpi) / 96,
|
2005-06-05 21:19:11 +02:00
|
|
|
hParent, NULL, NULL, NULL);
|
|
|
|
assert(hWnd);
|
|
|
|
|
|
|
|
zero_notify();
|
|
|
|
SendMessageA(hWnd, EM_REPLACESEL, 0, (LPARAM)str);
|
|
|
|
len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
|
2015-05-19 17:15:13 +02:00
|
|
|
if (len == lstrlenA(str)) /* Win 8 */
|
|
|
|
test_notify(1, 0, 1);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok(0 == len, "text should have been truncated, expected 0, got %d\n", len);
|
|
|
|
test_notify(1, 1, 1);
|
|
|
|
}
|
2005-06-05 21:19:11 +02:00
|
|
|
|
|
|
|
SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)"");
|
|
|
|
zero_notify();
|
|
|
|
SendMessageA(hWnd, EM_REPLACESEL, 0, (LPARAM)"a");
|
|
|
|
len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
|
|
|
|
ok(1 == SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0), "wrong text length, expected 1, got %d\n", len);
|
|
|
|
test_notify(1, 0, 1);
|
|
|
|
|
|
|
|
zero_notify();
|
|
|
|
SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)str);
|
|
|
|
len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
|
|
|
|
ok(lstrlenA(str) == len, "text shouldn't have been truncated\n");
|
|
|
|
test_notify(0, 0, 0);
|
|
|
|
|
|
|
|
SendMessageA(hWnd, EM_SETLIMITTEXT, 5, 0);
|
|
|
|
|
|
|
|
SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)"");
|
|
|
|
zero_notify();
|
|
|
|
SendMessageA(hWnd, EM_REPLACESEL, 0, (LPARAM)str);
|
|
|
|
len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
|
|
|
|
ok(5 == len, "text should have been truncated to limit, expected 5, got %d\n", len);
|
|
|
|
test_notify(1, 1, 1);
|
|
|
|
|
|
|
|
zero_notify();
|
|
|
|
SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)str);
|
|
|
|
len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
|
|
|
|
ok(lstrlenA(str) == len, "text shouldn't have been truncated\n");
|
|
|
|
test_notify(0, 0, 0);
|
|
|
|
|
|
|
|
DestroyWindow(hWnd);
|
|
|
|
|
|
|
|
trace("EDIT: Multline, ES_AUTOHSCROLL, no ES_AUTOVSCROLL\n");
|
|
|
|
hWnd = CreateWindowExA(0,
|
|
|
|
"EDIT",
|
|
|
|
NULL,
|
|
|
|
ES_MULTILINE | ES_AUTOHSCROLL,
|
2011-01-24 00:56:10 +01:00
|
|
|
10, 10, (50 * dpi) / 96, (50 * dpi) / 96,
|
2005-06-05 21:19:11 +02:00
|
|
|
hParent, NULL, NULL, NULL);
|
|
|
|
assert(hWnd);
|
|
|
|
|
|
|
|
zero_notify();
|
|
|
|
SendMessageA(hWnd, EM_REPLACESEL, 0, (LPARAM)str2);
|
|
|
|
len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
|
|
|
|
ok(0 == len, "text should have been truncated, expected 0, got %d\n", len);
|
|
|
|
test_notify(1, 1, 1);
|
|
|
|
|
|
|
|
SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)"");
|
|
|
|
zero_notify();
|
|
|
|
SendMessageA(hWnd, EM_REPLACESEL, 0, (LPARAM)"a");
|
|
|
|
len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
|
|
|
|
ok(1 == SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0), "wrong text length, expected 1, got %d\n", len);
|
|
|
|
test_notify(1, 0, 1);
|
|
|
|
|
|
|
|
zero_notify();
|
|
|
|
SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)str2);
|
|
|
|
len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
|
|
|
|
ok(lstrlenA(str2) == len, "text shouldn't have been truncated\n");
|
|
|
|
test_notify(0, 0, 0);
|
|
|
|
|
|
|
|
SendMessageA(hWnd, EM_SETLIMITTEXT, 5, 0);
|
|
|
|
|
|
|
|
SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)"");
|
|
|
|
zero_notify();
|
|
|
|
SendMessageA(hWnd, EM_REPLACESEL, 0, (LPARAM)str2);
|
|
|
|
len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
|
|
|
|
ok(5 == len, "text should have been truncated to limit, expected 5, got %d\n", len);
|
|
|
|
test_notify(1, 1, 1);
|
|
|
|
|
|
|
|
zero_notify();
|
|
|
|
SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)str2);
|
|
|
|
len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
|
|
|
|
ok(lstrlenA(str2) == len, "text shouldn't have been truncated\n");
|
|
|
|
test_notify(0, 0, 0);
|
|
|
|
|
|
|
|
DestroyWindow(hWnd);
|
|
|
|
|
|
|
|
trace("EDIT: Multline, ES_AUTOHSCROLL and ES_AUTOVSCROLL\n");
|
|
|
|
hWnd = CreateWindowExA(0,
|
|
|
|
"EDIT",
|
|
|
|
NULL,
|
|
|
|
ES_MULTILINE | ES_AUTOHSCROLL | ES_AUTOVSCROLL,
|
|
|
|
10, 10, 50, 50,
|
|
|
|
hParent, NULL, NULL, NULL);
|
|
|
|
assert(hWnd);
|
|
|
|
|
|
|
|
zero_notify();
|
|
|
|
SendMessageA(hWnd, EM_REPLACESEL, 0, (LPARAM)str2);
|
|
|
|
len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
|
|
|
|
ok(lstrlenA(str2) == len, "text shouldn't have been truncated\n");
|
|
|
|
test_notify(1, 0, 1);
|
|
|
|
|
|
|
|
zero_notify();
|
|
|
|
SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)str2);
|
|
|
|
len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
|
|
|
|
ok(lstrlenA(str2) == len, "text shouldn't have been truncated\n");
|
|
|
|
test_notify(0, 0, 0);
|
|
|
|
|
|
|
|
SendMessageA(hWnd, EM_SETLIMITTEXT, 5, 0);
|
|
|
|
|
|
|
|
SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)"");
|
|
|
|
zero_notify();
|
|
|
|
SendMessageA(hWnd, EM_REPLACESEL, 0, (LPARAM)str2);
|
|
|
|
len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
|
|
|
|
ok(5 == len, "text should have been truncated to limit, expected 5, got %d\n", len);
|
|
|
|
test_notify(1, 1, 1);
|
|
|
|
|
|
|
|
zero_notify();
|
|
|
|
SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)str2);
|
|
|
|
len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
|
|
|
|
ok(lstrlenA(str2) == len, "text shouldn't have been truncated\n");
|
|
|
|
test_notify(0, 0, 0);
|
|
|
|
|
|
|
|
DestroyWindow(hWnd);
|
|
|
|
}
|
|
|
|
|
2005-06-14 14:24:48 +02:00
|
|
|
/* Test EM_CHARFROMPOS and EM_POSFROMCHAR
|
|
|
|
*/
|
2019-11-07 13:06:11 +01:00
|
|
|
static void test_char_from_pos(void)
|
2005-06-14 14:24:48 +02:00
|
|
|
{
|
|
|
|
HWND hwEdit;
|
|
|
|
int lo, hi, mid;
|
|
|
|
int ret;
|
|
|
|
int i;
|
2019-11-07 13:06:11 +01:00
|
|
|
HDC dc;
|
|
|
|
SIZE size;
|
2005-06-14 14:24:48 +02:00
|
|
|
|
|
|
|
trace("EDIT: Test EM_CHARFROMPOS and EM_POSFROMCHAR\n");
|
2006-01-27 15:47:32 +01:00
|
|
|
hwEdit = create_editcontrol(ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0);
|
2013-10-23 07:53:42 +02:00
|
|
|
SendMessageA(hwEdit, WM_SETTEXT, 0, (LPARAM) "aa");
|
|
|
|
lo = LOWORD(SendMessageA(hwEdit, EM_POSFROMCHAR, 0, 0));
|
|
|
|
hi = LOWORD(SendMessageA(hwEdit, EM_POSFROMCHAR, 1, 0));
|
2005-06-14 14:24:48 +02:00
|
|
|
mid = lo + (hi - lo) / 2;
|
|
|
|
|
|
|
|
for (i = lo; i < mid; i++) {
|
2013-10-23 07:53:42 +02:00
|
|
|
ret = LOWORD(SendMessageA(hwEdit, EM_CHARFROMPOS, 0, i));
|
2005-06-14 14:24:48 +02:00
|
|
|
ok(0 == ret, "expected 0 got %d\n", ret);
|
|
|
|
}
|
|
|
|
for (i = mid; i <= hi; i++) {
|
2013-10-23 07:53:42 +02:00
|
|
|
ret = LOWORD(SendMessageA(hwEdit, EM_CHARFROMPOS, 0, i));
|
2005-06-14 14:24:48 +02:00
|
|
|
ok(1 == ret, "expected 1 got %d\n", ret);
|
|
|
|
}
|
2013-10-23 07:53:42 +02:00
|
|
|
ret = SendMessageA(hwEdit, EM_POSFROMCHAR, 2, 0);
|
2005-06-14 14:24:48 +02:00
|
|
|
ok(-1 == ret, "expected -1 got %d\n", ret);
|
|
|
|
DestroyWindow(hwEdit);
|
|
|
|
|
2006-01-27 15:47:32 +01:00
|
|
|
hwEdit = create_editcontrol(ES_RIGHT | ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0);
|
2013-10-23 07:53:42 +02:00
|
|
|
SendMessageA(hwEdit, WM_SETTEXT, 0, (LPARAM) "aa");
|
|
|
|
lo = LOWORD(SendMessageA(hwEdit, EM_POSFROMCHAR, 0, 0));
|
|
|
|
hi = LOWORD(SendMessageA(hwEdit, EM_POSFROMCHAR, 1, 0));
|
2005-06-14 14:24:48 +02:00
|
|
|
mid = lo + (hi - lo) / 2;
|
|
|
|
|
|
|
|
for (i = lo; i < mid; i++) {
|
2013-10-23 07:53:42 +02:00
|
|
|
ret = LOWORD(SendMessageA(hwEdit, EM_CHARFROMPOS, 0, i));
|
2005-06-14 14:24:48 +02:00
|
|
|
ok(0 == ret, "expected 0 got %d\n", ret);
|
|
|
|
}
|
|
|
|
for (i = mid; i <= hi; i++) {
|
2013-10-23 07:53:42 +02:00
|
|
|
ret = LOWORD(SendMessageA(hwEdit, EM_CHARFROMPOS, 0, i));
|
2005-06-14 14:24:48 +02:00
|
|
|
ok(1 == ret, "expected 1 got %d\n", ret);
|
|
|
|
}
|
2013-10-23 07:53:42 +02:00
|
|
|
ret = SendMessageA(hwEdit, EM_POSFROMCHAR, 2, 0);
|
2005-06-14 14:24:48 +02:00
|
|
|
ok(-1 == ret, "expected -1 got %d\n", ret);
|
|
|
|
DestroyWindow(hwEdit);
|
|
|
|
|
2006-01-27 15:47:32 +01:00
|
|
|
hwEdit = create_editcontrol(ES_CENTER | ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0);
|
2013-10-23 07:53:42 +02:00
|
|
|
SendMessageA(hwEdit, WM_SETTEXT, 0, (LPARAM) "aa");
|
|
|
|
lo = LOWORD(SendMessageA(hwEdit, EM_POSFROMCHAR, 0, 0));
|
|
|
|
hi = LOWORD(SendMessageA(hwEdit, EM_POSFROMCHAR, 1, 0));
|
2005-06-14 14:24:48 +02:00
|
|
|
mid = lo + (hi - lo) / 2;
|
|
|
|
|
|
|
|
for (i = lo; i < mid; i++) {
|
2013-10-23 07:53:42 +02:00
|
|
|
ret = LOWORD(SendMessageA(hwEdit, EM_CHARFROMPOS, 0, i));
|
2005-06-14 14:24:48 +02:00
|
|
|
ok(0 == ret, "expected 0 got %d\n", ret);
|
|
|
|
}
|
|
|
|
for (i = mid; i <= hi; i++) {
|
2013-10-23 07:53:42 +02:00
|
|
|
ret = LOWORD(SendMessageA(hwEdit, EM_CHARFROMPOS, 0, i));
|
2005-06-14 14:24:48 +02:00
|
|
|
ok(1 == ret, "expected 1 got %d\n", ret);
|
|
|
|
}
|
2013-10-23 07:53:42 +02:00
|
|
|
ret = SendMessageA(hwEdit, EM_POSFROMCHAR, 2, 0);
|
2005-06-14 14:24:48 +02:00
|
|
|
ok(-1 == ret, "expected -1 got %d\n", ret);
|
|
|
|
DestroyWindow(hwEdit);
|
|
|
|
|
2006-01-27 15:47:32 +01:00
|
|
|
hwEdit = create_editcontrol(ES_MULTILINE | ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0);
|
2013-10-23 07:53:42 +02:00
|
|
|
SendMessageA(hwEdit, WM_SETTEXT, 0, (LPARAM) "aa");
|
|
|
|
lo = LOWORD(SendMessageA(hwEdit, EM_POSFROMCHAR, 0, 0));
|
|
|
|
hi = LOWORD(SendMessageA(hwEdit, EM_POSFROMCHAR, 1, 0));
|
2005-07-05 16:04:25 +02:00
|
|
|
mid = lo + (hi - lo) / 2 +1;
|
2005-06-14 14:24:48 +02:00
|
|
|
|
|
|
|
for (i = lo; i < mid; i++) {
|
2013-10-23 07:53:42 +02:00
|
|
|
ret = LOWORD(SendMessageA(hwEdit, EM_CHARFROMPOS, 0, i));
|
2008-01-24 20:05:25 +01:00
|
|
|
ok((0 == ret || 1 == ret /* Vista */), "expected 0 or 1 got %d\n", ret);
|
2005-06-14 14:24:48 +02:00
|
|
|
}
|
|
|
|
for (i = mid; i <= hi; i++) {
|
2013-10-23 07:53:42 +02:00
|
|
|
ret = LOWORD(SendMessageA(hwEdit, EM_CHARFROMPOS, 0, i));
|
2005-06-14 14:24:48 +02:00
|
|
|
ok(1 == ret, "expected 1 got %d\n", ret);
|
|
|
|
}
|
2013-10-23 07:53:42 +02:00
|
|
|
ret = SendMessageA(hwEdit, EM_POSFROMCHAR, 2, 0);
|
2005-06-14 14:24:48 +02:00
|
|
|
ok(-1 == ret, "expected -1 got %d\n", ret);
|
|
|
|
DestroyWindow(hwEdit);
|
|
|
|
|
2006-01-27 15:47:32 +01:00
|
|
|
hwEdit = create_editcontrol(ES_MULTILINE | ES_RIGHT | ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0);
|
2013-10-23 07:53:42 +02:00
|
|
|
SendMessageA(hwEdit, WM_SETTEXT, 0, (LPARAM) "aa");
|
|
|
|
lo = LOWORD(SendMessageA(hwEdit, EM_POSFROMCHAR, 0, 0));
|
|
|
|
hi = LOWORD(SendMessageA(hwEdit, EM_POSFROMCHAR, 1, 0));
|
2005-07-05 16:04:25 +02:00
|
|
|
mid = lo + (hi - lo) / 2 +1;
|
2005-06-14 14:24:48 +02:00
|
|
|
|
|
|
|
for (i = lo; i < mid; i++) {
|
2013-10-23 07:53:42 +02:00
|
|
|
ret = LOWORD(SendMessageA(hwEdit, EM_CHARFROMPOS, 0, i));
|
2008-01-24 20:05:25 +01:00
|
|
|
ok((0 == ret || 1 == ret /* Vista */), "expected 0 or 1 got %d\n", ret);
|
2005-06-14 14:24:48 +02:00
|
|
|
}
|
|
|
|
for (i = mid; i <= hi; i++) {
|
2013-10-23 07:53:42 +02:00
|
|
|
ret = LOWORD(SendMessageA(hwEdit, EM_CHARFROMPOS, 0, i));
|
2005-06-14 14:24:48 +02:00
|
|
|
ok(1 == ret, "expected 1 got %d\n", ret);
|
|
|
|
}
|
2013-10-23 07:53:42 +02:00
|
|
|
ret = SendMessageA(hwEdit, EM_POSFROMCHAR, 2, 0);
|
2005-06-14 14:24:48 +02:00
|
|
|
ok(-1 == ret, "expected -1 got %d\n", ret);
|
|
|
|
DestroyWindow(hwEdit);
|
|
|
|
|
2006-01-27 15:47:32 +01:00
|
|
|
hwEdit = create_editcontrol(ES_MULTILINE | ES_CENTER | ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0);
|
2013-10-23 07:53:42 +02:00
|
|
|
SendMessageA(hwEdit, WM_SETTEXT, 0, (LPARAM) "aa");
|
|
|
|
lo = LOWORD(SendMessageA(hwEdit, EM_POSFROMCHAR, 0, 0));
|
|
|
|
hi = LOWORD(SendMessageA(hwEdit, EM_POSFROMCHAR, 1, 0));
|
2005-07-05 16:04:25 +02:00
|
|
|
mid = lo + (hi - lo) / 2 +1;
|
2005-06-14 14:24:48 +02:00
|
|
|
|
|
|
|
for (i = lo; i < mid; i++) {
|
2013-10-23 07:53:42 +02:00
|
|
|
ret = LOWORD(SendMessageA(hwEdit, EM_CHARFROMPOS, 0, i));
|
2008-01-24 20:05:25 +01:00
|
|
|
ok((0 == ret || 1 == ret /* Vista */), "expected 0 or 1 got %d\n", ret);
|
2005-06-14 14:24:48 +02:00
|
|
|
}
|
|
|
|
for (i = mid; i <= hi; i++) {
|
2013-10-23 07:53:42 +02:00
|
|
|
ret = LOWORD(SendMessageA(hwEdit, EM_CHARFROMPOS, 0, i));
|
2005-06-14 14:24:48 +02:00
|
|
|
ok(1 == ret, "expected 1 got %d\n", ret);
|
|
|
|
}
|
2013-10-23 07:53:42 +02:00
|
|
|
ret = SendMessageA(hwEdit, EM_POSFROMCHAR, 2, 0);
|
2005-06-14 14:24:48 +02:00
|
|
|
ok(-1 == ret, "expected -1 got %d\n", ret);
|
|
|
|
DestroyWindow(hwEdit);
|
2019-11-07 13:06:11 +01:00
|
|
|
|
|
|
|
/* Scrolled to the right with partially visible line, position on next line. */
|
|
|
|
hwEdit = create_editcontrol(ES_MULTILINE | ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0);
|
|
|
|
|
|
|
|
dc = GetDC(hwEdit);
|
|
|
|
GetTextExtentPoint32A(dc, "w", 1, &size);
|
|
|
|
ReleaseDC(hwEdit, dc);
|
|
|
|
|
|
|
|
SetWindowPos(hwEdit, NULL, 0, 0, size.cx * 15, size.cy * 5, SWP_NOMOVE | SWP_NOZORDER);
|
|
|
|
SendMessageA(hwEdit, WM_SETTEXT, 0, (LPARAM)"wwwwwwwwwwwwwwwwwwww\r\n\r\n");
|
|
|
|
SendMessageA(hwEdit, EM_SETSEL, 40, 40);
|
|
|
|
|
|
|
|
lo = (short)SendMessageA(hwEdit, EM_POSFROMCHAR, 22, 0);
|
|
|
|
ret = (short)SendMessageA(hwEdit, EM_POSFROMCHAR, 20, 0);
|
|
|
|
ret -= 20 * size.cx; /* Calculate expected position, 20 characters back. */
|
|
|
|
ok(ret == lo, "Unexpected position %d vs %d.\n", lo, ret);
|
|
|
|
|
|
|
|
DestroyWindow(hwEdit);
|
2005-06-14 14:24:48 +02:00
|
|
|
}
|
|
|
|
|
2005-12-19 09:53:19 +01:00
|
|
|
/* Test if creating edit control without ES_AUTOHSCROLL and ES_AUTOVSCROLL
|
|
|
|
* truncates text that doesn't fit.
|
|
|
|
*/
|
|
|
|
static void test_edit_control_5(void)
|
|
|
|
{
|
|
|
|
static const char *str = "test\r\ntest";
|
2009-05-01 10:57:32 +02:00
|
|
|
HWND parentWnd;
|
2005-12-19 09:53:19 +01:00
|
|
|
HWND hWnd;
|
|
|
|
int len;
|
2009-05-01 10:57:32 +02:00
|
|
|
RECT rc1 = { 10, 10, 11, 11};
|
|
|
|
RECT rc;
|
2005-12-19 09:53:19 +01:00
|
|
|
|
2009-05-01 10:57:32 +02:00
|
|
|
/* first show that a non-child won't do for this test */
|
2013-10-23 07:53:42 +02:00
|
|
|
hWnd = CreateWindowExA(0,
|
2005-12-19 09:53:19 +01:00
|
|
|
"EDIT",
|
|
|
|
str,
|
|
|
|
0,
|
|
|
|
10, 10, 1, 1,
|
|
|
|
NULL, NULL, NULL, NULL);
|
|
|
|
assert(hWnd);
|
2009-05-04 10:50:31 +02:00
|
|
|
/* size of non-child edit control is (much) bigger than requested */
|
2009-05-01 10:57:32 +02:00
|
|
|
GetWindowRect( hWnd, &rc);
|
2009-05-04 10:50:31 +02:00
|
|
|
ok( rc.right - rc.left > 20, "size of the window (%d) is smaller than expected\n",
|
2009-05-01 10:57:32 +02:00
|
|
|
rc.right - rc.left);
|
|
|
|
DestroyWindow(hWnd);
|
|
|
|
/* so create a parent, and give it edit controls children to test with */
|
2013-10-23 07:53:42 +02:00
|
|
|
parentWnd = CreateWindowExA(0,
|
2009-05-01 10:57:32 +02:00
|
|
|
szEditTextPositionClass,
|
|
|
|
"Edit Test", WS_VISIBLE |
|
|
|
|
WS_OVERLAPPEDWINDOW,
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
250, 250,
|
|
|
|
NULL, NULL, hinst, NULL);
|
|
|
|
assert(parentWnd);
|
|
|
|
ShowWindow( parentWnd, SW_SHOW);
|
|
|
|
/* single line */
|
2013-10-23 07:53:42 +02:00
|
|
|
hWnd = CreateWindowExA(0,
|
2009-05-01 10:57:32 +02:00
|
|
|
"EDIT",
|
|
|
|
str, WS_VISIBLE | WS_BORDER |
|
|
|
|
WS_CHILD,
|
|
|
|
rc1.left, rc1.top, rc1.right - rc1.left, rc1.bottom - rc1.top,
|
|
|
|
parentWnd, NULL, NULL, NULL);
|
|
|
|
assert(hWnd);
|
|
|
|
GetClientRect( hWnd, &rc);
|
|
|
|
ok( rc.right == rc1.right - rc1.left && rc.bottom == rc1.bottom - rc1.top,
|
2016-06-16 10:32:02 +02:00
|
|
|
"Client rectangle not the expected size %s\n", wine_dbgstr_rect( &rc ));
|
2005-12-19 09:53:19 +01:00
|
|
|
len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
|
|
|
|
ok(lstrlenA(str) == len, "text shouldn't have been truncated\n");
|
|
|
|
DestroyWindow(hWnd);
|
2009-05-01 10:57:32 +02:00
|
|
|
/* multi line */
|
2013-10-23 07:53:42 +02:00
|
|
|
hWnd = CreateWindowExA(0,
|
2005-12-19 09:53:19 +01:00
|
|
|
"EDIT",
|
|
|
|
str,
|
2009-05-01 10:57:32 +02:00
|
|
|
WS_CHILD | ES_MULTILINE,
|
|
|
|
rc1.left, rc1.top, rc1.right - rc1.left, rc1.bottom - rc1.top,
|
|
|
|
parentWnd, NULL, NULL, NULL);
|
2005-12-19 09:53:19 +01:00
|
|
|
assert(hWnd);
|
2009-05-01 10:57:32 +02:00
|
|
|
GetClientRect( hWnd, &rc);
|
|
|
|
ok( rc.right == rc1.right - rc1.left && rc.bottom == rc1.bottom - rc1.top,
|
2016-06-16 10:32:02 +02:00
|
|
|
"Client rectangle not the expected size %s\n", wine_dbgstr_rect( &rc ));
|
2005-12-19 09:53:19 +01:00
|
|
|
len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
|
|
|
|
ok(lstrlenA(str) == len, "text shouldn't have been truncated\n");
|
|
|
|
DestroyWindow(hWnd);
|
2014-04-07 18:43:45 +02:00
|
|
|
DestroyWindow(parentWnd);
|
2005-12-19 09:53:19 +01:00
|
|
|
}
|
|
|
|
|
2009-11-15 11:33:38 +01:00
|
|
|
/* Test WM_GETTEXT processing
|
|
|
|
* after destroy messages
|
|
|
|
*/
|
|
|
|
static void test_edit_control_6(void)
|
|
|
|
{
|
|
|
|
static const char *str = "test\r\ntest";
|
|
|
|
char buf[MAXLEN];
|
|
|
|
LONG ret;
|
|
|
|
HWND hWnd;
|
|
|
|
|
2013-10-23 07:53:42 +02:00
|
|
|
hWnd = CreateWindowExA(0,
|
2009-11-15 11:33:38 +01:00
|
|
|
"EDIT",
|
|
|
|
"Test",
|
|
|
|
0,
|
|
|
|
10, 10, 1, 1,
|
|
|
|
NULL, NULL, hinst, NULL);
|
|
|
|
assert(hWnd);
|
|
|
|
|
|
|
|
ret = SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)str);
|
|
|
|
ok(ret == TRUE, "Expected %d, got %d\n", TRUE, ret);
|
|
|
|
ret = SendMessageA(hWnd, WM_GETTEXT, MAXLEN, (LPARAM)buf);
|
2013-10-23 07:53:42 +02:00
|
|
|
ok(ret == strlen(str), "Expected %s, got len %d\n", str, ret);
|
|
|
|
ok(!strcmp(buf, str), "Expected %s, got %s\n", str, buf);
|
2009-11-15 11:33:38 +01:00
|
|
|
buf[0] = 0;
|
|
|
|
ret = SendMessageA(hWnd, WM_DESTROY, 0, 0);
|
|
|
|
ok(ret == 0, "Expected 0, got %d\n", ret);
|
|
|
|
ret = SendMessageA(hWnd, WM_GETTEXT, MAXLEN, (LPARAM)buf);
|
2013-10-23 07:53:42 +02:00
|
|
|
ok(ret == strlen(str), "Expected %s, got len %d\n", str, ret);
|
|
|
|
ok(!strcmp(buf, str), "Expected %s, got %s\n", str, buf);
|
2009-11-15 11:33:38 +01:00
|
|
|
buf[0] = 0;
|
|
|
|
ret = SendMessageA(hWnd, WM_NCDESTROY, 0, 0);
|
|
|
|
ok(ret == 0, "Expected 0, got %d\n", ret);
|
|
|
|
ret = SendMessageA(hWnd, WM_GETTEXT, MAXLEN, (LPARAM)buf);
|
|
|
|
ok(ret == 0, "Expected 0, got len %d\n", ret);
|
2013-10-23 07:53:42 +02:00
|
|
|
ok(!strcmp(buf, ""), "Expected empty string, got %s\n", buf);
|
2009-11-15 11:33:38 +01:00
|
|
|
|
|
|
|
DestroyWindow(hWnd);
|
|
|
|
}
|
|
|
|
|
2007-10-15 03:25:54 +02:00
|
|
|
static void test_edit_control_limittext(void)
|
|
|
|
{
|
|
|
|
HWND hwEdit;
|
|
|
|
DWORD r;
|
|
|
|
|
|
|
|
/* Test default limit for single-line control */
|
|
|
|
trace("EDIT: buffer limit for single-line\n");
|
|
|
|
hwEdit = create_editcontrol(ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0);
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, EM_GETLIMITTEXT, 0, 0);
|
2007-10-15 03:25:54 +02:00
|
|
|
ok(r == 30000, "Incorrect default text limit, expected 30000 got %u\n", r);
|
2013-10-23 07:53:42 +02:00
|
|
|
SendMessageA(hwEdit, EM_SETLIMITTEXT, 0, 0);
|
|
|
|
r = SendMessageA(hwEdit, EM_GETLIMITTEXT, 0, 0);
|
2011-07-27 04:11:34 +02:00
|
|
|
ok( r == 2147483646, "got limit %u (expected 2147483646)\n", r);
|
2007-10-15 03:25:54 +02:00
|
|
|
DestroyWindow(hwEdit);
|
|
|
|
|
|
|
|
/* Test default limit for multi-line control */
|
|
|
|
trace("EDIT: buffer limit for multi-line\n");
|
|
|
|
hwEdit = create_editcontrol(ES_MULTILINE | WS_VSCROLL | ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0);
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, EM_GETLIMITTEXT, 0, 0);
|
2007-10-15 03:25:54 +02:00
|
|
|
ok(r == 30000, "Incorrect default text limit, expected 30000 got %u\n", r);
|
2013-10-23 07:53:42 +02:00
|
|
|
SendMessageA(hwEdit, EM_SETLIMITTEXT, 0, 0);
|
|
|
|
r = SendMessageA(hwEdit, EM_GETLIMITTEXT, 0, 0);
|
2011-07-27 04:11:34 +02:00
|
|
|
ok( r == 4294967295U, "got limit %u (expected 4294967295)\n", r);
|
2007-10-15 03:25:54 +02:00
|
|
|
DestroyWindow(hwEdit);
|
|
|
|
}
|
|
|
|
|
2010-03-03 13:19:46 +01:00
|
|
|
/* Test EM_SCROLL */
|
|
|
|
static void test_edit_control_scroll(void)
|
|
|
|
{
|
|
|
|
static const char *single_line_str = "a";
|
2010-03-03 13:19:47 +01:00
|
|
|
static const char *multiline_str = "Test\r\nText";
|
2010-03-03 13:19:46 +01:00
|
|
|
HWND hwEdit;
|
|
|
|
LONG ret;
|
|
|
|
|
|
|
|
/* Check the return value when EM_SCROLL doesn't scroll
|
|
|
|
* anything. Should not return true unless any lines were actually
|
|
|
|
* scrolled. */
|
2013-10-23 07:53:42 +02:00
|
|
|
hwEdit = CreateWindowA(
|
2010-03-03 13:19:46 +01:00
|
|
|
"EDIT",
|
|
|
|
single_line_str,
|
|
|
|
WS_VSCROLL | ES_MULTILINE,
|
|
|
|
1, 1, 100, 100,
|
|
|
|
NULL, NULL, hinst, NULL);
|
|
|
|
|
|
|
|
assert(hwEdit);
|
|
|
|
|
2013-10-23 07:53:42 +02:00
|
|
|
ret = SendMessageA(hwEdit, EM_SCROLL, SB_PAGEDOWN, 0);
|
2010-03-03 13:19:46 +01:00
|
|
|
ok(!ret, "Returned %x, expected 0.\n", ret);
|
|
|
|
|
2013-10-23 07:53:42 +02:00
|
|
|
ret = SendMessageA(hwEdit, EM_SCROLL, SB_PAGEUP, 0);
|
2010-03-03 13:19:46 +01:00
|
|
|
ok(!ret, "Returned %x, expected 0.\n", ret);
|
|
|
|
|
2013-10-23 07:53:42 +02:00
|
|
|
ret = SendMessageA(hwEdit, EM_SCROLL, SB_LINEUP, 0);
|
2010-03-03 13:19:46 +01:00
|
|
|
ok(!ret, "Returned %x, expected 0.\n", ret);
|
|
|
|
|
2013-10-23 07:53:42 +02:00
|
|
|
ret = SendMessageA(hwEdit, EM_SCROLL, SB_LINEDOWN, 0);
|
2010-03-03 13:19:46 +01:00
|
|
|
ok(!ret, "Returned %x, expected 0.\n", ret);
|
|
|
|
|
|
|
|
DestroyWindow (hwEdit);
|
2010-03-03 13:19:47 +01:00
|
|
|
|
|
|
|
/* SB_PAGEDOWN while at the beginning of a buffer with few lines
|
|
|
|
should not cause EM_SCROLL to return a negative value of
|
|
|
|
scrolled lines that would put us "before" the beginning. */
|
2013-10-23 07:53:42 +02:00
|
|
|
hwEdit = CreateWindowA(
|
2010-03-03 13:19:47 +01:00
|
|
|
"EDIT",
|
|
|
|
multiline_str,
|
|
|
|
WS_VSCROLL | ES_MULTILINE,
|
|
|
|
0, 0, 100, 100,
|
|
|
|
NULL, NULL, hinst, NULL);
|
|
|
|
assert(hwEdit);
|
|
|
|
|
2013-10-23 07:53:42 +02:00
|
|
|
ret = SendMessageA(hwEdit, EM_SCROLL, SB_PAGEDOWN, 0);
|
2010-03-03 13:19:47 +01:00
|
|
|
ok(!ret, "Returned %x, expected 0.\n", ret);
|
|
|
|
|
|
|
|
DestroyWindow (hwEdit);
|
2010-03-03 13:19:46 +01:00
|
|
|
}
|
|
|
|
|
2019-03-14 15:55:21 +01:00
|
|
|
static BOOL is_cjk_charset(HDC dc)
|
|
|
|
{
|
|
|
|
switch (GdiGetCodePage(dc)) {
|
|
|
|
case 932: case 936: case 949: case 950: case 1361:
|
|
|
|
return TRUE;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-01 12:35:10 +02:00
|
|
|
static void test_margins_usefontinfo(UINT charset)
|
|
|
|
{
|
|
|
|
HWND hwnd;
|
|
|
|
HDC hdc;
|
2019-03-14 15:55:19 +01:00
|
|
|
TEXTMETRICW tm;
|
2016-09-01 12:35:10 +02:00
|
|
|
SIZE size;
|
|
|
|
LOGFONTA lf;
|
|
|
|
HFONT hfont;
|
|
|
|
RECT rect;
|
2019-03-14 15:55:21 +01:00
|
|
|
INT margins, threshold, expect, empty_expect;
|
|
|
|
const UINT small_margins = MAKELONG(1, 5);
|
2016-09-01 12:35:10 +02:00
|
|
|
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
lf.lfHeight = -11;
|
|
|
|
lf.lfWeight = FW_NORMAL;
|
|
|
|
lf.lfCharSet = charset;
|
|
|
|
strcpy(lf.lfFaceName, "Tahoma");
|
|
|
|
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
ok(hfont != NULL, "got %p\n", hfont);
|
|
|
|
|
|
|
|
/* Big window rectangle */
|
|
|
|
hwnd = CreateWindowExA(0, "Edit", "A", WS_POPUP, 0, 0, 5000, 1000, NULL, NULL, NULL, NULL);
|
|
|
|
ok(hwnd != NULL, "got %p\n", hwnd);
|
|
|
|
GetClientRect(hwnd, &rect);
|
|
|
|
ok(!IsRectEmpty(&rect), "got rect %s\n", wine_dbgstr_rect(&rect));
|
|
|
|
|
|
|
|
hdc = GetDC(hwnd);
|
|
|
|
hfont = SelectObject(hdc, hfont);
|
2019-03-14 15:55:19 +01:00
|
|
|
size.cx = GdiGetCharDimensions( hdc, &tm, &size.cy );
|
|
|
|
if ((charset != tm.tmCharSet && charset != DEFAULT_CHARSET) ||
|
|
|
|
!(tm.tmPitchAndFamily & (TMPF_TRUETYPE | TMPF_VECTOR))) {
|
|
|
|
skip("%s for charset %d isn't available\n", lf.lfFaceName, charset);
|
|
|
|
hfont = SelectObject(hdc, hfont);
|
|
|
|
ReleaseDC(hwnd, hdc);
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
DeleteObject(hfont);
|
|
|
|
return;
|
|
|
|
}
|
2016-09-01 12:35:10 +02:00
|
|
|
expect = MAKELONG(size.cx / 2, size.cx / 2);
|
|
|
|
hfont = SelectObject(hdc, hfont);
|
|
|
|
ReleaseDC(hwnd, hdc);
|
|
|
|
|
|
|
|
margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0);
|
|
|
|
ok(margins == 0, "got %x\n", margins);
|
|
|
|
SendMessageA(hwnd, WM_SETFONT, (WPARAM)hfont, MAKELPARAM(TRUE, 0));
|
2019-03-14 15:55:21 +01:00
|
|
|
SendMessageA(hwnd, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(EC_USEFONTINFO, EC_USEFONTINFO));
|
2019-03-14 15:55:24 +01:00
|
|
|
expect = SendMessageA(hwnd, EM_GETMARGINS, 0, 0);
|
2016-09-01 12:35:10 +02:00
|
|
|
DestroyWindow(hwnd);
|
|
|
|
|
2019-03-14 15:55:21 +01:00
|
|
|
threshold = HIWORD(expect) + LOWORD(expect) + size.cx * 2;
|
|
|
|
empty_expect = threshold > 80 ? small_margins : expect;
|
2016-09-01 12:35:10 +02:00
|
|
|
|
2019-03-14 15:55:21 +01:00
|
|
|
/* Size below the threshold, margins remain unchanged */
|
2016-09-01 12:35:10 +02:00
|
|
|
hwnd = CreateWindowExA(0, "Edit", "A", WS_POPUP, 0, 0, threshold - 1, 100, NULL, NULL, NULL, NULL);
|
|
|
|
ok(hwnd != NULL, "got %p\n", hwnd);
|
|
|
|
GetClientRect(hwnd, &rect);
|
|
|
|
ok(!IsRectEmpty(&rect), "got rect %s\n", wine_dbgstr_rect(&rect));
|
|
|
|
|
|
|
|
margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0);
|
|
|
|
ok(margins == 0, "got %x\n", margins);
|
|
|
|
|
|
|
|
SendMessageA(hwnd, WM_SETFONT, (WPARAM)hfont, MAKELPARAM(TRUE, 0));
|
2019-03-14 15:55:21 +01:00
|
|
|
SendMessageA(hwnd, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, small_margins);
|
|
|
|
SendMessageA(hwnd, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(EC_USEFONTINFO, EC_USEFONTINFO));
|
2016-09-01 12:35:10 +02:00
|
|
|
margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0);
|
2019-03-14 15:55:21 +01:00
|
|
|
ok(margins == small_margins, "%d: got %d, %d\n", charset, HIWORD(margins), LOWORD(margins));
|
2016-09-01 12:35:10 +02:00
|
|
|
DestroyWindow(hwnd);
|
|
|
|
|
2019-03-14 15:55:21 +01:00
|
|
|
/* Size at the threshold, margins become non-zero */
|
2016-09-01 12:35:10 +02:00
|
|
|
hwnd = CreateWindowExA(0, "Edit", "A", WS_POPUP, 0, 0, threshold, 100, NULL, NULL, NULL, NULL);
|
|
|
|
ok(hwnd != NULL, "got %p\n", hwnd);
|
|
|
|
GetClientRect(hwnd, &rect);
|
|
|
|
ok(!IsRectEmpty(&rect), "got rect %s\n", wine_dbgstr_rect(&rect));
|
|
|
|
|
|
|
|
margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0);
|
|
|
|
ok(margins == 0, "got %x\n", margins);
|
|
|
|
|
|
|
|
SendMessageA(hwnd, WM_SETFONT, (WPARAM)hfont, MAKELPARAM(TRUE, 0));
|
2019-03-14 15:55:21 +01:00
|
|
|
SendMessageA(hwnd, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, small_margins);
|
|
|
|
SendMessageA(hwnd, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(EC_USEFONTINFO, EC_USEFONTINFO));
|
2016-09-01 12:35:10 +02:00
|
|
|
margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0);
|
|
|
|
ok(margins == expect, "%d: got %d, %d\n", charset, HIWORD(margins), LOWORD(margins));
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
|
|
|
|
/* Empty rect */
|
|
|
|
hwnd = CreateWindowExA(0, "Edit", "A", WS_POPUP, 0, 0, 0, 0, NULL, NULL, NULL, NULL);
|
|
|
|
ok(hwnd != NULL, "got %p\n", hwnd);
|
|
|
|
GetClientRect(hwnd, &rect);
|
|
|
|
ok(IsRectEmpty(&rect), "got rect %s\n", wine_dbgstr_rect(&rect));
|
|
|
|
|
|
|
|
margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0);
|
|
|
|
ok(margins == 0, "got %x\n", margins);
|
|
|
|
|
|
|
|
SendMessageA(hwnd, WM_SETFONT, (WPARAM)hfont, MAKELPARAM(TRUE, 0));
|
2019-03-14 15:55:21 +01:00
|
|
|
SendMessageA(hwnd, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, small_margins);
|
|
|
|
SendMessageA(hwnd, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(EC_USEFONTINFO, EC_USEFONTINFO));
|
2016-09-01 12:35:10 +02:00
|
|
|
margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0);
|
|
|
|
ok(margins == empty_expect, "%d: got %d, %d\n", charset, HIWORD(margins), LOWORD(margins));
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
|
|
|
|
DeleteObject(hfont);
|
|
|
|
}
|
|
|
|
|
2019-04-20 08:10:17 +02:00
|
|
|
static BOOL is_cjk_font(HDC dc)
|
|
|
|
{
|
|
|
|
const DWORD FS_DBCS_MASK = FS_JISJAPAN|FS_CHINESESIMP|FS_WANSUNG|FS_CHINESETRAD|FS_JOHAB;
|
|
|
|
FONTSIGNATURE fs;
|
|
|
|
return (GetTextCharsetInfo(dc, &fs, 0) != DEFAULT_CHARSET &&
|
|
|
|
(fs.fsCsb[0] & FS_DBCS_MASK));
|
|
|
|
}
|
|
|
|
|
2019-04-10 17:04:39 +02:00
|
|
|
static INT get_cjk_fontinfo_margin(INT width, INT side_bearing)
|
|
|
|
{
|
|
|
|
INT margin;
|
|
|
|
if (side_bearing < 0)
|
|
|
|
margin = min(-side_bearing, width/2);
|
|
|
|
else
|
|
|
|
margin = 0;
|
|
|
|
return margin;
|
|
|
|
}
|
|
|
|
|
2019-04-18 16:51:01 +02:00
|
|
|
static DWORD get_cjk_font_margins(HDC hdc, BOOL unicode)
|
|
|
|
{
|
|
|
|
ABC abc[256];
|
|
|
|
SHORT left, right;
|
|
|
|
UINT i;
|
|
|
|
|
|
|
|
left = right = 0;
|
|
|
|
if (unicode) {
|
|
|
|
if (!GetCharABCWidthsW(hdc, 0, 255, abc))
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (!GetCharABCWidthsA(hdc, 0, 255, abc))
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
for (i = 0; i < ARRAY_SIZE(abc); i++) {
|
|
|
|
if (-abc[i].abcA > right) right = -abc[i].abcA;
|
|
|
|
if (-abc[i].abcC > left) left = -abc[i].abcC;
|
|
|
|
}
|
|
|
|
return MAKELONG(left, right);
|
|
|
|
}
|
|
|
|
|
2019-03-14 15:55:28 +01:00
|
|
|
static void test_margins_default(const char* facename, UINT charset)
|
2019-03-14 15:55:24 +01:00
|
|
|
{
|
|
|
|
HWND hwnd;
|
|
|
|
HDC hdc;
|
|
|
|
TEXTMETRICW tm;
|
|
|
|
SIZE size;
|
2019-04-20 08:10:17 +02:00
|
|
|
BOOL cjk_charset, cjk_font;
|
2019-03-14 15:55:24 +01:00
|
|
|
LOGFONTA lf;
|
|
|
|
HFONT hfont;
|
|
|
|
RECT rect;
|
2019-04-18 16:51:01 +02:00
|
|
|
INT margins, expect, font_expect;
|
2019-03-14 15:55:24 +01:00
|
|
|
const UINT small_margins = MAKELONG(1, 5);
|
2019-03-14 15:55:26 +01:00
|
|
|
const WCHAR EditW[] = {'E','d','i','t',0}, strW[] = {'W',0};
|
2019-04-10 17:04:39 +02:00
|
|
|
struct char_width_info {
|
|
|
|
INT lsb, rsb, unknown;
|
|
|
|
} info;
|
|
|
|
HMODULE hgdi32;
|
|
|
|
BOOL (WINAPI *pGetCharWidthInfo)(HDC, struct char_width_info *);
|
|
|
|
|
|
|
|
hgdi32 = GetModuleHandleA("gdi32.dll");
|
|
|
|
pGetCharWidthInfo = (void *)GetProcAddress(hgdi32, "GetCharWidthInfo");
|
2019-03-14 15:55:24 +01:00
|
|
|
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
lf.lfHeight = -11;
|
|
|
|
lf.lfWeight = FW_NORMAL;
|
|
|
|
lf.lfCharSet = charset;
|
2019-03-14 15:55:28 +01:00
|
|
|
strcpy(lf.lfFaceName, facename);
|
2019-03-14 15:55:24 +01:00
|
|
|
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
ok(hfont != NULL, "got %p\n", hfont);
|
|
|
|
|
2019-03-14 15:55:26 +01:00
|
|
|
/* Unicode version */
|
|
|
|
hwnd = CreateWindowExW(0, EditW, strW, WS_POPUP, 0, 0, 5000, 1000, NULL, NULL, NULL, NULL);
|
2019-03-14 15:55:24 +01:00
|
|
|
ok(hwnd != NULL, "got %p\n", hwnd);
|
|
|
|
GetClientRect(hwnd, &rect);
|
|
|
|
ok(!IsRectEmpty(&rect), "got rect %s\n", wine_dbgstr_rect(&rect));
|
|
|
|
|
|
|
|
hdc = GetDC(hwnd);
|
|
|
|
hfont = SelectObject(hdc, hfont);
|
|
|
|
size.cx = GdiGetCharDimensions( hdc, &tm, &size.cy );
|
|
|
|
if ((charset != tm.tmCharSet && charset != DEFAULT_CHARSET) ||
|
|
|
|
!(tm.tmPitchAndFamily & (TMPF_TRUETYPE | TMPF_VECTOR))) {
|
|
|
|
skip("%s for charset %d isn't available\n", lf.lfFaceName, charset);
|
|
|
|
hfont = SelectObject(hdc, hfont);
|
|
|
|
ReleaseDC(hwnd, hdc);
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
DeleteObject(hfont);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
cjk_charset = is_cjk_charset(hdc);
|
2019-04-20 08:10:17 +02:00
|
|
|
cjk_font = is_cjk_font(hdc);
|
|
|
|
if ((cjk_charset || cjk_font) &&
|
|
|
|
pGetCharWidthInfo && pGetCharWidthInfo(hdc, &info)) {
|
2019-04-10 17:04:39 +02:00
|
|
|
short left, right;
|
|
|
|
|
|
|
|
left = get_cjk_fontinfo_margin(size.cx, info.lsb);
|
|
|
|
right = get_cjk_fontinfo_margin(size.cx, info.rsb);
|
|
|
|
expect = MAKELONG(left, right);
|
2019-04-18 16:51:01 +02:00
|
|
|
|
|
|
|
font_expect = get_cjk_font_margins(hdc, TRUE);
|
|
|
|
if (!font_expect)
|
|
|
|
/* In this case, margins aren't updated */
|
|
|
|
font_expect = small_margins;
|
2019-04-10 17:04:39 +02:00
|
|
|
}
|
|
|
|
else
|
2019-04-18 16:51:01 +02:00
|
|
|
font_expect = expect = MAKELONG(size.cx / 2, size.cx / 2);
|
2019-03-14 15:55:24 +01:00
|
|
|
|
|
|
|
hfont = SelectObject(hdc, hfont);
|
|
|
|
ReleaseDC(hwnd, hdc);
|
|
|
|
|
|
|
|
margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0);
|
|
|
|
ok(margins == 0, "got %x\n", margins);
|
|
|
|
SendMessageA(hwnd, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, small_margins);
|
|
|
|
SendMessageA(hwnd, WM_SETFONT, (WPARAM)hfont, MAKELPARAM(TRUE, 0));
|
|
|
|
margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0);
|
2019-04-18 16:51:01 +02:00
|
|
|
ok(margins == font_expect, "%s:%d: expected %d, %d, got %d, %d\n", facename, charset, HIWORD(font_expect), LOWORD(font_expect), HIWORD(margins), LOWORD(margins));
|
2019-03-14 15:55:26 +01:00
|
|
|
SendMessageA(hwnd, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, small_margins);
|
|
|
|
SendMessageA(hwnd, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(EC_USEFONTINFO, EC_USEFONTINFO));
|
|
|
|
margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0);
|
2019-04-10 17:04:39 +02:00
|
|
|
ok(margins == expect, "%s:%d: expected %d, %d, got %d, %d\n", facename, charset, HIWORD(expect), LOWORD(expect), HIWORD(margins), LOWORD(margins));
|
2019-03-14 15:55:26 +01:00
|
|
|
DestroyWindow(hwnd);
|
|
|
|
|
|
|
|
/* ANSI version */
|
|
|
|
hwnd = CreateWindowExA(0, "Edit", "A", WS_POPUP, 0, 0, 5000, 1000, NULL, NULL, NULL, NULL);
|
|
|
|
ok(hwnd != NULL, "got %p\n", hwnd);
|
|
|
|
GetClientRect(hwnd, &rect);
|
|
|
|
ok(!IsRectEmpty(&rect), "got rect %s\n", wine_dbgstr_rect(&rect));
|
|
|
|
|
2019-04-18 16:51:01 +02:00
|
|
|
if (cjk_charset) {
|
|
|
|
hdc = GetDC(hwnd);
|
|
|
|
hfont = SelectObject(hdc, hfont);
|
|
|
|
font_expect = get_cjk_font_margins(hdc, FALSE);
|
|
|
|
if (!font_expect)
|
|
|
|
/* In this case, margins aren't updated */
|
|
|
|
font_expect = small_margins;
|
|
|
|
hfont = SelectObject(hdc, hfont);
|
|
|
|
ReleaseDC(hwnd, hdc);
|
|
|
|
}
|
2019-04-20 08:10:17 +02:00
|
|
|
else
|
|
|
|
/* we expect EC_USEFONTINFO size */
|
|
|
|
font_expect = expect;
|
2019-04-18 16:51:01 +02:00
|
|
|
|
2019-03-14 15:55:26 +01:00
|
|
|
margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0);
|
|
|
|
ok(margins == 0, "got %x\n", margins);
|
|
|
|
SendMessageA(hwnd, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, small_margins);
|
|
|
|
SendMessageA(hwnd, WM_SETFONT, (WPARAM)hfont, MAKELPARAM(TRUE, 0));
|
|
|
|
margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0);
|
2019-04-18 16:51:01 +02:00
|
|
|
ok(margins == font_expect, "%s:%d: expected %d, %d, got %d, %d\n", facename, charset, HIWORD(font_expect), LOWORD(font_expect), HIWORD(margins), LOWORD(margins));
|
2019-03-14 15:55:24 +01:00
|
|
|
SendMessageA(hwnd, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, small_margins);
|
|
|
|
SendMessageA(hwnd, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(EC_USEFONTINFO, EC_USEFONTINFO));
|
|
|
|
margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0);
|
2019-04-10 17:04:39 +02:00
|
|
|
ok(margins == expect, "%s:%d: expected %d, %d, got %d, %d\n", facename, charset, HIWORD(expect), LOWORD(expect), HIWORD(margins), LOWORD(margins));
|
2019-03-14 15:55:24 +01:00
|
|
|
DestroyWindow(hwnd);
|
|
|
|
|
|
|
|
DeleteObject(hfont);
|
|
|
|
}
|
|
|
|
|
2019-03-14 15:55:28 +01:00
|
|
|
static INT CALLBACK find_font_proc(const LOGFONTA *elf, const TEXTMETRICA *ntm, DWORD type, LPARAM lParam)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL is_font_installed(const char*name)
|
|
|
|
{
|
|
|
|
HDC hdc = GetDC(NULL);
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
|
|
|
if (!EnumFontFamiliesA(hdc, name, find_font_proc, 0))
|
|
|
|
ret = TRUE;
|
|
|
|
|
|
|
|
ReleaseDC(NULL, hdc);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2020-04-20 12:20:13 +02:00
|
|
|
static WNDPROC orig_class_proc;
|
|
|
|
|
|
|
|
static LRESULT CALLBACK test_class_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
RECT rect;
|
|
|
|
LRESULT result, r;
|
|
|
|
|
|
|
|
switch (message)
|
|
|
|
{
|
|
|
|
case WM_NCCREATE:
|
|
|
|
result = CallWindowProcA(orig_class_proc, hwnd, message, wParam, lParam);
|
|
|
|
|
|
|
|
memset(&rect, 0, sizeof(rect));
|
|
|
|
SendMessageA(hwnd, EM_GETRECT, 0, (LPARAM)&rect);
|
|
|
|
ok(!rect.right && !rect.bottom, "Invalid size after NCCREATE: %d x %d\n", rect.right, rect.bottom);
|
|
|
|
|
|
|
|
/* test that messages between WM_NCCREATE and WM_CREATE
|
|
|
|
don't crash or cause unexpected behavior */
|
|
|
|
r = SendMessageA(hwnd, EM_SETSEL, 0, 0);
|
|
|
|
ok(r == 1, "Returned %ld, expected 1.\n", r);
|
|
|
|
r = SendMessageA(hwnd, WM_SIZE, 0, 0x00100010);
|
|
|
|
todo_wine ok(r == 1, "Returned %ld, expected 1.\n", r);
|
2020-04-20 12:20:15 +02:00
|
|
|
r = SendMessageA(hwnd, EM_LINESCROLL, 1, 1);
|
|
|
|
ok(r == 1, "Returned %ld, expected 1.\n", r);
|
2020-04-20 12:20:13 +02:00
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
case WM_CREATE:
|
|
|
|
/* test that messages between WM_NCCREATE and WM_CREATE
|
|
|
|
don't crash or cause unexpected behavior */
|
|
|
|
r = SendMessageA(hwnd, EM_SETSEL, 0, 0);
|
|
|
|
ok(r == 1, "Returned %ld, expected 1.\n", r);
|
|
|
|
r = SendMessageA(hwnd, WM_SIZE, 0, 0x00100010);
|
|
|
|
todo_wine ok(r == 1, "Returned %ld, expected 1.\n", r);
|
2020-04-20 12:20:15 +02:00
|
|
|
r = SendMessageA(hwnd, EM_LINESCROLL, 1, 1);
|
|
|
|
ok(r == 1, "Returned %ld, expected 1.\n", r);
|
2020-04-20 12:20:13 +02:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return CallWindowProcA(orig_class_proc, hwnd, message, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_initialization(void)
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
ATOM atom;
|
|
|
|
HWND hwEdit;
|
|
|
|
WNDCLASSA cls;
|
|
|
|
|
|
|
|
ret = GetClassInfoA(NULL, "Edit", &cls);
|
|
|
|
ok(ret, "Failed to get class info.\n");
|
|
|
|
|
|
|
|
orig_class_proc = cls.lpfnWndProc;
|
|
|
|
cls.lpfnWndProc = test_class_proc;
|
|
|
|
cls.lpszClassName = "TestClassName";
|
|
|
|
|
|
|
|
atom = RegisterClassA(&cls);
|
|
|
|
ok(atom != 0, "Failed to register class.\n");
|
|
|
|
|
|
|
|
hwEdit = CreateWindowExA(0, (LPCSTR)MAKEINTATOM(atom), "Text Text",
|
|
|
|
ES_MULTILINE | WS_BORDER | ES_AUTOHSCROLL | ES_AUTOVSCROLL | WS_VSCROLL,
|
|
|
|
10, 10, 300, 300, NULL, NULL, hinst, NULL);
|
|
|
|
ok(hwEdit != NULL, "Failed to create a window.\n");
|
|
|
|
|
|
|
|
DestroyWindow(hwEdit);
|
|
|
|
UnregisterClassA((LPCSTR)MAKEINTATOM(atom), hinst);
|
|
|
|
}
|
|
|
|
|
2005-06-25 20:32:07 +02:00
|
|
|
static void test_margins(void)
|
|
|
|
{
|
|
|
|
HWND hwEdit;
|
|
|
|
RECT old_rect, new_rect;
|
2010-05-01 22:09:48 +02:00
|
|
|
INT old_right_margin;
|
2005-06-25 20:32:07 +02:00
|
|
|
DWORD old_margins, new_margins;
|
|
|
|
|
2006-01-27 15:47:32 +01:00
|
|
|
hwEdit = create_editcontrol(WS_BORDER | ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0);
|
2013-10-23 07:53:42 +02:00
|
|
|
|
|
|
|
old_margins = SendMessageA(hwEdit, EM_GETMARGINS, 0, 0);
|
2005-06-25 20:32:07 +02:00
|
|
|
old_right_margin = HIWORD(old_margins);
|
2013-10-23 07:53:42 +02:00
|
|
|
|
2005-06-25 20:32:07 +02:00
|
|
|
/* Check if setting the margins works */
|
2013-10-23 07:53:42 +02:00
|
|
|
|
|
|
|
SendMessageA(hwEdit, EM_SETMARGINS, EC_LEFTMARGIN, MAKELONG(10, 0));
|
|
|
|
new_margins = SendMessageA(hwEdit, EM_GETMARGINS, 0, 0);
|
2005-06-25 20:32:07 +02:00
|
|
|
ok(LOWORD(new_margins) == 10, "Wrong left margin: %d\n", LOWORD(new_margins));
|
|
|
|
ok(HIWORD(new_margins) == old_right_margin, "Wrong right margin: %d\n", HIWORD(new_margins));
|
2013-10-23 07:53:42 +02:00
|
|
|
|
|
|
|
SendMessageA(hwEdit, EM_SETMARGINS, EC_RIGHTMARGIN, MAKELONG(0, 10));
|
|
|
|
new_margins = SendMessageA(hwEdit, EM_GETMARGINS, 0, 0);
|
2005-06-25 20:32:07 +02:00
|
|
|
ok(LOWORD(new_margins) == 10, "Wrong left margin: %d\n", LOWORD(new_margins));
|
|
|
|
ok(HIWORD(new_margins) == 10, "Wrong right margin: %d\n", HIWORD(new_margins));
|
2013-10-23 07:53:42 +02:00
|
|
|
|
2005-06-25 20:32:07 +02:00
|
|
|
/* The size of the rectangle must decrease if we increase the margin */
|
2013-10-23 07:53:42 +02:00
|
|
|
|
|
|
|
SendMessageA(hwEdit, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(5, 5));
|
|
|
|
SendMessageA(hwEdit, EM_GETRECT, 0, (LPARAM)&old_rect);
|
|
|
|
SendMessageA(hwEdit, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(15, 20));
|
|
|
|
SendMessageA(hwEdit, EM_GETRECT, 0, (LPARAM)&new_rect);
|
2005-06-25 20:32:07 +02:00
|
|
|
ok(new_rect.left == old_rect.left + 10, "The left border of the rectangle is wrong\n");
|
|
|
|
ok(new_rect.right == old_rect.right - 15, "The right border of the rectangle is wrong\n");
|
|
|
|
ok(new_rect.top == old_rect.top, "The top border of the rectangle must not change\n");
|
|
|
|
ok(new_rect.bottom == old_rect.bottom, "The bottom border of the rectangle must not change\n");
|
2013-10-23 07:53:42 +02:00
|
|
|
|
2005-06-25 20:32:07 +02:00
|
|
|
/* If we set the margin to same value as the current margin,
|
|
|
|
the rectangle must not change */
|
2013-10-23 07:53:42 +02:00
|
|
|
|
|
|
|
SendMessageA(hwEdit, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(10, 10));
|
2016-04-18 10:12:23 +02:00
|
|
|
SetRect(&old_rect, 1, 1, 99, 99);
|
2013-10-23 07:53:42 +02:00
|
|
|
SendMessageA(hwEdit, EM_SETRECT, 0, (LPARAM)&old_rect);
|
|
|
|
SendMessageA(hwEdit, EM_GETRECT, 0, (LPARAM)&old_rect);
|
|
|
|
SendMessageA(hwEdit, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(10, 10));
|
|
|
|
SendMessageA(hwEdit, EM_GETRECT, 0, (LPARAM)&new_rect);
|
2015-10-06 03:32:07 +02:00
|
|
|
ok(EqualRect(&old_rect, &new_rect), "The border of the rectangle has changed\n");
|
|
|
|
|
|
|
|
/* The lParam argument of the WM_SIZE message should be ignored. */
|
|
|
|
|
|
|
|
SendMessageA(hwEdit, EM_GETRECT, 0, (LPARAM)&old_rect);
|
|
|
|
SendMessageA(hwEdit, WM_SIZE, SIZE_RESTORED, 0);
|
|
|
|
SendMessageA(hwEdit, EM_GETRECT, 0, (LPARAM)&new_rect);
|
2015-10-06 03:32:21 +02:00
|
|
|
ok(EqualRect(&old_rect, &new_rect), "The border of the rectangle has changed\n");
|
2015-10-06 03:32:07 +02:00
|
|
|
SendMessageA(hwEdit, WM_SIZE, SIZE_MINIMIZED, 0);
|
|
|
|
SendMessageA(hwEdit, EM_GETRECT, 0, (LPARAM)&new_rect);
|
2015-10-06 03:32:21 +02:00
|
|
|
ok(EqualRect(&old_rect, &new_rect), "The border of the rectangle has changed\n");
|
2015-10-06 03:32:07 +02:00
|
|
|
SendMessageA(hwEdit, WM_SIZE, SIZE_MAXIMIZED, 0);
|
|
|
|
SendMessageA(hwEdit, EM_GETRECT, 0, (LPARAM)&new_rect);
|
2015-10-06 03:32:21 +02:00
|
|
|
ok(EqualRect(&old_rect, &new_rect), "The border of the rectangle has changed\n");
|
2015-10-06 03:32:07 +02:00
|
|
|
SendMessageA(hwEdit, WM_SIZE, SIZE_RESTORED, MAKELONG(10, 10));
|
|
|
|
SendMessageA(hwEdit, EM_GETRECT, 0, (LPARAM)&new_rect);
|
2015-10-06 03:32:21 +02:00
|
|
|
ok(EqualRect(&old_rect, &new_rect), "The border of the rectangle has changed\n");
|
2006-03-22 13:16:44 +01:00
|
|
|
|
2005-06-25 20:32:07 +02:00
|
|
|
DestroyWindow (hwEdit);
|
2014-04-04 19:45:28 +02:00
|
|
|
|
2016-09-01 12:35:10 +02:00
|
|
|
test_margins_usefontinfo(ANSI_CHARSET);
|
|
|
|
test_margins_usefontinfo(EASTEUROPE_CHARSET);
|
2014-04-04 19:45:28 +02:00
|
|
|
|
2016-09-01 12:35:10 +02:00
|
|
|
test_margins_usefontinfo(SHIFTJIS_CHARSET);
|
|
|
|
test_margins_usefontinfo(HANGUL_CHARSET);
|
|
|
|
test_margins_usefontinfo(CHINESEBIG5_CHARSET);
|
|
|
|
/* Don't test JOHAB_CHARSET. Treated as CJK by Win 8,
|
|
|
|
but not by < Win 8 and Win 10. */
|
2014-04-04 19:45:28 +02:00
|
|
|
|
2016-09-01 12:35:10 +02:00
|
|
|
test_margins_usefontinfo(DEFAULT_CHARSET);
|
2019-03-14 15:55:24 +01:00
|
|
|
|
2019-03-14 15:55:28 +01:00
|
|
|
test_margins_default("Tahoma", ANSI_CHARSET);
|
|
|
|
test_margins_default("Tahoma", EASTEUROPE_CHARSET);
|
2019-03-14 15:55:24 +01:00
|
|
|
|
2019-03-14 15:55:28 +01:00
|
|
|
test_margins_default("Tahoma", HANGUL_CHARSET);
|
|
|
|
test_margins_default("Tahoma", CHINESEBIG5_CHARSET);
|
2005-06-25 20:32:07 +02:00
|
|
|
|
2019-04-20 08:10:17 +02:00
|
|
|
if (is_font_installed("MS PGothic")) {
|
2019-03-14 15:55:28 +01:00
|
|
|
test_margins_default("MS PGothic", SHIFTJIS_CHARSET);
|
2019-04-20 08:10:17 +02:00
|
|
|
test_margins_default("MS PGothic", GREEK_CHARSET);
|
|
|
|
}
|
2019-03-14 15:55:28 +01:00
|
|
|
else
|
|
|
|
skip("MS PGothic is not available, skipping some margin tests\n");
|
|
|
|
|
2019-04-20 08:10:17 +02:00
|
|
|
if (is_font_installed("Ume P Gothic")) {
|
2019-03-14 15:55:28 +01:00
|
|
|
test_margins_default("Ume P Gothic", SHIFTJIS_CHARSET);
|
2019-04-20 08:10:17 +02:00
|
|
|
test_margins_default("Ume P Gothic", GREEK_CHARSET);
|
|
|
|
}
|
2019-03-14 15:55:28 +01:00
|
|
|
else
|
|
|
|
skip("Ume P Gothic is not available, skipping some margin tests\n");
|
|
|
|
|
2019-04-20 08:10:17 +02:00
|
|
|
if (is_font_installed("SimSun")) {
|
2019-03-14 15:55:28 +01:00
|
|
|
test_margins_default("SimSun", GB2312_CHARSET);
|
2019-04-20 08:10:17 +02:00
|
|
|
test_margins_default("SimSun", ANSI_CHARSET);
|
|
|
|
}
|
2019-03-14 15:55:28 +01:00
|
|
|
else
|
|
|
|
skip("SimSun is not available, skipping some margin tests\n");
|
2006-03-22 13:16:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_margins_font_change(void)
|
|
|
|
{
|
|
|
|
HWND hwEdit;
|
|
|
|
DWORD margins, font_margins;
|
2013-10-23 07:53:42 +02:00
|
|
|
LOGFONTA lf;
|
2006-03-22 13:16:44 +01:00
|
|
|
HFONT hfont, hfont2;
|
|
|
|
|
2019-03-14 15:55:28 +01:00
|
|
|
if (!is_font_installed("Arial"))
|
2006-03-22 13:16:44 +01:00
|
|
|
{
|
2019-03-14 15:55:28 +01:00
|
|
|
skip("Arial not found - skipping font change margin tests\n");
|
2006-03-22 13:16:44 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
hwEdit = create_child_editcontrol(0, 0);
|
|
|
|
|
|
|
|
SetWindowPos(hwEdit, NULL, 10, 10, 1000, 100, SWP_NOZORDER | SWP_NOACTIVATE);
|
|
|
|
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
strcpy(lf.lfFaceName, "Arial");
|
|
|
|
lf.lfHeight = 16;
|
2019-04-18 16:50:57 +02:00
|
|
|
lf.lfCharSet = GREEK_CHARSET; /* to avoid associated charset feature */
|
2006-03-22 13:16:44 +01:00
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
lf.lfHeight = 30;
|
|
|
|
hfont2 = CreateFontIndirectA(&lf);
|
|
|
|
|
|
|
|
SendMessageA(hwEdit, WM_SETFONT, (WPARAM)hfont, 0);
|
2013-10-23 07:53:42 +02:00
|
|
|
font_margins = SendMessageA(hwEdit, EM_GETMARGINS, 0, 0);
|
2006-03-22 13:16:44 +01:00
|
|
|
ok(LOWORD(font_margins) != 0, "got %d\n", LOWORD(font_margins));
|
|
|
|
ok(HIWORD(font_margins) != 0, "got %d\n", HIWORD(font_margins));
|
|
|
|
|
|
|
|
/* With 'small' edit controls, test that the margin doesn't get set */
|
|
|
|
SetWindowPos(hwEdit, NULL, 10, 10, 16, 100, SWP_NOZORDER | SWP_NOACTIVATE);
|
|
|
|
SendMessageA(hwEdit, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(0,0));
|
|
|
|
SendMessageA(hwEdit, WM_SETFONT, (WPARAM)hfont, 0);
|
2013-10-23 07:53:42 +02:00
|
|
|
margins = SendMessageA(hwEdit, EM_GETMARGINS, 0, 0);
|
2019-04-18 16:50:59 +02:00
|
|
|
ok(LOWORD(margins) == 0,
|
2008-11-20 18:21:38 +01:00
|
|
|
"got %d\n", LOWORD(margins));
|
2019-04-18 16:50:59 +02:00
|
|
|
ok(HIWORD(margins) == 0,
|
2008-11-20 18:21:38 +01:00
|
|
|
"got %d\n", HIWORD(margins));
|
|
|
|
|
2006-03-22 13:16:44 +01:00
|
|
|
SendMessageA(hwEdit, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(1,0));
|
|
|
|
SendMessageA(hwEdit, WM_SETFONT, (WPARAM)hfont, 0);
|
2013-10-23 07:53:42 +02:00
|
|
|
margins = SendMessageA(hwEdit, EM_GETMARGINS, 0, 0);
|
2019-04-18 16:50:59 +02:00
|
|
|
ok(LOWORD(margins) == 1,
|
2008-11-20 18:21:38 +01:00
|
|
|
"got %d\n", LOWORD(margins));
|
2019-04-18 16:50:59 +02:00
|
|
|
ok(HIWORD(margins) == 0,
|
2008-11-20 18:21:38 +01:00
|
|
|
"got %d\n", HIWORD(margins));
|
2006-03-22 13:16:44 +01:00
|
|
|
|
|
|
|
SendMessageA(hwEdit, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(1,1));
|
|
|
|
SendMessageA(hwEdit, WM_SETFONT, (WPARAM)hfont, 0);
|
2013-10-23 07:53:42 +02:00
|
|
|
margins = SendMessageA(hwEdit, EM_GETMARGINS, 0, 0);
|
2019-04-18 16:50:59 +02:00
|
|
|
ok(LOWORD(margins) == 1,
|
2008-11-20 18:21:38 +01:00
|
|
|
"got %d\n", LOWORD(margins));
|
2019-04-18 16:50:59 +02:00
|
|
|
ok(HIWORD(margins) == 1,
|
2008-11-20 18:21:38 +01:00
|
|
|
"got %d\n", HIWORD(margins));
|
2006-03-22 13:16:44 +01:00
|
|
|
|
|
|
|
SendMessageA(hwEdit, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(EC_USEFONTINFO,EC_USEFONTINFO));
|
2013-10-23 07:53:42 +02:00
|
|
|
margins = SendMessageA(hwEdit, EM_GETMARGINS, 0, 0);
|
2019-04-18 16:50:59 +02:00
|
|
|
ok(LOWORD(margins) == 1,
|
2008-11-20 18:21:38 +01:00
|
|
|
"got %d\n", LOWORD(margins));
|
2019-04-18 16:50:59 +02:00
|
|
|
ok(HIWORD(margins) == 1,
|
2008-11-20 18:21:38 +01:00
|
|
|
"got %d\n", HIWORD(margins));
|
|
|
|
|
2006-03-22 13:16:44 +01:00
|
|
|
SendMessageA(hwEdit, WM_SETFONT, (WPARAM)hfont2, 0);
|
2013-10-23 07:53:42 +02:00
|
|
|
margins = SendMessageA(hwEdit, EM_GETMARGINS, 0, 0);
|
2019-04-18 16:50:59 +02:00
|
|
|
ok(LOWORD(margins) == 1,
|
2008-11-20 18:21:38 +01:00
|
|
|
"got %d\n", LOWORD(margins));
|
2019-04-18 16:50:59 +02:00
|
|
|
ok(HIWORD(margins) == 1,
|
2008-11-20 18:21:38 +01:00
|
|
|
"got %d\n", HIWORD(margins));
|
|
|
|
|
2006-03-22 13:16:44 +01:00
|
|
|
/* Above a certain size threshold then the margin is updated */
|
|
|
|
SetWindowPos(hwEdit, NULL, 10, 10, 1000, 100, SWP_NOZORDER | SWP_NOACTIVATE);
|
|
|
|
SendMessageA(hwEdit, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(1,0));
|
|
|
|
SendMessageA(hwEdit, WM_SETFONT, (WPARAM)hfont, 0);
|
2013-10-23 07:53:42 +02:00
|
|
|
margins = SendMessageA(hwEdit, EM_GETMARGINS, 0, 0);
|
2006-03-22 13:16:44 +01:00
|
|
|
ok(LOWORD(margins) == LOWORD(font_margins), "got %d\n", LOWORD(margins));
|
|
|
|
ok(HIWORD(margins) == HIWORD(font_margins), "got %d\n", HIWORD(margins));
|
|
|
|
|
|
|
|
SendMessageA(hwEdit, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(1,1));
|
|
|
|
SendMessageA(hwEdit, WM_SETFONT, (WPARAM)hfont, 0);
|
2013-10-23 07:53:42 +02:00
|
|
|
margins = SendMessageA(hwEdit, EM_GETMARGINS, 0, 0);
|
2006-03-22 13:16:44 +01:00
|
|
|
ok(LOWORD(margins) == LOWORD(font_margins), "got %d\n", LOWORD(margins));
|
|
|
|
ok(HIWORD(margins) == HIWORD(font_margins), "got %d\n", HIWORD(margins));
|
|
|
|
|
|
|
|
SendMessageA(hwEdit, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(EC_USEFONTINFO,EC_USEFONTINFO));
|
2011-01-24 00:56:10 +01:00
|
|
|
SendMessageA(hwEdit, WM_SETFONT, (WPARAM)hfont, 0);
|
2013-10-23 07:53:42 +02:00
|
|
|
margins = SendMessageA(hwEdit, EM_GETMARGINS, 0, 0);
|
2006-03-22 13:16:44 +01:00
|
|
|
ok(LOWORD(margins) == LOWORD(font_margins), "got %d\n", LOWORD(margins));
|
|
|
|
ok(HIWORD(margins) == HIWORD(font_margins), "got %d\n", HIWORD(margins));
|
|
|
|
SendMessageA(hwEdit, WM_SETFONT, (WPARAM)hfont2, 0);
|
2013-10-23 07:53:42 +02:00
|
|
|
margins = SendMessageA(hwEdit, EM_GETMARGINS, 0, 0);
|
2019-04-18 16:50:59 +02:00
|
|
|
ok(LOWORD(margins) != LOWORD(font_margins),
|
2008-11-20 18:21:38 +01:00
|
|
|
"got %d\n", LOWORD(margins));
|
2006-03-22 13:16:44 +01:00
|
|
|
ok(HIWORD(margins) != HIWORD(font_margins), "got %d\n", HIWORD(margins));
|
|
|
|
|
|
|
|
SendMessageA(hwEdit, WM_SETFONT, 0, 0);
|
2013-10-23 07:53:42 +02:00
|
|
|
|
2006-03-22 13:16:44 +01:00
|
|
|
DeleteObject(hfont2);
|
|
|
|
DeleteObject(hfont);
|
|
|
|
destroy_child_editcontrol(hwEdit);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2005-09-06 13:40:01 +02:00
|
|
|
#define edit_pos_ok(exp, got, txt) \
|
2006-10-07 21:45:11 +02:00
|
|
|
ok(exp == got, "wrong " #txt " expected %d got %d\n", exp, got);
|
2005-09-06 13:40:01 +02:00
|
|
|
|
|
|
|
#define check_pos(hwEdit, set_height, test_top, test_height, test_left) \
|
|
|
|
do { \
|
|
|
|
RECT format_rect; \
|
|
|
|
int left_margin; \
|
|
|
|
set_client_height(hwEdit, set_height); \
|
2013-10-23 07:53:42 +02:00
|
|
|
SendMessageA(hwEdit, EM_GETRECT, 0, (LPARAM) &format_rect); \
|
|
|
|
left_margin = LOWORD(SendMessageA(hwEdit, EM_GETMARGINS, 0, 0)); \
|
2005-09-06 13:40:01 +02:00
|
|
|
edit_pos_ok(test_top, format_rect.top, vertical position); \
|
|
|
|
edit_pos_ok((int)test_height, format_rect.bottom - format_rect.top, height); \
|
|
|
|
edit_pos_ok(test_left, format_rect.left - left_margin, left); \
|
|
|
|
} while(0)
|
|
|
|
|
2006-12-10 16:51:26 +01:00
|
|
|
static void test_text_position_style(DWORD style)
|
2005-09-06 13:40:01 +02:00
|
|
|
{
|
|
|
|
HWND hwEdit;
|
|
|
|
HFONT font, oldFont;
|
|
|
|
HDC dc;
|
2013-10-23 07:53:42 +02:00
|
|
|
TEXTMETRICA metrics;
|
2005-09-06 13:40:01 +02:00
|
|
|
INT b, bm, b2, b3;
|
2011-02-24 17:53:16 +01:00
|
|
|
BOOL xb, single_line = !(style & ES_MULTILINE);
|
2005-09-06 13:40:01 +02:00
|
|
|
|
|
|
|
b = GetSystemMetrics(SM_CYBORDER) + 1;
|
|
|
|
b2 = 2 * b;
|
|
|
|
b3 = 3 * b;
|
|
|
|
bm = b2 - 1;
|
2013-10-23 07:53:42 +02:00
|
|
|
|
2005-09-06 13:40:01 +02:00
|
|
|
/* Get a stock font for which we can determine the metrics */
|
2011-02-24 17:53:16 +01:00
|
|
|
font = GetStockObject(SYSTEM_FONT);
|
2016-05-22 11:54:02 +02:00
|
|
|
ok (font != NULL, "GetStockObject SYSTEM_FONT failed\n");
|
2011-02-24 17:53:16 +01:00
|
|
|
dc = GetDC(NULL);
|
|
|
|
ok (dc != NULL, "GetDC() failed\n");
|
2005-09-06 13:40:01 +02:00
|
|
|
oldFont = SelectObject(dc, font);
|
2013-10-23 07:53:42 +02:00
|
|
|
xb = GetTextMetricsA(dc, &metrics);
|
2011-02-24 17:53:16 +01:00
|
|
|
ok (xb, "GetTextMetrics failed\n");
|
2005-09-06 13:40:01 +02:00
|
|
|
SelectObject(dc, oldFont);
|
|
|
|
ReleaseDC(NULL, dc);
|
2013-10-23 07:53:42 +02:00
|
|
|
|
2005-09-06 13:40:01 +02:00
|
|
|
/* Windows' edit control has some bugs in multi-line mode:
|
|
|
|
* - Sometimes the format rectangle doesn't get updated
|
|
|
|
* (see workaround in set_client_height())
|
|
|
|
* - If the height of the control is smaller than the height of a text
|
|
|
|
* line, the format rectangle is still as high as a text line
|
|
|
|
* (higher than the client rectangle) and the caret is not shown
|
|
|
|
*/
|
2013-10-23 07:53:42 +02:00
|
|
|
|
2005-09-06 13:40:01 +02:00
|
|
|
/* Edit controls that are in a parent window */
|
2013-10-23 07:53:42 +02:00
|
|
|
|
2006-01-27 15:47:32 +01:00
|
|
|
hwEdit = create_child_editcontrol(style | WS_VISIBLE, 0);
|
2013-10-23 07:53:42 +02:00
|
|
|
SendMessageA(hwEdit, WM_SETFONT, (WPARAM) font, FALSE);
|
2005-09-06 13:40:01 +02:00
|
|
|
if (single_line)
|
|
|
|
check_pos(hwEdit, metrics.tmHeight - 1, 0, metrics.tmHeight - 1, 0);
|
|
|
|
check_pos(hwEdit, metrics.tmHeight , 0, metrics.tmHeight , 0);
|
|
|
|
check_pos(hwEdit, metrics.tmHeight + 1, 0, metrics.tmHeight , 0);
|
|
|
|
check_pos(hwEdit, metrics.tmHeight + 2, 0, metrics.tmHeight , 0);
|
|
|
|
check_pos(hwEdit, metrics.tmHeight + 10, 0, metrics.tmHeight , 0);
|
|
|
|
destroy_child_editcontrol(hwEdit);
|
|
|
|
|
2006-01-27 15:47:32 +01:00
|
|
|
hwEdit = create_child_editcontrol(style | WS_BORDER | WS_VISIBLE, 0);
|
2013-10-23 07:53:42 +02:00
|
|
|
SendMessageA(hwEdit, WM_SETFONT, (WPARAM) font, FALSE);
|
2005-09-06 13:40:01 +02:00
|
|
|
if (single_line)
|
|
|
|
check_pos(hwEdit, metrics.tmHeight - 1, 0, metrics.tmHeight - 1, b);
|
|
|
|
check_pos(hwEdit, metrics.tmHeight , 0, metrics.tmHeight , b);
|
|
|
|
check_pos(hwEdit, metrics.tmHeight + 1, 0, metrics.tmHeight , b);
|
|
|
|
check_pos(hwEdit, metrics.tmHeight + bm, 0, metrics.tmHeight , b);
|
|
|
|
check_pos(hwEdit, metrics.tmHeight + b2, b, metrics.tmHeight , b);
|
|
|
|
check_pos(hwEdit, metrics.tmHeight + b3, b, metrics.tmHeight , b);
|
|
|
|
destroy_child_editcontrol(hwEdit);
|
|
|
|
|
2006-01-27 15:47:32 +01:00
|
|
|
hwEdit = create_child_editcontrol(style | WS_VISIBLE, WS_EX_CLIENTEDGE);
|
2013-10-23 07:53:42 +02:00
|
|
|
SendMessageA(hwEdit, WM_SETFONT, (WPARAM) font, FALSE);
|
2005-09-06 13:40:01 +02:00
|
|
|
if (single_line)
|
|
|
|
check_pos(hwEdit, metrics.tmHeight - 1, 0, metrics.tmHeight - 1, 1);
|
|
|
|
check_pos(hwEdit, metrics.tmHeight , 0, metrics.tmHeight , 1);
|
|
|
|
check_pos(hwEdit, metrics.tmHeight + 1, 0, metrics.tmHeight , 1);
|
|
|
|
check_pos(hwEdit, metrics.tmHeight + 2, 1, metrics.tmHeight , 1);
|
|
|
|
check_pos(hwEdit, metrics.tmHeight + 10, 1, metrics.tmHeight , 1);
|
|
|
|
destroy_child_editcontrol(hwEdit);
|
|
|
|
|
2006-01-27 15:47:32 +01:00
|
|
|
hwEdit = create_child_editcontrol(style | WS_BORDER | WS_VISIBLE, WS_EX_CLIENTEDGE);
|
2013-10-23 07:53:42 +02:00
|
|
|
SendMessageA(hwEdit, WM_SETFONT, (WPARAM) font, FALSE);
|
2005-09-06 13:40:01 +02:00
|
|
|
if (single_line)
|
|
|
|
check_pos(hwEdit, metrics.tmHeight - 1, 0, metrics.tmHeight - 1, 1);
|
|
|
|
check_pos(hwEdit, metrics.tmHeight , 0, metrics.tmHeight , 1);
|
|
|
|
check_pos(hwEdit, metrics.tmHeight + 1, 0, metrics.tmHeight , 1);
|
|
|
|
check_pos(hwEdit, metrics.tmHeight + 2, 1, metrics.tmHeight , 1);
|
|
|
|
check_pos(hwEdit, metrics.tmHeight + 10, 1, metrics.tmHeight , 1);
|
|
|
|
destroy_child_editcontrol(hwEdit);
|
|
|
|
|
|
|
|
|
|
|
|
/* Edit controls that are popup windows */
|
2013-10-23 07:53:42 +02:00
|
|
|
|
2005-09-06 13:40:01 +02:00
|
|
|
hwEdit = create_editcontrol(style | WS_POPUP, 0);
|
2013-10-23 07:53:42 +02:00
|
|
|
SendMessageA(hwEdit, WM_SETFONT, (WPARAM) font, FALSE);
|
2005-09-06 13:40:01 +02:00
|
|
|
if (single_line)
|
|
|
|
check_pos(hwEdit, metrics.tmHeight - 1, 0, metrics.tmHeight - 1, 0);
|
|
|
|
check_pos(hwEdit, metrics.tmHeight , 0, metrics.tmHeight , 0);
|
|
|
|
check_pos(hwEdit, metrics.tmHeight + 1, 0, metrics.tmHeight , 0);
|
|
|
|
check_pos(hwEdit, metrics.tmHeight + 2, 0, metrics.tmHeight , 0);
|
|
|
|
check_pos(hwEdit, metrics.tmHeight + 10, 0, metrics.tmHeight , 0);
|
|
|
|
DestroyWindow(hwEdit);
|
|
|
|
|
|
|
|
hwEdit = create_editcontrol(style | WS_POPUP | WS_BORDER, 0);
|
2013-10-23 07:53:42 +02:00
|
|
|
SendMessageA(hwEdit, WM_SETFONT, (WPARAM) font, FALSE);
|
2005-09-06 13:40:01 +02:00
|
|
|
if (single_line)
|
|
|
|
check_pos(hwEdit, metrics.tmHeight - 1, 0, metrics.tmHeight - 1, b);
|
|
|
|
check_pos(hwEdit, metrics.tmHeight , 0, metrics.tmHeight , b);
|
|
|
|
check_pos(hwEdit, metrics.tmHeight + 1, 0, metrics.tmHeight , b);
|
|
|
|
check_pos(hwEdit, metrics.tmHeight + bm, 0, metrics.tmHeight , b);
|
|
|
|
check_pos(hwEdit, metrics.tmHeight + b2, b, metrics.tmHeight , b);
|
|
|
|
check_pos(hwEdit, metrics.tmHeight + b3, b, metrics.tmHeight , b);
|
|
|
|
DestroyWindow(hwEdit);
|
|
|
|
|
|
|
|
hwEdit = create_editcontrol(style | WS_POPUP, WS_EX_CLIENTEDGE);
|
2013-10-23 07:53:42 +02:00
|
|
|
SendMessageA(hwEdit, WM_SETFONT, (WPARAM) font, FALSE);
|
2005-09-06 13:40:01 +02:00
|
|
|
if (single_line)
|
|
|
|
check_pos(hwEdit, metrics.tmHeight - 1, 0, metrics.tmHeight - 1, 1);
|
|
|
|
check_pos(hwEdit, metrics.tmHeight , 0, metrics.tmHeight , 1);
|
|
|
|
check_pos(hwEdit, metrics.tmHeight + 1, 0, metrics.tmHeight , 1);
|
|
|
|
check_pos(hwEdit, metrics.tmHeight + 2, 1, metrics.tmHeight , 1);
|
|
|
|
check_pos(hwEdit, metrics.tmHeight + 10, 1, metrics.tmHeight , 1);
|
|
|
|
DestroyWindow(hwEdit);
|
|
|
|
|
|
|
|
hwEdit = create_editcontrol(style | WS_POPUP | WS_BORDER, WS_EX_CLIENTEDGE);
|
2013-10-23 07:53:42 +02:00
|
|
|
SendMessageA(hwEdit, WM_SETFONT, (WPARAM) font, FALSE);
|
2005-09-06 13:40:01 +02:00
|
|
|
if (single_line)
|
|
|
|
check_pos(hwEdit, metrics.tmHeight - 1, 0, metrics.tmHeight - 1, 1);
|
|
|
|
check_pos(hwEdit, metrics.tmHeight , 0, metrics.tmHeight , 1);
|
|
|
|
check_pos(hwEdit, metrics.tmHeight + 1, 0, metrics.tmHeight , 1);
|
|
|
|
check_pos(hwEdit, metrics.tmHeight + 2, 1, metrics.tmHeight , 1);
|
|
|
|
check_pos(hwEdit, metrics.tmHeight + 10, 1, metrics.tmHeight , 1);
|
|
|
|
DestroyWindow(hwEdit);
|
|
|
|
}
|
|
|
|
|
2006-12-10 16:51:26 +01:00
|
|
|
static void test_text_position(void)
|
2005-09-06 13:40:01 +02:00
|
|
|
{
|
|
|
|
trace("EDIT: Text position (Single line)\n");
|
2006-01-27 15:47:32 +01:00
|
|
|
test_text_position_style(ES_AUTOHSCROLL | ES_AUTOVSCROLL);
|
2005-09-06 13:40:01 +02:00
|
|
|
trace("EDIT: Text position (Multi line)\n");
|
2006-01-27 15:47:32 +01:00
|
|
|
test_text_position_style(ES_MULTILINE | ES_AUTOHSCROLL | ES_AUTOVSCROLL);
|
2005-09-06 13:40:01 +02:00
|
|
|
}
|
|
|
|
|
2007-06-14 02:22:49 +02:00
|
|
|
static void test_espassword(void)
|
|
|
|
{
|
|
|
|
HWND hwEdit;
|
|
|
|
LONG r;
|
|
|
|
char buffer[1024];
|
|
|
|
const char* password = "secret";
|
|
|
|
|
|
|
|
hwEdit = create_editcontrol(ES_PASSWORD, 0);
|
|
|
|
r = get_edit_style(hwEdit);
|
2012-01-17 14:59:19 +01:00
|
|
|
ok(r == ES_PASSWORD, "Wrong style expected ES_PASSWORD got: 0x%x\n", r);
|
2007-06-14 02:22:49 +02:00
|
|
|
/* set text */
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit , WM_SETTEXT, 0, (LPARAM) password);
|
2007-06-14 02:22:49 +02:00
|
|
|
ok(r == TRUE, "Expected: %d, got: %d\n", TRUE, r);
|
|
|
|
|
|
|
|
/* select all, cut (ctrl-x) */
|
2013-10-23 07:53:42 +02:00
|
|
|
SendMessageA(hwEdit, EM_SETSEL, 0, -1);
|
|
|
|
r = SendMessageA(hwEdit, WM_CHAR, 24, 0);
|
2008-04-07 23:11:58 +02:00
|
|
|
ok(1 == r, "Expected: %d, got: %d\n", 1, r);
|
2007-06-14 02:22:49 +02:00
|
|
|
|
|
|
|
/* get text */
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, WM_GETTEXT, 1024, (LPARAM) buffer);
|
2007-06-15 12:43:31 +02:00
|
|
|
ok(r == strlen(password), "Expected: %s, got len %d\n", password, r);
|
2007-06-14 02:22:49 +02:00
|
|
|
ok(strcmp(buffer, password) == 0, "expected %s, got %s\n", password, buffer);
|
|
|
|
|
|
|
|
r = OpenClipboard(hwEdit);
|
|
|
|
ok(r == TRUE, "expected %d, got %d\n", TRUE, r);
|
|
|
|
r = EmptyClipboard();
|
|
|
|
ok(r == TRUE, "expected %d, got %d\n", TRUE, r);
|
|
|
|
r = CloseClipboard();
|
|
|
|
ok(r == TRUE, "expected %d, got %d\n", TRUE, r);
|
|
|
|
|
|
|
|
/* select all, copy (ctrl-c) and paste (ctrl-v) */
|
2013-10-23 07:53:42 +02:00
|
|
|
SendMessageA(hwEdit, EM_SETSEL, 0, -1);
|
|
|
|
r = SendMessageA(hwEdit, WM_CHAR, 3, 0);
|
2008-04-07 23:11:58 +02:00
|
|
|
ok(1 == r, "Expected: %d, got: %d\n", 1, r);
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, WM_CHAR, 22, 0);
|
2008-04-07 23:11:58 +02:00
|
|
|
ok(1 == r, "Expected: %d, got: %d\n", 1, r);
|
2007-06-14 02:22:49 +02:00
|
|
|
|
|
|
|
/* get text */
|
|
|
|
buffer[0] = 0;
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, WM_GETTEXT, 1024, (LPARAM) buffer);
|
2007-06-14 02:22:49 +02:00
|
|
|
ok(r == 0, "Expected: 0, got: %d\n", r);
|
|
|
|
ok(strcmp(buffer, "") == 0, "expected empty string, got %s\n", buffer);
|
|
|
|
|
|
|
|
DestroyWindow (hwEdit);
|
|
|
|
}
|
|
|
|
|
2007-09-12 06:34:10 +02:00
|
|
|
static void test_undo(void)
|
|
|
|
{
|
|
|
|
HWND hwEdit;
|
|
|
|
LONG r;
|
|
|
|
DWORD cpMin, cpMax;
|
|
|
|
char buffer[1024];
|
|
|
|
const char* text = "undo this";
|
|
|
|
|
|
|
|
hwEdit = create_editcontrol(0, 0);
|
|
|
|
r = get_edit_style(hwEdit);
|
|
|
|
ok(0 == r, "Wrong style expected 0x%x got: 0x%x\n", 0, r);
|
|
|
|
|
|
|
|
/* set text */
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit , WM_SETTEXT, 0, (LPARAM) text);
|
2007-09-12 06:34:10 +02:00
|
|
|
ok(TRUE == r, "Expected: %d, got: %d\n", TRUE, r);
|
|
|
|
|
|
|
|
/* select all, */
|
|
|
|
cpMin = cpMax = 0xdeadbeef;
|
2013-10-23 07:53:42 +02:00
|
|
|
SendMessageA(hwEdit, EM_SETSEL, 0, -1);
|
|
|
|
r = SendMessageA(hwEdit, EM_GETSEL, (WPARAM) &cpMin, (LPARAM) &cpMax);
|
2007-09-12 06:34:10 +02:00
|
|
|
ok((strlen(text) << 16) == r, "Unexpected length %d\n", r);
|
|
|
|
ok(0 == cpMin, "Expected: %d, got %d\n", 0, cpMin);
|
|
|
|
ok(9 == cpMax, "Expected: %d, got %d\n", 9, cpMax);
|
|
|
|
|
|
|
|
/* cut (ctrl-x) */
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, WM_CHAR, 24, 0);
|
2008-04-07 23:11:58 +02:00
|
|
|
ok(1 == r, "Expected: %d, got: %d\n", 1, r);
|
2007-09-12 06:34:10 +02:00
|
|
|
|
|
|
|
/* get text */
|
|
|
|
buffer[0] = 0;
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, WM_GETTEXT, 1024, (LPARAM) buffer);
|
2007-09-12 06:34:10 +02:00
|
|
|
ok(0 == r, "Expected: %d, got len %d\n", 0, r);
|
|
|
|
ok(0 == strcmp(buffer, ""), "expected %s, got %s\n", "", buffer);
|
|
|
|
|
|
|
|
/* undo (ctrl-z) */
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, WM_CHAR, 26, 0);
|
2008-04-07 23:11:58 +02:00
|
|
|
ok(1 == r, "Expected: %d, got: %d\n", 1, r);
|
2007-09-12 06:34:10 +02:00
|
|
|
|
|
|
|
/* get text */
|
|
|
|
buffer[0] = 0;
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, WM_GETTEXT, 1024, (LPARAM) buffer);
|
2007-09-12 06:34:10 +02:00
|
|
|
ok(strlen(text) == r, "Unexpected length %d\n", r);
|
|
|
|
ok(0 == strcmp(buffer, text), "expected %s, got %s\n", text, buffer);
|
|
|
|
|
|
|
|
/* undo again (ctrl-z) */
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, WM_CHAR, 26, 0);
|
2008-04-07 23:11:58 +02:00
|
|
|
ok(1 == r, "Expected: %d, got: %d\n", 1, r);
|
2007-09-12 06:34:10 +02:00
|
|
|
|
|
|
|
/* get text */
|
|
|
|
buffer[0] = 0;
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, WM_GETTEXT, 1024, (LPARAM) buffer);
|
2007-09-12 06:34:10 +02:00
|
|
|
ok(r == 0, "Expected: %d, got len %d\n", 0, r);
|
|
|
|
ok(0 == strcmp(buffer, ""), "expected %s, got %s\n", "", buffer);
|
|
|
|
|
|
|
|
DestroyWindow (hwEdit);
|
|
|
|
}
|
|
|
|
|
2008-04-07 23:01:00 +02:00
|
|
|
static void test_enter(void)
|
|
|
|
{
|
|
|
|
HWND hwEdit;
|
|
|
|
LONG r;
|
|
|
|
char buffer[16];
|
|
|
|
|
|
|
|
/* multiline */
|
|
|
|
hwEdit = create_editcontrol(ES_MULTILINE, 0);
|
|
|
|
r = get_edit_style(hwEdit);
|
2012-01-17 14:59:19 +01:00
|
|
|
ok(ES_MULTILINE == r, "Wrong style expected ES_MULTILINE got: 0x%x\n", r);
|
2008-04-07 23:01:00 +02:00
|
|
|
|
|
|
|
/* set text */
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit , WM_SETTEXT, 0, (LPARAM) "");
|
2008-04-07 23:01:00 +02:00
|
|
|
ok(TRUE == r, "Expected: %d, got: %d\n", TRUE, r);
|
|
|
|
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, WM_CHAR, VK_RETURN, 0);
|
2008-04-09 20:33:03 +02:00
|
|
|
ok(1 == r, "Expected: %d, got: %d\n", 1, r);
|
2008-04-07 23:01:00 +02:00
|
|
|
|
|
|
|
/* get text */
|
|
|
|
buffer[0] = 0;
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, WM_GETTEXT, 16, (LPARAM) buffer);
|
2008-04-07 23:01:00 +02:00
|
|
|
ok(2 == r, "Expected: %d, got len %d\n", 2, r);
|
|
|
|
ok(0 == strcmp(buffer, "\r\n"), "expected \"\\r\\n\", got \"%s\"\n", buffer);
|
|
|
|
|
|
|
|
DestroyWindow (hwEdit);
|
|
|
|
|
|
|
|
/* single line */
|
|
|
|
hwEdit = create_editcontrol(0, 0);
|
|
|
|
r = get_edit_style(hwEdit);
|
|
|
|
ok(0 == r, "Wrong style expected 0x%x got: 0x%x\n", 0, r);
|
|
|
|
|
|
|
|
/* set text */
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit , WM_SETTEXT, 0, (LPARAM) "");
|
2008-04-07 23:01:00 +02:00
|
|
|
ok(TRUE == r, "Expected: %d, got: %d\n", TRUE, r);
|
|
|
|
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, WM_CHAR, VK_RETURN, 0);
|
2008-04-09 20:33:03 +02:00
|
|
|
ok(1 == r, "Expected: %d, got: %d\n", 1, r);
|
2008-04-07 23:01:00 +02:00
|
|
|
|
|
|
|
/* get text */
|
|
|
|
buffer[0] = 0;
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, WM_GETTEXT, 16, (LPARAM) buffer);
|
2008-04-07 23:01:00 +02:00
|
|
|
ok(0 == r, "Expected: %d, got len %d\n", 0, r);
|
|
|
|
ok(0 == strcmp(buffer, ""), "expected \"\", got \"%s\"\n", buffer);
|
|
|
|
|
|
|
|
DestroyWindow (hwEdit);
|
|
|
|
|
|
|
|
/* single line with ES_WANTRETURN */
|
|
|
|
hwEdit = create_editcontrol(ES_WANTRETURN, 0);
|
|
|
|
r = get_edit_style(hwEdit);
|
2012-01-17 14:59:19 +01:00
|
|
|
ok(ES_WANTRETURN == r, "Wrong style expected ES_WANTRETURN got: 0x%x\n", r);
|
2008-04-07 23:01:00 +02:00
|
|
|
|
|
|
|
/* set text */
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit , WM_SETTEXT, 0, (LPARAM) "");
|
2008-04-07 23:01:00 +02:00
|
|
|
ok(TRUE == r, "Expected: %d, got: %d\n", TRUE, r);
|
|
|
|
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, WM_CHAR, VK_RETURN, 0);
|
2008-04-09 20:33:03 +02:00
|
|
|
ok(1 == r, "Expected: %d, got: %d\n", 1, r);
|
2008-04-07 23:01:00 +02:00
|
|
|
|
|
|
|
/* get text */
|
|
|
|
buffer[0] = 0;
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, WM_GETTEXT, 16, (LPARAM) buffer);
|
2008-04-07 23:01:00 +02:00
|
|
|
ok(0 == r, "Expected: %d, got len %d\n", 0, r);
|
|
|
|
ok(0 == strcmp(buffer, ""), "expected \"\", got \"%s\"\n", buffer);
|
|
|
|
|
|
|
|
DestroyWindow (hwEdit);
|
|
|
|
}
|
|
|
|
|
2008-04-07 23:07:04 +02:00
|
|
|
static void test_tab(void)
|
|
|
|
{
|
|
|
|
HWND hwEdit;
|
|
|
|
LONG r;
|
|
|
|
char buffer[16];
|
|
|
|
|
|
|
|
/* multiline */
|
|
|
|
hwEdit = create_editcontrol(ES_MULTILINE, 0);
|
|
|
|
r = get_edit_style(hwEdit);
|
2012-01-17 14:59:19 +01:00
|
|
|
ok(ES_MULTILINE == r, "Wrong style expected ES_MULTILINE got: 0x%x\n", r);
|
2008-04-07 23:07:04 +02:00
|
|
|
|
|
|
|
/* set text */
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit , WM_SETTEXT, 0, (LPARAM) "");
|
2008-04-07 23:07:04 +02:00
|
|
|
ok(TRUE == r, "Expected: %d, got: %d\n", TRUE, r);
|
|
|
|
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, WM_CHAR, VK_TAB, 0);
|
2008-04-09 20:33:32 +02:00
|
|
|
ok(1 == r, "Expected: %d, got: %d\n", 1, r);
|
2008-04-07 23:07:04 +02:00
|
|
|
|
|
|
|
/* get text */
|
|
|
|
buffer[0] = 0;
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, WM_GETTEXT, 16, (LPARAM) buffer);
|
2008-04-07 23:07:04 +02:00
|
|
|
ok(1 == r, "Expected: %d, got len %d\n", 1, r);
|
|
|
|
ok(0 == strcmp(buffer, "\t"), "expected \"\\t\", got \"%s\"\n", buffer);
|
|
|
|
|
|
|
|
DestroyWindow (hwEdit);
|
|
|
|
|
|
|
|
/* single line */
|
|
|
|
hwEdit = create_editcontrol(0, 0);
|
|
|
|
r = get_edit_style(hwEdit);
|
|
|
|
ok(0 == r, "Wrong style expected 0x%x got: 0x%x\n", 0, r);
|
|
|
|
|
|
|
|
/* set text */
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit , WM_SETTEXT, 0, (LPARAM) "");
|
2008-04-07 23:07:04 +02:00
|
|
|
ok(TRUE == r, "Expected: %d, got: %d\n", TRUE, r);
|
|
|
|
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, WM_CHAR, VK_TAB, 0);
|
2008-04-09 20:33:32 +02:00
|
|
|
ok(1 == r, "Expected: %d, got: %d\n", 1, r);
|
2008-04-07 23:07:04 +02:00
|
|
|
|
|
|
|
/* get text */
|
|
|
|
buffer[0] = 0;
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, WM_GETTEXT, 16, (LPARAM) buffer);
|
2008-04-07 23:07:04 +02:00
|
|
|
ok(0 == r, "Expected: %d, got len %d\n", 0, r);
|
|
|
|
ok(0 == strcmp(buffer, ""), "expected \"\", got \"%s\"\n", buffer);
|
|
|
|
|
|
|
|
DestroyWindow (hwEdit);
|
|
|
|
}
|
|
|
|
|
2008-03-27 19:48:44 +01:00
|
|
|
static void test_edit_dialog(void)
|
2008-03-26 03:09:38 +01:00
|
|
|
{
|
|
|
|
int r;
|
2008-03-27 19:48:44 +01:00
|
|
|
|
|
|
|
/* from bug 11841 */
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_READONLY_DIALOG", NULL, edit_dialog_proc, 0);
|
2008-03-26 03:09:38 +01:00
|
|
|
ok(333 == r, "Expected %d, got %d\n", 333, r);
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_READONLY_DIALOG", NULL, edit_dialog_proc, 1);
|
2008-03-26 03:09:38 +01:00
|
|
|
ok(111 == r, "Expected %d, got %d\n", 111, r);
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_READONLY_DIALOG", NULL, edit_dialog_proc, 2);
|
2008-03-26 03:09:38 +01:00
|
|
|
ok(444 == r, "Expected %d, got %d\n", 444, r);
|
2008-03-27 20:17:23 +01:00
|
|
|
|
|
|
|
/* more tests for WM_CHAR */
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_READONLY_DIALOG", NULL, edit_dialog_proc, 3);
|
2008-03-27 20:17:23 +01:00
|
|
|
ok(444 == r, "Expected %d, got %d\n", 444, r);
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_READONLY_DIALOG", NULL, edit_dialog_proc, 4);
|
2008-03-27 20:17:23 +01:00
|
|
|
ok(444 == r, "Expected %d, got %d\n", 444, r);
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_READONLY_DIALOG", NULL, edit_dialog_proc, 5);
|
2008-03-27 20:17:23 +01:00
|
|
|
ok(444 == r, "Expected %d, got %d\n", 444, r);
|
|
|
|
|
|
|
|
/* more tests for WM_KEYDOWN + WM_CHAR */
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_READONLY_DIALOG", NULL, edit_dialog_proc, 6);
|
2009-08-23 23:33:20 +02:00
|
|
|
ok(444 == r, "Expected %d, got %d\n", 444, r);
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_READONLY_DIALOG", NULL, edit_dialog_proc, 7);
|
2009-08-25 17:01:05 +02:00
|
|
|
ok(444 == r, "Expected %d, got %d\n", 444, r);
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_READONLY_DIALOG", NULL, edit_dialog_proc, 8);
|
2008-03-27 20:17:23 +01:00
|
|
|
ok(444 == r, "Expected %d, got %d\n", 444, r);
|
|
|
|
|
|
|
|
/* tests with an editable edit control */
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_DIALOG", NULL, edit_dialog_proc, 0);
|
2008-03-27 20:17:23 +01:00
|
|
|
ok(333 == r, "Expected %d, got %d\n", 333, r);
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_DIALOG", NULL, edit_dialog_proc, 1);
|
2008-03-27 20:17:23 +01:00
|
|
|
ok(111 == r, "Expected %d, got %d\n", 111, r);
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_DIALOG", NULL, edit_dialog_proc, 2);
|
2008-03-27 20:17:23 +01:00
|
|
|
ok(444 == r, "Expected %d, got %d\n", 444, r);
|
|
|
|
|
|
|
|
/* tests for WM_CHAR */
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_DIALOG", NULL, edit_dialog_proc, 3);
|
2008-03-27 20:17:23 +01:00
|
|
|
ok(444 == r, "Expected %d, got %d\n", 444, r);
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_DIALOG", NULL, edit_dialog_proc, 4);
|
2008-03-27 20:22:04 +01:00
|
|
|
ok(444 == r, "Expected %d, got %d\n", 444, r);
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_DIALOG", NULL, edit_dialog_proc, 5);
|
2008-03-27 20:22:04 +01:00
|
|
|
ok(444 == r, "Expected %d, got %d\n", 444, r);
|
2008-03-27 20:17:23 +01:00
|
|
|
|
|
|
|
/* tests for WM_KEYDOWN + WM_CHAR */
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_DIALOG", NULL, edit_dialog_proc, 6);
|
2009-08-23 23:33:20 +02:00
|
|
|
ok(444 == r, "Expected %d, got %d\n", 444, r);
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_DIALOG", NULL, edit_dialog_proc, 7);
|
2009-08-25 17:01:05 +02:00
|
|
|
ok(444 == r, "Expected %d, got %d\n", 444, r);
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_DIALOG", NULL, edit_dialog_proc, 8);
|
2008-03-27 20:22:04 +01:00
|
|
|
ok(444 == r, "Expected %d, got %d\n", 444, r);
|
2008-04-02 19:50:09 +02:00
|
|
|
|
|
|
|
/* multiple tab tests */
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_DIALOG", NULL, edit_dialog_proc, 9);
|
2008-04-02 19:50:09 +02:00
|
|
|
ok(22 == r, "Expected %d, got %d\n", 22, r);
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_DIALOG", NULL, edit_dialog_proc, 10);
|
2008-04-02 19:50:09 +02:00
|
|
|
ok(33 == r, "Expected %d, got %d\n", 33, r);
|
2008-03-26 03:09:38 +01:00
|
|
|
}
|
|
|
|
|
2008-04-02 20:04:23 +02:00
|
|
|
static void test_multi_edit_dialog(void)
|
|
|
|
{
|
|
|
|
int r;
|
|
|
|
|
|
|
|
/* test for multiple edit dialogs (bug 12319) */
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "MULTI_EDIT_DIALOG", NULL, multi_edit_dialog_proc, 0);
|
2008-04-02 20:04:23 +02:00
|
|
|
ok(2222 == r, "Expected %d, got %d\n", 2222, r);
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "MULTI_EDIT_DIALOG", NULL, multi_edit_dialog_proc, 1);
|
2008-04-02 20:04:23 +02:00
|
|
|
ok(1111 == r, "Expected %d, got %d\n", 1111, r);
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "MULTI_EDIT_DIALOG", NULL, multi_edit_dialog_proc, 2);
|
2008-04-02 20:04:23 +02:00
|
|
|
ok(2222 == r, "Expected %d, got %d\n", 2222, r);
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "MULTI_EDIT_DIALOG", NULL, multi_edit_dialog_proc, 3);
|
2008-04-02 20:33:19 +02:00
|
|
|
ok(11 == r, "Expected %d, got %d\n", 11, r);
|
2008-04-02 20:04:23 +02:00
|
|
|
}
|
|
|
|
|
2008-04-07 22:32:20 +02:00
|
|
|
static void test_wantreturn_edit_dialog(void)
|
|
|
|
{
|
|
|
|
int r;
|
|
|
|
|
|
|
|
/* tests for WM_KEYDOWN */
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_WANTRETURN_DIALOG", NULL, edit_wantreturn_dialog_proc, 0);
|
2008-04-07 22:32:20 +02:00
|
|
|
ok(333 == r, "Expected %d, got %d\n", 333, r);
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_WANTRETURN_DIALOG", NULL, edit_wantreturn_dialog_proc, 1);
|
2008-04-07 22:32:20 +02:00
|
|
|
ok(444 == r, "Expected %d, got %d\n", 444, r);
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_WANTRETURN_DIALOG", NULL, edit_wantreturn_dialog_proc, 2);
|
2008-04-07 22:32:20 +02:00
|
|
|
ok(444 == r, "Expected %d, got %d\n", 444, r);
|
|
|
|
|
|
|
|
/* tests for WM_CHAR */
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_WANTRETURN_DIALOG", NULL, edit_wantreturn_dialog_proc, 3);
|
2008-04-07 22:32:20 +02:00
|
|
|
ok(444 == r, "Expected %d, got %d\n", 444, r);
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_WANTRETURN_DIALOG", NULL, edit_wantreturn_dialog_proc, 4);
|
2008-04-09 20:33:03 +02:00
|
|
|
ok(444 == r, "Expected %d, got %d\n", 444, r);
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_WANTRETURN_DIALOG", NULL, edit_wantreturn_dialog_proc, 5);
|
2008-04-07 22:32:20 +02:00
|
|
|
ok(444 == r, "Expected %d, got %d\n", 444, r);
|
|
|
|
|
|
|
|
/* tests for WM_KEYDOWN + WM_CHAR */
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_WANTRETURN_DIALOG", NULL, edit_wantreturn_dialog_proc, 6);
|
2009-08-23 23:33:20 +02:00
|
|
|
ok(444 == r, "Expected %d, got %d\n", 444, r);
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_WANTRETURN_DIALOG", NULL, edit_wantreturn_dialog_proc, 7);
|
2008-04-09 20:33:03 +02:00
|
|
|
ok(444 == r, "Expected %d, got %d\n", 444, r);
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_WANTRETURN_DIALOG", NULL, edit_wantreturn_dialog_proc, 8);
|
2008-04-07 22:32:20 +02:00
|
|
|
ok(444 == r, "Expected %d, got %d\n", 444, r);
|
|
|
|
}
|
|
|
|
|
2008-04-07 22:32:36 +02:00
|
|
|
static void test_singleline_wantreturn_edit_dialog(void)
|
|
|
|
{
|
|
|
|
int r;
|
|
|
|
|
|
|
|
/* tests for WM_KEYDOWN */
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_SINGLELINE_DIALOG", NULL, edit_singleline_dialog_proc, 0);
|
2008-04-07 23:18:34 +02:00
|
|
|
ok(222 == r, "Expected %d, got %d\n", 222, r);
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_SINGLELINE_DIALOG", NULL, edit_singleline_dialog_proc, 1);
|
2008-04-07 22:32:36 +02:00
|
|
|
ok(111 == r, "Expected %d, got %d\n", 111, r);
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_SINGLELINE_DIALOG", NULL, edit_singleline_dialog_proc, 2);
|
2008-04-07 22:32:36 +02:00
|
|
|
ok(444 == r, "Expected %d, got %d\n", 444, r);
|
|
|
|
|
|
|
|
/* tests for WM_CHAR */
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_SINGLELINE_DIALOG", NULL, edit_singleline_dialog_proc, 3);
|
2008-04-07 22:32:36 +02:00
|
|
|
ok(444 == r, "Expected %d, got %d\n", 444, r);
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_SINGLELINE_DIALOG", NULL, edit_singleline_dialog_proc, 4);
|
2008-04-07 22:32:36 +02:00
|
|
|
ok(444 == r, "Expected %d, got %d\n", 444, r);
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_SINGLELINE_DIALOG", NULL, edit_singleline_dialog_proc, 5);
|
2008-04-07 22:32:36 +02:00
|
|
|
ok(444 == r, "Expected %d, got %d\n", 444, r);
|
|
|
|
|
|
|
|
/* tests for WM_KEYDOWN + WM_CHAR */
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_SINGLELINE_DIALOG", NULL, edit_singleline_dialog_proc, 6);
|
2008-04-07 23:18:34 +02:00
|
|
|
ok(222 == r, "Expected %d, got %d\n", 222, r);
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_SINGLELINE_DIALOG", NULL, edit_singleline_dialog_proc, 7);
|
2008-04-07 22:32:36 +02:00
|
|
|
ok(111 == r, "Expected %d, got %d\n", 111, r);
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_SINGLELINE_DIALOG", NULL, edit_singleline_dialog_proc, 8);
|
2008-04-07 22:32:36 +02:00
|
|
|
ok(444 == r, "Expected %d, got %d\n", 444, r);
|
|
|
|
|
|
|
|
/* tests for WM_KEYDOWN */
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_SINGLELINE_WANTRETURN_DIALOG", NULL, edit_singleline_dialog_proc, 0);
|
2008-04-07 23:18:34 +02:00
|
|
|
ok(222 == r, "Expected %d, got %d\n", 222, r);
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_SINGLELINE_WANTRETURN_DIALOG", NULL, edit_singleline_dialog_proc, 1);
|
2008-04-07 23:13:04 +02:00
|
|
|
ok(111 == r, "Expected %d, got %d\n", 111, r);
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_SINGLELINE_WANTRETURN_DIALOG", NULL, edit_singleline_dialog_proc, 2);
|
2008-04-07 22:32:36 +02:00
|
|
|
ok(444 == r, "Expected %d, got %d\n", 444, r);
|
|
|
|
|
|
|
|
/* tests for WM_CHAR */
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_SINGLELINE_WANTRETURN_DIALOG", NULL, edit_singleline_dialog_proc, 3);
|
2008-04-07 22:32:36 +02:00
|
|
|
ok(444 == r, "Expected %d, got %d\n", 444, r);
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_SINGLELINE_WANTRETURN_DIALOG", NULL, edit_singleline_dialog_proc, 4);
|
2008-04-07 22:32:36 +02:00
|
|
|
ok(444 == r, "Expected %d, got %d\n", 444, r);
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_SINGLELINE_WANTRETURN_DIALOG", NULL, edit_singleline_dialog_proc, 5);
|
2008-04-07 22:32:36 +02:00
|
|
|
ok(444 == r, "Expected %d, got %d\n", 444, r);
|
|
|
|
|
|
|
|
/* tests for WM_KEYDOWN + WM_CHAR */
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_SINGLELINE_WANTRETURN_DIALOG", NULL, edit_singleline_dialog_proc, 6);
|
2008-04-07 23:18:34 +02:00
|
|
|
ok(222 == r, "Expected %d, got %d\n", 222, r);
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_SINGLELINE_WANTRETURN_DIALOG", NULL, edit_singleline_dialog_proc, 7);
|
2008-04-07 23:13:04 +02:00
|
|
|
ok(111 == r, "Expected %d, got %d\n", 111, r);
|
2013-10-23 07:53:42 +02:00
|
|
|
r = DialogBoxParamA(hinst, "EDIT_SINGLELINE_WANTRETURN_DIALOG", NULL, edit_singleline_dialog_proc, 8);
|
2008-04-07 22:32:36 +02:00
|
|
|
ok(444 == r, "Expected %d, got %d\n", 444, r);
|
|
|
|
}
|
|
|
|
|
2008-04-24 02:48:34 +02:00
|
|
|
static int child_edit_wmkeydown_num_messages = 0;
|
|
|
|
static INT_PTR CALLBACK child_edit_wmkeydown_proc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
|
|
|
|
{
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case WM_DESTROY:
|
|
|
|
case WM_NCDESTROY:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
child_edit_wmkeydown_num_messages++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_child_edit_wmkeydown(void)
|
|
|
|
{
|
|
|
|
HWND hwEdit, hwParent;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
hwEdit = create_child_editcontrol(0, 0);
|
|
|
|
hwParent = GetParent(hwEdit);
|
2013-10-23 07:53:42 +02:00
|
|
|
SetWindowLongPtrA(hwParent, GWLP_WNDPROC, (LONG_PTR)child_edit_wmkeydown_proc);
|
|
|
|
r = SendMessageA(hwEdit, WM_KEYDOWN, VK_RETURN, 0x1c0001);
|
2008-04-24 02:58:30 +02:00
|
|
|
ok(1 == r, "expected 1, got %d\n", r);
|
|
|
|
ok(0 == child_edit_wmkeydown_num_messages, "expected 0, got %d\n", child_edit_wmkeydown_num_messages);
|
2008-04-24 02:48:34 +02:00
|
|
|
destroy_child_editcontrol(hwEdit);
|
|
|
|
}
|
|
|
|
|
2013-11-05 01:05:01 +01:00
|
|
|
static BOOL got_en_setfocus = FALSE;
|
|
|
|
static BOOL got_wm_capturechanged = FALSE;
|
2012-05-16 13:36:52 +02:00
|
|
|
static LRESULT (CALLBACK *p_edit_proc)(HWND, UINT, WPARAM, LPARAM);
|
2010-04-24 21:33:00 +02:00
|
|
|
|
|
|
|
static LRESULT CALLBACK edit4_wnd_procA(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
switch (msg) {
|
|
|
|
case WM_COMMAND:
|
|
|
|
switch (HIWORD(wParam)) {
|
|
|
|
case EN_SETFOCUS:
|
2013-11-05 01:05:01 +01:00
|
|
|
got_en_setfocus = TRUE;
|
2010-04-24 21:33:00 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_CAPTURECHANGED:
|
|
|
|
if (hWnd != (HWND)lParam)
|
|
|
|
{
|
2013-11-05 01:05:01 +01:00
|
|
|
got_wm_capturechanged = TRUE;
|
2017-12-06 13:23:38 +01:00
|
|
|
EndMenu();
|
2010-04-24 21:33:00 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return DefWindowProcA(hWnd, msg, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
2012-05-16 13:36:52 +02:00
|
|
|
static LRESULT CALLBACK edit_proc_proxy(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
switch (msg) {
|
|
|
|
case WM_ENTERIDLE: {
|
|
|
|
MENUBARINFO mbi;
|
|
|
|
BOOL ret;
|
|
|
|
HWND ctx_menu = (HWND)lParam;
|
|
|
|
|
|
|
|
memset(&mbi, 0, sizeof(mbi));
|
|
|
|
mbi.cbSize = sizeof(mbi);
|
|
|
|
SetLastError(0xdeadbeef);
|
2017-12-18 09:35:17 +01:00
|
|
|
ret = GetMenuBarInfo(ctx_menu, OBJID_CLIENT, 0, &mbi);
|
|
|
|
ok(ret, "GetMenuBarInfo failed\n");
|
2012-05-16 13:36:52 +02:00
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
ok(mbi.hMenu != NULL, "mbi.hMenu = NULL\n");
|
|
|
|
ok(!mbi.hwndMenu, "mbi.hwndMenu != NULL\n");
|
|
|
|
ok(mbi.fBarFocused, "mbi.fBarFocused = FALSE\n");
|
|
|
|
ok(mbi.fFocused, "mbi.fFocused = FALSE\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&mbi, 0, sizeof(mbi));
|
|
|
|
mbi.cbSize = sizeof(mbi);
|
|
|
|
SetLastError(0xdeadbeef);
|
2017-12-18 09:35:17 +01:00
|
|
|
ret = GetMenuBarInfo(ctx_menu, OBJID_CLIENT, 1, &mbi);
|
|
|
|
ok(ret, "GetMenuBarInfo failed\n");
|
2012-05-16 13:36:52 +02:00
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
ok(mbi.hMenu != NULL, "mbi.hMenu = NULL\n");
|
|
|
|
ok(!mbi.hwndMenu, "mbi.hwndMenu != NULL\n");
|
|
|
|
ok(mbi.fBarFocused, "mbi.fBarFocused = FALSE\n");
|
|
|
|
ok(!mbi.fFocused, "mbi.fFocused = TRUE\n");
|
|
|
|
}
|
|
|
|
|
2017-12-06 13:23:38 +01:00
|
|
|
EndMenu();
|
2012-05-16 13:36:52 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return p_edit_proc(hWnd, msg, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
2014-04-07 18:43:48 +02:00
|
|
|
struct context_menu_messages
|
|
|
|
{
|
|
|
|
unsigned int wm_command, em_setsel;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct context_menu_messages menu_messages;
|
|
|
|
|
|
|
|
static LRESULT CALLBACK child_edit_menu_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
switch (msg) {
|
|
|
|
case WM_ENTERIDLE:
|
|
|
|
if (wParam == MSGF_MENU) {
|
|
|
|
HWND hwndMenu = (HWND)lParam;
|
|
|
|
MENUBARINFO mbi = { sizeof(MENUBARINFO) };
|
2017-12-18 09:35:17 +01:00
|
|
|
if (GetMenuBarInfo(hwndMenu, OBJID_CLIENT, 0, &mbi)) {
|
2014-04-07 18:43:48 +02:00
|
|
|
MENUITEMINFOA mii = { sizeof(MENUITEMINFOA), MIIM_STATE };
|
|
|
|
if (GetMenuItemInfoA(mbi.hMenu, EM_SETSEL, FALSE, &mii)) {
|
|
|
|
if (mii.fState & MFS_HILITE) {
|
|
|
|
PostMessageA(hwnd, WM_KEYDOWN, VK_RETURN, 0x1c0001);
|
|
|
|
PostMessageA(hwnd, WM_KEYUP, VK_RETURN, 0x1c0001);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
PostMessageA(hwnd, WM_KEYDOWN, VK_DOWN, 0x500001);
|
|
|
|
PostMessageA(hwnd, WM_KEYUP, VK_DOWN, 0x500001);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_COMMAND:
|
|
|
|
menu_messages.wm_command++;
|
|
|
|
break;
|
|
|
|
case EM_SETSEL:
|
|
|
|
menu_messages.em_setsel++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return CallWindowProcA(p_edit_proc, hwnd, msg, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
2012-05-16 13:36:52 +02:00
|
|
|
static void test_contextmenu(void)
|
2010-04-24 21:33:00 +02:00
|
|
|
{
|
|
|
|
HWND hwndMain, hwndEdit;
|
2014-04-07 18:43:48 +02:00
|
|
|
MSG msg;
|
2010-04-24 21:33:00 +02:00
|
|
|
|
2013-10-23 07:53:42 +02:00
|
|
|
hwndMain = CreateWindowA(szEditTest4Class, "ET4", WS_OVERLAPPEDWINDOW|WS_VISIBLE,
|
2010-04-24 21:33:00 +02:00
|
|
|
0, 0, 200, 200, NULL, NULL, hinst, NULL);
|
|
|
|
assert(hwndMain);
|
|
|
|
|
2013-10-23 07:53:42 +02:00
|
|
|
hwndEdit = CreateWindowA("EDIT", NULL,
|
2010-04-24 21:33:00 +02:00
|
|
|
WS_CHILD|WS_BORDER|WS_VISIBLE|ES_LEFT|ES_AUTOHSCROLL,
|
|
|
|
0, 0, 150, 50, /* important this not be 0 size. */
|
|
|
|
hwndMain, (HMENU) ID_EDITTEST2, hinst, NULL);
|
|
|
|
assert(hwndEdit);
|
|
|
|
|
|
|
|
SetFocus(NULL);
|
|
|
|
SetCapture(hwndMain);
|
2013-10-23 07:53:42 +02:00
|
|
|
SendMessageA(hwndEdit, WM_CONTEXTMENU, (WPARAM)hwndEdit, MAKEWORD(10, 10));
|
2010-04-24 21:33:00 +02:00
|
|
|
ok(got_en_setfocus, "edit box didn't get focused\n");
|
|
|
|
ok(got_wm_capturechanged, "main window capture did not change\n");
|
|
|
|
|
2017-12-18 09:35:17 +01:00
|
|
|
p_edit_proc = (void*)SetWindowLongPtrA(hwndEdit, GWLP_WNDPROC, (ULONG_PTR)edit_proc_proxy);
|
|
|
|
SendMessageA(hwndEdit, WM_CONTEXTMENU, (WPARAM)hwndEdit, MAKEWORD(10, 10));
|
2012-05-16 13:36:52 +02:00
|
|
|
|
2014-04-07 18:43:48 +02:00
|
|
|
DestroyWindow (hwndEdit);
|
|
|
|
|
|
|
|
hwndEdit = CreateWindowA("EDIT", "Test Text",
|
|
|
|
WS_CHILD | WS_BORDER | WS_VISIBLE,
|
|
|
|
0, 0, 100, 100,
|
|
|
|
hwndMain, NULL, hinst, NULL);
|
|
|
|
memset(&menu_messages, 0, sizeof(menu_messages));
|
|
|
|
p_edit_proc = (void*)SetWindowLongPtrA(hwndEdit, GWLP_WNDPROC,
|
|
|
|
(ULONG_PTR)child_edit_menu_proc);
|
|
|
|
|
|
|
|
SetFocus(hwndEdit);
|
|
|
|
SendMessageA(hwndEdit, WM_SETTEXT, 0, (LPARAM)"foo");
|
|
|
|
SendMessageA(hwndEdit, WM_CONTEXTMENU, (WPARAM)hwndEdit, MAKEWORD(-1, -1));
|
|
|
|
while (PeekMessageA(&msg, hwndEdit, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
|
2014-04-07 18:43:51 +02:00
|
|
|
ok(menu_messages.wm_command == 0,
|
2014-04-07 18:43:48 +02:00
|
|
|
"Expected no WM_COMMAND messages, got %d\n", menu_messages.wm_command);
|
2014-04-07 18:43:53 +02:00
|
|
|
ok(menu_messages.em_setsel == 1,
|
2014-04-07 18:43:48 +02:00
|
|
|
"Expected 1 EM_SETSEL message, got %d\n", menu_messages.em_setsel);
|
|
|
|
|
2010-04-24 21:33:00 +02:00
|
|
|
DestroyWindow (hwndEdit);
|
|
|
|
DestroyWindow (hwndMain);
|
|
|
|
}
|
|
|
|
|
2005-09-06 13:40:01 +02:00
|
|
|
static BOOL RegisterWindowClasses (void)
|
|
|
|
{
|
|
|
|
WNDCLASSA test2;
|
|
|
|
WNDCLASSA test3;
|
2010-04-24 21:33:00 +02:00
|
|
|
WNDCLASSA test4;
|
2005-09-06 13:40:01 +02:00
|
|
|
WNDCLASSA text_position;
|
2013-10-23 07:53:42 +02:00
|
|
|
|
2005-09-06 13:40:01 +02:00
|
|
|
test2.style = 0;
|
|
|
|
test2.lpfnWndProc = ET2_WndProc;
|
|
|
|
test2.cbClsExtra = 0;
|
|
|
|
test2.cbWndExtra = 0;
|
|
|
|
test2.hInstance = hinst;
|
|
|
|
test2.hIcon = NULL;
|
2013-10-23 07:53:42 +02:00
|
|
|
test2.hCursor = LoadCursorA (NULL, (LPCSTR)IDC_ARROW);
|
2005-09-06 13:40:01 +02:00
|
|
|
test2.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
|
|
|
|
test2.lpszMenuName = NULL;
|
|
|
|
test2.lpszClassName = szEditTest2Class;
|
|
|
|
if (!RegisterClassA(&test2)) return FALSE;
|
|
|
|
|
|
|
|
test3.style = 0;
|
|
|
|
test3.lpfnWndProc = edit3_wnd_procA;
|
|
|
|
test3.cbClsExtra = 0;
|
|
|
|
test3.cbWndExtra = 0;
|
|
|
|
test3.hInstance = hinst;
|
|
|
|
test3.hIcon = 0;
|
2013-10-23 07:53:42 +02:00
|
|
|
test3.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW);
|
2005-09-06 13:40:01 +02:00
|
|
|
test3.hbrBackground = GetStockObject(WHITE_BRUSH);
|
|
|
|
test3.lpszMenuName = NULL;
|
|
|
|
test3.lpszClassName = szEditTest3Class;
|
|
|
|
if (!RegisterClassA(&test3)) return FALSE;
|
2013-10-23 07:53:42 +02:00
|
|
|
|
2010-04-24 21:33:00 +02:00
|
|
|
test4.style = 0;
|
|
|
|
test4.lpfnWndProc = edit4_wnd_procA;
|
|
|
|
test4.cbClsExtra = 0;
|
|
|
|
test4.cbWndExtra = 0;
|
|
|
|
test4.hInstance = hinst;
|
|
|
|
test4.hIcon = NULL;
|
2013-10-23 07:53:42 +02:00
|
|
|
test4.hCursor = LoadCursorA (NULL, (LPCSTR)IDC_ARROW);
|
2010-04-24 21:33:00 +02:00
|
|
|
test4.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
|
|
|
|
test4.lpszMenuName = NULL;
|
|
|
|
test4.lpszClassName = szEditTest4Class;
|
|
|
|
if (!RegisterClassA(&test4)) return FALSE;
|
2005-09-06 13:40:01 +02:00
|
|
|
|
|
|
|
text_position.style = CS_HREDRAW | CS_VREDRAW;
|
|
|
|
text_position.cbClsExtra = 0;
|
|
|
|
text_position.cbWndExtra = 0;
|
|
|
|
text_position.hInstance = hinst;
|
|
|
|
text_position.hIcon = NULL;
|
2013-10-23 07:53:42 +02:00
|
|
|
text_position.hCursor = LoadCursorA(NULL, (LPCSTR)IDC_ARROW);
|
2005-09-06 13:40:01 +02:00
|
|
|
text_position.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
|
|
|
|
text_position.lpszMenuName = NULL;
|
|
|
|
text_position.lpszClassName = szEditTextPositionClass;
|
2013-10-23 07:53:42 +02:00
|
|
|
text_position.lpfnWndProc = DefWindowProcA;
|
2005-09-06 13:40:01 +02:00
|
|
|
if (!RegisterClassA(&text_position)) return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void UnregisterWindowClasses (void)
|
|
|
|
{
|
|
|
|
UnregisterClassA(szEditTest2Class, hinst);
|
|
|
|
UnregisterClassA(szEditTest3Class, hinst);
|
2010-04-24 21:33:00 +02:00
|
|
|
UnregisterClassA(szEditTest4Class, hinst);
|
2005-09-06 13:40:01 +02:00
|
|
|
UnregisterClassA(szEditTextPositionClass, hinst);
|
|
|
|
}
|
|
|
|
|
2008-12-12 10:22:24 +01:00
|
|
|
static void test_fontsize(void)
|
2008-10-15 14:30:22 +02:00
|
|
|
{
|
|
|
|
HWND hwEdit;
|
|
|
|
HFONT hfont;
|
2011-01-24 00:56:10 +01:00
|
|
|
HDC hDC;
|
2013-10-23 07:53:42 +02:00
|
|
|
LOGFONTA lf;
|
2008-10-15 14:30:22 +02:00
|
|
|
LONG r;
|
|
|
|
char szLocalString[MAXLEN];
|
2011-01-24 00:56:10 +01:00
|
|
|
int dpi;
|
|
|
|
|
|
|
|
hDC = GetDC(NULL);
|
|
|
|
dpi = GetDeviceCaps(hDC, LOGPIXELSY);
|
|
|
|
ReleaseDC(NULL, hDC);
|
2008-10-15 14:30:22 +02:00
|
|
|
|
|
|
|
memset(&lf,0,sizeof(LOGFONTA));
|
|
|
|
strcpy(lf.lfFaceName,"Arial");
|
|
|
|
lf.lfHeight = -300; /* taller than the edit box */
|
|
|
|
lf.lfWeight = 500;
|
2013-10-23 07:53:42 +02:00
|
|
|
hfont = CreateFontIndirectA(&lf);
|
2008-10-15 14:30:22 +02:00
|
|
|
|
|
|
|
trace("EDIT: Oversized font (Multi line)\n");
|
2013-10-23 07:53:42 +02:00
|
|
|
hwEdit= CreateWindowA("EDIT", NULL, ES_MULTILINE|ES_AUTOHSCROLL,
|
2011-01-24 00:56:10 +01:00
|
|
|
0, 0, (150 * dpi) / 96, (50 * dpi) / 96, NULL, NULL,
|
|
|
|
hinst, NULL);
|
2008-10-15 14:30:22 +02:00
|
|
|
|
2013-10-23 07:53:42 +02:00
|
|
|
SendMessageA(hwEdit,WM_SETFONT,(WPARAM)hfont,0);
|
2008-10-15 14:30:22 +02:00
|
|
|
|
|
|
|
if (winetest_interactive)
|
|
|
|
ShowWindow (hwEdit, SW_SHOW);
|
|
|
|
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, WM_CHAR, 'A', 1);
|
2008-10-15 14:30:22 +02:00
|
|
|
ok(1 == r, "Expected: %d, got: %d\n", 1, r);
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, WM_CHAR, 'B', 1);
|
2008-10-15 14:30:22 +02:00
|
|
|
ok(1 == r, "Expected: %d, got: %d\n", 1, r);
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, WM_CHAR, 'C', 1);
|
2008-10-15 14:30:22 +02:00
|
|
|
ok(1 == r, "Expected: %d, got: %d\n", 1, r);
|
|
|
|
|
2013-10-23 07:53:42 +02:00
|
|
|
GetWindowTextA(hwEdit, szLocalString, MAXLEN);
|
|
|
|
ok(strcmp(szLocalString, "ABC")==0,
|
2008-10-15 14:30:22 +02:00
|
|
|
"Wrong contents of edit: %s\n", szLocalString);
|
|
|
|
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, EM_POSFROMCHAR,0,0);
|
2008-10-15 14:30:22 +02:00
|
|
|
ok(r != -1,"EM_POSFROMCHAR failed index 0\n");
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, EM_POSFROMCHAR,1,0);
|
2008-10-15 14:30:22 +02:00
|
|
|
ok(r != -1,"EM_POSFROMCHAR failed index 1\n");
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, EM_POSFROMCHAR,2,0);
|
2008-10-15 14:30:22 +02:00
|
|
|
ok(r != -1,"EM_POSFROMCHAR failed index 2\n");
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, EM_POSFROMCHAR,3,0);
|
2008-10-15 14:30:22 +02:00
|
|
|
ok(r == -1,"EM_POSFROMCHAR succeeded index 3\n");
|
|
|
|
|
|
|
|
DestroyWindow (hwEdit);
|
|
|
|
DeleteObject(hfont);
|
|
|
|
}
|
|
|
|
|
2009-08-23 23:33:20 +02:00
|
|
|
struct dialog_mode_messages
|
|
|
|
{
|
|
|
|
int wm_getdefid, wm_close, wm_command, wm_nextdlgctl;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct dialog_mode_messages dm_messages;
|
|
|
|
|
|
|
|
static void zero_dm_messages(void)
|
|
|
|
{
|
|
|
|
dm_messages.wm_command = 0;
|
|
|
|
dm_messages.wm_close = 0;
|
|
|
|
dm_messages.wm_getdefid = 0;
|
|
|
|
dm_messages.wm_nextdlgctl = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define test_dm_messages(wmcommand, wmclose, wmgetdefid, wmnextdlgctl) \
|
|
|
|
ok(dm_messages.wm_command == wmcommand, "expected %d WM_COMMAND messages, " \
|
|
|
|
"got %d\n", wmcommand, dm_messages.wm_command); \
|
|
|
|
ok(dm_messages.wm_close == wmclose, "expected %d WM_CLOSE messages, " \
|
|
|
|
"got %d\n", wmclose, dm_messages.wm_close); \
|
|
|
|
ok(dm_messages.wm_getdefid == wmgetdefid, "expected %d WM_GETDIFID messages, " \
|
|
|
|
"got %d\n", wmgetdefid, dm_messages.wm_getdefid);\
|
|
|
|
ok(dm_messages.wm_nextdlgctl == wmnextdlgctl, "expected %d WM_NEXTDLGCTL messages, " \
|
2009-08-28 01:32:44 +02:00
|
|
|
"got %d\n", wmnextdlgctl, dm_messages.wm_nextdlgctl)
|
2009-08-23 23:33:20 +02:00
|
|
|
|
|
|
|
static LRESULT CALLBACK dialog_mode_wnd_proc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
switch (iMsg)
|
|
|
|
{
|
|
|
|
case WM_COMMAND:
|
|
|
|
dm_messages.wm_command++;
|
|
|
|
break;
|
|
|
|
case DM_GETDEFID:
|
|
|
|
dm_messages.wm_getdefid++;
|
2009-08-25 17:01:05 +02:00
|
|
|
return MAKELONG(ID_EDITTESTDBUTTON, DC_HASDEFID);
|
2009-08-23 23:33:20 +02:00
|
|
|
case WM_NEXTDLGCTL:
|
|
|
|
dm_messages.wm_nextdlgctl++;
|
|
|
|
break;
|
|
|
|
case WM_CLOSE:
|
|
|
|
dm_messages.wm_close++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-10-23 07:53:42 +02:00
|
|
|
return DefWindowProcA(hwnd, iMsg, wParam, lParam);
|
2009-08-23 23:33:20 +02:00
|
|
|
}
|
|
|
|
|
2009-08-23 23:10:01 +02:00
|
|
|
static void test_dialogmode(void)
|
|
|
|
{
|
2009-08-25 17:01:05 +02:00
|
|
|
HWND hwEdit, hwParent, hwButton;
|
2009-08-23 23:10:01 +02:00
|
|
|
MSG msg= {0};
|
|
|
|
int len, r;
|
|
|
|
hwEdit = create_child_editcontrol(ES_MULTILINE, 0);
|
|
|
|
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, WM_CHAR, VK_RETURN, 0x1c0001);
|
2009-08-23 23:10:01 +02:00
|
|
|
ok(1 == r, "expected 1, got %d\n", r);
|
2013-10-23 07:53:42 +02:00
|
|
|
len = SendMessageA(hwEdit, WM_GETTEXTLENGTH, 0, 0);
|
2009-08-23 23:10:01 +02:00
|
|
|
ok(11 == len, "expected 11, got %d\n", len);
|
|
|
|
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, WM_GETDLGCODE, 0, 0);
|
2009-08-23 23:10:01 +02:00
|
|
|
ok(0x8d == r, "expected 0x8d, got 0x%x\n", r);
|
|
|
|
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, WM_CHAR, VK_RETURN, 0x1c0001);
|
2009-08-23 23:10:01 +02:00
|
|
|
ok(1 == r, "expected 1, got %d\n", r);
|
2013-10-23 07:53:42 +02:00
|
|
|
len = SendMessageA(hwEdit, WM_GETTEXTLENGTH, 0, 0);
|
2009-08-23 23:10:01 +02:00
|
|
|
ok(13 == len, "expected 13, got %d\n", len);
|
|
|
|
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, WM_GETDLGCODE, 0, (LPARAM)&msg);
|
2009-08-23 23:10:01 +02:00
|
|
|
ok(0x8d == r, "expected 0x8d, got 0x%x\n", r);
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, WM_CHAR, VK_RETURN, 0x1c0001);
|
2009-08-23 23:10:01 +02:00
|
|
|
ok(1 == r, "expected 1, got %d\n", r);
|
2013-10-23 07:53:42 +02:00
|
|
|
len = SendMessageA(hwEdit, WM_GETTEXTLENGTH, 0, 0);
|
2009-08-23 23:10:01 +02:00
|
|
|
ok(13 == len, "expected 13, got %d\n", len);
|
|
|
|
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, WM_CHAR, VK_RETURN, 0x1c0001);
|
2009-08-23 23:10:01 +02:00
|
|
|
ok(1 == r, "expected 1, got %d\n", r);
|
2013-10-23 07:53:42 +02:00
|
|
|
len = SendMessageA(hwEdit, WM_GETTEXTLENGTH, 0, 0);
|
2009-08-23 23:10:01 +02:00
|
|
|
ok(13 == len, "expected 13, got %d\n", len);
|
|
|
|
|
|
|
|
destroy_child_editcontrol(hwEdit);
|
|
|
|
|
|
|
|
hwEdit = create_editcontrol(ES_MULTILINE, 0);
|
|
|
|
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, WM_CHAR, VK_RETURN, 0x1c0001);
|
2009-08-23 23:10:01 +02:00
|
|
|
ok(1 == r, "expected 1, got %d\n", r);
|
2013-10-23 07:53:42 +02:00
|
|
|
len = SendMessageA(hwEdit, WM_GETTEXTLENGTH, 0, 0);
|
2009-08-23 23:10:01 +02:00
|
|
|
ok(11 == len, "expected 11, got %d\n", len);
|
|
|
|
|
|
|
|
msg.hwnd = hwEdit;
|
|
|
|
msg.message = WM_KEYDOWN;
|
|
|
|
msg.wParam = VK_BACK;
|
|
|
|
msg.lParam = 0xe0001;
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, WM_GETDLGCODE, VK_BACK, (LPARAM)&msg);
|
2009-08-23 23:10:01 +02:00
|
|
|
ok(0x8d == r, "expected 0x8d, got 0x%x\n", r);
|
|
|
|
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, WM_CHAR, VK_RETURN, 0x1c0001);
|
2009-08-23 23:10:01 +02:00
|
|
|
ok(1 == r, "expected 1, got %d\n", r);
|
2013-10-23 07:53:42 +02:00
|
|
|
len = SendMessageA(hwEdit, WM_GETTEXTLENGTH, 0, 0);
|
2009-08-23 23:10:01 +02:00
|
|
|
ok(11 == len, "expected 11, got %d\n", len);
|
|
|
|
|
|
|
|
DestroyWindow(hwEdit);
|
2009-08-23 23:33:20 +02:00
|
|
|
|
|
|
|
hwEdit = create_child_editcontrol(0, 0);
|
|
|
|
hwParent = GetParent(hwEdit);
|
2013-10-23 07:53:42 +02:00
|
|
|
SetWindowLongPtrA(hwParent, GWLP_WNDPROC, (LONG_PTR)dialog_mode_wnd_proc);
|
2009-08-23 23:33:20 +02:00
|
|
|
|
|
|
|
zero_dm_messages();
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, WM_KEYDOWN, VK_ESCAPE, 0x10001);
|
2009-08-23 23:33:20 +02:00
|
|
|
ok(1 == r, "expected 1, got %d\n", r);
|
|
|
|
test_dm_messages(0, 0, 0, 0);
|
|
|
|
zero_dm_messages();
|
|
|
|
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, WM_KEYDOWN, VK_TAB, 0xf0001);
|
2009-08-24 00:47:15 +02:00
|
|
|
ok(1 == r, "expected 1, got %d\n", r);
|
|
|
|
test_dm_messages(0, 0, 0, 0);
|
|
|
|
zero_dm_messages();
|
|
|
|
|
|
|
|
msg.hwnd = hwEdit;
|
|
|
|
msg.message = WM_KEYDOWN;
|
|
|
|
msg.wParam = VK_TAB;
|
|
|
|
msg.lParam = 0xf0001;
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, WM_GETDLGCODE, VK_TAB, (LPARAM)&msg);
|
2009-08-24 00:47:15 +02:00
|
|
|
ok(0x89 == r, "expected 0x89, got 0x%x\n", r);
|
|
|
|
test_dm_messages(0, 0, 0, 0);
|
|
|
|
zero_dm_messages();
|
|
|
|
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, WM_KEYDOWN, VK_TAB, 0xf0001);
|
2009-08-24 00:47:15 +02:00
|
|
|
ok(1 == r, "expected 1, got %d\n", r);
|
|
|
|
test_dm_messages(0, 0, 0, 0);
|
|
|
|
zero_dm_messages();
|
|
|
|
|
2009-08-23 23:33:20 +02:00
|
|
|
destroy_child_editcontrol(hwEdit);
|
|
|
|
|
|
|
|
hwEdit = create_child_editcontrol(ES_MULTILINE, 0);
|
|
|
|
hwParent = GetParent(hwEdit);
|
2013-10-23 07:53:42 +02:00
|
|
|
SetWindowLongPtrA(hwParent, GWLP_WNDPROC, (LONG_PTR)dialog_mode_wnd_proc);
|
2009-08-23 23:33:20 +02:00
|
|
|
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, WM_KEYDOWN, VK_TAB, 0xf0001);
|
2009-08-24 00:47:15 +02:00
|
|
|
ok(1 == r, "expected 1, got %d\n", r);
|
|
|
|
test_dm_messages(0, 0, 0, 0);
|
|
|
|
zero_dm_messages();
|
|
|
|
|
2009-08-23 23:33:20 +02:00
|
|
|
msg.hwnd = hwEdit;
|
|
|
|
msg.message = WM_KEYDOWN;
|
|
|
|
msg.wParam = VK_ESCAPE;
|
|
|
|
msg.lParam = 0x10001;
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, WM_GETDLGCODE, VK_ESCAPE, (LPARAM)&msg);
|
2009-08-23 23:33:20 +02:00
|
|
|
ok(0x8d == r, "expected 0x8d, got 0x%x\n", r);
|
|
|
|
test_dm_messages(0, 0, 0, 0);
|
|
|
|
zero_dm_messages();
|
|
|
|
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, WM_KEYDOWN, VK_ESCAPE, 0x10001);
|
2009-08-23 23:33:20 +02:00
|
|
|
ok(1 == r, "expected 1, got %d\n", r);
|
|
|
|
test_dm_messages(0, 0, 0, 0);
|
|
|
|
zero_dm_messages();
|
|
|
|
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, WM_KEYDOWN, VK_TAB, 0xf0001);
|
2009-08-24 00:47:15 +02:00
|
|
|
ok(1 == r, "expected 1, got %d\n", r);
|
|
|
|
test_dm_messages(0, 0, 0, 1);
|
|
|
|
zero_dm_messages();
|
|
|
|
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, WM_KEYDOWN, VK_RETURN, 0x1c0001);
|
2009-08-25 17:01:05 +02:00
|
|
|
ok(1 == r, "expected 1, got %d\n", r);
|
|
|
|
test_dm_messages(0, 0, 1, 0);
|
|
|
|
zero_dm_messages();
|
|
|
|
|
2013-10-23 07:53:42 +02:00
|
|
|
hwButton = CreateWindowA("BUTTON", "OK", WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON,
|
2009-08-25 17:01:05 +02:00
|
|
|
100, 100, 50, 20, hwParent, (HMENU)ID_EDITTESTDBUTTON, hinst, NULL);
|
|
|
|
ok(hwButton!=NULL, "CreateWindow failed with error code %d\n", GetLastError());
|
|
|
|
|
2013-10-23 07:53:42 +02:00
|
|
|
r = SendMessageA(hwEdit, WM_KEYDOWN, VK_RETURN, 0x1c0001);
|
2009-08-25 17:01:05 +02:00
|
|
|
ok(1 == r, "expected 1, got %d\n", r);
|
|
|
|
test_dm_messages(0, 0, 1, 1);
|
|
|
|
zero_dm_messages();
|
|
|
|
|
|
|
|
DestroyWindow(hwButton);
|
2009-08-23 23:33:20 +02:00
|
|
|
destroy_child_editcontrol(hwEdit);
|
2009-08-23 23:10:01 +02:00
|
|
|
}
|
|
|
|
|
2013-05-03 09:22:44 +02:00
|
|
|
static void test_EM_GETHANDLE(void)
|
|
|
|
{
|
|
|
|
static const char str0[] = "untouched";
|
|
|
|
static const char str1[] = "1111+1111+1111#";
|
2017-12-04 19:31:35 +01:00
|
|
|
static const char str1_1[] = "2111+1111+1111#";
|
2013-05-03 09:22:44 +02:00
|
|
|
static const char str2[] = "2222-2222-2222-2222#";
|
|
|
|
static const char str3[] = "3333*3333*3333*3333*3333#";
|
|
|
|
CHAR current[42];
|
|
|
|
HWND hEdit;
|
|
|
|
HLOCAL hmem;
|
|
|
|
HLOCAL hmem2;
|
|
|
|
HLOCAL halloc;
|
|
|
|
char *buffer;
|
|
|
|
int len;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
trace("EDIT: EM_GETHANDLE\n");
|
|
|
|
|
|
|
|
/* EM_GETHANDLE is not supported for a single line edit control */
|
|
|
|
hEdit = create_editcontrol(WS_BORDER, 0);
|
|
|
|
ok(hEdit != NULL, "got %p (expected != NULL)\n", hEdit);
|
|
|
|
|
2013-10-23 07:53:42 +02:00
|
|
|
hmem = (HGLOBAL) SendMessageA(hEdit, EM_GETHANDLE, 0, 0);
|
2013-05-03 09:22:44 +02:00
|
|
|
ok(hmem == NULL, "got %p (expected NULL)\n", hmem);
|
|
|
|
DestroyWindow(hEdit);
|
|
|
|
|
|
|
|
|
|
|
|
/* EM_GETHANDLE needs a multiline edit control */
|
|
|
|
hEdit = create_editcontrol(WS_BORDER | ES_MULTILINE, 0);
|
|
|
|
ok(hEdit != NULL, "got %p (expected != NULL)\n", hEdit);
|
|
|
|
|
|
|
|
/* set some text */
|
|
|
|
r = SendMessageA(hEdit, WM_SETTEXT, 0, (LPARAM)str1);
|
|
|
|
len = SendMessageA(hEdit, WM_GETTEXTLENGTH, 0, 0);
|
|
|
|
ok((r == 1) && (len == lstrlenA(str1)), "got %d and %d (expected 1 and %d)\n", r, len, lstrlenA(str1));
|
|
|
|
|
|
|
|
lstrcpyA(current, str0);
|
|
|
|
r = SendMessageA(hEdit, WM_GETTEXT, sizeof(current), (LPARAM)current);
|
|
|
|
ok((r == lstrlenA(str1)) && !lstrcmpA(current, str1),
|
|
|
|
"got %d and \"%s\" (expected %d and \"%s\")\n", r, current, lstrlenA(str1), str1);
|
|
|
|
|
2013-10-23 07:53:42 +02:00
|
|
|
hmem = (HGLOBAL) SendMessageA(hEdit, EM_GETHANDLE, 0, 0);
|
2013-05-03 09:22:44 +02:00
|
|
|
ok(hmem != NULL, "got %p (expected != NULL)\n", hmem);
|
|
|
|
/* The buffer belongs to the app now. According to MSDN, the app has to LocalFree the
|
|
|
|
buffer, LocalAlloc a new buffer and pass it to the edit control with EM_SETHANDLE. */
|
|
|
|
|
|
|
|
buffer = LocalLock(hmem);
|
|
|
|
ok(buffer != NULL, "got %p (expected != NULL)\n", buffer);
|
|
|
|
len = lstrlenA(buffer);
|
|
|
|
ok((len == lstrlenA(str1)) && !lstrcmpA(buffer, str1),
|
|
|
|
"got %d and \"%s\" (expected %d and \"%s\")\n", len, buffer, lstrlenA(str1), str1);
|
|
|
|
LocalUnlock(hmem);
|
|
|
|
|
2017-12-04 19:31:35 +01:00
|
|
|
/* See if WM_GETTEXTLENGTH/WM_GETTEXT still work. */
|
|
|
|
len = SendMessageA(hEdit, WM_GETTEXTLENGTH, 0, 0);
|
|
|
|
ok(len == lstrlenA(str1), "Unexpected text length %d.\n", len);
|
|
|
|
|
|
|
|
lstrcpyA(current, str0);
|
|
|
|
r = SendMessageA(hEdit, WM_GETTEXT, sizeof(current), (LPARAM)current);
|
|
|
|
ok((r == lstrlenA(str1)) && !lstrcmpA(current, str1),
|
|
|
|
"Unexpected retval %d and text \"%s\" (expected %d and \"%s\")\n", r, current, lstrlenA(str1), str1);
|
|
|
|
|
|
|
|
/* Application altered buffer contents, see if WM_GETTEXTLENGTH/WM_GETTEXT pick that up. */
|
|
|
|
buffer = LocalLock(hmem);
|
|
|
|
ok(buffer != NULL, "got %p (expected != NULL)\n", buffer);
|
|
|
|
buffer[0] = '2';
|
|
|
|
LocalUnlock(hmem);
|
|
|
|
|
|
|
|
len = SendMessageA(hEdit, WM_GETTEXTLENGTH, 0, 0);
|
2017-12-05 13:09:03 +01:00
|
|
|
ok(len == lstrlenA(str1_1), "Unexpected text length %d.\n", len);
|
2017-12-04 19:31:35 +01:00
|
|
|
|
|
|
|
lstrcpyA(current, str0);
|
|
|
|
r = SendMessageA(hEdit, WM_GETTEXT, sizeof(current), (LPARAM)current);
|
|
|
|
ok((r == lstrlenA(str1_1)) && !lstrcmpA(current, str1_1),
|
|
|
|
"Unexpected retval %d and text \"%s\" (expected %d and \"%s\")\n", r, current, lstrlenA(str1_1), str1_1);
|
|
|
|
|
2017-12-05 13:09:03 +01:00
|
|
|
/* See if WM_SETTEXT/EM_REPLACESEL work. */
|
|
|
|
r = SendMessageA(hEdit, WM_SETTEXT, 0, (LPARAM)str1);
|
|
|
|
ok(r, "Failed to set text.\n");
|
|
|
|
|
|
|
|
buffer = LocalLock(hmem);
|
|
|
|
ok(buffer != NULL && buffer[0] == '1', "Unexpected buffer contents\n");
|
|
|
|
LocalUnlock(hmem);
|
|
|
|
|
|
|
|
r = SendMessageA(hEdit, EM_REPLACESEL, 0, (LPARAM)str1_1);
|
|
|
|
ok(r, "Failed to replace selection.\n");
|
|
|
|
|
|
|
|
buffer = LocalLock(hmem);
|
|
|
|
ok(buffer != NULL && buffer[0] == '2', "Unexpected buffer contents\n");
|
|
|
|
LocalUnlock(hmem);
|
|
|
|
|
2013-05-03 09:22:44 +02:00
|
|
|
/* use LocalAlloc first to get a different handle */
|
|
|
|
halloc = LocalAlloc(LMEM_MOVEABLE, 42);
|
|
|
|
ok(halloc != NULL, "got %p (expected != NULL)\n", halloc);
|
|
|
|
/* prepare our new memory */
|
|
|
|
buffer = LocalLock(halloc);
|
|
|
|
ok(buffer != NULL, "got %p (expected != NULL)\n", buffer);
|
|
|
|
lstrcpyA(buffer, str2);
|
|
|
|
LocalUnlock(halloc);
|
|
|
|
|
|
|
|
/* LocalFree the old memory handle before EM_SETHANDLE the new handle */
|
|
|
|
LocalFree(hmem);
|
|
|
|
/* use LocalAlloc after the LocalFree to likely consume the handle */
|
|
|
|
hmem2 = LocalAlloc(LMEM_MOVEABLE, 42);
|
|
|
|
ok(hmem2 != NULL, "got %p (expected != NULL)\n", hmem2);
|
|
|
|
|
2013-10-23 07:53:42 +02:00
|
|
|
SendMessageA(hEdit, EM_SETHANDLE, (WPARAM)halloc, 0);
|
2013-05-03 09:22:44 +02:00
|
|
|
|
|
|
|
len = SendMessageA(hEdit, WM_GETTEXTLENGTH, 0, 0);
|
|
|
|
ok(len == lstrlenA(str2), "got %d (expected %d)\n", len, lstrlenA(str2));
|
|
|
|
|
|
|
|
lstrcpyA(current, str0);
|
|
|
|
r = SendMessageA(hEdit, WM_GETTEXT, sizeof(current), (LPARAM)current);
|
|
|
|
ok((r == lstrlenA(str2)) && !lstrcmpA(current, str2),
|
|
|
|
"got %d and \"%s\" (expected %d and \"%s\")\n", r, current, lstrlenA(str2), str2);
|
|
|
|
|
|
|
|
/* set a different text */
|
|
|
|
r = SendMessageA(hEdit, WM_SETTEXT, 0, (LPARAM)str3);
|
|
|
|
len = SendMessageA(hEdit, WM_GETTEXTLENGTH, 0, 0);
|
|
|
|
ok((r == 1) && (len == lstrlenA(str3)), "got %d and %d (expected 1 and %d)\n", r, len, lstrlenA(str3));
|
|
|
|
|
|
|
|
lstrcpyA(current, str0);
|
|
|
|
r = SendMessageA(hEdit, WM_GETTEXT, sizeof(current), (LPARAM)current);
|
|
|
|
ok((r == lstrlenA(str3)) && !lstrcmpA(current, str3),
|
|
|
|
"got %d and \"%s\" (expected %d and \"%s\")\n", r, current, lstrlenA(str3), str3);
|
|
|
|
|
|
|
|
LocalFree(hmem2);
|
|
|
|
DestroyWindow(hEdit);
|
|
|
|
|
|
|
|
/* Some apps have bugs ... */
|
|
|
|
hEdit = create_editcontrol(WS_BORDER | ES_MULTILINE, 0);
|
|
|
|
|
|
|
|
/* set some text */
|
|
|
|
r = SendMessageA(hEdit, WM_SETTEXT, 0, (LPARAM)str1);
|
|
|
|
len = SendMessageA(hEdit, WM_GETTEXTLENGTH, 0, 0);
|
|
|
|
ok((r == 1) && (len == lstrlenA(str1)), "got %d and %d (expected 1 and %d)\n", r, len, lstrlenA(str1));
|
|
|
|
|
2013-07-03 12:11:13 +02:00
|
|
|
/* everything is normal up to EM_GETHANDLE */
|
2013-10-23 07:53:42 +02:00
|
|
|
hmem = (HGLOBAL) SendMessageA(hEdit, EM_GETHANDLE, 0, 0);
|
2013-05-03 09:22:44 +02:00
|
|
|
/* Some messages still work while other messages fail.
|
|
|
|
After LocalFree the memory handle, messages can crash the app */
|
|
|
|
|
|
|
|
/* A buggy editor used EM_GETHANDLE twice */
|
2013-10-23 07:53:42 +02:00
|
|
|
hmem2 = (HGLOBAL) SendMessageA(hEdit, EM_GETHANDLE, 0, 0);
|
2013-05-03 09:22:44 +02:00
|
|
|
ok(hmem2 == hmem, "got %p (expected %p)\n", hmem2, hmem);
|
|
|
|
|
|
|
|
/* Let the edit control free the memory handle */
|
2013-10-23 07:53:42 +02:00
|
|
|
SendMessageA(hEdit, EM_SETHANDLE, (WPARAM)hmem2, 0);
|
2013-05-03 09:22:44 +02:00
|
|
|
|
|
|
|
DestroyWindow(hEdit);
|
|
|
|
}
|
|
|
|
|
2017-11-05 19:28:38 +01:00
|
|
|
static void test_paste(void)
|
|
|
|
{
|
|
|
|
HWND hEdit, hMultilineEdit;
|
|
|
|
HANDLE hmem, hmem_ret;
|
|
|
|
char *buffer;
|
|
|
|
int r, len;
|
|
|
|
static const char *str = "this is a simple text";
|
|
|
|
static const char *str2 = "first line\r\nsecond line";
|
|
|
|
|
|
|
|
hEdit = create_editcontrol(ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0);
|
|
|
|
hMultilineEdit = create_editcontrol(ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_MULTILINE, 0);
|
|
|
|
|
|
|
|
/* Prepare clipboard data with simple text */
|
|
|
|
hmem = GlobalAlloc(GMEM_MOVEABLE, 255);
|
|
|
|
ok(hmem != NULL, "got %p (expected != NULL)\n", hmem);
|
|
|
|
buffer = GlobalLock(hmem);
|
|
|
|
ok(buffer != NULL, "got %p (expected != NULL)\n", buffer);
|
|
|
|
strcpy(buffer, str);
|
|
|
|
GlobalUnlock(hmem);
|
|
|
|
|
|
|
|
r = OpenClipboard(hEdit);
|
|
|
|
ok(r == TRUE, "expected %d, got %d\n", TRUE, r);
|
|
|
|
r = EmptyClipboard();
|
|
|
|
ok(r == TRUE, "expected %d, got %d\n", TRUE, r);
|
|
|
|
hmem_ret = SetClipboardData(CF_TEXT, hmem);
|
|
|
|
ok(hmem_ret == hmem, "expected %p, got %p\n", hmem, hmem_ret);
|
|
|
|
r = CloseClipboard();
|
|
|
|
ok(r == TRUE, "expected %d, got %d\n", TRUE, r);
|
|
|
|
|
|
|
|
/* Paste single line */
|
|
|
|
SendMessageA(hEdit, WM_SETTEXT, 0, (LPARAM)"");
|
|
|
|
r = SendMessageA(hEdit, WM_PASTE, 0, 0);
|
|
|
|
len = SendMessageA(hEdit, WM_GETTEXTLENGTH, 0, 0);
|
2017-11-08 22:12:45 +01:00
|
|
|
ok(strlen(str) == len, "got %d\n", len);
|
2017-11-05 19:28:38 +01:00
|
|
|
|
|
|
|
/* Prepare clipboard data with multiline text */
|
|
|
|
hmem = GlobalAlloc(GMEM_MOVEABLE, 255);
|
|
|
|
ok(hmem != NULL, "got %p (expected != NULL)\n", hmem);
|
|
|
|
buffer = GlobalLock(hmem);
|
|
|
|
ok(buffer != NULL, "got %p (expected != NULL)\n", buffer);
|
|
|
|
strcpy(buffer, str2);
|
|
|
|
GlobalUnlock(hmem);
|
|
|
|
|
|
|
|
r = OpenClipboard(hEdit);
|
|
|
|
ok(r == TRUE, "expected %d, got %d\n", TRUE, r);
|
|
|
|
r = EmptyClipboard();
|
|
|
|
ok(r == TRUE, "expected %d, got %d\n", TRUE, r);
|
|
|
|
hmem_ret = SetClipboardData(CF_TEXT, hmem);
|
|
|
|
ok(hmem_ret == hmem, "expected %p, got %p\n", hmem, hmem_ret);
|
|
|
|
r = CloseClipboard();
|
|
|
|
ok(r == TRUE, "expected %d, got %d\n", TRUE, r);
|
|
|
|
|
|
|
|
/* Paste multiline text in singleline edit - should be cut */
|
|
|
|
SendMessageA(hEdit, WM_SETTEXT, 0, (LPARAM)"");
|
|
|
|
r = SendMessageA(hEdit, WM_PASTE, 0, 0);
|
|
|
|
len = SendMessageA(hEdit, WM_GETTEXTLENGTH, 0, 0);
|
2017-11-08 22:12:45 +01:00
|
|
|
ok(strlen("first line") == len, "got %d\n", len);
|
2017-11-05 19:28:38 +01:00
|
|
|
|
|
|
|
/* Paste multiline text in multiline edit */
|
|
|
|
SendMessageA(hMultilineEdit, WM_SETTEXT, 0, (LPARAM)"");
|
|
|
|
r = SendMessageA(hMultilineEdit, WM_PASTE, 0, 0);
|
|
|
|
len = SendMessageA(hMultilineEdit, WM_GETTEXTLENGTH, 0, 0);
|
2017-11-08 22:12:45 +01:00
|
|
|
ok(strlen(str2) == len, "got %d\n", len);
|
2017-11-05 19:28:38 +01:00
|
|
|
|
|
|
|
/* Cleanup */
|
|
|
|
DestroyWindow(hEdit);
|
|
|
|
DestroyWindow(hMultilineEdit);
|
|
|
|
}
|
2013-05-03 09:22:44 +02:00
|
|
|
|
2018-01-12 12:26:51 +01:00
|
|
|
static void test_EM_GETLINE(void)
|
|
|
|
{
|
|
|
|
HWND hwnd[2];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
hwnd[0] = create_editcontrol(ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0);
|
|
|
|
hwnd[1] = create_editcontrolW(ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0);
|
|
|
|
|
2018-06-28 18:17:01 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(hwnd); i++)
|
2018-01-12 12:26:51 +01:00
|
|
|
{
|
|
|
|
static const WCHAR strW[] = {'t','e','x','t',0};
|
|
|
|
static const char *str = "text";
|
|
|
|
WCHAR buffW[16];
|
|
|
|
char buff[16];
|
|
|
|
int r;
|
|
|
|
|
|
|
|
if (i == 0)
|
|
|
|
ok(!IsWindowUnicode(hwnd[i]), "Expected ansi window.\n");
|
|
|
|
else
|
|
|
|
ok(IsWindowUnicode(hwnd[i]), "Expected unicode window.\n");
|
|
|
|
|
|
|
|
SendMessageA(hwnd[i], WM_SETTEXT, 0, (LPARAM)str);
|
|
|
|
|
|
|
|
memset(buff, 0, sizeof(buff));
|
|
|
|
*(WORD *)buff = sizeof(buff);
|
|
|
|
r = SendMessageA(hwnd[i], EM_GETLINE, 0, (LPARAM)buff);
|
|
|
|
ok(r == strlen(str), "Failed to get a line %d.\n", r);
|
|
|
|
ok(!strcmp(buff, str), "Unexpected line data %s.\n", buff);
|
|
|
|
|
|
|
|
memset(buff, 0, sizeof(buff));
|
|
|
|
*(WORD *)buff = sizeof(buff);
|
|
|
|
r = SendMessageA(hwnd[i], EM_GETLINE, 1, (LPARAM)buff);
|
|
|
|
ok(r == strlen(str), "Failed to get a line %d.\n", r);
|
|
|
|
ok(!strcmp(buff, str), "Unexpected line data %s.\n", buff);
|
|
|
|
|
|
|
|
memset(buffW, 0, sizeof(buffW));
|
2018-06-28 18:17:01 +02:00
|
|
|
*(WORD *)buffW = ARRAY_SIZE(buffW);
|
2018-01-12 12:26:51 +01:00
|
|
|
r = SendMessageW(hwnd[i], EM_GETLINE, 0, (LPARAM)buffW);
|
|
|
|
ok(r == lstrlenW(strW), "Failed to get a line %d.\n", r);
|
|
|
|
ok(!lstrcmpW(buffW, strW), "Unexpected line data %s.\n", wine_dbgstr_w(buffW));
|
|
|
|
|
|
|
|
memset(buffW, 0, sizeof(buffW));
|
2018-06-28 18:17:01 +02:00
|
|
|
*(WORD *)buffW = ARRAY_SIZE(buffW);
|
2018-01-12 12:26:51 +01:00
|
|
|
r = SendMessageW(hwnd[i], EM_GETLINE, 1, (LPARAM)buffW);
|
|
|
|
ok(r == lstrlenW(strW), "Failed to get a line %d.\n", r);
|
|
|
|
ok(!lstrcmpW(buffW, strW), "Unexpected line data %s.\n", wine_dbgstr_w(buffW));
|
|
|
|
|
|
|
|
DestroyWindow(hwnd[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-22 14:54:16 +01:00
|
|
|
static int CALLBACK test_wordbreak_procA(char *text, int current, int length, int code)
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_wordbreak_proc(void)
|
|
|
|
{
|
|
|
|
EDITWORDBREAKPROCA proc;
|
|
|
|
LRESULT ret;
|
|
|
|
HWND hwnd;
|
|
|
|
|
|
|
|
hwnd = create_editcontrol(ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0);
|
|
|
|
|
|
|
|
proc = (void *)SendMessageA(hwnd, EM_GETWORDBREAKPROC, 0, 0);
|
|
|
|
ok(proc == NULL, "Unexpected wordbreak proc %p.\n", proc);
|
|
|
|
|
|
|
|
ret = SendMessageA(hwnd, EM_SETWORDBREAKPROC, 0, (LPARAM)test_wordbreak_procA);
|
|
|
|
ok(ret == 1, "Unexpected return value %ld.\n", ret);
|
|
|
|
|
|
|
|
proc = (void *)SendMessageA(hwnd, EM_GETWORDBREAKPROC, 0, 0);
|
|
|
|
ok(proc == test_wordbreak_procA, "Unexpected wordbreak proc %p.\n", proc);
|
|
|
|
|
|
|
|
ret = SendMessageA(hwnd, EM_SETWORDBREAKPROC, 0, 0);
|
|
|
|
ok(ret == 1, "Unexpected return value %ld.\n", ret);
|
|
|
|
|
|
|
|
proc = (void *)SendMessageA(hwnd, EM_GETWORDBREAKPROC, 0, 0);
|
|
|
|
ok(proc == NULL, "Unexpected wordbreak proc %p.\n", proc);
|
|
|
|
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
}
|
|
|
|
|
2004-11-08 23:10:05 +01:00
|
|
|
START_TEST(edit)
|
|
|
|
{
|
2011-02-24 17:53:16 +01:00
|
|
|
BOOL b;
|
|
|
|
|
2005-09-06 13:40:01 +02:00
|
|
|
hinst = GetModuleHandleA(NULL);
|
2011-02-24 17:53:16 +01:00
|
|
|
b = RegisterWindowClasses();
|
|
|
|
ok (b, "RegisterWindowClasses failed\n");
|
|
|
|
if (!b) return;
|
2005-03-22 17:40:36 +01:00
|
|
|
|
|
|
|
test_edit_control_1();
|
|
|
|
test_edit_control_2();
|
2005-06-05 21:19:11 +02:00
|
|
|
test_edit_control_3();
|
2019-11-07 13:06:11 +01:00
|
|
|
test_char_from_pos();
|
2005-12-19 09:53:19 +01:00
|
|
|
test_edit_control_5();
|
2009-11-15 11:33:38 +01:00
|
|
|
test_edit_control_6();
|
2007-10-15 03:25:54 +02:00
|
|
|
test_edit_control_limittext();
|
2010-03-03 13:19:46 +01:00
|
|
|
test_edit_control_scroll();
|
2020-04-20 12:20:13 +02:00
|
|
|
test_initialization();
|
2005-06-25 20:32:07 +02:00
|
|
|
test_margins();
|
2006-03-22 13:16:44 +01:00
|
|
|
test_margins_font_change();
|
2005-09-06 13:40:01 +02:00
|
|
|
test_text_position();
|
2007-06-14 02:22:49 +02:00
|
|
|
test_espassword();
|
2007-09-12 06:34:10 +02:00
|
|
|
test_undo();
|
2008-04-07 23:01:00 +02:00
|
|
|
test_enter();
|
2008-04-07 23:07:04 +02:00
|
|
|
test_tab();
|
2008-03-27 19:48:44 +01:00
|
|
|
test_edit_dialog();
|
2008-04-02 20:04:23 +02:00
|
|
|
test_multi_edit_dialog();
|
2008-04-07 22:32:20 +02:00
|
|
|
test_wantreturn_edit_dialog();
|
2008-04-07 22:32:36 +02:00
|
|
|
test_singleline_wantreturn_edit_dialog();
|
2008-04-24 02:48:34 +02:00
|
|
|
test_child_edit_wmkeydown();
|
2008-10-15 14:30:22 +02:00
|
|
|
test_fontsize();
|
2009-08-23 23:10:01 +02:00
|
|
|
test_dialogmode();
|
2017-12-06 13:23:38 +01:00
|
|
|
test_contextmenu();
|
2013-05-03 09:22:44 +02:00
|
|
|
test_EM_GETHANDLE();
|
2017-11-05 19:28:38 +01:00
|
|
|
test_paste();
|
2018-01-12 12:26:51 +01:00
|
|
|
test_EM_GETLINE();
|
2018-01-22 14:54:16 +01:00
|
|
|
test_wordbreak_proc();
|
2013-05-03 09:22:44 +02:00
|
|
|
|
2005-09-06 13:40:01 +02:00
|
|
|
UnregisterWindowClasses();
|
2004-11-08 23:10:05 +01:00
|
|
|
}
|