2005-09-21 11:41:44 +02:00
|
|
|
/* Unit test suite for comboex control.
|
|
|
|
*
|
|
|
|
* Copyright 2005 Jason Edmeades
|
|
|
|
*
|
|
|
|
* 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
|
|
|
*/
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
#include <commctrl.h>
|
|
|
|
|
|
|
|
#include "wine/test.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
|
|
|
|
|
2009-12-23 21:08:32 +01:00
|
|
|
#define expect(expected, got) ok(got == expected, "Expected %d, got %d\n", expected, got)
|
|
|
|
|
2009-12-23 20:51:54 +01:00
|
|
|
static struct msg_sequence *sequences[NUM_MSG_SEQUENCES];
|
2005-09-21 11:41:44 +02:00
|
|
|
|
|
|
|
static HWND hComboExParentWnd;
|
|
|
|
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;
|
|
|
|
|
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;
|
|
|
|
LRESULT ret;
|
|
|
|
struct message msg;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2006-02-06 13:13:28 +01:00
|
|
|
static void test_comboboxex(void) {
|
2005-09-21 11:41:44 +02:00
|
|
|
HWND myHwnd = 0;
|
|
|
|
LONG res = -1;
|
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 */
|
2007-06-28 23:00:54 +02:00
|
|
|
textBuffer = HeapAlloc(GetProcessHeap(), 0, 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 */
|
2007-06-28 23:00:54 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, textBuffer);
|
2008-07-03 17:37:10 +02:00
|
|
|
DestroyWindow(myHwnd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_WM_LBUTTONDOWN(void)
|
|
|
|
{
|
|
|
|
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'};
|
2008-07-30 09:16:08 +02:00
|
|
|
BOOL (WINAPI *pGetComboBoxInfo)(HWND, PCOMBOBOXINFO);
|
|
|
|
|
|
|
|
pGetComboBoxInfo = (void*)GetProcAddress(GetModuleHandleA("user32.dll"), "GetComboBoxInfo");
|
|
|
|
if (!pGetComboBoxInfo){
|
2009-02-26 09:45:25 +01:00
|
|
|
win_skip("GetComboBoxInfo is not available\n");
|
2008-07-30 09:16:08 +02:00
|
|
|
return;
|
|
|
|
}
|
2008-07-03 17:37:10 +02:00
|
|
|
|
|
|
|
hComboEx = CreateWindowExA(0, WC_COMBOBOXEXA, NULL,
|
|
|
|
WS_VISIBLE|WS_CHILD|CBS_DROPDOWN, 0, 0, 200, 150,
|
|
|
|
hComboExParentWnd, NULL, hMainHinst, NULL);
|
|
|
|
|
|
|
|
for (i = 0; i < sizeof(choices)/sizeof(UINT); i++){
|
|
|
|
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
|
|
|
|
|
|
|
cbInfo.cbSize = sizeof(COMBOBOXINFO);
|
2008-07-30 09:16:08 +02:00
|
|
|
result = pGetComboBoxInfo(hCombo, &cbInfo);
|
2008-07-03 17:37:10 +02:00
|
|
|
ok(result, "Failed to get combobox info structure. LastError=%d\n",
|
|
|
|
GetLastError());
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2009-10-13 18:59:39 +02:00
|
|
|
static void test_CB_GETLBTEXT(void)
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2011-02-06 17:41:30 +01:00
|
|
|
static void test_WM_WINDOWPOSCHANGING(void)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2013-10-22 00:16:11 +02:00
|
|
|
static BOOL init(void)
|
2008-02-05 11:59:47 +01:00
|
|
|
{
|
|
|
|
HMODULE hComctl32;
|
|
|
|
BOOL (WINAPI *pInitCommonControlsEx)(const INITCOMMONCONTROLSEX*);
|
2005-09-21 11:41:44 +02:00
|
|
|
WNDCLASSA wc;
|
2008-02-05 11:59:47 +01:00
|
|
|
INITCOMMONCONTROLSEX iccex;
|
|
|
|
|
|
|
|
hComctl32 = GetModuleHandleA("comctl32.dll");
|
|
|
|
pInitCommonControlsEx = (void*)GetProcAddress(hComctl32, "InitCommonControlsEx");
|
|
|
|
if (!pInitCommonControlsEx)
|
|
|
|
{
|
2009-02-26 09:45:25 +01:00
|
|
|
win_skip("InitCommonControlsEx() is missing. Skipping the tests\n");
|
2013-10-22 00:16:11 +02:00
|
|
|
return FALSE;
|
2008-02-05 11:59:47 +01:00
|
|
|
}
|
|
|
|
iccex.dwSize = sizeof(iccex);
|
|
|
|
iccex.dwICC = ICC_USEREX_CLASSES;
|
|
|
|
pInitCommonControlsEx(&iccex);
|
2005-09-21 11:41:44 +02:00
|
|
|
|
2009-12-23 20:50:26 +01:00
|
|
|
pSetWindowSubclass = (void*)GetProcAddress(hComctl32, (LPSTR)410);
|
|
|
|
|
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);
|
|
|
|
|
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));
|
|
|
|
}
|
|
|
|
|
2009-12-23 20:50:26 +01:00
|
|
|
static void test_comboboxex_subclass(void)
|
|
|
|
{
|
|
|
|
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 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static void test_get_set_item(void)
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2005-09-21 11:41:44 +02:00
|
|
|
START_TEST(comboex)
|
|
|
|
{
|
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);
|
|
|
|
|
2005-09-21 11:41:44 +02:00
|
|
|
test_comboboxex();
|
2008-07-03 17:37:10 +02:00
|
|
|
test_WM_LBUTTONDOWN();
|
2009-10-13 18:59:39 +02:00
|
|
|
test_CB_GETLBTEXT();
|
2011-02-06 17:41:30 +01:00
|
|
|
test_WM_WINDOWPOSCHANGING();
|
2009-12-23 20:50:26 +01:00
|
|
|
test_comboboxex_subclass();
|
2009-12-23 20:51:54 +01:00
|
|
|
test_get_set_item();
|
2005-09-21 11:41:44 +02:00
|
|
|
|
|
|
|
cleanup();
|
|
|
|
}
|