2017-12-14 07:50:20 +01:00
|
|
|
/* Unit test suite for ComboBox and ComboBoxEx32 controls.
|
2005-09-21 11:41:44 +02:00
|
|
|
*
|
|
|
|
* Copyright 2005 Jason Edmeades
|
2017-12-14 07:50:20 +01:00
|
|
|
* Copyright 2007 Mikolaj Zalewski
|
2005-09-21 11:41:44 +02: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
|
2005-09-21 11:41:44 +02:00
|
|
|
*/
|
|
|
|
|
2017-12-14 07:50:20 +01:00
|
|
|
#include <limits.h>
|
|
|
|
#include <stdio.h>
|
2005-09-21 11:41:44 +02:00
|
|
|
#include <windows.h>
|
|
|
|
#include <commctrl.h>
|
|
|
|
|
|
|
|
#include "wine/test.h"
|
2017-12-14 07:50:20 +01:00
|
|
|
#include "v6util.h"
|
2009-12-23 20:51:54 +01:00
|
|
|
#include "msg.h"
|
|
|
|
|
|
|
|
#define EDITBOX_SEQ_INDEX 0
|
|
|
|
#define NUM_MSG_SEQUENCES 1
|
|
|
|
|
|
|
|
#define EDITBOX_ID 0
|
2017-12-14 07:50:20 +01:00
|
|
|
#define COMBO_ID 1995
|
2009-12-23 20:51:54 +01:00
|
|
|
|
2009-12-23 21:08:32 +01:00
|
|
|
#define expect(expected, got) ok(got == expected, "Expected %d, got %d\n", expected, got)
|
|
|
|
|
2017-12-14 07:50:20 +01:00
|
|
|
#define expect_rect(r, _left, _top, _right, _bottom) ok(r.left == _left && r.top == _top && \
|
|
|
|
r.bottom == _bottom && r.right == _right, "Invalid rect %s vs (%d,%d)-(%d,%d)\n", \
|
|
|
|
wine_dbgstr_rect(&r), _left, _top, _right, _bottom);
|
|
|
|
|
|
|
|
|
2009-12-23 20:51:54 +01:00
|
|
|
static struct msg_sequence *sequences[NUM_MSG_SEQUENCES];
|
2005-09-21 11:41:44 +02:00
|
|
|
|
2017-12-14 07:50:20 +01:00
|
|
|
static HWND hComboExParentWnd, hMainWnd;
|
2005-09-21 11:41:44 +02:00
|
|
|
static HINSTANCE hMainHinst;
|
2006-01-24 14:00:32 +01:00
|
|
|
static const char ComboExTestClass[] = "ComboExTestClass";
|
2005-09-21 11:41:44 +02:00
|
|
|
|
2009-12-23 20:50:26 +01:00
|
|
|
static BOOL (WINAPI *pSetWindowSubclass)(HWND, SUBCLASSPROC, UINT_PTR, DWORD_PTR);
|
|
|
|
|
2005-09-21 11:41:44 +02:00
|
|
|
#define MAX_CHARS 100
|
|
|
|
static char *textBuffer = NULL;
|
|
|
|
|
2011-06-23 20:56:14 +02:00
|
|
|
static BOOL received_end_edit = FALSE;
|
|
|
|
|
2017-12-14 07:50:20 +01:00
|
|
|
static void get_combobox_info(HWND hwnd, COMBOBOXINFO *info)
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
info->cbSize = sizeof(*info);
|
|
|
|
ret = GetComboBoxInfo(hwnd, info);
|
|
|
|
ok(ret, "Failed to get combobox info structure, error %d\n", GetLastError());
|
|
|
|
}
|
|
|
|
|
2005-09-21 11:41:44 +02:00
|
|
|
static HWND createComboEx(DWORD style) {
|
|
|
|
return CreateWindowExA(0, WC_COMBOBOXEXA, NULL, style, 0, 0, 300, 300,
|
|
|
|
hComboExParentWnd, NULL, hMainHinst, NULL);
|
|
|
|
}
|
|
|
|
|
2013-10-22 17:12:18 +02:00
|
|
|
static LONG addItem(HWND cbex, int idx, const char *text) {
|
|
|
|
COMBOBOXEXITEMA cbexItem;
|
2005-09-21 11:41:44 +02:00
|
|
|
memset(&cbexItem, 0x00, sizeof(cbexItem));
|
|
|
|
cbexItem.mask = CBEIF_TEXT;
|
|
|
|
cbexItem.iItem = idx;
|
2013-10-22 17:12:18 +02:00
|
|
|
cbexItem.pszText = (char*)text;
|
2005-09-21 11:41:44 +02:00
|
|
|
cbexItem.cchTextMax = 0;
|
2013-10-22 17:12:18 +02:00
|
|
|
return SendMessageA(cbex, CBEM_INSERTITEMA, 0, (LPARAM)&cbexItem);
|
2005-09-21 11:41:44 +02:00
|
|
|
}
|
|
|
|
|
2013-10-22 17:12:18 +02:00
|
|
|
static LONG setItem(HWND cbex, int idx, const char *text) {
|
|
|
|
COMBOBOXEXITEMA cbexItem;
|
2005-09-21 11:41:44 +02:00
|
|
|
memset(&cbexItem, 0x00, sizeof(cbexItem));
|
|
|
|
cbexItem.mask = CBEIF_TEXT;
|
|
|
|
cbexItem.iItem = idx;
|
2013-10-22 17:12:18 +02:00
|
|
|
cbexItem.pszText = (char*)text;
|
2005-09-21 11:41:44 +02:00
|
|
|
cbexItem.cchTextMax = 0;
|
2013-10-22 17:12:18 +02:00
|
|
|
return SendMessageA(cbex, CBEM_SETITEMA, 0, (LPARAM)&cbexItem);
|
2005-09-21 11:41:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static LONG delItem(HWND cbex, int idx) {
|
2013-10-22 17:12:18 +02:00
|
|
|
return SendMessageA(cbex, CBEM_DELETEITEM, idx, 0);
|
2005-09-21 11:41:44 +02:00
|
|
|
}
|
|
|
|
|
2013-10-22 17:12:18 +02:00
|
|
|
static LONG getItem(HWND cbex, int idx, COMBOBOXEXITEMA *cbItem) {
|
|
|
|
memset(cbItem, 0x00, sizeof(COMBOBOXEXITEMA));
|
2005-09-21 11:41:44 +02:00
|
|
|
cbItem->mask = CBEIF_TEXT;
|
|
|
|
cbItem->pszText = textBuffer;
|
|
|
|
cbItem->iItem = idx;
|
|
|
|
cbItem->cchTextMax = 100;
|
2013-10-22 17:12:18 +02:00
|
|
|
return SendMessageA(cbex, CBEM_GETITEMA, 0, (LPARAM)cbItem);
|
2005-09-21 11:41:44 +02:00
|
|
|
}
|
|
|
|
|
2009-12-23 20:51:54 +01:00
|
|
|
static LRESULT WINAPI editbox_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
WNDPROC oldproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_USERDATA);
|
|
|
|
static LONG defwndproc_counter = 0;
|
2017-04-30 20:20:28 +02:00
|
|
|
struct message msg = { 0 };
|
2009-12-23 20:51:54 +01:00
|
|
|
LRESULT ret;
|
|
|
|
|
|
|
|
msg.message = message;
|
|
|
|
msg.flags = sent|wparam|lparam;
|
|
|
|
if (defwndproc_counter) msg.flags |= defwinproc;
|
|
|
|
msg.wParam = wParam;
|
|
|
|
msg.lParam = lParam;
|
|
|
|
msg.id = EDITBOX_ID;
|
|
|
|
|
|
|
|
if (message != WM_PAINT &&
|
|
|
|
message != WM_ERASEBKGND &&
|
|
|
|
message != WM_NCPAINT &&
|
|
|
|
message != WM_NCHITTEST &&
|
|
|
|
message != WM_GETTEXT &&
|
|
|
|
message != WM_GETICON &&
|
|
|
|
message != WM_DEVICECHANGE)
|
|
|
|
{
|
|
|
|
add_message(sequences, EDITBOX_SEQ_INDEX, &msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
defwndproc_counter++;
|
|
|
|
ret = CallWindowProcA(oldproc, hwnd, message, wParam, lParam);
|
|
|
|
defwndproc_counter--;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HWND subclass_editbox(HWND hwndComboEx)
|
|
|
|
{
|
|
|
|
WNDPROC oldproc;
|
|
|
|
HWND hwnd;
|
|
|
|
|
2013-10-22 17:12:18 +02:00
|
|
|
hwnd = (HWND)SendMessageA(hwndComboEx, CBEM_GETEDITCONTROL, 0, 0);
|
2009-12-23 20:51:54 +01:00
|
|
|
oldproc = (WNDPROC)SetWindowLongPtrA(hwnd, GWLP_WNDPROC,
|
|
|
|
(LONG_PTR)editbox_subclass_proc);
|
|
|
|
SetWindowLongPtrA(hwnd, GWLP_USERDATA, (LONG_PTR)oldproc);
|
|
|
|
|
|
|
|
return hwnd;
|
|
|
|
}
|
|
|
|
|
2017-12-14 07:50:20 +01:00
|
|
|
static void test_comboex(void)
|
|
|
|
{
|
2005-09-21 11:41:44 +02:00
|
|
|
HWND myHwnd = 0;
|
2014-10-31 03:24:38 +01:00
|
|
|
LONG res;
|
2013-10-22 17:12:18 +02:00
|
|
|
COMBOBOXEXITEMA cbexItem;
|
|
|
|
static const char *first_item = "First Item",
|
|
|
|
*second_item = "Second Item",
|
|
|
|
*third_item = "Third Item",
|
|
|
|
*middle_item = "Between First and Second Items",
|
|
|
|
*replacement_item = "Between First and Second Items",
|
|
|
|
*out_of_range_item = "Out of Range Item";
|
2005-09-21 11:41:44 +02:00
|
|
|
|
|
|
|
/* Allocate space for result */
|
2018-02-15 09:00:08 +01:00
|
|
|
textBuffer = heap_alloc(MAX_CHARS);
|
2005-09-21 11:41:44 +02:00
|
|
|
|
|
|
|
/* Basic comboboxex test */
|
|
|
|
myHwnd = createComboEx(WS_BORDER | WS_VISIBLE | WS_CHILD | CBS_DROPDOWN);
|
|
|
|
|
|
|
|
/* Add items onto the end of the combobox */
|
2006-07-29 18:17:20 +02:00
|
|
|
res = addItem(myHwnd, -1, first_item);
|
2006-10-13 15:17:40 +02:00
|
|
|
ok(res == 0, "Adding simple item failed (%d)\n", res);
|
2006-07-29 18:17:20 +02:00
|
|
|
res = addItem(myHwnd, -1, second_item);
|
2006-10-13 15:17:40 +02:00
|
|
|
ok(res == 1, "Adding simple item failed (%d)\n", res);
|
2006-07-29 18:17:20 +02:00
|
|
|
res = addItem(myHwnd, 2, third_item);
|
2006-10-13 15:17:40 +02:00
|
|
|
ok(res == 2, "Adding simple item failed (%d)\n", res);
|
2006-07-29 18:17:20 +02:00
|
|
|
res = addItem(myHwnd, 1, middle_item);
|
2006-10-13 15:17:40 +02:00
|
|
|
ok(res == 1, "Inserting simple item failed (%d)\n", res);
|
2005-09-21 11:41:44 +02:00
|
|
|
|
|
|
|
/* Add an item completely out of range */
|
2006-07-29 18:17:20 +02:00
|
|
|
res = addItem(myHwnd, 99, out_of_range_item);
|
2006-10-13 15:17:40 +02:00
|
|
|
ok(res == -1, "Adding using out of range index worked unexpectedly (%d)\n", res);
|
2006-07-29 18:17:20 +02:00
|
|
|
res = addItem(myHwnd, 5, out_of_range_item);
|
2006-10-13 15:17:40 +02:00
|
|
|
ok(res == -1, "Adding using out of range index worked unexpectedly (%d)\n", res);
|
2005-09-21 11:41:44 +02:00
|
|
|
/* Removed: Causes traps on Windows XP
|
|
|
|
res = addItem(myHwnd, -2, "Out Of Range Item");
|
|
|
|
ok(res == -1, "Adding out of range worked unexpectedly (%ld)\n", res);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Get an item completely out of range */
|
|
|
|
res = getItem(myHwnd, 99, &cbexItem);
|
2006-10-13 15:17:40 +02:00
|
|
|
ok(res == 0, "Getting item using out of range index worked unexpectedly (%d, %s)\n", res, cbexItem.pszText);
|
2005-09-21 11:41:44 +02:00
|
|
|
res = getItem(myHwnd, 4, &cbexItem);
|
2006-10-13 15:17:40 +02:00
|
|
|
ok(res == 0, "Getting item using out of range index worked unexpectedly (%d, %s)\n", res, cbexItem.pszText);
|
2005-09-21 11:41:44 +02:00
|
|
|
res = getItem(myHwnd, -2, &cbexItem);
|
2006-10-13 15:17:40 +02:00
|
|
|
ok(res == 0, "Getting item using out of range index worked unexpectedly (%d, %s)\n", res, cbexItem.pszText);
|
2005-09-21 11:41:44 +02:00
|
|
|
|
|
|
|
/* Get an item in range */
|
|
|
|
res = getItem(myHwnd, 0, &cbexItem);
|
2006-10-13 15:17:40 +02:00
|
|
|
ok(res != 0, "Getting item using valid index failed unexpectedly (%d)\n", res);
|
2006-07-29 18:17:20 +02:00
|
|
|
ok(strcmp(first_item, cbexItem.pszText) == 0, "Getting item returned wrong string (%s)\n", cbexItem.pszText);
|
2005-09-21 11:41:44 +02:00
|
|
|
|
|
|
|
res = getItem(myHwnd, 1, &cbexItem);
|
2006-10-13 15:17:40 +02:00
|
|
|
ok(res != 0, "Getting item using valid index failed unexpectedly (%d)\n", res);
|
2006-07-29 18:17:20 +02:00
|
|
|
ok(strcmp(middle_item, cbexItem.pszText) == 0, "Getting item returned wrong string (%s)\n", cbexItem.pszText);
|
2005-09-21 11:41:44 +02:00
|
|
|
|
|
|
|
res = getItem(myHwnd, 2, &cbexItem);
|
2006-10-13 15:17:40 +02:00
|
|
|
ok(res != 0, "Getting item using valid index failed unexpectedly (%d)\n", res);
|
2006-07-29 18:17:20 +02:00
|
|
|
ok(strcmp(second_item, cbexItem.pszText) == 0, "Getting item returned wrong string (%s)\n", cbexItem.pszText);
|
2005-09-21 11:41:44 +02:00
|
|
|
|
|
|
|
res = getItem(myHwnd, 3, &cbexItem);
|
2006-10-13 15:17:40 +02:00
|
|
|
ok(res != 0, "Getting item using valid index failed unexpectedly (%d)\n", res);
|
2006-07-29 18:17:20 +02:00
|
|
|
ok(strcmp(third_item, cbexItem.pszText) == 0, "Getting item returned wrong string (%s)\n", cbexItem.pszText);
|
2005-09-21 11:41:44 +02:00
|
|
|
|
|
|
|
/* Set an item completely out of range */
|
2006-07-29 18:17:20 +02:00
|
|
|
res = setItem(myHwnd, 99, replacement_item);
|
2006-10-13 15:17:40 +02:00
|
|
|
ok(res == 0, "Setting item using out of range index worked unexpectedly (%d)\n", res);
|
2006-07-29 18:17:20 +02:00
|
|
|
res = setItem(myHwnd, 4, replacement_item);
|
2006-10-13 15:17:40 +02:00
|
|
|
ok(res == 0, "Setting item using out of range index worked unexpectedly (%d)\n", res);
|
2006-07-29 18:17:20 +02:00
|
|
|
res = setItem(myHwnd, -2, replacement_item);
|
2006-10-13 15:17:40 +02:00
|
|
|
ok(res == 0, "Setting item using out of range index worked unexpectedly (%d)\n", res);
|
2005-09-21 11:41:44 +02:00
|
|
|
|
|
|
|
/* Set an item in range */
|
2006-07-29 18:17:20 +02:00
|
|
|
res = setItem(myHwnd, 0, replacement_item);
|
2006-10-13 15:17:40 +02:00
|
|
|
ok(res != 0, "Setting first item failed (%d)\n", res);
|
2006-07-29 18:17:20 +02:00
|
|
|
res = setItem(myHwnd, 3, replacement_item);
|
2006-10-13 15:17:40 +02:00
|
|
|
ok(res != 0, "Setting last item failed (%d)\n", res);
|
2005-09-21 11:41:44 +02:00
|
|
|
|
|
|
|
/* Remove items completely out of range (4 items in control at this point) */
|
|
|
|
res = delItem(myHwnd, -1);
|
2006-10-13 15:17:40 +02:00
|
|
|
ok(res == CB_ERR, "Deleting using out of range index worked unexpectedly (%d)\n", res);
|
2005-09-21 11:41:44 +02:00
|
|
|
res = delItem(myHwnd, 4);
|
2006-10-13 15:17:40 +02:00
|
|
|
ok(res == CB_ERR, "Deleting using out of range index worked unexpectedly (%d)\n", res);
|
2005-09-21 11:41:44 +02:00
|
|
|
|
|
|
|
/* Remove items in range (4 items in control at this point) */
|
|
|
|
res = delItem(myHwnd, 3);
|
2006-10-13 15:17:40 +02:00
|
|
|
ok(res == 3, "Deleting using out of range index failed (%d)\n", res);
|
2005-09-21 11:41:44 +02:00
|
|
|
res = delItem(myHwnd, 0);
|
2006-10-13 15:17:40 +02:00
|
|
|
ok(res == 2, "Deleting using out of range index failed (%d)\n", res);
|
2005-09-21 11:41:44 +02:00
|
|
|
res = delItem(myHwnd, 0);
|
2006-10-13 15:17:40 +02:00
|
|
|
ok(res == 1, "Deleting using out of range index failed (%d)\n", res);
|
2005-09-21 11:41:44 +02:00
|
|
|
res = delItem(myHwnd, 0);
|
2006-10-13 15:17:40 +02:00
|
|
|
ok(res == 0, "Deleting using out of range index failed (%d)\n", res);
|
2005-09-21 11:41:44 +02:00
|
|
|
|
|
|
|
/* Remove from an empty box */
|
|
|
|
res = delItem(myHwnd, 0);
|
2006-10-13 15:17:40 +02:00
|
|
|
ok(res == CB_ERR, "Deleting using out of range index worked unexpectedly (%d)\n", res);
|
2005-09-21 11:41:44 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* Cleanup */
|
2018-02-15 09:00:08 +01:00
|
|
|
heap_free(textBuffer);
|
2008-07-03 17:37:10 +02:00
|
|
|
DestroyWindow(myHwnd);
|
|
|
|
}
|
|
|
|
|
2017-12-14 07:50:20 +01:00
|
|
|
static void test_comboex_WM_LBUTTONDOWN(void)
|
2008-07-03 17:37:10 +02:00
|
|
|
{
|
|
|
|
HWND hComboEx, hCombo, hEdit, hList;
|
|
|
|
COMBOBOXINFO cbInfo;
|
|
|
|
UINT x, y, item_height;
|
|
|
|
LRESULT result;
|
2010-10-02 01:29:45 +02:00
|
|
|
UINT i;
|
|
|
|
int idx;
|
2008-07-03 17:37:10 +02:00
|
|
|
RECT rect;
|
|
|
|
WCHAR buffer[3];
|
|
|
|
static const UINT choices[] = {8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72};
|
|
|
|
static const WCHAR stringFormat[] = {'%','2','d','\0'};
|
|
|
|
|
|
|
|
hComboEx = CreateWindowExA(0, WC_COMBOBOXEXA, NULL,
|
|
|
|
WS_VISIBLE|WS_CHILD|CBS_DROPDOWN, 0, 0, 200, 150,
|
|
|
|
hComboExParentWnd, NULL, hMainHinst, NULL);
|
|
|
|
|
2018-06-06 20:36:15 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(choices); i++){
|
2008-07-03 17:37:10 +02:00
|
|
|
COMBOBOXEXITEMW cbexItem;
|
|
|
|
wsprintfW(buffer, stringFormat, choices[i]);
|
|
|
|
|
|
|
|
memset(&cbexItem, 0x00, sizeof(cbexItem));
|
|
|
|
cbexItem.mask = CBEIF_TEXT;
|
|
|
|
cbexItem.iItem = i;
|
|
|
|
cbexItem.pszText = buffer;
|
|
|
|
cbexItem.cchTextMax = 0;
|
|
|
|
ok(SendMessageW(hComboEx, CBEM_INSERTITEMW, 0, (LPARAM)&cbexItem) >= 0,
|
|
|
|
"Failed to add item %d\n", i);
|
|
|
|
}
|
2005-09-21 11:41:44 +02:00
|
|
|
|
2013-10-22 17:12:18 +02:00
|
|
|
hCombo = (HWND)SendMessageA(hComboEx, CBEM_GETCOMBOCONTROL, 0, 0);
|
|
|
|
hEdit = (HWND)SendMessageA(hComboEx, CBEM_GETEDITCONTROL, 0, 0);
|
2008-07-03 17:37:10 +02:00
|
|
|
|
2017-12-14 07:50:20 +01:00
|
|
|
get_combobox_info(hCombo, &cbInfo);
|
2008-07-03 17:37:10 +02:00
|
|
|
hList = cbInfo.hwndList;
|
|
|
|
|
|
|
|
ok(GetFocus() == hComboExParentWnd,
|
|
|
|
"Focus not on Main Window, instead on %p\n", GetFocus());
|
|
|
|
|
|
|
|
/* Click on the button to drop down the list */
|
|
|
|
x = cbInfo.rcButton.left + (cbInfo.rcButton.right-cbInfo.rcButton.left)/2;
|
|
|
|
y = cbInfo.rcButton.top + (cbInfo.rcButton.bottom-cbInfo.rcButton.top)/2;
|
2013-10-22 17:12:18 +02:00
|
|
|
result = SendMessageA(hCombo, WM_LBUTTONDOWN, 0, MAKELPARAM(x, y));
|
2008-07-03 17:37:10 +02:00
|
|
|
ok(result, "WM_LBUTTONDOWN was not processed. LastError=%d\n",
|
|
|
|
GetLastError());
|
2008-08-29 04:17:44 +02:00
|
|
|
ok(GetFocus() == hCombo ||
|
|
|
|
broken(GetFocus() != hCombo), /* win98 */
|
2008-07-03 17:37:10 +02:00
|
|
|
"Focus not on ComboBoxEx's ComboBox Control, instead on %p\n",
|
|
|
|
GetFocus());
|
2013-10-22 17:12:18 +02:00
|
|
|
ok(SendMessageA(hComboEx, CB_GETDROPPEDSTATE, 0, 0),
|
2008-07-03 17:37:10 +02:00
|
|
|
"The dropdown list should have appeared after clicking the button.\n");
|
2013-10-22 17:12:18 +02:00
|
|
|
idx = SendMessageA(hCombo, CB_GETTOPINDEX, 0, 0);
|
2008-07-03 17:37:10 +02:00
|
|
|
ok(idx == 0, "For TopIndex expected %d, got %d\n", 0, idx);
|
|
|
|
|
2013-10-22 17:12:18 +02:00
|
|
|
result = SendMessageA(hCombo, WM_LBUTTONUP, 0, MAKELPARAM(x, y));
|
2008-07-03 17:37:10 +02:00
|
|
|
ok(result, "WM_LBUTTONUP was not processed. LastError=%d\n",
|
|
|
|
GetLastError());
|
2008-08-29 04:17:44 +02:00
|
|
|
ok(GetFocus() == hCombo ||
|
|
|
|
broken(GetFocus() != hCombo), /* win98 */
|
2008-07-03 17:37:10 +02:00
|
|
|
"Focus not on ComboBoxEx's ComboBox Control, instead on %p\n",
|
|
|
|
GetFocus());
|
|
|
|
|
|
|
|
/* Click on the 5th item in the list */
|
2013-10-22 17:12:18 +02:00
|
|
|
item_height = SendMessageA(hCombo, CB_GETITEMHEIGHT, 0, 0);
|
2008-07-03 17:37:10 +02:00
|
|
|
ok(GetClientRect(hList, &rect), "Failed to get list's client rect.\n");
|
|
|
|
x = rect.left + (rect.right-rect.left)/2;
|
|
|
|
y = item_height/2 + item_height*4;
|
2013-10-22 17:12:18 +02:00
|
|
|
result = SendMessageA(hList, WM_MOUSEMOVE, 0, MAKELPARAM(x, y));
|
2008-07-03 17:37:10 +02:00
|
|
|
ok(!result, "WM_MOUSEMOVE was not processed. LastError=%d\n",
|
|
|
|
GetLastError());
|
2008-08-29 04:17:44 +02:00
|
|
|
ok(GetFocus() == hCombo ||
|
|
|
|
broken(GetFocus() != hCombo), /* win98 */
|
2008-07-03 17:37:10 +02:00
|
|
|
"Focus not on ComboBoxEx's ComboBox Control, instead on %p\n",
|
|
|
|
GetFocus());
|
|
|
|
|
2013-10-22 17:12:18 +02:00
|
|
|
result = SendMessageA(hList, WM_LBUTTONDOWN, 0, MAKELPARAM(x, y));
|
2008-07-03 17:37:10 +02:00
|
|
|
ok(!result, "WM_LBUTTONDOWN was not processed. LastError=%d\n",
|
|
|
|
GetLastError());
|
2008-08-29 04:17:44 +02:00
|
|
|
ok(GetFocus() == hCombo ||
|
|
|
|
broken(GetFocus() != hCombo), /* win98 */
|
2008-07-03 17:37:10 +02:00
|
|
|
"Focus not on ComboBoxEx's ComboBox Control, instead on %p\n",
|
|
|
|
GetFocus());
|
2013-10-22 17:12:18 +02:00
|
|
|
ok(SendMessageA(hComboEx, CB_GETDROPPEDSTATE, 0, 0),
|
2008-07-03 17:37:10 +02:00
|
|
|
"The dropdown list should still be visible.\n");
|
|
|
|
|
2013-10-22 17:12:18 +02:00
|
|
|
result = SendMessageA(hList, WM_LBUTTONUP, 0, MAKELPARAM(x, y));
|
2008-07-03 17:37:10 +02:00
|
|
|
ok(!result, "WM_LBUTTONUP was not processed. LastError=%d\n",
|
|
|
|
GetLastError());
|
2008-09-03 05:43:00 +02:00
|
|
|
todo_wine ok(GetFocus() == hEdit ||
|
|
|
|
broken(GetFocus() == hCombo), /* win98 */
|
2008-07-03 17:37:10 +02:00
|
|
|
"Focus not on ComboBoxEx's Edit Control, instead on %p\n",
|
|
|
|
GetFocus());
|
2008-08-29 04:17:44 +02:00
|
|
|
|
2013-10-22 17:12:18 +02:00
|
|
|
result = SendMessageA(hCombo, CB_GETDROPPEDSTATE, 0, 0);
|
2008-08-29 04:17:44 +02:00
|
|
|
ok(!result ||
|
|
|
|
broken(result != 0), /* win98 */
|
2008-07-03 17:37:10 +02:00
|
|
|
"The dropdown list should have been rolled up.\n");
|
2013-10-22 17:12:18 +02:00
|
|
|
idx = SendMessageA(hComboEx, CB_GETCURSEL, 0, 0);
|
2008-08-29 04:17:44 +02:00
|
|
|
ok(idx == 4 ||
|
|
|
|
broken(idx == -1), /* win98 */
|
|
|
|
"Current Selection: expected %d, got %d\n", 4, idx);
|
2011-06-23 20:56:14 +02:00
|
|
|
ok(received_end_edit, "Expected to receive a CBEN_ENDEDIT message\n");
|
2008-07-03 17:37:10 +02:00
|
|
|
|
2012-09-25 13:40:17 +02:00
|
|
|
SetFocus( hComboExParentWnd );
|
|
|
|
ok( GetFocus() == hComboExParentWnd, "got %p\n", GetFocus() );
|
|
|
|
SetFocus( hComboEx );
|
|
|
|
ok( GetFocus() == hEdit, "got %p\n", GetFocus() );
|
|
|
|
|
2008-07-03 17:37:10 +02:00
|
|
|
DestroyWindow(hComboEx);
|
2005-09-21 11:41:44 +02:00
|
|
|
}
|
|
|
|
|
2017-12-14 07:50:20 +01:00
|
|
|
static void test_comboex_CB_GETLBTEXT(void)
|
2009-10-13 18:59:39 +02:00
|
|
|
{
|
|
|
|
HWND hCombo;
|
|
|
|
CHAR buff[1];
|
|
|
|
COMBOBOXEXITEMA item;
|
|
|
|
LRESULT ret;
|
|
|
|
|
|
|
|
hCombo = createComboEx(WS_BORDER | WS_VISIBLE | WS_CHILD | CBS_DROPDOWN);
|
|
|
|
|
|
|
|
/* set text to null */
|
|
|
|
addItem(hCombo, 0, NULL);
|
|
|
|
|
|
|
|
buff[0] = 'a';
|
|
|
|
item.mask = CBEIF_TEXT;
|
|
|
|
item.iItem = 0;
|
|
|
|
item.pszText = buff;
|
|
|
|
item.cchTextMax = 1;
|
2013-10-22 17:12:18 +02:00
|
|
|
ret = SendMessageA(hCombo, CBEM_GETITEMA, 0, (LPARAM)&item);
|
2009-10-13 18:59:39 +02:00
|
|
|
ok(ret != 0, "CBEM_GETITEM failed\n");
|
|
|
|
ok(buff[0] == 0, "\n");
|
|
|
|
|
2013-10-22 17:12:18 +02:00
|
|
|
ret = SendMessageA(hCombo, CB_GETLBTEXTLEN, 0, 0);
|
2009-10-13 18:59:39 +02:00
|
|
|
ok(ret == 0, "Expected zero length\n");
|
|
|
|
|
2013-10-22 17:12:18 +02:00
|
|
|
ret = SendMessageA(hCombo, CB_GETLBTEXTLEN, 0, 0);
|
2009-10-13 18:59:39 +02:00
|
|
|
ok(ret == 0, "Expected zero length\n");
|
|
|
|
|
|
|
|
buff[0] = 'a';
|
2013-10-22 17:12:18 +02:00
|
|
|
ret = SendMessageA(hCombo, CB_GETLBTEXT, 0, (LPARAM)buff);
|
2009-10-13 18:59:39 +02:00
|
|
|
ok(ret == 0, "Expected zero length\n");
|
|
|
|
ok(buff[0] == 0, "Expected null terminator as a string, got %s\n", buff);
|
|
|
|
|
|
|
|
DestroyWindow(hCombo);
|
|
|
|
}
|
|
|
|
|
2017-12-14 07:50:20 +01:00
|
|
|
static void test_comboex_WM_WINDOWPOSCHANGING(void)
|
2011-02-06 17:41:30 +01:00
|
|
|
{
|
|
|
|
HWND hCombo;
|
|
|
|
WINDOWPOS wp;
|
|
|
|
RECT rect;
|
|
|
|
int combo_height;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
hCombo = createComboEx(WS_BORDER | WS_VISIBLE | WS_CHILD | CBS_DROPDOWN);
|
|
|
|
ok(hCombo != NULL, "createComboEx failed\n");
|
|
|
|
ret = GetWindowRect(hCombo, &rect);
|
|
|
|
ok(ret, "GetWindowRect failed\n");
|
|
|
|
combo_height = rect.bottom - rect.top;
|
|
|
|
ok(combo_height > 0, "wrong combo height\n");
|
|
|
|
|
|
|
|
/* Test height > combo_height */
|
|
|
|
wp.x = rect.left;
|
|
|
|
wp.y = rect.top;
|
|
|
|
wp.cx = (rect.right - rect.left);
|
|
|
|
wp.cy = combo_height * 2;
|
|
|
|
wp.flags = 0;
|
|
|
|
wp.hwnd = hCombo;
|
|
|
|
wp.hwndInsertAfter = NULL;
|
|
|
|
|
|
|
|
ret = SendMessageA(hCombo, WM_WINDOWPOSCHANGING, 0, (LPARAM)&wp);
|
2011-03-05 11:50:23 +01:00
|
|
|
ok(ret == 0, "expected 0, got %x\n", ret);
|
2011-02-06 17:41:30 +01:00
|
|
|
ok(wp.cy == combo_height,
|
|
|
|
"Expected height %d, got %d\n", combo_height, wp.cy);
|
|
|
|
|
|
|
|
/* Test height < combo_height */
|
|
|
|
wp.x = rect.left;
|
|
|
|
wp.y = rect.top;
|
|
|
|
wp.cx = (rect.right - rect.left);
|
|
|
|
wp.cy = combo_height / 2;
|
|
|
|
wp.flags = 0;
|
|
|
|
wp.hwnd = hCombo;
|
|
|
|
wp.hwndInsertAfter = NULL;
|
|
|
|
|
|
|
|
ret = SendMessageA(hCombo, WM_WINDOWPOSCHANGING, 0, (LPARAM)&wp);
|
2011-03-05 11:50:23 +01:00
|
|
|
ok(ret == 0, "expected 0, got %x\n", ret);
|
2011-02-06 17:41:30 +01:00
|
|
|
ok(wp.cy == combo_height,
|
|
|
|
"Expected height %d, got %d\n", combo_height, wp.cy);
|
|
|
|
|
|
|
|
ret = DestroyWindow(hCombo);
|
|
|
|
ok(ret, "DestroyWindow failed\n");
|
|
|
|
}
|
|
|
|
|
2011-06-23 20:56:14 +02:00
|
|
|
static LRESULT ComboExTestOnNotify(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
NMHDR *hdr = (NMHDR*)lParam;
|
|
|
|
switch(hdr->code){
|
|
|
|
case CBEN_ENDEDITA:
|
|
|
|
{
|
|
|
|
NMCBEENDEDITA *edit_info = (NMCBEENDEDITA*)hdr;
|
|
|
|
if(edit_info->iWhy==CBENF_DROPDOWN){
|
|
|
|
received_end_edit = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CBEN_ENDEDITW:
|
|
|
|
{
|
|
|
|
NMCBEENDEDITW *edit_info = (NMCBEENDEDITW*)hdr;
|
|
|
|
if(edit_info->iWhy==CBENF_DROPDOWN){
|
|
|
|
received_end_edit = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-12-11 21:22:02 +01:00
|
|
|
static LRESULT CALLBACK ComboExTestWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
2005-09-21 11:41:44 +02:00
|
|
|
{
|
|
|
|
switch(msg) {
|
2006-12-11 21:22:02 +01:00
|
|
|
|
2005-09-21 11:41:44 +02:00
|
|
|
case WM_DESTROY:
|
|
|
|
PostQuitMessage(0);
|
|
|
|
break;
|
2011-06-23 20:56:14 +02:00
|
|
|
case WM_NOTIFY:
|
|
|
|
return ComboExTestOnNotify(hWnd,msg,wParam,lParam);
|
2005-09-21 11:41:44 +02:00
|
|
|
default:
|
|
|
|
return DefWindowProcA(hWnd, msg, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0L;
|
|
|
|
}
|
|
|
|
|
2018-01-24 13:47:09 +01:00
|
|
|
static void init_functions(void)
|
2008-02-05 11:59:47 +01:00
|
|
|
{
|
2018-01-24 13:47:09 +01:00
|
|
|
HMODULE hComCtl32 = LoadLibraryA("comctl32.dll");
|
2008-02-05 11:59:47 +01:00
|
|
|
|
2018-01-24 13:47:09 +01:00
|
|
|
#define X(f) p##f = (void*)GetProcAddress(hComCtl32, #f);
|
|
|
|
#define X2(f, ord) p##f = (void*)GetProcAddress(hComCtl32, (const char *)ord);
|
|
|
|
X2(SetWindowSubclass, 410);
|
|
|
|
#undef X
|
|
|
|
#undef X2
|
|
|
|
}
|
2005-09-21 11:41:44 +02:00
|
|
|
|
2018-01-24 13:47:09 +01:00
|
|
|
static BOOL init(void)
|
|
|
|
{
|
|
|
|
WNDCLASSA wc;
|
2009-12-23 20:50:26 +01:00
|
|
|
|
2005-09-21 11:41:44 +02:00
|
|
|
wc.style = CS_HREDRAW | CS_VREDRAW;
|
|
|
|
wc.cbClsExtra = 0;
|
|
|
|
wc.cbWndExtra = 0;
|
|
|
|
wc.hInstance = GetModuleHandleA(NULL);
|
|
|
|
wc.hIcon = NULL;
|
2013-12-04 00:49:00 +01:00
|
|
|
wc.hCursor = LoadCursorA(NULL, (LPCSTR)IDC_ARROW);
|
2005-09-21 11:41:44 +02:00
|
|
|
wc.hbrBackground = GetSysColorBrush(COLOR_WINDOW);
|
|
|
|
wc.lpszMenuName = NULL;
|
|
|
|
wc.lpszClassName = ComboExTestClass;
|
|
|
|
wc.lpfnWndProc = ComboExTestWndProc;
|
|
|
|
RegisterClassA(&wc);
|
|
|
|
|
2018-02-14 06:33:50 +01:00
|
|
|
hMainWnd = CreateWindowA(WC_STATICA, "Test", WS_OVERLAPPEDWINDOW, 10, 10, 300, 300, NULL, NULL, NULL, 0);
|
2017-12-14 07:50:20 +01:00
|
|
|
ShowWindow(hMainWnd, SW_SHOW);
|
|
|
|
|
2008-07-03 17:37:10 +02:00
|
|
|
hComboExParentWnd = CreateWindowExA(0, ComboExTestClass, "ComboEx test", WS_OVERLAPPEDWINDOW|WS_VISIBLE,
|
2005-09-21 11:41:44 +02:00
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT, 680, 260, NULL, NULL, GetModuleHandleA(NULL), 0);
|
2014-02-13 09:31:48 +01:00
|
|
|
ok(hComboExParentWnd != NULL, "failed to create parent window\n");
|
2005-09-21 11:41:44 +02:00
|
|
|
|
|
|
|
hMainHinst = GetModuleHandleA(NULL);
|
2014-02-13 09:31:48 +01:00
|
|
|
|
|
|
|
return hComboExParentWnd != NULL;
|
2005-09-21 11:41:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void cleanup(void)
|
|
|
|
{
|
|
|
|
MSG msg;
|
|
|
|
|
|
|
|
PostMessageA(hComboExParentWnd, WM_CLOSE, 0, 0);
|
|
|
|
while (GetMessageA(&msg,0,0,0)) {
|
|
|
|
TranslateMessage(&msg);
|
|
|
|
DispatchMessageA(&msg);
|
|
|
|
}
|
|
|
|
|
2008-12-15 18:39:06 +01:00
|
|
|
DestroyWindow(hComboExParentWnd);
|
2005-09-21 11:41:44 +02:00
|
|
|
UnregisterClassA(ComboExTestClass, GetModuleHandleA(NULL));
|
2017-12-14 07:50:20 +01:00
|
|
|
|
|
|
|
DestroyWindow(hMainWnd);
|
2005-09-21 11:41:44 +02:00
|
|
|
}
|
|
|
|
|
2017-12-14 07:50:20 +01:00
|
|
|
static void test_comboex_subclass(void)
|
2009-12-23 20:50:26 +01:00
|
|
|
{
|
|
|
|
HWND hComboEx, hCombo, hEdit;
|
|
|
|
|
|
|
|
hComboEx = createComboEx(WS_BORDER | WS_VISIBLE | WS_CHILD | CBS_DROPDOWN);
|
|
|
|
|
2013-10-22 17:12:18 +02:00
|
|
|
hCombo = (HWND)SendMessageA(hComboEx, CBEM_GETCOMBOCONTROL, 0, 0);
|
2009-12-23 20:50:26 +01:00
|
|
|
ok(hCombo != NULL, "Failed to get internal combo\n");
|
2013-10-22 17:12:18 +02:00
|
|
|
hEdit = (HWND)SendMessageA(hComboEx, CBEM_GETEDITCONTROL, 0, 0);
|
2009-12-23 20:50:26 +01:00
|
|
|
ok(hEdit != NULL, "Failed to get internal edit\n");
|
|
|
|
|
|
|
|
if (pSetWindowSubclass)
|
|
|
|
{
|
|
|
|
ok(GetPropA(hCombo, "CC32SubclassInfo") != NULL, "Expected CC32SubclassInfo property\n");
|
|
|
|
ok(GetPropA(hEdit, "CC32SubclassInfo") != NULL, "Expected CC32SubclassInfo property\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
DestroyWindow(hComboEx);
|
|
|
|
}
|
|
|
|
|
2009-12-23 20:51:54 +01:00
|
|
|
static const struct message test_setitem_edit_seq[] = {
|
|
|
|
{ WM_SETTEXT, sent|id, 0, 0, EDITBOX_ID },
|
|
|
|
{ EM_SETSEL, sent|id|wparam|lparam, 0, 0, EDITBOX_ID },
|
|
|
|
{ EM_SETSEL, sent|id|wparam|lparam, 0, -1, EDITBOX_ID },
|
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
2017-12-14 07:50:20 +01:00
|
|
|
static void test_comboex_get_set_item(void)
|
2009-12-23 20:51:54 +01:00
|
|
|
{
|
|
|
|
char textA[] = "test";
|
|
|
|
HWND hComboEx;
|
|
|
|
COMBOBOXEXITEMA item;
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
hComboEx = createComboEx(WS_BORDER | WS_VISIBLE | WS_CHILD | CBS_DROPDOWN);
|
|
|
|
|
|
|
|
subclass_editbox(hComboEx);
|
|
|
|
|
|
|
|
flush_sequences(sequences, NUM_MSG_SEQUENCES);
|
|
|
|
|
|
|
|
memset(&item, 0, sizeof(item));
|
|
|
|
item.mask = CBEIF_TEXT;
|
|
|
|
item.pszText = textA;
|
|
|
|
item.iItem = -1;
|
2013-10-22 17:12:18 +02:00
|
|
|
ret = SendMessageA(hComboEx, CBEM_SETITEMA, 0, (LPARAM)&item);
|
2009-12-23 21:08:32 +01:00
|
|
|
expect(TRUE, ret);
|
2009-12-23 20:51:54 +01:00
|
|
|
|
|
|
|
ok_sequence(sequences, EDITBOX_SEQ_INDEX, test_setitem_edit_seq, "set item data for edit", FALSE);
|
|
|
|
|
2009-12-23 21:08:32 +01:00
|
|
|
/* get/set lParam */
|
|
|
|
item.mask = CBEIF_LPARAM;
|
|
|
|
item.iItem = -1;
|
|
|
|
item.lParam = 0xdeadbeef;
|
2013-10-22 17:12:18 +02:00
|
|
|
ret = SendMessageA(hComboEx, CBEM_GETITEMA, 0, (LPARAM)&item);
|
2009-12-23 21:08:32 +01:00
|
|
|
expect(TRUE, ret);
|
2010-10-02 01:29:45 +02:00
|
|
|
ok(item.lParam == 0, "Expected zero, got %lx\n", item.lParam);
|
2009-12-23 21:08:32 +01:00
|
|
|
|
2010-10-02 01:29:45 +02:00
|
|
|
item.lParam = 0x1abe11ed;
|
2013-10-22 17:12:18 +02:00
|
|
|
ret = SendMessageA(hComboEx, CBEM_SETITEMA, 0, (LPARAM)&item);
|
2009-12-23 21:08:32 +01:00
|
|
|
expect(TRUE, ret);
|
|
|
|
|
|
|
|
item.lParam = 0;
|
2013-10-22 17:12:18 +02:00
|
|
|
ret = SendMessageA(hComboEx, CBEM_GETITEMA, 0, (LPARAM)&item);
|
2009-12-23 21:08:32 +01:00
|
|
|
expect(TRUE, ret);
|
2010-10-02 01:29:45 +02:00
|
|
|
ok(item.lParam == 0x1abe11ed, "Expected 0x1abe11ed, got %lx\n", item.lParam);
|
2009-12-23 21:08:32 +01:00
|
|
|
|
2009-12-23 20:51:54 +01:00
|
|
|
DestroyWindow(hComboEx);
|
|
|
|
}
|
|
|
|
|
2017-12-14 07:50:20 +01:00
|
|
|
static HWND create_combobox(DWORD style)
|
|
|
|
{
|
2018-02-14 06:33:50 +01:00
|
|
|
return CreateWindowA(WC_COMBOBOXA, "Combo", WS_VISIBLE|WS_CHILD|style, 5, 5, 100, 100, hMainWnd, (HMENU)COMBO_ID, NULL, 0);
|
2017-12-14 07:50:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int font_height(HFONT hFont)
|
|
|
|
{
|
|
|
|
TEXTMETRICA tm;
|
|
|
|
HFONT hFontOld;
|
|
|
|
HDC hDC;
|
|
|
|
|
|
|
|
hDC = CreateCompatibleDC(NULL);
|
|
|
|
hFontOld = SelectObject(hDC, hFont);
|
|
|
|
GetTextMetricsA(hDC, &tm);
|
|
|
|
SelectObject(hDC, hFontOld);
|
|
|
|
DeleteDC(hDC);
|
|
|
|
|
|
|
|
return tm.tmHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_combo_setitemheight(DWORD style)
|
|
|
|
{
|
|
|
|
HWND hCombo = create_combobox(style);
|
|
|
|
RECT r;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
GetClientRect(hCombo, &r);
|
|
|
|
expect_rect(r, 0, 0, 100, font_height(GetStockObject(SYSTEM_FONT)) + 8);
|
|
|
|
SendMessageA(hCombo, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)&r);
|
|
|
|
MapWindowPoints(HWND_DESKTOP, hMainWnd, (LPPOINT)&r, 2);
|
|
|
|
todo_wine expect_rect(r, 5, 5, 105, 105);
|
|
|
|
|
|
|
|
for (i = 1; i < 30; i++)
|
|
|
|
{
|
|
|
|
SendMessageA(hCombo, CB_SETITEMHEIGHT, -1, i);
|
|
|
|
GetClientRect(hCombo, &r);
|
|
|
|
ok((r.bottom - r.top) == (i + 6), "Unexpected client rect height.\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
DestroyWindow(hCombo);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_combo_setfont(DWORD style)
|
|
|
|
{
|
|
|
|
HFONT hFont1, hFont2;
|
|
|
|
HWND hCombo;
|
|
|
|
RECT r;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
hCombo = create_combobox(style);
|
|
|
|
hFont1 = CreateFontA(10, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, SYMBOL_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, "Marlett");
|
|
|
|
hFont2 = CreateFontA(8, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, SYMBOL_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, "Marlett");
|
|
|
|
|
|
|
|
GetClientRect(hCombo, &r);
|
|
|
|
expect_rect(r, 0, 0, 100, font_height(GetStockObject(SYSTEM_FONT)) + 8);
|
|
|
|
SendMessageA(hCombo, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)&r);
|
|
|
|
MapWindowPoints(HWND_DESKTOP, hMainWnd, (LPPOINT)&r, 2);
|
|
|
|
todo_wine expect_rect(r, 5, 5, 105, 105);
|
|
|
|
|
|
|
|
/* The size of the dropped control is initially equal to the size
|
|
|
|
of the window when it was created. The size of the calculated
|
|
|
|
dropped area changes only by how much the selection area
|
|
|
|
changes, not by how much the list area changes. */
|
|
|
|
if (font_height(hFont1) == 10 && font_height(hFont2) == 8)
|
|
|
|
{
|
|
|
|
SendMessageA(hCombo, WM_SETFONT, (WPARAM)hFont1, FALSE);
|
|
|
|
GetClientRect(hCombo, &r);
|
|
|
|
expect_rect(r, 0, 0, 100, 18);
|
|
|
|
SendMessageA(hCombo, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)&r);
|
|
|
|
MapWindowPoints(HWND_DESKTOP, hMainWnd, (LPPOINT)&r, 2);
|
|
|
|
todo_wine expect_rect(r, 5, 5, 105, 105 - (font_height(GetStockObject(SYSTEM_FONT)) - font_height(hFont1)));
|
|
|
|
|
|
|
|
SendMessageA(hCombo, WM_SETFONT, (WPARAM)hFont2, FALSE);
|
|
|
|
GetClientRect(hCombo, &r);
|
|
|
|
expect_rect(r, 0, 0, 100, 16);
|
|
|
|
SendMessageA(hCombo, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)&r);
|
|
|
|
MapWindowPoints(HWND_DESKTOP, hMainWnd, (LPPOINT)&r, 2);
|
|
|
|
todo_wine expect_rect(r, 5, 5, 105, 105 - (font_height(GetStockObject(SYSTEM_FONT)) - font_height(hFont2)));
|
|
|
|
|
|
|
|
SendMessageA(hCombo, WM_SETFONT, (WPARAM)hFont1, FALSE);
|
|
|
|
GetClientRect(hCombo, &r);
|
|
|
|
expect_rect(r, 0, 0, 100, 18);
|
|
|
|
SendMessageA(hCombo, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)&r);
|
|
|
|
MapWindowPoints(HWND_DESKTOP, hMainWnd, (LPPOINT)&r, 2);
|
|
|
|
todo_wine expect_rect(r, 5, 5, 105, 105 - (font_height(GetStockObject(SYSTEM_FONT)) - font_height(hFont1)));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok(0, "Expected Marlett font heights 10/8, got %d/%d\n",
|
|
|
|
font_height(hFont1), font_height(hFont2));
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 1; i < 30; i++)
|
|
|
|
{
|
|
|
|
HFONT hFont = CreateFontA(i, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, SYMBOL_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, "Marlett");
|
|
|
|
int height = font_height(hFont);
|
|
|
|
|
|
|
|
SendMessageA(hCombo, WM_SETFONT, (WPARAM)hFont, FALSE);
|
|
|
|
GetClientRect(hCombo, &r);
|
|
|
|
ok((r.bottom - r.top) == (height + 8), "Unexpected client rect height.\n");
|
|
|
|
SendMessageA(hCombo, WM_SETFONT, 0, FALSE);
|
|
|
|
DeleteObject(hFont);
|
|
|
|
}
|
|
|
|
|
|
|
|
DestroyWindow(hCombo);
|
|
|
|
DeleteObject(hFont1);
|
|
|
|
DeleteObject(hFont2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static LRESULT (CALLBACK *old_parent_proc)(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
|
|
|
static LPCSTR expected_edit_text;
|
|
|
|
static LPCSTR expected_list_text;
|
|
|
|
static BOOL selchange_fired;
|
|
|
|
|
|
|
|
static LRESULT CALLBACK parent_wnd_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
|
|
|
{
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case WM_COMMAND:
|
|
|
|
switch (wparam)
|
|
|
|
{
|
|
|
|
case MAKEWPARAM(COMBO_ID, CBN_SELCHANGE):
|
|
|
|
{
|
|
|
|
HWND hCombo = (HWND)lparam;
|
|
|
|
char list[20], edit[20];
|
|
|
|
int idx;
|
|
|
|
|
|
|
|
memset(list, 0, sizeof(list));
|
|
|
|
memset(edit, 0, sizeof(edit));
|
|
|
|
|
|
|
|
idx = SendMessageA(hCombo, CB_GETCURSEL, 0, 0);
|
|
|
|
SendMessageA(hCombo, CB_GETLBTEXT, idx, (LPARAM)list);
|
|
|
|
SendMessageA(hCombo, WM_GETTEXT, sizeof(edit), (LPARAM)edit);
|
|
|
|
|
|
|
|
ok(!strcmp(edit, expected_edit_text), "edit: got %s, expected %s\n",
|
|
|
|
edit, expected_edit_text);
|
|
|
|
ok(!strcmp(list, expected_list_text), "list: got %s, expected %s\n",
|
|
|
|
list, expected_list_text);
|
|
|
|
|
|
|
|
selchange_fired = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return CallWindowProcA(old_parent_proc, hwnd, msg, wparam, lparam);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_selection(DWORD style, const char * const text[], const int *edit, const int *list)
|
|
|
|
{
|
|
|
|
HWND hCombo;
|
|
|
|
INT idx;
|
|
|
|
|
|
|
|
hCombo = create_combobox(style);
|
|
|
|
|
|
|
|
SendMessageA(hCombo, CB_ADDSTRING, 0, (LPARAM)text[0]);
|
|
|
|
SendMessageA(hCombo, CB_ADDSTRING, 0, (LPARAM)text[1]);
|
|
|
|
SendMessageA(hCombo, CB_SETCURSEL, -1, 0);
|
|
|
|
|
|
|
|
old_parent_proc = (void *)SetWindowLongPtrA(hMainWnd, GWLP_WNDPROC, (ULONG_PTR)parent_wnd_proc);
|
|
|
|
|
|
|
|
idx = SendMessageA(hCombo, CB_GETCURSEL, 0, 0);
|
|
|
|
ok(idx == -1, "expected selection -1, got %d\n", idx);
|
|
|
|
|
|
|
|
/* keyboard navigation */
|
|
|
|
|
|
|
|
expected_list_text = text[list[0]];
|
|
|
|
expected_edit_text = text[edit[0]];
|
|
|
|
selchange_fired = FALSE;
|
|
|
|
SendMessageA(hCombo, WM_KEYDOWN, VK_DOWN, 0);
|
|
|
|
ok(selchange_fired, "CBN_SELCHANGE not sent!\n");
|
|
|
|
|
|
|
|
expected_list_text = text[list[1]];
|
|
|
|
expected_edit_text = text[edit[1]];
|
|
|
|
selchange_fired = FALSE;
|
|
|
|
SendMessageA(hCombo, WM_KEYDOWN, VK_DOWN, 0);
|
|
|
|
ok(selchange_fired, "CBN_SELCHANGE not sent!\n");
|
|
|
|
|
|
|
|
expected_list_text = text[list[2]];
|
|
|
|
expected_edit_text = text[edit[2]];
|
|
|
|
selchange_fired = FALSE;
|
|
|
|
SendMessageA(hCombo, WM_KEYDOWN, VK_UP, 0);
|
|
|
|
ok(selchange_fired, "CBN_SELCHANGE not sent!\n");
|
|
|
|
|
|
|
|
/* programmatic navigation */
|
|
|
|
|
|
|
|
expected_list_text = text[list[3]];
|
|
|
|
expected_edit_text = text[edit[3]];
|
|
|
|
selchange_fired = FALSE;
|
|
|
|
SendMessageA(hCombo, CB_SETCURSEL, list[3], 0);
|
|
|
|
ok(!selchange_fired, "CBN_SELCHANGE sent!\n");
|
|
|
|
|
|
|
|
expected_list_text = text[list[4]];
|
|
|
|
expected_edit_text = text[edit[4]];
|
|
|
|
selchange_fired = FALSE;
|
|
|
|
SendMessageA(hCombo, CB_SETCURSEL, list[4], 0);
|
|
|
|
ok(!selchange_fired, "CBN_SELCHANGE sent!\n");
|
|
|
|
|
|
|
|
SetWindowLongPtrA(hMainWnd, GWLP_WNDPROC, (ULONG_PTR)old_parent_proc);
|
|
|
|
DestroyWindow(hCombo);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_combo_CBN_SELCHANGE(void)
|
|
|
|
{
|
|
|
|
static const char * const text[] = { "alpha", "beta", "" };
|
|
|
|
static const int sel_1[] = { 2, 0, 1, 0, 1 };
|
|
|
|
static const int sel_2[] = { 0, 1, 0, 0, 1 };
|
|
|
|
|
|
|
|
test_selection(CBS_SIMPLE, text, sel_1, sel_2);
|
|
|
|
test_selection(CBS_DROPDOWN, text, sel_1, sel_2);
|
|
|
|
test_selection(CBS_DROPDOWNLIST, text, sel_2, sel_2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_combo_changesize(DWORD style)
|
|
|
|
{
|
|
|
|
INT ddheight, clheight, ddwidth, clwidth;
|
|
|
|
HWND hCombo;
|
|
|
|
RECT rc;
|
|
|
|
|
|
|
|
hCombo = create_combobox(style);
|
|
|
|
|
|
|
|
/* get initial measurements */
|
|
|
|
GetClientRect( hCombo, &rc);
|
|
|
|
clheight = rc.bottom - rc.top;
|
|
|
|
clwidth = rc.right - rc.left;
|
|
|
|
SendMessageA(hCombo, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)&rc);
|
|
|
|
ddheight = rc.bottom - rc.top;
|
|
|
|
ddwidth = rc.right - rc.left;
|
|
|
|
/* use MoveWindow to move & resize the combo */
|
|
|
|
/* first make it slightly smaller */
|
|
|
|
MoveWindow( hCombo, 10, 10, clwidth - 2, clheight - 2, TRUE);
|
|
|
|
GetClientRect( hCombo, &rc);
|
|
|
|
ok( rc.right - rc.left == clwidth - 2, "clientrect width is %d vs %d\n",
|
|
|
|
rc.right - rc.left, clwidth - 2);
|
|
|
|
ok( rc.bottom - rc.top == clheight, "clientrect height is %d vs %d\n",
|
|
|
|
rc.bottom - rc.top, clheight);
|
|
|
|
SendMessageA(hCombo, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)&rc);
|
|
|
|
ok( rc.right - rc.left == clwidth - 2, "drop-down rect width is %d vs %d\n",
|
|
|
|
rc.right - rc.left, clwidth - 2);
|
|
|
|
ok( rc.bottom - rc.top == ddheight, "drop-down rect height is %d vs %d\n",
|
|
|
|
rc.bottom - rc.top, ddheight);
|
|
|
|
ok( rc.right - rc.left == ddwidth -2, "drop-down rect width is %d vs %d\n",
|
|
|
|
rc.right - rc.left, ddwidth - 2);
|
|
|
|
/* new cx, cy is slightly bigger than the initial values */
|
|
|
|
MoveWindow( hCombo, 10, 10, clwidth + 2, clheight + 2, TRUE);
|
|
|
|
GetClientRect( hCombo, &rc);
|
|
|
|
ok( rc.right - rc.left == clwidth + 2, "clientrect width is %d vs %d\n",
|
|
|
|
rc.right - rc.left, clwidth + 2);
|
|
|
|
ok( rc.bottom - rc.top == clheight, "clientrect height is %d vs %d\n",
|
|
|
|
rc.bottom - rc.top, clheight);
|
|
|
|
SendMessageA(hCombo, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)&rc);
|
|
|
|
ok( rc.right - rc.left == clwidth + 2, "drop-down rect width is %d vs %d\n",
|
|
|
|
rc.right - rc.left, clwidth + 2);
|
|
|
|
todo_wine {
|
|
|
|
ok( rc.bottom - rc.top == clheight + 2, "drop-down rect height is %d vs %d\n",
|
|
|
|
rc.bottom - rc.top, clheight + 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
ddwidth = SendMessageA(hCombo, CB_SETDROPPEDWIDTH, -1, 0);
|
|
|
|
ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2);
|
|
|
|
ddwidth = SendMessageA(hCombo, CB_GETDROPPEDWIDTH, 0, 0);
|
|
|
|
ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2);
|
|
|
|
|
|
|
|
ddwidth = SendMessageA(hCombo, CB_SETDROPPEDWIDTH, 0, 0);
|
|
|
|
ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2);
|
|
|
|
ddwidth = SendMessageA(hCombo, CB_GETDROPPEDWIDTH, 0, 0);
|
|
|
|
ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2);
|
|
|
|
|
|
|
|
ddwidth = SendMessageA(hCombo, CB_SETDROPPEDWIDTH, clwidth - 1, 0);
|
|
|
|
ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2);
|
|
|
|
ddwidth = SendMessageA(hCombo, CB_GETDROPPEDWIDTH, 0, 0);
|
|
|
|
ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2);
|
|
|
|
|
|
|
|
ddwidth = SendMessageA(hCombo, CB_SETDROPPEDWIDTH, clwidth << 1, 0);
|
|
|
|
ok( ddwidth == (clwidth << 1), "drop-width is %d vs %d\n", ddwidth, clwidth << 1);
|
|
|
|
ddwidth = SendMessageA(hCombo, CB_GETDROPPEDWIDTH, 0, 0);
|
|
|
|
ok( ddwidth == (clwidth << 1), "drop-width is %d vs %d\n", ddwidth, clwidth << 1);
|
|
|
|
|
|
|
|
ddwidth = SendMessageA(hCombo, CB_SETDROPPEDWIDTH, 0, 0);
|
|
|
|
ok( ddwidth == (clwidth << 1), "drop-width is %d vs %d\n", ddwidth, clwidth << 1);
|
|
|
|
ddwidth = SendMessageA(hCombo, CB_GETDROPPEDWIDTH, 0, 0);
|
|
|
|
ok( ddwidth == (clwidth << 1), "drop-width is %d vs %d\n", ddwidth, clwidth << 1);
|
|
|
|
|
|
|
|
ddwidth = SendMessageA(hCombo, CB_SETDROPPEDWIDTH, 1, 0);
|
|
|
|
ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2);
|
|
|
|
ddwidth = SendMessageA(hCombo, CB_GETDROPPEDWIDTH, 0, 0);
|
|
|
|
ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2);
|
|
|
|
|
|
|
|
DestroyWindow(hCombo);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_combo_editselection(void)
|
|
|
|
{
|
|
|
|
COMBOBOXINFO cbInfo;
|
|
|
|
INT start, end;
|
|
|
|
char edit[20];
|
|
|
|
HWND hCombo;
|
|
|
|
HWND hEdit;
|
|
|
|
DWORD len;
|
|
|
|
|
|
|
|
/* Build a combo */
|
|
|
|
hCombo = create_combobox(CBS_SIMPLE);
|
|
|
|
|
|
|
|
get_combobox_info(hCombo, &cbInfo);
|
|
|
|
hEdit = cbInfo.hwndItem;
|
|
|
|
|
|
|
|
/* Initially combo selection is empty*/
|
|
|
|
len = SendMessageA(hCombo, CB_GETEDITSEL, 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));
|
|
|
|
|
|
|
|
/* Set some text, and press a key to replace it */
|
|
|
|
edit[0] = 0x00;
|
|
|
|
SendMessageA(hCombo, WM_SETTEXT, 0, (LPARAM)"Jason1");
|
|
|
|
SendMessageA(hCombo, WM_GETTEXT, sizeof(edit), (LPARAM)edit);
|
|
|
|
ok(strcmp(edit, "Jason1")==0, "Unexpected text retrieved %s\n", edit);
|
|
|
|
|
|
|
|
/* Now what is the selection - still empty */
|
|
|
|
SendMessageA(hCombo, CB_GETEDITSEL, (WPARAM)&start, (WPARAM)&end);
|
|
|
|
ok(start==0, "Unexpected start position for selection %d\n", start);
|
|
|
|
ok(end==0, "Unexpected end position for selection %d\n", end);
|
|
|
|
len = SendMessageA(hCombo, CB_GETEDITSEL, 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));
|
|
|
|
|
|
|
|
/* Give it focus, and it gets selected */
|
|
|
|
SendMessageA(hCombo, WM_SETFOCUS, 0, (LPARAM)hEdit);
|
|
|
|
SendMessageA(hCombo, CB_GETEDITSEL, (WPARAM)&start, (WPARAM)&end);
|
|
|
|
ok(start==0, "Unexpected start position for selection %d\n", start);
|
|
|
|
ok(end==6, "Unexpected end position for selection %d\n", end);
|
|
|
|
len = SendMessageA(hCombo, CB_GETEDITSEL, 0,0);
|
|
|
|
ok(LOWORD(len)==0, "Unexpected start position for selection %d\n", LOWORD(len));
|
|
|
|
ok(HIWORD(len)==6, "Unexpected end position for selection %d\n", HIWORD(len));
|
|
|
|
|
|
|
|
/* Now emulate a key press */
|
|
|
|
edit[0] = 0x00;
|
|
|
|
SendMessageA(hCombo, WM_CHAR, 'A', 0x1c0001);
|
|
|
|
SendMessageA(hCombo, WM_GETTEXT, sizeof(edit), (LPARAM)edit);
|
|
|
|
ok(strcmp(edit, "A")==0, "Unexpected text retrieved %s\n", edit);
|
|
|
|
|
|
|
|
len = SendMessageA(hCombo, CB_GETEDITSEL, 0,0);
|
|
|
|
ok(LOWORD(len)==1, "Unexpected start position for selection %d\n", LOWORD(len));
|
|
|
|
ok(HIWORD(len)==1, "Unexpected end position for selection %d\n", HIWORD(len));
|
|
|
|
|
|
|
|
/* Now what happens when it gets more focus a second time - it doesn't reselect */
|
|
|
|
SendMessageA(hCombo, WM_SETFOCUS, 0, (LPARAM)hEdit);
|
|
|
|
len = SendMessageA(hCombo, CB_GETEDITSEL, 0,0);
|
|
|
|
ok(LOWORD(len)==1, "Unexpected start position for selection %d\n", LOWORD(len));
|
|
|
|
ok(HIWORD(len)==1, "Unexpected end position for selection %d\n", HIWORD(len));
|
|
|
|
DestroyWindow(hCombo);
|
|
|
|
|
|
|
|
/* Start again - Build a combo */
|
|
|
|
hCombo = create_combobox(CBS_SIMPLE);
|
|
|
|
get_combobox_info(hCombo, &cbInfo);
|
|
|
|
hEdit = cbInfo.hwndItem;
|
|
|
|
|
|
|
|
/* Set some text and give focus so it gets selected */
|
|
|
|
edit[0] = 0x00;
|
|
|
|
SendMessageA(hCombo, WM_SETTEXT, 0, (LPARAM)"Jason2");
|
|
|
|
SendMessageA(hCombo, WM_GETTEXT, sizeof(edit), (LPARAM)edit);
|
|
|
|
ok(strcmp(edit, "Jason2")==0, "Unexpected text retrieved %s\n", edit);
|
|
|
|
|
|
|
|
SendMessageA(hCombo, WM_SETFOCUS, 0, (LPARAM)hEdit);
|
|
|
|
|
|
|
|
/* Now what is the selection */
|
|
|
|
SendMessageA(hCombo, CB_GETEDITSEL, (WPARAM)&start, (WPARAM)&end);
|
|
|
|
ok(start==0, "Unexpected start position for selection %d\n", start);
|
|
|
|
ok(end==6, "Unexpected end position for selection %d\n", end);
|
|
|
|
len = SendMessageA(hCombo, CB_GETEDITSEL, 0,0);
|
|
|
|
ok(LOWORD(len)==0, "Unexpected start position for selection %d\n", LOWORD(len));
|
|
|
|
ok(HIWORD(len)==6, "Unexpected end position for selection %d\n", HIWORD(len));
|
|
|
|
|
|
|
|
/* Now change the selection to the apparently invalid start -1, end -1 and
|
|
|
|
show it means no selection (ie start -1) but cursor at end */
|
|
|
|
SendMessageA(hCombo, CB_SETEDITSEL, 0, -1);
|
|
|
|
edit[0] = 0x00;
|
|
|
|
SendMessageA(hCombo, WM_CHAR, 'A', 0x1c0001);
|
|
|
|
SendMessageA(hCombo, WM_GETTEXT, sizeof(edit), (LPARAM)edit);
|
|
|
|
ok(strcmp(edit, "Jason2A")==0, "Unexpected text retrieved %s\n", edit);
|
|
|
|
DestroyWindow(hCombo);
|
|
|
|
}
|
|
|
|
|
|
|
|
static WNDPROC edit_window_proc;
|
|
|
|
static long setsel_start = 1, setsel_end = 1;
|
|
|
|
static HWND hCBN_SetFocus, hCBN_KillFocus;
|
|
|
|
|
|
|
|
static LRESULT CALLBACK combobox_subclass_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
if (msg == EM_SETSEL)
|
|
|
|
{
|
|
|
|
setsel_start = wParam;
|
|
|
|
setsel_end = lParam;
|
|
|
|
}
|
|
|
|
return CallWindowProcA(edit_window_proc, hwnd, msg, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
|
|
|
static LRESULT CALLBACK test_window_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case WM_COMMAND:
|
|
|
|
switch (HIWORD(wParam))
|
|
|
|
{
|
|
|
|
case CBN_SETFOCUS:
|
|
|
|
hCBN_SetFocus = (HWND)lParam;
|
|
|
|
break;
|
|
|
|
case CBN_KILLFOCUS:
|
|
|
|
hCBN_KillFocus = (HWND)lParam;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_NEXTDLGCTL:
|
|
|
|
SetFocus((HWND)wParam);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return CallWindowProcA(old_parent_proc, hwnd, msg, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_combo_editselection_focus(DWORD style)
|
|
|
|
{
|
|
|
|
static const char wine_test[] = "Wine Test";
|
|
|
|
HWND hCombo, hEdit, hButton;
|
|
|
|
char buffer[16] = {0};
|
|
|
|
COMBOBOXINFO cbInfo;
|
|
|
|
DWORD len;
|
|
|
|
|
|
|
|
hCombo = create_combobox(style);
|
|
|
|
get_combobox_info(hCombo, &cbInfo);
|
|
|
|
hEdit = cbInfo.hwndItem;
|
|
|
|
|
2018-02-14 06:33:50 +01:00
|
|
|
hButton = CreateWindowA(WC_BUTTONA, "OK", WS_VISIBLE|WS_CHILD|BS_DEFPUSHBUTTON,
|
2017-12-14 07:50:20 +01:00
|
|
|
5, 50, 100, 20, hMainWnd, NULL,
|
|
|
|
(HINSTANCE)GetWindowLongPtrA(hMainWnd, GWLP_HINSTANCE), NULL);
|
|
|
|
|
|
|
|
old_parent_proc = (WNDPROC)SetWindowLongPtrA(hMainWnd, GWLP_WNDPROC, (ULONG_PTR)test_window_proc);
|
|
|
|
edit_window_proc = (WNDPROC)SetWindowLongPtrA(hEdit, GWLP_WNDPROC, (ULONG_PTR)combobox_subclass_proc);
|
|
|
|
|
|
|
|
SendMessageA(hCombo, WM_SETFOCUS, 0, (LPARAM)hEdit);
|
|
|
|
ok(setsel_start == 0, "Unexpected EM_SETSEL start value; got %ld\n", setsel_start);
|
|
|
|
todo_wine ok(setsel_end == INT_MAX, "Unexpected EM_SETSEL end value; got %ld\n", setsel_end);
|
|
|
|
ok(hCBN_SetFocus == hCombo, "Wrong handle set by CBN_SETFOCUS; got %p\n", hCBN_SetFocus);
|
|
|
|
ok(GetFocus() == hEdit, "hEdit should have keyboard focus\n");
|
|
|
|
|
|
|
|
SendMessageA(hMainWnd, WM_NEXTDLGCTL, (WPARAM)hButton, TRUE);
|
|
|
|
ok(setsel_start == 0, "Unexpected EM_SETSEL start value; got %ld\n", setsel_start);
|
|
|
|
todo_wine ok(setsel_end == 0, "Unexpected EM_SETSEL end value; got %ld\n", setsel_end);
|
|
|
|
ok(hCBN_KillFocus == hCombo, "Wrong handle set by CBN_KILLFOCUS; got %p\n", hCBN_KillFocus);
|
|
|
|
ok(GetFocus() == hButton, "hButton should have keyboard focus\n");
|
|
|
|
|
|
|
|
SendMessageA(hCombo, WM_SETTEXT, 0, (LPARAM)wine_test);
|
|
|
|
SendMessageA(hMainWnd, WM_NEXTDLGCTL, (WPARAM)hCombo, TRUE);
|
|
|
|
ok(setsel_start == 0, "Unexpected EM_SETSEL start value; got %ld\n", setsel_start);
|
|
|
|
todo_wine ok(setsel_end == INT_MAX, "Unexpected EM_SETSEL end value; got %ld\n", setsel_end);
|
|
|
|
ok(hCBN_SetFocus == hCombo, "Wrong handle set by CBN_SETFOCUS; got %p\n", hCBN_SetFocus);
|
|
|
|
ok(GetFocus() == hEdit, "hEdit should have keyboard focus\n");
|
|
|
|
SendMessageA(hCombo, WM_GETTEXT, sizeof(buffer), (LPARAM)buffer);
|
|
|
|
ok(!strcmp(buffer, wine_test), "Unexpected text in edit control; got '%s'\n", buffer);
|
|
|
|
|
|
|
|
SendMessageA(hMainWnd, WM_NEXTDLGCTL, (WPARAM)hButton, TRUE);
|
|
|
|
ok(setsel_start == 0, "Unexpected EM_SETSEL start value; got %ld\n", setsel_start);
|
|
|
|
todo_wine ok(setsel_end == 0, "Unexpected EM_SETSEL end value; got %ld\n", setsel_end);
|
|
|
|
ok(hCBN_KillFocus == hCombo, "Wrong handle set by CBN_KILLFOCUS; got %p\n", hCBN_KillFocus);
|
|
|
|
ok(GetFocus() == hButton, "hButton should have keyboard focus\n");
|
|
|
|
len = SendMessageA(hCombo, CB_GETEDITSEL, 0, 0);
|
|
|
|
ok(len == 0, "Unexpected text selection; start: %u, end: %u\n", LOWORD(len), HIWORD(len));
|
|
|
|
|
|
|
|
SetWindowLongPtrA(hMainWnd, GWLP_WNDPROC, (ULONG_PTR)old_parent_proc);
|
|
|
|
DestroyWindow(hButton);
|
|
|
|
DestroyWindow(hCombo);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_combo_listbox_styles(DWORD cb_style)
|
|
|
|
{
|
|
|
|
DWORD style, exstyle, expect_style, expect_exstyle;
|
|
|
|
COMBOBOXINFO info;
|
|
|
|
HWND combo;
|
|
|
|
|
|
|
|
expect_style = WS_CHILD|WS_CLIPSIBLINGS|LBS_COMBOBOX|LBS_HASSTRINGS|LBS_NOTIFY;
|
|
|
|
if (cb_style == CBS_SIMPLE)
|
|
|
|
{
|
|
|
|
expect_style |= WS_VISIBLE;
|
|
|
|
expect_exstyle = WS_EX_CLIENTEDGE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
expect_style |= WS_BORDER;
|
|
|
|
expect_exstyle = WS_EX_TOOLWINDOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
combo = create_combobox(cb_style);
|
|
|
|
get_combobox_info(combo, &info);
|
|
|
|
|
|
|
|
style = GetWindowLongW( info.hwndList, GWL_STYLE );
|
|
|
|
exstyle = GetWindowLongW( info.hwndList, GWL_EXSTYLE );
|
|
|
|
ok(style == expect_style, "%08x: got %08x\n", cb_style, style);
|
|
|
|
ok(exstyle == expect_exstyle, "%08x: got %08x\n", cb_style, exstyle);
|
|
|
|
|
|
|
|
if (cb_style != CBS_SIMPLE)
|
|
|
|
expect_exstyle |= WS_EX_TOPMOST;
|
|
|
|
|
|
|
|
SendMessageW(combo, CB_SHOWDROPDOWN, TRUE, 0 );
|
|
|
|
style = GetWindowLongW( info.hwndList, GWL_STYLE );
|
|
|
|
exstyle = GetWindowLongW( info.hwndList, GWL_EXSTYLE );
|
|
|
|
ok(style == (expect_style | WS_VISIBLE), "%08x: got %08x\n", cb_style, style);
|
|
|
|
ok(exstyle == expect_exstyle, "%08x: got %08x\n", cb_style, exstyle);
|
|
|
|
|
|
|
|
SendMessageW(combo, CB_SHOWDROPDOWN, FALSE, 0 );
|
|
|
|
style = GetWindowLongW( info.hwndList, GWL_STYLE );
|
|
|
|
exstyle = GetWindowLongW( info.hwndList, GWL_EXSTYLE );
|
|
|
|
ok(style == expect_style, "%08x: got %08x\n", cb_style, style);
|
|
|
|
ok(exstyle == expect_exstyle, "%08x: got %08x\n", cb_style, exstyle);
|
|
|
|
|
|
|
|
DestroyWindow(combo);
|
|
|
|
}
|
|
|
|
|
2018-01-04 15:58:17 +01:00
|
|
|
static void test_combo_WS_VSCROLL(void)
|
2017-12-14 07:50:20 +01:00
|
|
|
{
|
|
|
|
HWND hCombo, hList;
|
|
|
|
COMBOBOXINFO info;
|
|
|
|
DWORD style;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
hCombo = create_combobox(CBS_DROPDOWNLIST);
|
|
|
|
|
|
|
|
get_combobox_info(hCombo, &info);
|
|
|
|
hList = info.hwndList;
|
|
|
|
|
|
|
|
for (i = 0; i < 3; i++)
|
|
|
|
{
|
|
|
|
char buffer[2];
|
|
|
|
sprintf(buffer, "%d", i);
|
|
|
|
SendMessageA(hCombo, CB_ADDSTRING, 0, (LPARAM)buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
style = GetWindowLongA(info.hwndList, GWL_STYLE);
|
|
|
|
SetWindowLongA(hList, GWL_STYLE, style | WS_VSCROLL);
|
|
|
|
|
|
|
|
SendMessageA(hCombo, CB_SHOWDROPDOWN, TRUE, 0);
|
|
|
|
SendMessageA(hCombo, CB_SHOWDROPDOWN, FALSE, 0);
|
|
|
|
|
|
|
|
style = GetWindowLongA(hList, GWL_STYLE);
|
|
|
|
ok((style & WS_VSCROLL) != 0, "Style does not include WS_VSCROLL\n");
|
|
|
|
|
|
|
|
DestroyWindow(hCombo);
|
|
|
|
}
|
|
|
|
|
2018-02-06 08:26:25 +01:00
|
|
|
static void test_combo_dropdown_size(DWORD style)
|
|
|
|
{
|
|
|
|
static const char wine_test[] = "Wine Test";
|
|
|
|
HWND hCombo, hList;
|
|
|
|
COMBOBOXINFO cbInfo;
|
|
|
|
int i, test, ret;
|
|
|
|
|
|
|
|
static const struct list_size_info
|
|
|
|
{
|
|
|
|
int num_items;
|
|
|
|
int height_combo;
|
|
|
|
int limit;
|
|
|
|
} info_height[] = {
|
|
|
|
{33, 50, -1},
|
2018-08-19 21:03:55 +02:00
|
|
|
{35, 100, 40},
|
2018-02-06 08:26:25 +01:00
|
|
|
{15, 50, 3},
|
|
|
|
};
|
|
|
|
|
2018-06-06 20:36:15 +02:00
|
|
|
for (test = 0; test < ARRAY_SIZE(info_height); test++)
|
2018-02-06 08:26:25 +01:00
|
|
|
{
|
|
|
|
const struct list_size_info *info_test = &info_height[test];
|
|
|
|
int height_item; /* Height of a list item */
|
|
|
|
int height_list; /* Height of the list we got */
|
|
|
|
int expected_height_list;
|
|
|
|
RECT rect_list_client;
|
|
|
|
int min_visible_expected;
|
|
|
|
|
|
|
|
hCombo = CreateWindowA(WC_COMBOBOXA, "Combo", CBS_DROPDOWN | WS_VISIBLE | WS_CHILD | style, 5, 5, 100,
|
|
|
|
info_test->height_combo, hMainWnd, (HMENU)COMBO_ID, NULL, 0);
|
|
|
|
|
|
|
|
min_visible_expected = SendMessageA(hCombo, CB_GETMINVISIBLE, 0, 0);
|
|
|
|
ok(min_visible_expected == 30, "Unexpected number of items %d.\n", min_visible_expected);
|
|
|
|
|
|
|
|
cbInfo.cbSize = sizeof(COMBOBOXINFO);
|
|
|
|
ret = SendMessageA(hCombo, CB_GETCOMBOBOXINFO, 0, (LPARAM)&cbInfo);
|
|
|
|
ok(ret, "Failed to get combo info, %d\n", ret);
|
|
|
|
|
|
|
|
hList = cbInfo.hwndList;
|
|
|
|
for (i = 0; i < info_test->num_items; i++)
|
|
|
|
{
|
|
|
|
ret = SendMessageA(hCombo, CB_ADDSTRING, 0, (LPARAM) wine_test);
|
|
|
|
ok(ret == i, "Failed to add string %d, returned %d.\n", i, ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info_test->limit != -1)
|
|
|
|
{
|
|
|
|
int min_visible_actual;
|
|
|
|
min_visible_expected = info_test->limit;
|
|
|
|
|
|
|
|
ret = SendMessageA(hCombo, CB_SETMINVISIBLE, min_visible_expected, 0);
|
|
|
|
ok(ret, "Failed to set visible limit.\n");
|
|
|
|
min_visible_actual = SendMessageA(hCombo, CB_GETMINVISIBLE, 0, 0);
|
|
|
|
ok(min_visible_expected == min_visible_actual, "test %d: unexpected number of items %d.\n",
|
|
|
|
test, min_visible_actual);
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = SendMessageA(hCombo, CB_SHOWDROPDOWN, TRUE,0);
|
|
|
|
ok(ret, "Failed to show dropdown.\n");
|
|
|
|
ret = SendMessageA(hCombo, CB_GETDROPPEDSTATE, 0, 0);
|
|
|
|
ok(ret, "Unexpected dropped state.\n");
|
|
|
|
|
|
|
|
GetClientRect(hList, &rect_list_client);
|
|
|
|
height_list = rect_list_client.bottom - rect_list_client.top;
|
|
|
|
height_item = (int)SendMessageA(hList, LB_GETITEMHEIGHT, 0, 0);
|
|
|
|
|
|
|
|
if (style & CBS_NOINTEGRALHEIGHT)
|
|
|
|
{
|
|
|
|
RECT rect_list_complete;
|
|
|
|
int list_height_nonclient;
|
|
|
|
int list_height_calculated;
|
|
|
|
int edit_padding_size = cbInfo.rcItem.top; /* edit client rect top is the padding it has to its parent
|
|
|
|
We assume it's the same on the bottom */
|
|
|
|
|
|
|
|
GetWindowRect(hList, &rect_list_complete);
|
|
|
|
|
|
|
|
list_height_nonclient = (rect_list_complete.bottom - rect_list_complete.top)
|
|
|
|
- (rect_list_client.bottom - rect_list_client.top);
|
|
|
|
|
|
|
|
/* Calculate the expected client size of the listbox popup from the size of the combobox. */
|
|
|
|
list_height_calculated = info_test->height_combo /* Take height we created combobox with */
|
|
|
|
- (cbInfo.rcItem.bottom - cbInfo.rcItem.top) /* Subtract size of edit control */
|
|
|
|
- list_height_nonclient /* Subtract list nonclient area */
|
|
|
|
- edit_padding_size * 2; /* subtract space around the edit control */
|
|
|
|
|
|
|
|
expected_height_list = min(list_height_calculated, height_item * info_test->num_items);
|
|
|
|
if (expected_height_list < 0)
|
|
|
|
expected_height_list = 0;
|
|
|
|
|
|
|
|
ok(expected_height_list == height_list, "Test %d, expected list height to be %d, got %d\n",
|
|
|
|
test, expected_height_list, height_list);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
expected_height_list = min(info_test->num_items, min_visible_expected) * height_item;
|
|
|
|
|
|
|
|
ok(expected_height_list == height_list, "Test %d, expected list height to be %d, got %d\n",
|
|
|
|
test, expected_height_list, height_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
DestroyWindow(hCombo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-14 07:50:19 +01:00
|
|
|
START_TEST(combo)
|
2005-09-21 11:41:44 +02:00
|
|
|
{
|
2017-12-14 07:50:20 +01:00
|
|
|
ULONG_PTR ctx_cookie;
|
|
|
|
HANDLE hCtx;
|
|
|
|
|
2018-01-24 13:47:09 +01:00
|
|
|
init_functions();
|
|
|
|
|
2008-02-05 11:59:47 +01:00
|
|
|
if (!init())
|
|
|
|
return;
|
2005-09-21 11:41:44 +02:00
|
|
|
|
2009-12-23 20:51:54 +01:00
|
|
|
init_msg_sequences(sequences, NUM_MSG_SEQUENCES);
|
|
|
|
|
2017-12-14 07:50:20 +01:00
|
|
|
/* ComboBoxEx32 tests. */
|
|
|
|
test_comboex();
|
|
|
|
test_comboex_WM_LBUTTONDOWN();
|
|
|
|
test_comboex_CB_GETLBTEXT();
|
|
|
|
test_comboex_WM_WINDOWPOSCHANGING();
|
|
|
|
test_comboex_subclass();
|
|
|
|
test_comboex_get_set_item();
|
|
|
|
|
|
|
|
if (!load_v6_module(&ctx_cookie, &hCtx))
|
|
|
|
{
|
|
|
|
cleanup();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ComboBox control tests. */
|
|
|
|
test_combo_WS_VSCROLL();
|
|
|
|
test_combo_setfont(CBS_DROPDOWN);
|
|
|
|
test_combo_setfont(CBS_DROPDOWNLIST);
|
|
|
|
test_combo_setitemheight(CBS_DROPDOWN);
|
|
|
|
test_combo_setitemheight(CBS_DROPDOWNLIST);
|
|
|
|
test_combo_CBN_SELCHANGE();
|
|
|
|
test_combo_changesize(CBS_DROPDOWN);
|
|
|
|
test_combo_changesize(CBS_DROPDOWNLIST);
|
|
|
|
test_combo_editselection();
|
|
|
|
test_combo_editselection_focus(CBS_SIMPLE);
|
|
|
|
test_combo_editselection_focus(CBS_DROPDOWN);
|
|
|
|
test_combo_listbox_styles(CBS_SIMPLE);
|
|
|
|
test_combo_listbox_styles(CBS_DROPDOWN);
|
|
|
|
test_combo_listbox_styles(CBS_DROPDOWNLIST);
|
2018-02-06 08:26:25 +01:00
|
|
|
test_combo_dropdown_size(0);
|
|
|
|
test_combo_dropdown_size(CBS_NOINTEGRALHEIGHT);
|
2005-09-21 11:41:44 +02:00
|
|
|
|
|
|
|
cleanup();
|
2017-12-14 07:50:20 +01:00
|
|
|
unload_v6_module(ctx_cookie, hCtx);
|
2005-09-21 11:41:44 +02:00
|
|
|
}
|