2003-10-31 01:06:42 +01:00
|
|
|
/* Unit test suite for tab control.
|
|
|
|
*
|
|
|
|
* Copyright 2003 Vitaliy Margolen
|
2007-03-11 22:21:12 +01:00
|
|
|
* Copyright 2007 Hagop Hagopian
|
2003-10-31 01:06:42 +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
|
2003-10-31 01:06:42 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
#include <commctrl.h>
|
2007-03-11 22:21:12 +01:00
|
|
|
#include <stdio.h>
|
2003-10-31 01:06:42 +01:00
|
|
|
|
|
|
|
#include "wine/test.h"
|
2007-03-17 23:12:13 +01:00
|
|
|
#include "msg.h"
|
2003-10-31 01:06:42 +01:00
|
|
|
|
2005-08-23 12:05:54 +02:00
|
|
|
#define DEFAULT_MIN_TAB_WIDTH 54
|
|
|
|
#define TAB_PADDING_X 6
|
|
|
|
#define EXTRA_ICON_PADDING 3
|
2007-03-11 22:21:12 +01:00
|
|
|
#define MAX_TABLEN 32
|
|
|
|
|
2007-03-17 23:12:13 +01:00
|
|
|
#define NUM_MSG_SEQUENCES 2
|
|
|
|
#define PARENT_SEQ_INDEX 0
|
|
|
|
#define TAB_SEQ_INDEX 1
|
|
|
|
|
2007-03-11 22:21:12 +01:00
|
|
|
#define expect(expected, got) ok ( expected == got, "Expected %d, got %d\n", expected, got)
|
|
|
|
#define expect_str(expected, got)\
|
|
|
|
ok ( strcmp(expected, got) == 0, "Expected '%s', got '%s'\n", expected, got)
|
2005-08-23 12:05:54 +02:00
|
|
|
|
|
|
|
#define TabWidthPadded(padd_x, num) (DEFAULT_MIN_TAB_WIDTH - (TAB_PADDING_X - (padd_x)) * num)
|
|
|
|
|
2018-01-24 13:47:09 +01:00
|
|
|
static HIMAGELIST (WINAPI *pImageList_Create)(INT,INT,UINT,INT,INT);
|
|
|
|
static BOOL (WINAPI *pImageList_Destroy)(HIMAGELIST);
|
|
|
|
static INT (WINAPI *pImageList_GetImageCount)(HIMAGELIST);
|
|
|
|
static INT (WINAPI *pImageList_ReplaceIcon)(HIMAGELIST,INT,HICON);
|
|
|
|
|
2011-05-12 09:59:53 +02:00
|
|
|
static void CheckSize(HWND hwnd, INT width, INT height, const char *msg, int line)
|
|
|
|
{
|
|
|
|
RECT r;
|
|
|
|
|
2013-11-25 10:09:00 +01:00
|
|
|
SendMessageA(hwnd, TCM_GETITEMRECT, 0, (LPARAM)&r);
|
2011-05-12 09:59:53 +02:00
|
|
|
if (width >= 0 && height < 0)
|
2012-06-07 00:58:11 +02:00
|
|
|
ok_(__FILE__,line) (width == r.right - r.left, "%s: Expected width [%d] got [%d]\n",
|
|
|
|
msg, width, r.right - r.left);
|
2011-05-12 09:59:53 +02:00
|
|
|
else if (height >= 0 && width < 0)
|
2012-06-07 00:58:11 +02:00
|
|
|
ok_(__FILE__,line) (height == r.bottom - r.top, "%s: Expected height [%d] got [%d]\n",
|
|
|
|
msg, height, r.bottom - r.top);
|
2011-05-12 09:59:53 +02:00
|
|
|
else
|
|
|
|
ok_(__FILE__,line) ((width == r.right - r.left) && (height == r.bottom - r.top ),
|
|
|
|
"%s: Expected [%d,%d] got [%d,%d]\n", msg, width, height,
|
|
|
|
r.right - r.left, r.bottom - r.top);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define CHECKSIZE(hwnd,width,height,msg) CheckSize(hwnd,width,height,msg,__LINE__)
|
|
|
|
|
|
|
|
static void TabCheckSetSize(HWND hwnd, INT set_width, INT set_height, INT exp_width,
|
|
|
|
INT exp_height, const char *msg, int line)
|
|
|
|
{
|
2013-11-25 10:09:00 +01:00
|
|
|
SendMessageA(hwnd, TCM_SETITEMSIZE, 0,
|
|
|
|
MAKELPARAM((set_width >= 0) ? set_width : 0, (set_height >= 0) ? set_height : 0));
|
2011-05-12 09:59:53 +02:00
|
|
|
if (winetest_interactive) RedrawWindow (hwnd, NULL, 0, RDW_UPDATENOW);
|
|
|
|
CheckSize(hwnd, exp_width, exp_height, msg, line);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define TABCHECKSETSIZE(hwnd,set_width,set_height,exp_width,exp_height,msg) \
|
|
|
|
TabCheckSetSize(hwnd,set_width,set_height,exp_width,exp_height,msg,__LINE__)
|
2005-08-23 12:05:54 +02:00
|
|
|
|
2010-10-02 23:58:12 +02:00
|
|
|
static HFONT hFont;
|
|
|
|
static DRAWITEMSTRUCT g_drawitem;
|
2011-04-23 21:37:34 +02:00
|
|
|
static HWND parent_wnd;
|
2018-01-25 15:23:14 +01:00
|
|
|
static LRESULT tcn_selchanging_result;
|
2003-10-31 01:06:42 +01:00
|
|
|
|
2007-03-17 23:12:13 +01:00
|
|
|
static struct msg_sequence *sequences[NUM_MSG_SEQUENCES];
|
|
|
|
|
|
|
|
static const struct message empty_sequence[] = {
|
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct message get_row_count_seq[] = {
|
|
|
|
{ TCM_GETROWCOUNT, sent|wparam|lparam, 0, 0 },
|
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct message getset_cur_focus_seq[] = {
|
|
|
|
{ TCM_SETCURFOCUS, sent|lparam, 0 },
|
|
|
|
{ TCM_GETCURFOCUS, sent|wparam|lparam, 0, 0 },
|
|
|
|
{ TCM_SETCURFOCUS, sent|lparam, 0 },
|
|
|
|
{ TCM_GETCURFOCUS, sent|wparam|lparam, 0, 0 },
|
|
|
|
{ TCM_SETCURSEL, sent|lparam, 0 },
|
|
|
|
{ TCM_SETCURFOCUS, sent|lparam, 0 },
|
|
|
|
{ TCM_GETCURFOCUS, sent|wparam|lparam, 0, 0 },
|
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct message getset_cur_sel_seq[] = {
|
|
|
|
{ TCM_SETCURSEL, sent|lparam, 0 },
|
|
|
|
{ TCM_GETCURSEL, sent|wparam|lparam, 0, 0 },
|
2007-09-04 08:38:19 +02:00
|
|
|
{ TCM_GETCURFOCUS, sent|wparam|lparam, 0, 0 },
|
2007-03-17 23:12:13 +01:00
|
|
|
{ TCM_SETCURSEL, sent|lparam, 0 },
|
|
|
|
{ TCM_GETCURSEL, sent|wparam|lparam, 0, 0 },
|
|
|
|
{ TCM_SETCURSEL, sent|lparam, 0 },
|
|
|
|
{ TCM_SETCURSEL, sent|lparam, 0 },
|
|
|
|
{ TCM_GETCURFOCUS, sent|wparam|lparam, 0, 0 },
|
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct message getset_extended_style_seq[] = {
|
|
|
|
{ TCM_GETEXTENDEDSTYLE, sent|wparam|lparam, 0, 0 },
|
|
|
|
{ TCM_SETEXTENDEDSTYLE, sent },
|
|
|
|
{ TCM_GETEXTENDEDSTYLE, sent|wparam|lparam, 0, 0 },
|
|
|
|
{ TCM_SETEXTENDEDSTYLE, sent },
|
|
|
|
{ TCM_GETEXTENDEDSTYLE, sent|wparam|lparam, 0, 0 },
|
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct message getset_unicode_format_seq[] = {
|
|
|
|
{ CCM_SETUNICODEFORMAT, sent|lparam, 0 },
|
|
|
|
{ CCM_GETUNICODEFORMAT, sent|wparam|lparam, 0, 0 },
|
|
|
|
{ CCM_SETUNICODEFORMAT, sent|lparam, 0 },
|
|
|
|
{ CCM_GETUNICODEFORMAT, sent|wparam|lparam, 0, 0 },
|
|
|
|
{ CCM_SETUNICODEFORMAT, sent|lparam, 0 },
|
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct message getset_item_seq[] = {
|
|
|
|
{ TCM_SETITEMA, sent },
|
|
|
|
{ TCM_GETITEMA, sent },
|
|
|
|
{ TCM_GETITEMA, sent },
|
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct message getset_tooltip_seq[] = {
|
2008-09-08 07:46:00 +02:00
|
|
|
{ WM_NOTIFYFORMAT, sent|optional },
|
|
|
|
{ WM_QUERYUISTATE, sent|wparam|lparam|optional, 0, 0 },
|
2007-03-17 23:12:13 +01:00
|
|
|
{ WM_WINDOWPOSCHANGING, sent|wparam, 0 },
|
2008-09-08 07:46:00 +02:00
|
|
|
{ WM_NOTIFYFORMAT, sent|optional },
|
2007-03-17 23:12:13 +01:00
|
|
|
{ TCM_SETTOOLTIPS, sent|lparam, 0 },
|
|
|
|
{ TCM_GETTOOLTIPS, sent|wparam|lparam, 0, 0 },
|
|
|
|
{ TCM_SETTOOLTIPS, sent|lparam, 0 },
|
|
|
|
{ TCM_GETTOOLTIPS, sent|wparam|lparam, 0, 0 },
|
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct message getset_tooltip_parent_seq[] = {
|
|
|
|
{ WM_WINDOWPOSCHANGING, sent|wparam, 0 },
|
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
2007-10-30 02:32:34 +01:00
|
|
|
static const struct message insert_focus_seq[] = {
|
|
|
|
{ TCM_GETITEMCOUNT, sent|wparam|lparam, 0, 0 },
|
|
|
|
{ TCM_GETCURFOCUS, sent|wparam|lparam, 0, 0 },
|
2013-11-25 10:09:00 +01:00
|
|
|
{ TCM_INSERTITEMA, sent|wparam, 1 },
|
2009-08-05 14:00:03 +02:00
|
|
|
{ WM_NOTIFYFORMAT, sent|defwinproc|optional },
|
|
|
|
{ WM_QUERYUISTATE, sent|defwinproc|optional },
|
|
|
|
{ WM_PARENTNOTIFY, sent|defwinproc|optional },
|
2007-10-30 02:32:34 +01:00
|
|
|
{ TCM_GETITEMCOUNT, sent|wparam|lparam, 0, 0 },
|
|
|
|
{ TCM_GETCURFOCUS, sent|wparam|lparam, 0, 0 },
|
2013-11-25 10:09:00 +01:00
|
|
|
{ TCM_INSERTITEMA, sent|wparam, 2 },
|
2009-08-05 14:00:03 +02:00
|
|
|
{ WM_NOTIFYFORMAT, sent|defwinproc|optional },
|
2008-09-08 07:46:00 +02:00
|
|
|
{ WM_QUERYUISTATE, sent|defwinproc|optional, },
|
2009-08-05 14:00:03 +02:00
|
|
|
{ WM_PARENTNOTIFY, sent|defwinproc|optional },
|
2007-10-30 02:32:34 +01:00
|
|
|
{ TCM_GETITEMCOUNT, sent|wparam|lparam, 0, 0 },
|
|
|
|
{ TCM_GETCURFOCUS, sent|wparam|lparam, 0, 0 },
|
|
|
|
{ TCM_SETCURFOCUS, sent|wparam|lparam, -1, 0 },
|
|
|
|
{ TCM_GETCURFOCUS, sent|wparam|lparam, 0, 0 },
|
2013-11-25 10:09:00 +01:00
|
|
|
{ TCM_INSERTITEMA, sent|wparam, 3 },
|
2007-10-30 02:32:34 +01:00
|
|
|
{ TCM_GETCURFOCUS, sent|wparam|lparam, 0, 0 },
|
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
2007-10-30 02:44:48 +01:00
|
|
|
static const struct message delete_focus_seq[] = {
|
|
|
|
{ TCM_GETITEMCOUNT, sent|wparam|lparam, 0, 0 },
|
|
|
|
{ TCM_GETCURFOCUS, sent|wparam|lparam, 0, 0 },
|
|
|
|
{ TCM_DELETEITEM, sent|wparam|lparam, 1, 0 },
|
|
|
|
{ TCM_GETITEMCOUNT, sent|wparam|lparam, 0, 0 },
|
|
|
|
{ TCM_GETCURFOCUS, sent|wparam|lparam, 0, 0 },
|
|
|
|
{ TCM_SETCURFOCUS, sent|wparam|lparam, -1, 0 },
|
|
|
|
{ TCM_GETCURFOCUS, sent|wparam|lparam, 0, 0 },
|
|
|
|
{ TCM_DELETEITEM, sent|wparam|lparam, 0, 0 },
|
|
|
|
{ TCM_GETITEMCOUNT, sent|wparam|lparam, 0, 0 },
|
|
|
|
{ TCM_GETCURFOCUS, sent|wparam|lparam, 0, 0 },
|
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
2011-07-03 08:19:21 +02:00
|
|
|
static const struct message rbuttonup_seq[] = {
|
|
|
|
{ WM_RBUTTONUP, sent|wparam|lparam, 0, 0 },
|
|
|
|
{ WM_CONTEXTMENU, sent|defwinproc },
|
|
|
|
{ 0 }
|
|
|
|
};
|
2007-10-30 02:32:34 +01:00
|
|
|
|
2018-01-25 15:23:14 +01:00
|
|
|
static const struct message full_selchange_parent_seq[] = {
|
|
|
|
{ WM_NOTIFY, sent|id, 0, 0, TCN_SELCHANGING },
|
|
|
|
{ WM_NOTIFY, sent|id, 0, 0, TCN_SELCHANGE },
|
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct message selchanging_parent_seq[] = {
|
|
|
|
{ WM_NOTIFY, sent|id, 0, 0, TCN_SELCHANGING },
|
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct message selchange_parent_seq[] = {
|
|
|
|
{ WM_NOTIFY, sent|id, 0, 0, TCN_SELCHANGE },
|
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
2018-01-29 12:20:40 +01:00
|
|
|
static const struct message setfocus_parent_seq[] = {
|
|
|
|
{ WM_NOTIFY, sent|id, 0, 0, TCN_FOCUSCHANGE },
|
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
2005-06-09 11:50:56 +02:00
|
|
|
static HWND
|
2005-08-23 12:05:54 +02:00
|
|
|
create_tabcontrol (DWORD style, DWORD mask)
|
2003-10-31 01:06:42 +01:00
|
|
|
{
|
|
|
|
HWND handle;
|
2013-11-25 10:09:00 +01:00
|
|
|
TCITEMA tcNewTab;
|
2006-05-27 19:14:52 +02:00
|
|
|
static char text1[] = "Tab 1",
|
|
|
|
text2[] = "Wide Tab 2",
|
|
|
|
text3[] = "T 3";
|
2003-10-31 01:06:42 +01:00
|
|
|
|
2013-11-25 10:09:00 +01:00
|
|
|
handle = CreateWindowA(WC_TABCONTROLA, "TestTab",
|
|
|
|
WS_CLIPSIBLINGS | WS_CLIPCHILDREN | TCS_FOCUSNEVER | style, 10, 10, 300, 100, NULL,
|
|
|
|
NULL, NULL, 0);
|
2014-02-13 09:31:48 +01:00
|
|
|
ok(handle != NULL, "failed to create tab wnd\n");
|
2005-08-23 12:05:54 +02:00
|
|
|
|
2013-11-25 10:09:00 +01:00
|
|
|
SetWindowLongA(handle, GWL_STYLE, WS_CLIPSIBLINGS | WS_CLIPCHILDREN | TCS_FOCUSNEVER | style);
|
|
|
|
SendMessageA(handle, WM_SETFONT, 0, (LPARAM)hFont);
|
2003-10-31 01:06:42 +01:00
|
|
|
|
2005-08-23 12:05:54 +02:00
|
|
|
tcNewTab.mask = mask;
|
2006-05-27 19:14:52 +02:00
|
|
|
tcNewTab.pszText = text1;
|
2003-10-31 01:06:42 +01:00
|
|
|
tcNewTab.iImage = 0;
|
2013-11-25 10:09:00 +01:00
|
|
|
SendMessageA(handle, TCM_INSERTITEMA, 0, (LPARAM)&tcNewTab);
|
2006-05-27 19:14:52 +02:00
|
|
|
tcNewTab.pszText = text2;
|
2003-10-31 01:06:42 +01:00
|
|
|
tcNewTab.iImage = 1;
|
2013-11-25 10:09:00 +01:00
|
|
|
SendMessageA(handle, TCM_INSERTITEMA, 1, (LPARAM)&tcNewTab);
|
2006-05-27 19:14:52 +02:00
|
|
|
tcNewTab.pszText = text3;
|
2003-10-31 01:06:42 +01:00
|
|
|
tcNewTab.iImage = 2;
|
2013-11-25 10:09:00 +01:00
|
|
|
SendMessageA(handle, TCM_INSERTITEMA, 2, (LPARAM)&tcNewTab);
|
2003-10-31 01:06:42 +01:00
|
|
|
|
2005-08-23 12:05:54 +02:00
|
|
|
if (winetest_interactive)
|
|
|
|
{
|
|
|
|
ShowWindow (handle, SW_SHOW);
|
|
|
|
RedrawWindow (handle, NULL, 0, RDW_UPDATENOW);
|
|
|
|
Sleep (1000);
|
|
|
|
}
|
2003-10-31 01:06:42 +01:00
|
|
|
|
|
|
|
return handle;
|
|
|
|
}
|
|
|
|
|
2018-01-25 15:23:15 +01:00
|
|
|
static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
2007-03-17 23:12:13 +01:00
|
|
|
{
|
2009-04-02 12:04:50 +02:00
|
|
|
static LONG defwndproc_counter = 0;
|
2017-03-29 10:11:39 +02:00
|
|
|
struct message msg = { 0 };
|
2007-03-17 23:12:13 +01:00
|
|
|
LRESULT ret;
|
|
|
|
|
|
|
|
/* do not log painting messages */
|
|
|
|
if (message != WM_PAINT &&
|
|
|
|
message != WM_ERASEBKGND &&
|
|
|
|
message != WM_NCPAINT &&
|
|
|
|
message != WM_NCHITTEST &&
|
|
|
|
message != WM_GETTEXT &&
|
|
|
|
message != WM_GETICON &&
|
|
|
|
message != WM_DEVICECHANGE)
|
|
|
|
{
|
|
|
|
msg.message = message;
|
|
|
|
msg.flags = sent|wparam|lparam;
|
|
|
|
if (defwndproc_counter) msg.flags |= defwinproc;
|
|
|
|
msg.wParam = wParam;
|
|
|
|
msg.lParam = lParam;
|
2018-01-25 15:23:14 +01:00
|
|
|
if (message == WM_NOTIFY && lParam)
|
|
|
|
msg.id = ((NMHDR*)lParam)->code;
|
2007-03-17 23:12:13 +01:00
|
|
|
add_message(sequences, PARENT_SEQ_INDEX, &msg);
|
|
|
|
}
|
|
|
|
|
2010-10-02 23:58:12 +02:00
|
|
|
/* dump sent structure data */
|
|
|
|
if (message == WM_DRAWITEM)
|
|
|
|
g_drawitem = *(DRAWITEMSTRUCT*)lParam;
|
|
|
|
|
2018-01-25 15:23:14 +01:00
|
|
|
if (message == WM_NOTIFY)
|
|
|
|
{
|
|
|
|
NMHDR *nmhdr = (NMHDR *)lParam;
|
|
|
|
if (nmhdr && nmhdr->code == TCN_SELCHANGING)
|
|
|
|
return tcn_selchanging_result;
|
|
|
|
}
|
|
|
|
|
2007-03-17 23:12:13 +01:00
|
|
|
defwndproc_counter++;
|
|
|
|
ret = DefWindowProcA(hwnd, message, wParam, lParam);
|
|
|
|
defwndproc_counter--;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL registerParentWindowClass(void)
|
|
|
|
{
|
|
|
|
WNDCLASSA cls;
|
|
|
|
|
|
|
|
cls.style = 0;
|
2018-01-25 15:23:15 +01:00
|
|
|
cls.lpfnWndProc = parent_wnd_proc;
|
2007-03-17 23:12:13 +01:00
|
|
|
cls.cbClsExtra = 0;
|
|
|
|
cls.cbWndExtra = 0;
|
|
|
|
cls.hInstance = GetModuleHandleA(NULL);
|
|
|
|
cls.hIcon = 0;
|
2013-11-25 10:09:00 +01:00
|
|
|
cls.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW);
|
2007-03-17 23:12:13 +01:00
|
|
|
cls.hbrBackground = GetStockObject(WHITE_BRUSH);
|
|
|
|
cls.lpszMenuName = NULL;
|
|
|
|
cls.lpszClassName = "Tab test parent class";
|
|
|
|
return RegisterClassA(&cls);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HWND createParentWindow(void)
|
|
|
|
{
|
|
|
|
if (!registerParentWindowClass())
|
|
|
|
return NULL;
|
|
|
|
|
2013-11-25 10:09:00 +01:00
|
|
|
return CreateWindowExA(0, "Tab test parent class", "Tab test parent window",
|
|
|
|
WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_VISIBLE, 0, 0, 100, 100,
|
|
|
|
GetDesktopWindow(), NULL, GetModuleHandleA(NULL), NULL);
|
2007-03-17 23:12:13 +01:00
|
|
|
}
|
|
|
|
|
2018-01-25 15:23:15 +01:00
|
|
|
static LRESULT WINAPI tab_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
2007-03-17 23:12:13 +01:00
|
|
|
{
|
2009-10-11 14:25:17 +02:00
|
|
|
WNDPROC oldproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_USERDATA);
|
2009-04-02 12:04:50 +02:00
|
|
|
static LONG defwndproc_counter = 0;
|
2017-03-29 10:11:39 +02:00
|
|
|
struct message msg = { 0 };
|
2007-03-17 23:12:13 +01:00
|
|
|
LRESULT ret;
|
|
|
|
|
|
|
|
/* do not log painting messages */
|
|
|
|
if (message != WM_PAINT &&
|
|
|
|
message != WM_ERASEBKGND &&
|
|
|
|
message != WM_NCPAINT &&
|
|
|
|
message != WM_NCHITTEST &&
|
|
|
|
message != WM_GETTEXT &&
|
|
|
|
message != WM_GETICON &&
|
|
|
|
message != WM_DEVICECHANGE)
|
|
|
|
{
|
|
|
|
msg.message = message;
|
|
|
|
msg.flags = sent|wparam|lparam;
|
|
|
|
if (defwndproc_counter) msg.flags |= defwinproc;
|
|
|
|
msg.wParam = wParam;
|
|
|
|
msg.lParam = lParam;
|
|
|
|
add_message(sequences, TAB_SEQ_INDEX, &msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
defwndproc_counter++;
|
2009-10-11 14:25:17 +02:00
|
|
|
ret = CallWindowProcA(oldproc, hwnd, message, wParam, lParam);
|
2007-03-17 23:12:13 +01:00
|
|
|
defwndproc_counter--;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HWND createFilledTabControl(HWND parent_wnd, DWORD style, DWORD mask, INT nTabs)
|
2007-03-11 22:21:12 +01:00
|
|
|
{
|
|
|
|
HWND tabHandle;
|
2013-11-25 10:09:00 +01:00
|
|
|
TCITEMA tcNewTab;
|
2009-10-11 14:25:17 +02:00
|
|
|
WNDPROC oldproc;
|
2007-03-17 23:12:13 +01:00
|
|
|
RECT rect;
|
2007-03-11 22:21:12 +01:00
|
|
|
INT i;
|
|
|
|
|
2007-03-17 23:12:13 +01:00
|
|
|
GetClientRect(parent_wnd, &rect);
|
|
|
|
|
2013-11-25 10:09:00 +01:00
|
|
|
tabHandle = CreateWindowA(WC_TABCONTROLA, "TestTab",
|
|
|
|
WS_CLIPSIBLINGS | WS_CLIPCHILDREN | TCS_FOCUSNEVER | style, 0, 0, rect.right,
|
|
|
|
rect.bottom, parent_wnd, NULL, NULL, 0);
|
2014-02-13 09:31:48 +01:00
|
|
|
ok(tabHandle != NULL, "failed to create tab wnd\n");
|
2007-03-11 22:21:12 +01:00
|
|
|
|
2018-01-25 15:23:15 +01:00
|
|
|
oldproc = (WNDPROC)SetWindowLongPtrA(tabHandle, GWLP_WNDPROC, (LONG_PTR)tab_subclass_proc);
|
2009-10-11 14:25:17 +02:00
|
|
|
SetWindowLongPtrA(tabHandle, GWLP_USERDATA, (LONG_PTR)oldproc);
|
2007-03-11 22:21:12 +01:00
|
|
|
|
|
|
|
tcNewTab.mask = mask;
|
|
|
|
|
|
|
|
for (i = 0; i < nTabs; i++)
|
|
|
|
{
|
|
|
|
char tabName[MAX_TABLEN];
|
|
|
|
|
|
|
|
sprintf(tabName, "Tab %d", i+1);
|
|
|
|
tcNewTab.pszText = tabName;
|
|
|
|
tcNewTab.iImage = i;
|
2013-11-25 10:09:00 +01:00
|
|
|
SendMessageA(tabHandle, TCM_INSERTITEMA, i, (LPARAM)&tcNewTab);
|
2007-03-11 22:21:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (winetest_interactive)
|
|
|
|
{
|
|
|
|
ShowWindow (tabHandle, SW_SHOW);
|
|
|
|
RedrawWindow (tabHandle, NULL, 0, RDW_UPDATENOW);
|
|
|
|
Sleep (1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
return tabHandle;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HWND create_tooltip (HWND hTab, char toolTipText[])
|
|
|
|
{
|
|
|
|
HWND hwndTT;
|
|
|
|
|
2013-11-25 10:09:00 +01:00
|
|
|
TTTOOLINFOA ti;
|
|
|
|
LPSTR lptstr = toolTipText;
|
2007-03-11 22:21:12 +01:00
|
|
|
RECT rect;
|
|
|
|
|
|
|
|
/* Creating a tooltip window*/
|
2013-11-25 10:09:00 +01:00
|
|
|
hwndTT = CreateWindowExA(WS_EX_TOPMOST, TOOLTIPS_CLASSA, NULL,
|
|
|
|
WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
CW_USEDEFAULT, hTab, NULL, 0, NULL);
|
2007-03-11 22:21:12 +01:00
|
|
|
|
|
|
|
SetWindowPos(
|
|
|
|
hwndTT,
|
|
|
|
HWND_TOPMOST,
|
|
|
|
0, 0, 0, 0,
|
|
|
|
SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
|
|
|
|
|
|
|
|
GetClientRect (hTab, &rect);
|
|
|
|
|
|
|
|
/* Initialize members of toolinfo*/
|
2013-11-25 10:09:00 +01:00
|
|
|
ti.cbSize = sizeof(TTTOOLINFOA);
|
2007-03-11 22:21:12 +01:00
|
|
|
ti.uFlags = TTF_SUBCLASS;
|
|
|
|
ti.hwnd = hTab;
|
|
|
|
ti.hinst = 0;
|
|
|
|
ti.uId = 0;
|
|
|
|
ti.lpszText = lptstr;
|
|
|
|
|
|
|
|
ti.rect = rect;
|
|
|
|
|
|
|
|
/* Add toolinfo structure to the tooltip control */
|
2013-11-25 10:09:00 +01:00
|
|
|
SendMessageA(hwndTT, TTM_ADDTOOLA, 0, (LPARAM)&ti);
|
2007-03-11 22:21:12 +01:00
|
|
|
|
|
|
|
return hwndTT;
|
|
|
|
}
|
|
|
|
|
2005-08-23 12:05:54 +02:00
|
|
|
static void test_tab(INT nMinTabWidth)
|
2003-10-31 01:06:42 +01:00
|
|
|
{
|
|
|
|
HWND hwTab;
|
2005-08-23 12:05:54 +02:00
|
|
|
RECT rTab;
|
2018-01-24 13:47:09 +01:00
|
|
|
HIMAGELIST himl = pImageList_Create(21, 21, ILC_COLOR, 3, 4);
|
2005-08-23 12:05:54 +02:00
|
|
|
SIZE size;
|
|
|
|
HDC hdc;
|
|
|
|
HFONT hOldFont;
|
2009-08-05 14:00:03 +02:00
|
|
|
INT i, dpi, exp;
|
2005-08-23 12:05:54 +02:00
|
|
|
|
|
|
|
hwTab = create_tabcontrol(TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE);
|
2013-11-25 10:09:00 +01:00
|
|
|
SendMessageA(hwTab, TCM_SETMINTABWIDTH, 0, nMinTabWidth);
|
2008-12-02 15:14:35 +01:00
|
|
|
/* Get System default MinTabWidth */
|
|
|
|
if (nMinTabWidth < 0)
|
2013-11-25 10:09:00 +01:00
|
|
|
nMinTabWidth = SendMessageA(hwTab, TCM_SETMINTABWIDTH, 0, nMinTabWidth);
|
2005-08-23 12:05:54 +02:00
|
|
|
|
|
|
|
hdc = GetDC(hwTab);
|
2008-10-14 01:17:43 +02:00
|
|
|
dpi = GetDeviceCaps(hdc, LOGPIXELSX);
|
2013-11-25 10:09:00 +01:00
|
|
|
hOldFont = SelectObject(hdc, (HFONT)SendMessageA(hwTab, WM_GETFONT, 0, 0));
|
2005-08-23 12:05:54 +02:00
|
|
|
GetTextExtentPoint32A(hdc, "Tab 1", strlen("Tab 1"), &size);
|
2006-10-13 15:17:40 +02:00
|
|
|
trace("Tab1 text size: size.cx=%d size.cy=%d\n", size.cx, size.cy);
|
2005-08-23 12:05:54 +02:00
|
|
|
SelectObject(hdc, hOldFont);
|
|
|
|
ReleaseDC(hwTab, hdc);
|
|
|
|
|
|
|
|
trace (" TCS_FIXEDWIDTH tabs no icon...\n");
|
2011-05-12 09:59:53 +02:00
|
|
|
CHECKSIZE(hwTab, dpi, -1, "default width");
|
|
|
|
TABCHECKSETSIZE(hwTab, 50, 20, 50, 20, "set size");
|
|
|
|
TABCHECKSETSIZE(hwTab, 0, 1, 0, 1, "min size");
|
2003-10-31 01:06:42 +01:00
|
|
|
|
2013-11-25 10:09:00 +01:00
|
|
|
SendMessageA(hwTab, TCM_SETIMAGELIST, 0, (LPARAM)himl);
|
2003-10-31 01:06:42 +01:00
|
|
|
|
2005-08-23 12:05:54 +02:00
|
|
|
trace (" TCS_FIXEDWIDTH tabs with icon...\n");
|
2011-05-12 09:59:53 +02:00
|
|
|
TABCHECKSETSIZE(hwTab, 50, 30, 50, 30, "set size > icon");
|
|
|
|
TABCHECKSETSIZE(hwTab, 20, 20, 25, 20, "set size < icon");
|
|
|
|
TABCHECKSETSIZE(hwTab, 0, 1, 25, 1, "min size");
|
2005-08-23 12:05:54 +02:00
|
|
|
|
|
|
|
DestroyWindow (hwTab);
|
2003-10-31 01:06:42 +01:00
|
|
|
|
2005-08-23 12:05:54 +02:00
|
|
|
hwTab = create_tabcontrol(TCS_FIXEDWIDTH | TCS_BUTTONS, TCIF_TEXT|TCIF_IMAGE);
|
2013-11-25 10:09:00 +01:00
|
|
|
SendMessageA(hwTab, TCM_SETMINTABWIDTH, 0, nMinTabWidth);
|
2003-10-31 01:06:42 +01:00
|
|
|
|
2008-10-14 01:17:43 +02:00
|
|
|
hdc = GetDC(hwTab);
|
|
|
|
dpi = GetDeviceCaps(hdc, LOGPIXELSX);
|
|
|
|
ReleaseDC(hwTab, hdc);
|
2005-08-23 12:05:54 +02:00
|
|
|
trace (" TCS_FIXEDWIDTH buttons no icon...\n");
|
2011-05-12 09:59:53 +02:00
|
|
|
CHECKSIZE(hwTab, dpi, -1, "default width");
|
|
|
|
TABCHECKSETSIZE(hwTab, 20, 20, 20, 20, "set size 1");
|
|
|
|
TABCHECKSETSIZE(hwTab, 10, 50, 10, 50, "set size 2");
|
|
|
|
TABCHECKSETSIZE(hwTab, 0, 1, 0, 1, "min size");
|
2003-10-31 01:06:42 +01:00
|
|
|
|
2013-11-25 10:09:00 +01:00
|
|
|
SendMessageA(hwTab, TCM_SETIMAGELIST, 0, (LPARAM)himl);
|
2003-10-31 01:06:42 +01:00
|
|
|
|
2005-08-23 12:05:54 +02:00
|
|
|
trace (" TCS_FIXEDWIDTH buttons with icon...\n");
|
2011-05-12 09:59:53 +02:00
|
|
|
TABCHECKSETSIZE(hwTab, 50, 30, 50, 30, "set size > icon");
|
|
|
|
TABCHECKSETSIZE(hwTab, 20, 20, 25, 20, "set size < icon");
|
|
|
|
TABCHECKSETSIZE(hwTab, 0, 1, 25, 1, "min size");
|
2013-11-25 10:09:00 +01:00
|
|
|
SendMessageA(hwTab, TCM_SETPADDING, 0, MAKELPARAM(4, 4));
|
2011-05-12 09:59:53 +02:00
|
|
|
TABCHECKSETSIZE(hwTab, 0, 1, 25, 1, "set padding, min size");
|
2003-10-31 01:06:42 +01:00
|
|
|
|
|
|
|
DestroyWindow (hwTab);
|
|
|
|
|
2005-08-23 12:05:54 +02:00
|
|
|
hwTab = create_tabcontrol(TCS_FIXEDWIDTH | TCS_BOTTOM, TCIF_TEXT|TCIF_IMAGE);
|
2013-11-25 10:09:00 +01:00
|
|
|
SendMessageA(hwTab, TCM_SETMINTABWIDTH, 0, nMinTabWidth);
|
2005-08-23 12:05:54 +02:00
|
|
|
|
2008-10-14 01:17:43 +02:00
|
|
|
hdc = GetDC(hwTab);
|
|
|
|
dpi = GetDeviceCaps(hdc, LOGPIXELSX);
|
|
|
|
ReleaseDC(hwTab, hdc);
|
2005-08-23 12:05:54 +02:00
|
|
|
trace (" TCS_FIXEDWIDTH | TCS_BOTTOM tabs...\n");
|
2011-05-12 09:59:53 +02:00
|
|
|
CHECKSIZE(hwTab, dpi, -1, "no icon, default width");
|
2003-10-31 01:06:42 +01:00
|
|
|
|
2011-05-12 09:59:53 +02:00
|
|
|
TABCHECKSETSIZE(hwTab, 20, 20, 20, 20, "no icon, set size 1");
|
|
|
|
TABCHECKSETSIZE(hwTab, 10, 50, 10, 50, "no icon, set size 2");
|
|
|
|
TABCHECKSETSIZE(hwTab, 0, 1, 0, 1, "no icon, min size");
|
2003-10-31 01:06:42 +01:00
|
|
|
|
2013-11-25 10:09:00 +01:00
|
|
|
SendMessageA(hwTab, TCM_SETIMAGELIST, 0, (LPARAM)himl);
|
2003-10-31 01:06:42 +01:00
|
|
|
|
2011-05-12 09:59:53 +02:00
|
|
|
TABCHECKSETSIZE(hwTab, 50, 30, 50, 30, "with icon, set size > icon");
|
|
|
|
TABCHECKSETSIZE(hwTab, 20, 20, 25, 20, "with icon, set size < icon");
|
|
|
|
TABCHECKSETSIZE(hwTab, 0, 1, 25, 1, "with icon, min size");
|
2013-11-25 10:09:00 +01:00
|
|
|
SendMessageA(hwTab, TCM_SETPADDING, 0, MAKELPARAM(4, 4));
|
2011-05-12 09:59:53 +02:00
|
|
|
TABCHECKSETSIZE(hwTab, 0, 1, 25, 1, "set padding, min size");
|
2003-12-02 04:31:44 +01:00
|
|
|
|
|
|
|
DestroyWindow (hwTab);
|
|
|
|
|
2005-08-23 12:05:54 +02:00
|
|
|
hwTab = create_tabcontrol(0, TCIF_TEXT|TCIF_IMAGE);
|
2013-11-25 10:09:00 +01:00
|
|
|
SendMessageA(hwTab, TCM_SETMINTABWIDTH, 0, nMinTabWidth);
|
2003-12-02 04:31:44 +01:00
|
|
|
|
2005-08-23 12:05:54 +02:00
|
|
|
trace (" non fixed width, with text...\n");
|
2009-08-05 14:00:03 +02:00
|
|
|
exp = max(size.cx +TAB_PADDING_X*2, (nMinTabWidth < 0) ? DEFAULT_MIN_TAB_WIDTH : nMinTabWidth);
|
2013-11-25 10:09:00 +01:00
|
|
|
SendMessageA( hwTab, TCM_GETITEMRECT, 0, (LPARAM)&rTab );
|
2009-08-05 14:00:03 +02:00
|
|
|
ok( rTab.right - rTab.left == exp || broken(rTab.right - rTab.left == DEFAULT_MIN_TAB_WIDTH),
|
|
|
|
"no icon, default width: Expected width [%d] got [%d]\n", exp, rTab.right - rTab.left );
|
|
|
|
|
2005-08-23 12:05:54 +02:00
|
|
|
for (i=0; i<8; i++)
|
|
|
|
{
|
|
|
|
INT nTabWidth = (nMinTabWidth < 0) ? TabWidthPadded(i, 2) : nMinTabWidth;
|
2003-12-02 04:31:44 +01:00
|
|
|
|
2013-11-25 10:09:00 +01:00
|
|
|
SendMessageA(hwTab, TCM_SETIMAGELIST, 0, 0);
|
|
|
|
SendMessageA(hwTab, TCM_SETPADDING, 0, MAKELPARAM(i, i));
|
2003-12-02 04:31:44 +01:00
|
|
|
|
2011-05-12 09:59:53 +02:00
|
|
|
TABCHECKSETSIZE(hwTab, 50, 20, max(size.cx + i*2, nTabWidth), 20, "no icon, set size");
|
|
|
|
TABCHECKSETSIZE(hwTab, 0, 1, max(size.cx + i*2, nTabWidth), 1, "no icon, min size");
|
2005-08-23 12:05:54 +02:00
|
|
|
|
2013-11-25 10:09:00 +01:00
|
|
|
SendMessageA(hwTab, TCM_SETIMAGELIST, 0, (LPARAM)himl);
|
2005-08-23 12:05:54 +02:00
|
|
|
nTabWidth = (nMinTabWidth < 0) ? TabWidthPadded(i, 3) : nMinTabWidth;
|
|
|
|
|
2011-05-12 09:59:53 +02:00
|
|
|
TABCHECKSETSIZE(hwTab, 50, 30, max(size.cx + 21 + i*3, nTabWidth), 30, "with icon, set size > icon");
|
|
|
|
TABCHECKSETSIZE(hwTab, 20, 20, max(size.cx + 21 + i*3, nTabWidth), 20, "with icon, set size < icon");
|
|
|
|
TABCHECKSETSIZE(hwTab, 0, 1, max(size.cx + 21 + i*3, nTabWidth), 1, "with icon, min size");
|
2005-08-23 12:05:54 +02:00
|
|
|
}
|
2003-10-31 01:06:42 +01:00
|
|
|
DestroyWindow (hwTab);
|
2003-12-02 04:31:44 +01:00
|
|
|
|
2005-08-23 12:05:54 +02:00
|
|
|
hwTab = create_tabcontrol(0, TCIF_IMAGE);
|
2013-11-25 10:09:00 +01:00
|
|
|
SendMessageA(hwTab, TCM_SETMINTABWIDTH, 0, nMinTabWidth);
|
2005-08-23 12:05:54 +02:00
|
|
|
|
|
|
|
trace (" non fixed width, no text...\n");
|
2009-08-05 14:00:03 +02:00
|
|
|
exp = (nMinTabWidth < 0) ? DEFAULT_MIN_TAB_WIDTH : nMinTabWidth;
|
2013-11-25 10:09:00 +01:00
|
|
|
SendMessageA( hwTab, TCM_GETITEMRECT, 0, (LPARAM)&rTab );
|
2009-08-05 14:00:03 +02:00
|
|
|
ok( rTab.right - rTab.left == exp || broken(rTab.right - rTab.left == DEFAULT_MIN_TAB_WIDTH),
|
|
|
|
"no icon, default width: Expected width [%d] got [%d]\n", exp, rTab.right - rTab.left );
|
|
|
|
|
2005-08-23 12:05:54 +02:00
|
|
|
for (i=0; i<8; i++)
|
|
|
|
{
|
|
|
|
INT nTabWidth = (nMinTabWidth < 0) ? TabWidthPadded(i, 2) : nMinTabWidth;
|
|
|
|
|
2013-11-25 10:09:00 +01:00
|
|
|
SendMessageA(hwTab, TCM_SETIMAGELIST, 0, 0);
|
|
|
|
SendMessageA(hwTab, TCM_SETPADDING, 0, MAKELPARAM(i, i));
|
2005-08-23 12:05:54 +02:00
|
|
|
|
2011-05-12 09:59:53 +02:00
|
|
|
TABCHECKSETSIZE(hwTab, 50, 20, nTabWidth, 20, "no icon, set size");
|
|
|
|
TABCHECKSETSIZE(hwTab, 0, 1, nTabWidth, 1, "no icon, min size");
|
2005-08-23 12:05:54 +02:00
|
|
|
|
2013-11-25 10:09:00 +01:00
|
|
|
SendMessageA(hwTab, TCM_SETIMAGELIST, 0, (LPARAM)himl);
|
2005-08-23 12:05:54 +02:00
|
|
|
if (i > 1 && nMinTabWidth > 0 && nMinTabWidth < DEFAULT_MIN_TAB_WIDTH)
|
|
|
|
nTabWidth += EXTRA_ICON_PADDING *(i-1);
|
|
|
|
|
2011-05-12 09:59:53 +02:00
|
|
|
TABCHECKSETSIZE(hwTab, 50, 30, nTabWidth, 30, "with icon, set size > icon");
|
|
|
|
TABCHECKSETSIZE(hwTab, 20, 20, nTabWidth, 20, "with icon, set size < icon");
|
|
|
|
TABCHECKSETSIZE(hwTab, 0, 1, nTabWidth, 1, "with icon, min size");
|
2005-08-23 12:05:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DestroyWindow (hwTab);
|
2003-12-02 04:31:44 +01:00
|
|
|
|
2018-01-24 13:47:09 +01:00
|
|
|
pImageList_Destroy(himl);
|
2005-08-23 12:05:54 +02:00
|
|
|
}
|
|
|
|
|
2011-04-23 21:37:34 +02:00
|
|
|
static void test_width(void)
|
2009-11-20 06:37:23 +01:00
|
|
|
{
|
2011-04-23 21:37:34 +02:00
|
|
|
trace ("Testing with default MinWidth\n");
|
|
|
|
test_tab(-1);
|
|
|
|
trace ("Testing with MinWidth set to -3\n");
|
|
|
|
test_tab(-3);
|
|
|
|
trace ("Testing with MinWidth set to 24\n");
|
|
|
|
test_tab(24);
|
|
|
|
trace ("Testing with MinWidth set to 54\n");
|
|
|
|
test_tab(54);
|
|
|
|
trace ("Testing with MinWidth set to 94\n");
|
|
|
|
test_tab(94);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_curfocus(void)
|
|
|
|
{
|
|
|
|
const INT nTabs = 5;
|
2018-01-29 12:20:40 +01:00
|
|
|
INT ret;
|
2009-11-20 06:37:23 +01:00
|
|
|
HWND hTab;
|
|
|
|
|
|
|
|
hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE, nTabs);
|
|
|
|
ok(hTab != NULL, "Failed to create tab control\n");
|
|
|
|
|
|
|
|
flush_sequences(sequences, NUM_MSG_SEQUENCES);
|
|
|
|
|
|
|
|
/* Testing CurFocus with largest appropriate value */
|
2018-01-29 12:20:40 +01:00
|
|
|
ret = SendMessageA(hTab, TCM_SETCURFOCUS, nTabs - 1, 0);
|
|
|
|
ok(ret == 0, "Unexpected ret value %d.\n", ret);
|
|
|
|
ret = SendMessageA(hTab, TCM_GETCURFOCUS, 0, 0);
|
|
|
|
ok(ret == nTabs - 1, "Unexpected focus index %d.\n", ret);
|
2009-11-20 06:37:23 +01:00
|
|
|
|
|
|
|
/* Testing CurFocus with negative value */
|
2018-01-29 12:20:40 +01:00
|
|
|
ret = SendMessageA(hTab, TCM_SETCURFOCUS, -10, 0);
|
|
|
|
ok(ret == 0, "Unexpected ret value %d.\n", ret);
|
|
|
|
ret = SendMessageA(hTab, TCM_GETCURFOCUS, 0, 0);
|
|
|
|
ok(ret == -1, "Unexpected focus index %d.\n", ret);
|
2009-11-20 06:37:23 +01:00
|
|
|
|
|
|
|
/* Testing CurFocus with value larger than number of tabs */
|
2018-01-29 12:20:40 +01:00
|
|
|
ret = SendMessageA(hTab, TCM_SETCURSEL, 1, 0);
|
|
|
|
ok(ret == -1, "Unexpected focus index %d.\n", ret);
|
|
|
|
|
|
|
|
ret = SendMessageA(hTab, TCM_SETCURFOCUS, nTabs + 1, 0);
|
|
|
|
ok(ret == 0, "Unexpected ret value %d.\n", ret);
|
|
|
|
ret = SendMessageA(hTab, TCM_GETCURFOCUS, 0, 0);
|
|
|
|
ok(ret == 1, "Unexpected focus index %d.\n", ret);
|
2009-11-20 06:37:23 +01:00
|
|
|
|
2018-01-29 12:20:40 +01:00
|
|
|
ok_sequence(sequences, TAB_SEQ_INDEX, getset_cur_focus_seq, "Set focused tab sequence", FALSE);
|
|
|
|
ok_sequence(sequences, PARENT_SEQ_INDEX, empty_sequence, "Set focused tab parent sequence", TRUE);
|
|
|
|
|
|
|
|
DestroyWindow(hTab);
|
|
|
|
|
|
|
|
/* TCS_BUTTONS */
|
|
|
|
hTab = createFilledTabControl(parent_wnd, TCS_BUTTONS, TCIF_TEXT|TCIF_IMAGE, nTabs);
|
|
|
|
ok(hTab != NULL, "Failed to create tab control\n");
|
2009-11-20 06:37:23 +01:00
|
|
|
|
2018-01-29 12:20:40 +01:00
|
|
|
flush_sequences(sequences, NUM_MSG_SEQUENCES);
|
|
|
|
|
|
|
|
/* Testing CurFocus with largest appropriate value */
|
|
|
|
ret = SendMessageA(hTab, TCM_SETCURFOCUS, nTabs - 1, 0);
|
|
|
|
ok(ret == 0, "Unexpected ret value %d.\n", ret);
|
|
|
|
ret = SendMessageA(hTab, TCM_GETCURFOCUS, 0, 0);
|
|
|
|
ok(ret == nTabs - 1, "Unexpected focus index %d.\n", ret);
|
|
|
|
|
|
|
|
/* Testing CurFocus with negative value */
|
|
|
|
ret = SendMessageA(hTab, TCM_SETCURFOCUS, -10, 0);
|
|
|
|
ok(ret == 0, "Unexpected ret value %d.\n", ret);
|
|
|
|
ret = SendMessageA(hTab, TCM_GETCURFOCUS, 0, 0);
|
|
|
|
todo_wine
|
|
|
|
ok(ret == nTabs - 1, "Unexpected focus index %d.\n", ret);
|
|
|
|
|
|
|
|
/* Testing CurFocus with value larger than number of tabs */
|
|
|
|
ret = SendMessageA(hTab, TCM_SETCURSEL, 1, 0);
|
|
|
|
todo_wine
|
|
|
|
ok(ret == 0, "Unexpected focus index %d.\n", ret);
|
|
|
|
|
|
|
|
ret = SendMessageA(hTab, TCM_SETCURFOCUS, nTabs + 1, 0);
|
|
|
|
ok(ret == 0, "Unexpected ret value %d.\n", ret);
|
|
|
|
ret = SendMessageA(hTab, TCM_GETCURFOCUS, 0, 0);
|
|
|
|
todo_wine
|
|
|
|
ok(ret == nTabs - 1, "Unexpected focus index %d.\n", ret);
|
|
|
|
|
|
|
|
ok_sequence(sequences, TAB_SEQ_INDEX, getset_cur_focus_seq, "TCS_BUTTONS: set focused tab sequence", FALSE);
|
|
|
|
ok_sequence(sequences, PARENT_SEQ_INDEX, setfocus_parent_seq, "TCS_BUTTONS: set focused tab parent sequence", TRUE);
|
2009-11-20 06:37:23 +01:00
|
|
|
|
|
|
|
DestroyWindow(hTab);
|
|
|
|
}
|
|
|
|
|
2011-04-23 21:37:34 +02:00
|
|
|
static void test_cursel(void)
|
2009-11-20 06:37:23 +01:00
|
|
|
{
|
2011-04-23 21:37:34 +02:00
|
|
|
const INT nTabs = 5;
|
2009-11-20 06:37:23 +01:00
|
|
|
INT selectionIndex;
|
|
|
|
INT focusIndex;
|
2013-11-25 10:09:00 +01:00
|
|
|
TCITEMA tcItem;
|
2009-11-20 06:37:23 +01:00
|
|
|
HWND hTab;
|
|
|
|
|
|
|
|
hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE, nTabs);
|
|
|
|
ok(hTab != NULL, "Failed to create tab control\n");
|
|
|
|
|
|
|
|
flush_sequences(sequences, NUM_MSG_SEQUENCES);
|
|
|
|
|
|
|
|
/* Testing CurSel with largest appropriate value */
|
2013-11-25 10:09:00 +01:00
|
|
|
selectionIndex = SendMessageA(hTab, TCM_SETCURSEL, nTabs - 1, 0);
|
2009-11-20 06:37:23 +01:00
|
|
|
expect(0, selectionIndex);
|
2013-11-25 10:09:00 +01:00
|
|
|
selectionIndex = SendMessageA(hTab, TCM_GETCURSEL, 0, 0);
|
2009-11-20 06:37:23 +01:00
|
|
|
expect(nTabs-1, selectionIndex);
|
|
|
|
|
|
|
|
/* Focus should switch with selection */
|
2013-11-25 10:09:00 +01:00
|
|
|
focusIndex = SendMessageA(hTab, TCM_GETCURFOCUS, 0, 0);
|
2009-11-20 06:37:23 +01:00
|
|
|
expect(nTabs-1, focusIndex);
|
|
|
|
|
|
|
|
/* Testing CurSel with negative value */
|
2013-11-25 10:09:00 +01:00
|
|
|
SendMessageA(hTab, TCM_SETCURSEL, -10, 0);
|
|
|
|
selectionIndex = SendMessageA(hTab, TCM_GETCURSEL, 0, 0);
|
2009-11-20 06:37:23 +01:00
|
|
|
expect(-1, selectionIndex);
|
|
|
|
|
|
|
|
/* Testing CurSel with value larger than number of tabs */
|
2013-11-25 10:09:00 +01:00
|
|
|
selectionIndex = SendMessageA(hTab, TCM_SETCURSEL, 1, 0);
|
2009-11-20 06:37:23 +01:00
|
|
|
expect(-1, selectionIndex);
|
|
|
|
|
2013-11-25 10:09:00 +01:00
|
|
|
selectionIndex = SendMessageA(hTab, TCM_SETCURSEL, nTabs + 1, 0);
|
2009-11-20 06:37:23 +01:00
|
|
|
expect(-1, selectionIndex);
|
2013-11-25 10:09:00 +01:00
|
|
|
selectionIndex = SendMessageA(hTab, TCM_GETCURFOCUS, 0, 0);
|
2009-11-20 06:37:23 +01:00
|
|
|
expect(1, selectionIndex);
|
|
|
|
|
|
|
|
ok_sequence(sequences, TAB_SEQ_INDEX, getset_cur_sel_seq, "Getset curSel test sequence", FALSE);
|
|
|
|
ok_sequence(sequences, PARENT_SEQ_INDEX, empty_sequence, "Getset curSel test parent sequence", FALSE);
|
|
|
|
|
|
|
|
/* selected item should have TCIS_BUTTONPRESSED state
|
|
|
|
It doesn't depend on button state */
|
2013-11-25 10:09:00 +01:00
|
|
|
memset(&tcItem, 0, sizeof(TCITEMA));
|
2009-11-20 06:37:23 +01:00
|
|
|
tcItem.mask = TCIF_STATE;
|
|
|
|
tcItem.dwStateMask = TCIS_BUTTONPRESSED;
|
2013-11-25 10:09:00 +01:00
|
|
|
selectionIndex = SendMessageA(hTab, TCM_GETCURSEL, 0, 0);
|
|
|
|
SendMessageA(hTab, TCM_GETITEMA, selectionIndex, (LPARAM)&tcItem);
|
2009-11-20 06:37:23 +01:00
|
|
|
ok (tcItem.dwState & TCIS_BUTTONPRESSED || broken(tcItem.dwState == 0), /* older comctl32 */
|
|
|
|
"Selected item should have TCIS_BUTTONPRESSED\n");
|
|
|
|
|
2014-02-09 14:52:17 +01:00
|
|
|
/* now deselect all and check previously selected item state */
|
|
|
|
focusIndex = SendMessageA(hTab, TCM_GETCURFOCUS, 0, 0);
|
|
|
|
ok(focusIndex == 1, "got %d\n", focusIndex);
|
|
|
|
|
|
|
|
selectionIndex = SendMessageA(hTab, TCM_SETCURSEL, -1, 0);
|
|
|
|
ok(selectionIndex == 1, "got %d\n", selectionIndex);
|
|
|
|
|
|
|
|
memset(&tcItem, 0, sizeof(TCITEMA));
|
|
|
|
|
|
|
|
/* focus is reset too */
|
|
|
|
focusIndex = SendMessageA(hTab, TCM_GETCURFOCUS, 0, 0);
|
|
|
|
ok(focusIndex == -1, "got %d\n", focusIndex);
|
|
|
|
|
|
|
|
tcItem.mask = TCIF_STATE;
|
|
|
|
tcItem.dwStateMask = TCIS_BUTTONPRESSED;
|
|
|
|
SendMessageA(hTab, TCM_GETITEMA, selectionIndex, (LPARAM)&tcItem);
|
|
|
|
ok(tcItem.dwState == 0, "got state %d\n", tcItem.dwState);
|
|
|
|
|
2009-11-20 06:37:23 +01:00
|
|
|
DestroyWindow(hTab);
|
|
|
|
}
|
|
|
|
|
2011-04-23 21:37:34 +02:00
|
|
|
static void test_extendedstyle(void)
|
2009-11-20 06:37:23 +01:00
|
|
|
{
|
2011-04-23 21:37:34 +02:00
|
|
|
const INT nTabs = 5;
|
2009-11-20 06:37:23 +01:00
|
|
|
DWORD prevExtendedStyle;
|
|
|
|
DWORD extendedStyle;
|
|
|
|
HWND hTab;
|
|
|
|
|
|
|
|
hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE, nTabs);
|
|
|
|
ok(hTab != NULL, "Failed to create tab control\n");
|
|
|
|
|
|
|
|
flush_sequences(sequences, NUM_MSG_SEQUENCES);
|
|
|
|
|
|
|
|
/* Testing Flat Separators */
|
2013-11-25 10:09:00 +01:00
|
|
|
extendedStyle = SendMessageA(hTab, TCM_GETEXTENDEDSTYLE, 0, 0);
|
|
|
|
prevExtendedStyle = SendMessageA(hTab, TCM_SETEXTENDEDSTYLE, 0, TCS_EX_FLATSEPARATORS);
|
2009-11-20 06:37:23 +01:00
|
|
|
expect(extendedStyle, prevExtendedStyle);
|
|
|
|
|
2013-11-25 10:09:00 +01:00
|
|
|
extendedStyle = SendMessageA(hTab, TCM_GETEXTENDEDSTYLE, 0, 0);
|
2009-11-20 06:37:23 +01:00
|
|
|
expect(TCS_EX_FLATSEPARATORS, extendedStyle);
|
|
|
|
|
|
|
|
/* Testing Register Drop */
|
2013-11-25 10:09:00 +01:00
|
|
|
prevExtendedStyle = SendMessageA(hTab, TCM_SETEXTENDEDSTYLE, 0, TCS_EX_REGISTERDROP);
|
2009-11-20 06:37:23 +01:00
|
|
|
expect(extendedStyle, prevExtendedStyle);
|
|
|
|
|
2013-11-25 10:09:00 +01:00
|
|
|
extendedStyle = SendMessageA(hTab, TCM_GETEXTENDEDSTYLE, 0, 0);
|
2009-11-20 06:37:23 +01:00
|
|
|
todo_wine{
|
|
|
|
expect(TCS_EX_REGISTERDROP, extendedStyle);
|
|
|
|
}
|
|
|
|
|
|
|
|
ok_sequence(sequences, TAB_SEQ_INDEX, getset_extended_style_seq, "Getset extendedStyle test sequence", FALSE);
|
|
|
|
ok_sequence(sequences, PARENT_SEQ_INDEX, empty_sequence, "Getset extendedStyle test parent sequence", FALSE);
|
|
|
|
|
|
|
|
DestroyWindow(hTab);
|
|
|
|
}
|
|
|
|
|
2011-04-23 21:37:34 +02:00
|
|
|
static void test_unicodeformat(void)
|
2009-11-20 06:37:23 +01:00
|
|
|
{
|
2011-04-23 21:37:34 +02:00
|
|
|
const INT nTabs = 5;
|
2009-11-20 06:37:23 +01:00
|
|
|
INT unicodeFormat;
|
|
|
|
HWND hTab;
|
|
|
|
|
|
|
|
hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE, nTabs);
|
|
|
|
ok(hTab != NULL, "Failed to create tab control\n");
|
|
|
|
|
|
|
|
flush_sequences(sequences, NUM_MSG_SEQUENCES);
|
|
|
|
|
2013-11-25 10:09:00 +01:00
|
|
|
unicodeFormat = SendMessageA(hTab, TCM_SETUNICODEFORMAT, TRUE, 0);
|
2009-11-20 06:37:23 +01:00
|
|
|
todo_wine{
|
|
|
|
expect(0, unicodeFormat);
|
|
|
|
}
|
2013-11-25 10:09:00 +01:00
|
|
|
unicodeFormat = SendMessageA(hTab, TCM_GETUNICODEFORMAT, 0, 0);
|
2009-11-20 06:37:23 +01:00
|
|
|
expect(1, unicodeFormat);
|
|
|
|
|
2013-11-25 10:09:00 +01:00
|
|
|
unicodeFormat = SendMessageA(hTab, TCM_SETUNICODEFORMAT, FALSE, 0);
|
2009-11-20 06:37:23 +01:00
|
|
|
expect(1, unicodeFormat);
|
2013-11-25 10:09:00 +01:00
|
|
|
unicodeFormat = SendMessageA(hTab, TCM_GETUNICODEFORMAT, 0, 0);
|
2009-11-20 06:37:23 +01:00
|
|
|
expect(0, unicodeFormat);
|
|
|
|
|
2013-11-25 10:09:00 +01:00
|
|
|
unicodeFormat = SendMessageA(hTab, TCM_SETUNICODEFORMAT, TRUE, 0);
|
2009-11-20 06:37:23 +01:00
|
|
|
expect(0, unicodeFormat);
|
|
|
|
|
|
|
|
ok_sequence(sequences, TAB_SEQ_INDEX, getset_unicode_format_seq, "Getset unicodeFormat test sequence", FALSE);
|
|
|
|
ok_sequence(sequences, PARENT_SEQ_INDEX, empty_sequence, "Getset unicodeFormat test parent sequence", FALSE);
|
|
|
|
|
|
|
|
DestroyWindow(hTab);
|
|
|
|
}
|
|
|
|
|
2011-04-23 21:37:34 +02:00
|
|
|
static void test_getset_item(void)
|
2009-11-20 06:37:23 +01:00
|
|
|
{
|
2010-10-02 23:58:12 +02:00
|
|
|
char szText[32] = "New Label";
|
2011-04-23 21:37:34 +02:00
|
|
|
const INT nTabs = 5;
|
2013-11-25 10:09:00 +01:00
|
|
|
TCITEMA tcItem;
|
2010-10-02 23:58:12 +02:00
|
|
|
LPARAM lparam;
|
2009-11-20 06:37:23 +01:00
|
|
|
DWORD ret;
|
|
|
|
HWND hTab;
|
|
|
|
|
2010-10-02 23:58:12 +02:00
|
|
|
hTab = CreateWindowA(
|
|
|
|
WC_TABCONTROLA,
|
|
|
|
"TestTab",
|
|
|
|
WS_CLIPSIBLINGS | WS_CLIPCHILDREN | TCS_FOCUSNEVER | TCS_FIXEDWIDTH | TCS_OWNERDRAWFIXED,
|
|
|
|
10, 10, 300, 100,
|
|
|
|
parent_wnd, NULL, NULL, 0);
|
|
|
|
|
|
|
|
ok(GetParent(hTab) == NULL, "got %p, expected null parent\n", GetParent(hTab));
|
|
|
|
|
|
|
|
ret = SendMessageA(hTab, TCM_SETITEMEXTRA, sizeof(LPARAM)-1, 0);
|
|
|
|
ok(ret == TRUE, "got %d\n", ret);
|
|
|
|
|
|
|
|
/* set some item data */
|
|
|
|
tcItem.lParam = ~0;
|
|
|
|
tcItem.mask = TCIF_PARAM;
|
|
|
|
|
|
|
|
ret = SendMessageA(hTab, TCM_INSERTITEMA, 0, (LPARAM)&tcItem);
|
|
|
|
ok(ret == 0, "got %d\n", ret);
|
|
|
|
|
|
|
|
/* all sizeof(LPARAM) returned anyway when using sizeof(LPARAM)-1 size */
|
|
|
|
memset(&lparam, 0xaa, sizeof(lparam));
|
|
|
|
tcItem.lParam = lparam;
|
|
|
|
tcItem.mask = TCIF_PARAM;
|
2013-11-25 10:09:00 +01:00
|
|
|
ret = SendMessageA(hTab, TCM_GETITEMA, 0, (LPARAM)&tcItem);
|
2010-10-02 23:58:12 +02:00
|
|
|
expect(TRUE, ret);
|
|
|
|
/* everything higher specified size is preserved */
|
|
|
|
memset(&lparam, 0xff, sizeof(lparam)-1);
|
|
|
|
ok(tcItem.lParam == lparam, "Expected 0x%lx, got 0x%lx\n", lparam, tcItem.lParam);
|
|
|
|
|
|
|
|
DestroyWindow(hTab);
|
|
|
|
|
2009-11-20 06:37:23 +01:00
|
|
|
hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE, nTabs);
|
|
|
|
ok(hTab != NULL, "Failed to create tab control\n");
|
|
|
|
|
|
|
|
/* passing invalid index should result in initialization to zero
|
|
|
|
for members mentioned in mask requested */
|
|
|
|
|
|
|
|
/* valid range here is [0,4] */
|
|
|
|
memset(&tcItem, 0xcc, sizeof(tcItem));
|
|
|
|
tcItem.mask = TCIF_PARAM;
|
2013-11-25 10:09:00 +01:00
|
|
|
ret = SendMessageA(hTab, TCM_GETITEMA, 5, (LPARAM)&tcItem);
|
2009-11-20 06:37:23 +01:00
|
|
|
expect(FALSE, ret);
|
|
|
|
ok(tcItem.lParam == 0, "Expected zero lParam, got %lu\n", tcItem.lParam);
|
|
|
|
|
|
|
|
memset(&tcItem, 0xcc, sizeof(tcItem));
|
|
|
|
tcItem.mask = TCIF_IMAGE;
|
2013-11-25 10:09:00 +01:00
|
|
|
ret = SendMessageA(hTab, TCM_GETITEMA, 5, (LPARAM)&tcItem);
|
2009-11-20 06:37:23 +01:00
|
|
|
expect(FALSE, ret);
|
|
|
|
expect(0, tcItem.iImage);
|
|
|
|
|
|
|
|
memset(&tcItem, 0xcc, sizeof(tcItem));
|
|
|
|
tcItem.mask = TCIF_TEXT;
|
|
|
|
tcItem.pszText = szText;
|
|
|
|
szText[0] = 'a';
|
2013-11-25 10:09:00 +01:00
|
|
|
ret = SendMessageA(hTab, TCM_GETITEMA, 5, (LPARAM)&tcItem);
|
2009-11-20 06:37:23 +01:00
|
|
|
expect(FALSE, ret);
|
|
|
|
expect('a', szText[0]);
|
|
|
|
|
|
|
|
memset(&tcItem, 0xcc, sizeof(tcItem));
|
|
|
|
tcItem.mask = TCIF_STATE;
|
|
|
|
tcItem.dwStateMask = 0;
|
|
|
|
tcItem.dwState = TCIS_BUTTONPRESSED;
|
2013-11-25 10:09:00 +01:00
|
|
|
ret = SendMessageA(hTab, TCM_GETITEMA, 5, (LPARAM)&tcItem);
|
2009-11-20 06:37:23 +01:00
|
|
|
expect(FALSE, ret);
|
|
|
|
ok(tcItem.dwState == 0, "Expected zero dwState, got %u\n", tcItem.dwState);
|
|
|
|
|
|
|
|
memset(&tcItem, 0xcc, sizeof(tcItem));
|
|
|
|
tcItem.mask = TCIF_STATE;
|
|
|
|
tcItem.dwStateMask = TCIS_BUTTONPRESSED;
|
|
|
|
tcItem.dwState = TCIS_BUTTONPRESSED;
|
2013-11-25 10:09:00 +01:00
|
|
|
ret = SendMessageA(hTab, TCM_GETITEMA, 5, (LPARAM)&tcItem);
|
2009-11-20 06:37:23 +01:00
|
|
|
expect(FALSE, ret);
|
|
|
|
ok(tcItem.dwState == 0, "Expected zero dwState\n");
|
|
|
|
|
|
|
|
/* check with negative index to be sure */
|
|
|
|
memset(&tcItem, 0xcc, sizeof(tcItem));
|
|
|
|
tcItem.mask = TCIF_PARAM;
|
2013-11-25 10:09:00 +01:00
|
|
|
ret = SendMessageA(hTab, TCM_GETITEMA, -1, (LPARAM)&tcItem);
|
2009-11-20 06:37:23 +01:00
|
|
|
expect(FALSE, ret);
|
|
|
|
ok(tcItem.lParam == 0, "Expected zero lParam, got %lu\n", tcItem.lParam);
|
|
|
|
|
|
|
|
memset(&tcItem, 0xcc, sizeof(tcItem));
|
|
|
|
tcItem.mask = TCIF_PARAM;
|
2013-11-25 10:09:00 +01:00
|
|
|
ret = SendMessageA(hTab, TCM_GETITEMA, -2, (LPARAM)&tcItem);
|
2009-11-20 06:37:23 +01:00
|
|
|
expect(FALSE, ret);
|
|
|
|
ok(tcItem.lParam == 0, "Expected zero lParam, got %lu\n", tcItem.lParam);
|
|
|
|
|
|
|
|
flush_sequences(sequences, NUM_MSG_SEQUENCES);
|
|
|
|
|
|
|
|
tcItem.mask = TCIF_TEXT;
|
|
|
|
tcItem.pszText = &szText[0];
|
|
|
|
tcItem.cchTextMax = sizeof(szText);
|
|
|
|
|
|
|
|
strcpy(szText, "New Label");
|
2013-11-25 10:09:00 +01:00
|
|
|
ok(SendMessageA(hTab, TCM_SETITEMA, 0, (LPARAM)&tcItem), "Setting new item failed.\n");
|
|
|
|
ok(SendMessageA(hTab, TCM_GETITEMA, 0, (LPARAM)&tcItem), "Getting item failed.\n");
|
2009-11-20 06:37:23 +01:00
|
|
|
expect_str("New Label", tcItem.pszText);
|
|
|
|
|
2013-11-25 10:09:00 +01:00
|
|
|
ok(SendMessageA(hTab, TCM_GETITEMA, 1, (LPARAM)&tcItem), "Getting item failed.\n");
|
2009-11-20 06:37:23 +01:00
|
|
|
expect_str("Tab 2", tcItem.pszText);
|
|
|
|
|
|
|
|
ok_sequence(sequences, TAB_SEQ_INDEX, getset_item_seq, "Getset item test sequence", FALSE);
|
|
|
|
ok_sequence(sequences, PARENT_SEQ_INDEX, empty_sequence, "Getset item test parent sequence", FALSE);
|
|
|
|
|
|
|
|
/* TCIS_BUTTONPRESSED doesn't depend on tab style */
|
|
|
|
memset(&tcItem, 0, sizeof(tcItem));
|
|
|
|
tcItem.mask = TCIF_STATE;
|
|
|
|
tcItem.dwStateMask = TCIS_BUTTONPRESSED;
|
|
|
|
tcItem.dwState = TCIS_BUTTONPRESSED;
|
2013-11-25 10:09:00 +01:00
|
|
|
ok(SendMessageA(hTab, TCM_SETITEMA, 0, (LPARAM)&tcItem), "Setting new item failed.\n");
|
2009-11-20 06:37:23 +01:00
|
|
|
tcItem.dwState = 0;
|
2013-11-25 10:09:00 +01:00
|
|
|
ok(SendMessageA(hTab, TCM_GETITEMA, 0, (LPARAM)&tcItem), "Getting item failed.\n");
|
2009-11-20 06:37:23 +01:00
|
|
|
if (tcItem.dwState)
|
|
|
|
{
|
|
|
|
ok (tcItem.dwState == TCIS_BUTTONPRESSED, "TCIS_BUTTONPRESSED should be set.\n");
|
|
|
|
/* next highlight item, test that dwStateMask actually masks */
|
|
|
|
tcItem.mask = TCIF_STATE;
|
|
|
|
tcItem.dwStateMask = TCIS_HIGHLIGHTED;
|
|
|
|
tcItem.dwState = TCIS_HIGHLIGHTED;
|
2013-11-25 10:09:00 +01:00
|
|
|
ok(SendMessageA(hTab, TCM_SETITEMA, 0, (LPARAM)&tcItem), "Setting new item failed.\n");
|
2009-11-20 06:37:23 +01:00
|
|
|
tcItem.dwState = 0;
|
2013-11-25 10:09:00 +01:00
|
|
|
ok(SendMessageA(hTab, TCM_GETITEMA, 0, (LPARAM)&tcItem), "Getting item failed.\n");
|
2009-11-20 06:37:23 +01:00
|
|
|
ok (tcItem.dwState == TCIS_HIGHLIGHTED, "TCIS_HIGHLIGHTED should be set.\n");
|
|
|
|
tcItem.mask = TCIF_STATE;
|
|
|
|
tcItem.dwStateMask = TCIS_BUTTONPRESSED;
|
|
|
|
tcItem.dwState = 0;
|
2013-11-25 10:09:00 +01:00
|
|
|
ok(SendMessageA(hTab, TCM_GETITEMA, 0, (LPARAM)&tcItem), "Getting item failed.\n");
|
2009-11-20 06:37:23 +01:00
|
|
|
ok (tcItem.dwState == TCIS_BUTTONPRESSED, "TCIS_BUTTONPRESSED should be set.\n");
|
|
|
|
}
|
|
|
|
else win_skip( "Item state mask not supported\n" );
|
|
|
|
|
|
|
|
DestroyWindow(hTab);
|
|
|
|
}
|
|
|
|
|
2011-04-23 21:37:34 +02:00
|
|
|
static void test_getset_tooltips(void)
|
2009-11-20 06:37:23 +01:00
|
|
|
{
|
|
|
|
char toolTipText[32] = "ToolTip Text Test";
|
2018-01-25 15:23:16 +01:00
|
|
|
HWND hTab, toolTip, hwnd;
|
2011-04-23 21:37:34 +02:00
|
|
|
const INT nTabs = 5;
|
2018-01-25 15:23:16 +01:00
|
|
|
int ret;
|
2009-11-20 06:37:23 +01:00
|
|
|
|
|
|
|
hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE, nTabs);
|
|
|
|
ok(hTab != NULL, "Failed to create tab control\n");
|
|
|
|
|
|
|
|
flush_sequences(sequences, NUM_MSG_SEQUENCES);
|
|
|
|
|
|
|
|
toolTip = create_tooltip(hTab, toolTipText);
|
2018-01-25 15:23:16 +01:00
|
|
|
ret = SendMessageA(hTab, TCM_SETTOOLTIPS, (WPARAM)toolTip, 0);
|
|
|
|
ok(ret == 0, "Unexpected ret value %d.\n", ret);
|
|
|
|
hwnd = (HWND)SendMessageA(hTab, TCM_GETTOOLTIPS, 0, 0);
|
|
|
|
ok(toolTip == hwnd, "Unexpected tooltip window.\n");
|
2009-11-20 06:37:23 +01:00
|
|
|
|
2018-01-25 15:23:16 +01:00
|
|
|
ret = SendMessageA(hTab, TCM_SETTOOLTIPS, 0, 0);
|
|
|
|
ok(ret == 0, "Unexpected ret value %d.\n", ret);
|
|
|
|
hwnd = (HWND)SendMessageA(hTab, TCM_GETTOOLTIPS, 0, 0);
|
|
|
|
ok(hwnd == NULL, "Unexpected tooltip window.\n");
|
|
|
|
ok(IsWindow(toolTip), "Expected tooltip window to be alive.\n");
|
2009-11-20 06:37:23 +01:00
|
|
|
|
|
|
|
ok_sequence(sequences, TAB_SEQ_INDEX, getset_tooltip_seq, "Getset tooltip test sequence", TRUE);
|
|
|
|
ok_sequence(sequences, PARENT_SEQ_INDEX, getset_tooltip_parent_seq, "Getset tooltip test parent sequence", TRUE);
|
|
|
|
|
|
|
|
DestroyWindow(hTab);
|
2018-01-25 15:23:16 +01:00
|
|
|
DestroyWindow(toolTip);
|
2009-11-20 06:37:23 +01:00
|
|
|
}
|
|
|
|
|
2011-04-23 21:37:34 +02:00
|
|
|
static void test_adjustrect(void)
|
2008-11-11 05:39:29 +01:00
|
|
|
{
|
|
|
|
HWND hTab;
|
|
|
|
INT r;
|
|
|
|
|
|
|
|
ok(parent_wnd != NULL, "no parent window!\n");
|
|
|
|
|
|
|
|
hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, 0, 0);
|
|
|
|
ok(hTab != NULL, "Failed to create tab control\n");
|
|
|
|
|
2013-11-25 10:09:00 +01:00
|
|
|
r = SendMessageA(hTab, TCM_ADJUSTRECT, FALSE, 0);
|
2008-11-11 05:39:29 +01:00
|
|
|
expect(-1, r);
|
|
|
|
|
2013-11-25 10:09:00 +01:00
|
|
|
r = SendMessageA(hTab, TCM_ADJUSTRECT, TRUE, 0);
|
2008-11-11 05:39:29 +01:00
|
|
|
expect(-1, r);
|
|
|
|
}
|
2009-11-20 06:37:23 +01:00
|
|
|
|
2011-04-23 21:37:34 +02:00
|
|
|
static void test_insert_focus(void)
|
2007-10-30 02:32:34 +01:00
|
|
|
{
|
|
|
|
HWND hTab;
|
|
|
|
INT nTabsRetrieved;
|
|
|
|
INT r;
|
2013-11-25 10:09:00 +01:00
|
|
|
TCITEMA tcNewTab;
|
2007-10-30 02:32:34 +01:00
|
|
|
DWORD mask = TCIF_TEXT|TCIF_IMAGE;
|
|
|
|
static char tabName[] = "TAB";
|
|
|
|
tcNewTab.mask = mask;
|
|
|
|
tcNewTab.pszText = tabName;
|
|
|
|
|
|
|
|
ok(parent_wnd != NULL, "no parent window!\n");
|
|
|
|
|
|
|
|
hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, mask, 0);
|
|
|
|
ok(hTab != NULL, "Failed to create tab control\n");
|
|
|
|
|
2013-11-25 10:09:00 +01:00
|
|
|
r = SendMessageA(hTab, TCM_GETCURSEL, 0, 0);
|
2011-04-09 17:39:45 +02:00
|
|
|
expect(-1, r);
|
|
|
|
|
2007-10-30 02:32:34 +01:00
|
|
|
flush_sequences(sequences, NUM_MSG_SEQUENCES);
|
|
|
|
|
2013-11-25 10:09:00 +01:00
|
|
|
nTabsRetrieved = SendMessageA(hTab, TCM_GETITEMCOUNT, 0, 0);
|
2007-10-30 02:32:34 +01:00
|
|
|
expect(0, nTabsRetrieved);
|
|
|
|
|
2013-11-25 10:09:00 +01:00
|
|
|
r = SendMessageA(hTab, TCM_GETCURFOCUS, 0, 0);
|
2007-10-30 02:32:34 +01:00
|
|
|
expect(-1, r);
|
|
|
|
|
|
|
|
tcNewTab.iImage = 1;
|
2013-11-25 10:09:00 +01:00
|
|
|
r = SendMessageA(hTab, TCM_INSERTITEMA, 1, (LPARAM)&tcNewTab);
|
2007-10-30 02:32:34 +01:00
|
|
|
expect(0, r);
|
|
|
|
|
2013-11-25 10:09:00 +01:00
|
|
|
nTabsRetrieved = SendMessageA(hTab, TCM_GETITEMCOUNT, 0, 0);
|
2007-10-30 02:32:34 +01:00
|
|
|
expect(1, nTabsRetrieved);
|
|
|
|
|
2013-11-25 10:09:00 +01:00
|
|
|
r = SendMessageA(hTab, TCM_GETCURFOCUS, 0, 0);
|
2007-10-30 02:47:09 +01:00
|
|
|
expect(0, r);
|
2007-10-30 02:32:34 +01:00
|
|
|
|
|
|
|
tcNewTab.iImage = 2;
|
2013-11-25 10:09:00 +01:00
|
|
|
r = SendMessageA(hTab, TCM_INSERTITEMA, 2, (LPARAM)&tcNewTab);
|
2007-10-30 02:32:34 +01:00
|
|
|
expect(1, r);
|
|
|
|
|
2013-11-25 10:09:00 +01:00
|
|
|
nTabsRetrieved = SendMessageA(hTab, TCM_GETITEMCOUNT, 0, 0);
|
2007-10-30 02:32:34 +01:00
|
|
|
expect(2, nTabsRetrieved);
|
|
|
|
|
2013-11-25 10:09:00 +01:00
|
|
|
r = SendMessageA(hTab, TCM_GETCURFOCUS, 0, 0);
|
2007-10-30 02:47:09 +01:00
|
|
|
expect(0, r);
|
2007-10-30 02:32:34 +01:00
|
|
|
|
2013-11-25 10:09:00 +01:00
|
|
|
r = SendMessageA(hTab, TCM_SETCURFOCUS, -1, 0);
|
2007-10-30 02:32:34 +01:00
|
|
|
expect(0, r);
|
|
|
|
|
2013-11-25 10:09:00 +01:00
|
|
|
r = SendMessageA(hTab, TCM_GETCURFOCUS, 0, 0);
|
2007-10-30 02:32:34 +01:00
|
|
|
expect(-1, r);
|
|
|
|
|
|
|
|
tcNewTab.iImage = 3;
|
2013-11-25 10:09:00 +01:00
|
|
|
r = SendMessageA(hTab, TCM_INSERTITEMA, 3, (LPARAM)&tcNewTab);
|
2007-10-30 02:32:34 +01:00
|
|
|
expect(2, r);
|
|
|
|
|
2013-11-25 10:09:00 +01:00
|
|
|
r = SendMessageA(hTab, TCM_GETCURFOCUS, 0, 0);
|
2007-10-30 02:47:09 +01:00
|
|
|
expect(2, r);
|
2007-10-30 02:32:34 +01:00
|
|
|
|
2009-08-05 14:00:03 +02:00
|
|
|
ok_sequence(sequences, TAB_SEQ_INDEX, insert_focus_seq, "insert_focus test sequence", FALSE);
|
2009-11-20 13:32:44 +01:00
|
|
|
ok_sequence(sequences, PARENT_SEQ_INDEX, empty_sequence, "insert_focus parent test sequence", TRUE);
|
2007-10-30 02:32:34 +01:00
|
|
|
|
|
|
|
DestroyWindow(hTab);
|
|
|
|
}
|
|
|
|
|
2011-04-23 21:37:34 +02:00
|
|
|
static void test_delete_focus(void)
|
2007-10-30 02:44:48 +01:00
|
|
|
{
|
|
|
|
HWND hTab;
|
|
|
|
INT nTabsRetrieved;
|
|
|
|
INT r;
|
|
|
|
|
|
|
|
ok(parent_wnd != NULL, "no parent window!\n");
|
|
|
|
|
|
|
|
hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE, 2);
|
|
|
|
ok(hTab != NULL, "Failed to create tab control\n");
|
|
|
|
|
|
|
|
flush_sequences(sequences, NUM_MSG_SEQUENCES);
|
|
|
|
|
2013-11-25 10:09:00 +01:00
|
|
|
nTabsRetrieved = SendMessageA(hTab, TCM_GETITEMCOUNT, 0, 0);
|
2007-10-30 02:44:48 +01:00
|
|
|
expect(2, nTabsRetrieved);
|
|
|
|
|
2013-11-25 10:09:00 +01:00
|
|
|
r = SendMessageA(hTab, TCM_GETCURFOCUS, 0, 0);
|
2007-10-30 02:47:09 +01:00
|
|
|
expect(0, r);
|
2007-10-30 02:44:48 +01:00
|
|
|
|
2013-11-25 10:09:00 +01:00
|
|
|
r = SendMessageA(hTab, TCM_DELETEITEM, 1, 0);
|
2007-10-30 02:44:48 +01:00
|
|
|
expect(1, r);
|
|
|
|
|
2013-11-25 10:09:00 +01:00
|
|
|
nTabsRetrieved = SendMessageA(hTab, TCM_GETITEMCOUNT, 0, 0);
|
2007-10-30 02:44:48 +01:00
|
|
|
expect(1, nTabsRetrieved);
|
|
|
|
|
2013-11-25 10:09:00 +01:00
|
|
|
r = SendMessageA(hTab, TCM_GETCURFOCUS, 0, 0);
|
2007-10-30 02:47:09 +01:00
|
|
|
expect(0, r);
|
2007-10-30 02:44:48 +01:00
|
|
|
|
2013-11-25 10:09:00 +01:00
|
|
|
r = SendMessageA(hTab, TCM_SETCURFOCUS, -1, 0);
|
2007-10-30 02:44:48 +01:00
|
|
|
expect(0, r);
|
|
|
|
|
2013-11-25 10:09:00 +01:00
|
|
|
r = SendMessageA(hTab, TCM_GETCURFOCUS, 0, 0);
|
2007-10-30 02:44:48 +01:00
|
|
|
expect(-1, r);
|
|
|
|
|
2013-11-25 10:09:00 +01:00
|
|
|
r = SendMessageA(hTab, TCM_DELETEITEM, 0, 0);
|
2007-10-30 02:44:48 +01:00
|
|
|
expect(1, r);
|
|
|
|
|
2013-11-25 10:09:00 +01:00
|
|
|
nTabsRetrieved = SendMessageA(hTab, TCM_GETITEMCOUNT, 0, 0);
|
2007-10-30 02:44:48 +01:00
|
|
|
expect(0, nTabsRetrieved);
|
|
|
|
|
2013-11-25 10:09:00 +01:00
|
|
|
r = SendMessageA(hTab, TCM_GETCURFOCUS, 0, 0);
|
2007-10-30 02:44:48 +01:00
|
|
|
expect(-1, r);
|
|
|
|
|
|
|
|
ok_sequence(sequences, TAB_SEQ_INDEX, delete_focus_seq, "delete_focus test sequence", FALSE);
|
2009-11-20 13:32:44 +01:00
|
|
|
ok_sequence(sequences, PARENT_SEQ_INDEX, empty_sequence, "delete_focus parent test sequence", TRUE);
|
2007-10-30 02:44:48 +01:00
|
|
|
|
|
|
|
DestroyWindow(hTab);
|
|
|
|
}
|
|
|
|
|
2011-02-13 00:54:25 +01:00
|
|
|
static void test_removeimage(void)
|
2009-03-23 20:45:44 +01:00
|
|
|
{
|
|
|
|
static const BYTE bits[32];
|
|
|
|
HWND hwTab;
|
|
|
|
INT i;
|
2013-11-25 10:09:00 +01:00
|
|
|
TCITEMA item;
|
2009-03-23 20:45:44 +01:00
|
|
|
HICON hicon;
|
2018-01-24 13:47:09 +01:00
|
|
|
HIMAGELIST himl = pImageList_Create(16, 16, ILC_COLOR, 3, 4);
|
2009-03-23 20:45:44 +01:00
|
|
|
|
|
|
|
hicon = CreateIcon(NULL, 16, 16, 1, 1, bits, bits);
|
2018-01-24 13:47:09 +01:00
|
|
|
pImageList_ReplaceIcon(himl, -1, hicon);
|
|
|
|
pImageList_ReplaceIcon(himl, -1, hicon);
|
|
|
|
pImageList_ReplaceIcon(himl, -1, hicon);
|
2009-03-23 20:45:44 +01:00
|
|
|
|
|
|
|
hwTab = create_tabcontrol(TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE);
|
2013-11-25 10:09:00 +01:00
|
|
|
SendMessageA(hwTab, TCM_SETIMAGELIST, 0, (LPARAM)himl);
|
2009-03-23 20:45:44 +01:00
|
|
|
|
2013-11-25 10:09:00 +01:00
|
|
|
memset(&item, 0, sizeof(TCITEMA));
|
2009-03-23 20:45:44 +01:00
|
|
|
item.mask = TCIF_IMAGE;
|
|
|
|
|
|
|
|
for(i = 0; i < 3; i++) {
|
2013-11-25 10:09:00 +01:00
|
|
|
SendMessageA(hwTab, TCM_GETITEMA, i, (LPARAM)&item);
|
2009-03-23 20:45:44 +01:00
|
|
|
expect(i, item.iImage);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* remove image middle image */
|
2013-11-25 10:09:00 +01:00
|
|
|
SendMessageA(hwTab, TCM_REMOVEIMAGE, 1, 0);
|
2018-01-24 13:47:09 +01:00
|
|
|
i = pImageList_GetImageCount(himl);
|
|
|
|
ok(i == 2, "Unexpected image count %d.\n", i);
|
2009-03-23 20:45:44 +01:00
|
|
|
item.iImage = -1;
|
2013-11-25 10:09:00 +01:00
|
|
|
SendMessageA(hwTab, TCM_GETITEMA, 0, (LPARAM)&item);
|
2009-03-23 20:45:44 +01:00
|
|
|
expect(0, item.iImage);
|
|
|
|
item.iImage = 0;
|
2013-11-25 10:09:00 +01:00
|
|
|
SendMessageA(hwTab, TCM_GETITEMA, 1, (LPARAM)&item);
|
2009-03-23 20:45:44 +01:00
|
|
|
expect(-1, item.iImage);
|
|
|
|
item.iImage = 0;
|
2013-11-25 10:09:00 +01:00
|
|
|
SendMessageA(hwTab, TCM_GETITEMA, 2, (LPARAM)&item);
|
2009-03-23 20:45:44 +01:00
|
|
|
expect(1, item.iImage);
|
|
|
|
/* remove first image */
|
2013-11-25 10:09:00 +01:00
|
|
|
SendMessageA(hwTab, TCM_REMOVEIMAGE, 0, 0);
|
2018-01-24 13:47:09 +01:00
|
|
|
i = pImageList_GetImageCount(himl);
|
|
|
|
ok(i == 1, "Unexpected image count %d.\n", i);
|
2009-03-23 20:45:44 +01:00
|
|
|
item.iImage = 0;
|
2013-11-25 10:09:00 +01:00
|
|
|
SendMessageA(hwTab, TCM_GETITEMA, 0, (LPARAM)&item);
|
2009-03-23 20:45:44 +01:00
|
|
|
expect(-1, item.iImage);
|
|
|
|
item.iImage = 0;
|
2013-11-25 10:09:00 +01:00
|
|
|
SendMessageA(hwTab, TCM_GETITEMA, 1, (LPARAM)&item);
|
2009-03-23 20:45:44 +01:00
|
|
|
expect(-1, item.iImage);
|
|
|
|
item.iImage = -1;
|
2013-11-25 10:09:00 +01:00
|
|
|
SendMessageA(hwTab, TCM_GETITEMA, 2, (LPARAM)&item);
|
2009-03-23 20:45:44 +01:00
|
|
|
expect(0, item.iImage);
|
|
|
|
/* remove the last one */
|
2013-11-25 10:09:00 +01:00
|
|
|
SendMessageA(hwTab, TCM_REMOVEIMAGE, 0, 0);
|
2018-01-24 13:47:09 +01:00
|
|
|
i = pImageList_GetImageCount(himl);
|
|
|
|
ok(i == 0, "Unexpected image count %d.\n", i);
|
2009-03-23 20:45:44 +01:00
|
|
|
for(i = 0; i < 3; i++) {
|
|
|
|
item.iImage = 0;
|
2013-11-25 10:09:00 +01:00
|
|
|
SendMessageA(hwTab, TCM_GETITEMA, i, (LPARAM)&item);
|
2009-03-23 20:45:44 +01:00
|
|
|
expect(-1, item.iImage);
|
|
|
|
}
|
|
|
|
|
|
|
|
DestroyWindow(hwTab);
|
2018-01-24 13:47:09 +01:00
|
|
|
pImageList_Destroy(himl);
|
2009-03-23 20:45:44 +01:00
|
|
|
DestroyIcon(hicon);
|
|
|
|
}
|
|
|
|
|
2011-04-23 21:37:34 +02:00
|
|
|
static void test_delete_selection(void)
|
2009-11-20 06:50:24 +01:00
|
|
|
{
|
|
|
|
HWND hTab;
|
2011-06-02 17:31:30 +02:00
|
|
|
INT ret;
|
2009-11-20 06:50:24 +01:00
|
|
|
|
|
|
|
hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE, 4);
|
|
|
|
ok(hTab != NULL, "Failed to create tab control\n");
|
|
|
|
|
2013-11-25 10:09:00 +01:00
|
|
|
ret = SendMessageA(hTab, TCM_SETCURSEL, 3, 0);
|
2009-11-20 06:50:24 +01:00
|
|
|
expect(0, ret);
|
2013-11-25 10:09:00 +01:00
|
|
|
ret = SendMessageA(hTab, TCM_GETCURSEL, 0, 0);
|
2009-11-20 06:50:24 +01:00
|
|
|
expect(3, ret);
|
|
|
|
/* delete selected item - selection goes to -1 */
|
2013-11-25 10:09:00 +01:00
|
|
|
ret = SendMessageA(hTab, TCM_DELETEITEM, 3, 0);
|
2009-11-20 06:50:24 +01:00
|
|
|
expect(TRUE, ret);
|
|
|
|
|
2013-11-25 10:09:00 +01:00
|
|
|
ret = SendMessageA(hTab, TCM_GETCURSEL, 0, 0);
|
2009-11-20 06:50:24 +01:00
|
|
|
expect(-1, ret);
|
|
|
|
|
|
|
|
DestroyWindow(hTab);
|
|
|
|
}
|
|
|
|
|
2011-04-23 21:37:34 +02:00
|
|
|
static void test_TCM_SETITEMEXTRA(void)
|
2010-09-27 23:40:32 +02:00
|
|
|
{
|
|
|
|
HWND hTab;
|
|
|
|
DWORD ret;
|
|
|
|
|
|
|
|
hTab = CreateWindowA(
|
|
|
|
WC_TABCONTROLA,
|
|
|
|
"TestTab",
|
|
|
|
WS_CLIPSIBLINGS | WS_CLIPCHILDREN | TCS_FOCUSNEVER | TCS_FIXEDWIDTH,
|
|
|
|
10, 10, 300, 100,
|
|
|
|
parent_wnd, NULL, NULL, 0);
|
|
|
|
|
|
|
|
/* zero is valid size too */
|
|
|
|
ret = SendMessageA(hTab, TCM_SETITEMEXTRA, 0, 0);
|
|
|
|
if (ret == FALSE)
|
|
|
|
{
|
|
|
|
win_skip("TCM_SETITEMEXTRA not supported\n");
|
|
|
|
DestroyWindow(hTab);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = SendMessageA(hTab, TCM_SETITEMEXTRA, -1, 0);
|
|
|
|
ok(ret == FALSE, "got %d\n", ret);
|
|
|
|
|
|
|
|
ret = SendMessageA(hTab, TCM_SETITEMEXTRA, 2, 0);
|
|
|
|
ok(ret == TRUE, "got %d\n", ret);
|
|
|
|
DestroyWindow(hTab);
|
|
|
|
|
|
|
|
/* it's not possible to change extra data size for control with tabs */
|
|
|
|
hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE, 4);
|
|
|
|
ok(hTab != NULL, "Failed to create tab control\n");
|
|
|
|
|
|
|
|
ret = SendMessageA(hTab, TCM_SETITEMEXTRA, 2, 0);
|
|
|
|
ok(ret == FALSE, "got %d\n", ret);
|
|
|
|
DestroyWindow(hTab);
|
|
|
|
}
|
|
|
|
|
2011-04-23 21:37:34 +02:00
|
|
|
static void test_TCS_OWNERDRAWFIXED(void)
|
2010-10-02 23:58:12 +02:00
|
|
|
{
|
2011-06-02 17:31:30 +02:00
|
|
|
LPARAM lparam;
|
|
|
|
ULONG_PTR itemdata, itemdata2;
|
2010-10-02 23:58:12 +02:00
|
|
|
TCITEMA item;
|
|
|
|
HWND hTab;
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH|TCS_OWNERDRAWFIXED, TCIF_TEXT|TCIF_IMAGE, 4);
|
|
|
|
ok(hTab != NULL, "Failed to create tab control\n");
|
|
|
|
|
|
|
|
ok(GetParent(hTab) == NULL, "got %p, expected null parent\n", GetParent(hTab));
|
|
|
|
|
|
|
|
/* set some item data */
|
|
|
|
memset(&lparam, 0xde, sizeof(LPARAM));
|
|
|
|
|
|
|
|
item.mask = TCIF_PARAM;
|
|
|
|
item.lParam = lparam;
|
|
|
|
ret = SendMessageA(hTab, TCM_SETITEMA, 0, (LPARAM)&item);
|
|
|
|
ok(ret == TRUE, "got %d\n", ret);
|
|
|
|
|
|
|
|
memset(&g_drawitem, 0, sizeof(g_drawitem));
|
|
|
|
|
|
|
|
ShowWindow(hTab, SW_SHOW);
|
|
|
|
RedrawWindow(hTab, NULL, 0, RDW_UPDATENOW);
|
|
|
|
|
2011-05-22 20:51:30 +02:00
|
|
|
itemdata = 0;
|
|
|
|
memset(&itemdata, 0xde, 4);
|
2011-06-02 17:31:30 +02:00
|
|
|
ok(g_drawitem.itemData == itemdata, "got 0x%lx, expected 0x%lx\n", g_drawitem.itemData, itemdata);
|
2010-10-02 23:58:12 +02:00
|
|
|
|
|
|
|
DestroyWindow(hTab);
|
|
|
|
|
|
|
|
/* now with custom extra data length */
|
|
|
|
hTab = CreateWindowA(
|
|
|
|
WC_TABCONTROLA,
|
|
|
|
"TestTab",
|
|
|
|
WS_CLIPSIBLINGS | WS_CLIPCHILDREN | TCS_FOCUSNEVER | TCS_FIXEDWIDTH | TCS_OWNERDRAWFIXED,
|
|
|
|
10, 10, 300, 100,
|
|
|
|
parent_wnd, NULL, NULL, 0);
|
|
|
|
|
|
|
|
ok(GetParent(hTab) == NULL, "got %p, expected null parent\n", GetParent(hTab));
|
|
|
|
|
|
|
|
ret = SendMessageA(hTab, TCM_SETITEMEXTRA, sizeof(LPARAM)+1, 0);
|
|
|
|
ok(ret == TRUE, "got %d\n", ret);
|
|
|
|
|
|
|
|
/* set some item data */
|
|
|
|
memset(&lparam, 0xde, sizeof(LPARAM));
|
|
|
|
item.mask = TCIF_PARAM;
|
|
|
|
item.lParam = lparam;
|
|
|
|
|
|
|
|
ret = SendMessageA(hTab, TCM_INSERTITEMA, 0, (LPARAM)&item);
|
|
|
|
ok(ret == 0, "got %d\n", ret);
|
|
|
|
|
|
|
|
memset(&g_drawitem, 0, sizeof(g_drawitem));
|
|
|
|
|
|
|
|
ShowWindow(hTab, SW_SHOW);
|
|
|
|
RedrawWindow(hTab, NULL, 0, RDW_UPDATENOW);
|
|
|
|
|
2011-06-02 17:31:30 +02:00
|
|
|
memset(&itemdata, 0xde, sizeof(ULONG_PTR));
|
|
|
|
ok(*(ULONG_PTR*)g_drawitem.itemData == itemdata, "got 0x%lx, expected 0x%lx\n", g_drawitem.itemData, itemdata);
|
2010-10-02 23:58:12 +02:00
|
|
|
|
|
|
|
DestroyWindow(hTab);
|
|
|
|
|
|
|
|
/* same thing, but size smaller than default */
|
|
|
|
hTab = CreateWindowA(
|
|
|
|
WC_TABCONTROLA,
|
|
|
|
"TestTab",
|
|
|
|
WS_CLIPSIBLINGS | WS_CLIPCHILDREN | TCS_FOCUSNEVER | TCS_FIXEDWIDTH | TCS_OWNERDRAWFIXED,
|
|
|
|
10, 10, 300, 100,
|
|
|
|
parent_wnd, NULL, NULL, 0);
|
|
|
|
|
|
|
|
ok(GetParent(hTab) == NULL, "got %p, expected null parent\n", GetParent(hTab));
|
|
|
|
|
|
|
|
ret = SendMessageA(hTab, TCM_SETITEMEXTRA, sizeof(LPARAM)-1, 0);
|
|
|
|
ok(ret == TRUE, "got %d\n", ret);
|
|
|
|
|
|
|
|
memset(&lparam, 0xde, sizeof(lparam));
|
|
|
|
item.mask = TCIF_PARAM;
|
|
|
|
item.lParam = lparam;
|
|
|
|
|
|
|
|
ret = SendMessageA(hTab, TCM_INSERTITEMA, 0, (LPARAM)&item);
|
|
|
|
ok(ret == 0, "got %d\n", ret);
|
|
|
|
|
|
|
|
memset(&g_drawitem, 0, sizeof(g_drawitem));
|
|
|
|
|
|
|
|
ShowWindow(hTab, SW_SHOW);
|
|
|
|
RedrawWindow(hTab, NULL, 0, RDW_UPDATENOW);
|
|
|
|
|
2011-06-02 17:31:30 +02:00
|
|
|
itemdata = itemdata2 = 0;
|
|
|
|
memset(&itemdata, 0xde, 4);
|
|
|
|
memset(&itemdata2, 0xde, sizeof(LPARAM)-1);
|
|
|
|
ok(g_drawitem.itemData == itemdata || broken(g_drawitem.itemData == itemdata2) /* win98 */,
|
|
|
|
"got 0x%lx, expected 0x%lx\n", g_drawitem.itemData, itemdata);
|
2010-10-02 23:58:12 +02:00
|
|
|
|
|
|
|
DestroyWindow(hTab);
|
|
|
|
}
|
|
|
|
|
2011-07-03 08:19:21 +02:00
|
|
|
static void test_WM_CONTEXTMENU(void)
|
|
|
|
{
|
|
|
|
HWND hTab;
|
|
|
|
|
|
|
|
hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE, 4);
|
|
|
|
ok(hTab != NULL, "Failed to create tab control\n");
|
|
|
|
|
|
|
|
flush_sequences(sequences, NUM_MSG_SEQUENCES);
|
|
|
|
|
|
|
|
SendMessageA(hTab, WM_RBUTTONUP, 0, 0);
|
|
|
|
|
|
|
|
ok_sequence(sequences, TAB_SEQ_INDEX, rbuttonup_seq, "WM_RBUTTONUP response sequence", FALSE);
|
|
|
|
|
|
|
|
DestroyWindow(hTab);
|
|
|
|
}
|
|
|
|
|
2012-05-17 08:53:45 +02:00
|
|
|
struct tabcreate_style {
|
|
|
|
DWORD style;
|
|
|
|
DWORD act_style;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct tabcreate_style create_styles[] =
|
|
|
|
{
|
|
|
|
{ WS_CHILD|TCS_BOTTOM|TCS_VERTICAL, WS_CHILD|WS_CLIPSIBLINGS|TCS_BOTTOM|TCS_VERTICAL|TCS_MULTILINE },
|
|
|
|
{ WS_CHILD|TCS_VERTICAL, WS_CHILD|WS_CLIPSIBLINGS|TCS_VERTICAL|TCS_MULTILINE },
|
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static void test_create(void)
|
|
|
|
{
|
|
|
|
const struct tabcreate_style *ptr = create_styles;
|
|
|
|
DWORD style;
|
|
|
|
HWND hTab;
|
|
|
|
|
|
|
|
while (ptr->style)
|
|
|
|
{
|
|
|
|
hTab = CreateWindowA(WC_TABCONTROLA, "TestTab", ptr->style,
|
|
|
|
10, 10, 300, 100, parent_wnd, NULL, NULL, 0);
|
|
|
|
style = GetWindowLongA(hTab, GWL_STYLE);
|
|
|
|
ok(style == ptr->act_style, "expected style 0x%08x, got style 0x%08x\n", ptr->act_style, style);
|
|
|
|
|
|
|
|
DestroyWindow(hTab);
|
|
|
|
ptr++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-24 13:47:09 +01:00
|
|
|
static void init_functions(void)
|
|
|
|
{
|
|
|
|
HMODULE hComCtl32 = LoadLibraryA("comctl32.dll");
|
|
|
|
|
|
|
|
#define X(f) p##f = (void*)GetProcAddress(hComCtl32, #f);
|
|
|
|
X(ImageList_Create);
|
|
|
|
X(ImageList_Destroy);
|
|
|
|
X(ImageList_GetImageCount);
|
|
|
|
X(ImageList_ReplaceIcon);
|
|
|
|
#undef X
|
|
|
|
}
|
|
|
|
|
2018-01-25 15:23:14 +01:00
|
|
|
static void test_TCN_SELCHANGING(void)
|
|
|
|
{
|
|
|
|
const INT nTabs = 5;
|
|
|
|
HWND hTab;
|
|
|
|
INT ret;
|
|
|
|
|
|
|
|
hTab = createFilledTabControl(parent_wnd, WS_CHILD|TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE, nTabs);
|
|
|
|
ok(hTab != NULL, "Failed to create tab control\n");
|
|
|
|
|
|
|
|
/* Initially first tab is focused. */
|
|
|
|
ret = SendMessageA(hTab, TCM_GETCURFOCUS, 0, 0);
|
|
|
|
ok(ret == 0, "Unexpected tab focus %d.\n", ret);
|
|
|
|
|
|
|
|
flush_sequences(sequences, NUM_MSG_SEQUENCES);
|
|
|
|
|
|
|
|
/* Setting focus to currently focused item should do nothing. */
|
|
|
|
ret = SendMessageA(hTab, TCM_SETCURFOCUS, 0, 0);
|
|
|
|
ok(ret == 0, "Unexpected ret value %d.\n", ret);
|
|
|
|
|
|
|
|
ok_sequence(sequences, PARENT_SEQ_INDEX, empty_sequence, "Set focus to focused tab sequence", FALSE);
|
|
|
|
|
|
|
|
/* Allow selection change. */
|
|
|
|
flush_sequences(sequences, NUM_MSG_SEQUENCES);
|
|
|
|
|
|
|
|
tcn_selchanging_result = 0;
|
|
|
|
ret = SendMessageA(hTab, TCM_SETCURFOCUS, nTabs - 1, 0);
|
|
|
|
ok(ret == 0, "Unexpected ret value %d.\n", ret);
|
|
|
|
|
|
|
|
ok_sequence(sequences, PARENT_SEQ_INDEX, full_selchange_parent_seq, "Focus change allowed sequence", FALSE);
|
|
|
|
|
|
|
|
ret = SendMessageA(hTab, TCM_GETCURFOCUS, 0, 0);
|
|
|
|
ok(ret == nTabs - 1, "Unexpected focused tab %d.\n", ret);
|
|
|
|
ret = SendMessageA(hTab, TCM_GETCURSEL, 0, 0);
|
|
|
|
ok(ret == nTabs - 1, "Unexpected selected tab %d.\n", ret);
|
|
|
|
|
|
|
|
/* Forbid selection change. */
|
|
|
|
flush_sequences(sequences, NUM_MSG_SEQUENCES);
|
|
|
|
|
|
|
|
tcn_selchanging_result = 1;
|
|
|
|
ret = SendMessageA(hTab, TCM_SETCURFOCUS, 0, 0);
|
|
|
|
ok(ret == 0, "Unexpected ret value %d.\n", ret);
|
|
|
|
|
|
|
|
ok_sequence(sequences, PARENT_SEQ_INDEX, selchanging_parent_seq, "Focus change disallowed sequence", FALSE);
|
|
|
|
|
|
|
|
ret = SendMessageA(hTab, TCM_GETCURFOCUS, 0, 0);
|
|
|
|
todo_wine
|
|
|
|
ok(ret == nTabs - 1, "Unexpected focused tab %d.\n", ret);
|
|
|
|
ret = SendMessageA(hTab, TCM_GETCURSEL, 0, 0);
|
|
|
|
todo_wine
|
|
|
|
ok(ret == nTabs - 1, "Unexpected selected tab %d.\n", ret);
|
|
|
|
|
|
|
|
/* Removing focus sends only TCN_SELCHANGE */
|
|
|
|
flush_sequences(sequences, NUM_MSG_SEQUENCES);
|
|
|
|
|
|
|
|
ret = SendMessageA(hTab, TCM_SETCURFOCUS, -1, 0);
|
|
|
|
ok(ret == 0, "Unexpected ret value %d.\n", ret);
|
|
|
|
|
|
|
|
ok_sequence(sequences, PARENT_SEQ_INDEX, selchange_parent_seq, "Remove focus sequence", FALSE);
|
|
|
|
|
|
|
|
ret = SendMessageA(hTab, TCM_GETCURFOCUS, 0, 0);
|
|
|
|
ok(ret == -1, "Unexpected focused tab %d.\n", ret);
|
|
|
|
|
|
|
|
tcn_selchanging_result = 0;
|
|
|
|
|
|
|
|
DestroyWindow(hTab);
|
|
|
|
}
|
|
|
|
|
2018-01-25 15:23:17 +01:00
|
|
|
static void test_TCM_GETROWCOUNT(void)
|
|
|
|
{
|
|
|
|
const INT nTabs = 5;
|
|
|
|
HWND hTab;
|
|
|
|
INT count;
|
|
|
|
|
|
|
|
flush_sequences(sequences, NUM_MSG_SEQUENCES);
|
|
|
|
|
|
|
|
hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE, nTabs);
|
|
|
|
ok(hTab != NULL, "Failed to create tab control\n");
|
|
|
|
|
|
|
|
flush_sequences(sequences, NUM_MSG_SEQUENCES);
|
|
|
|
|
|
|
|
count = SendMessageA(hTab, TCM_GETROWCOUNT, 0, 0);
|
|
|
|
ok(count == 1, "Unexpected row count %d.\n", count);
|
|
|
|
|
|
|
|
ok_sequence(sequences, TAB_SEQ_INDEX, get_row_count_seq, "Get rowCount test sequence", FALSE);
|
|
|
|
ok_sequence(sequences, PARENT_SEQ_INDEX, empty_sequence, "Get rowCount test parent sequence", FALSE);
|
|
|
|
|
|
|
|
DestroyWindow(hTab);
|
|
|
|
}
|
|
|
|
|
2005-08-23 12:05:54 +02:00
|
|
|
START_TEST(tab)
|
|
|
|
{
|
|
|
|
LOGFONTA logfont;
|
|
|
|
|
|
|
|
lstrcpyA(logfont.lfFaceName, "Arial");
|
|
|
|
memset(&logfont, 0, sizeof(logfont));
|
|
|
|
logfont.lfHeight = -12;
|
|
|
|
logfont.lfWeight = FW_NORMAL;
|
|
|
|
logfont.lfCharSet = ANSI_CHARSET;
|
|
|
|
hFont = CreateFontIndirectA(&logfont);
|
|
|
|
|
2018-01-24 13:47:09 +01:00
|
|
|
init_functions();
|
2005-08-23 12:05:54 +02:00
|
|
|
|
2007-03-17 23:12:13 +01:00
|
|
|
init_msg_sequences(sequences, NUM_MSG_SEQUENCES);
|
|
|
|
|
2007-10-30 00:39:10 +01:00
|
|
|
parent_wnd = createParentWindow();
|
|
|
|
ok(parent_wnd != NULL, "Failed to create parent window!\n");
|
|
|
|
|
2018-01-25 15:23:17 +01:00
|
|
|
test_width();
|
2011-04-23 21:37:34 +02:00
|
|
|
test_curfocus();
|
|
|
|
test_cursel();
|
|
|
|
test_extendedstyle();
|
|
|
|
test_unicodeformat();
|
|
|
|
test_getset_item();
|
|
|
|
test_getset_tooltips();
|
|
|
|
test_adjustrect();
|
|
|
|
test_insert_focus();
|
|
|
|
test_delete_focus();
|
|
|
|
test_delete_selection();
|
2011-02-13 00:54:25 +01:00
|
|
|
test_removeimage();
|
2011-04-23 21:37:34 +02:00
|
|
|
test_TCM_SETITEMEXTRA();
|
|
|
|
test_TCS_OWNERDRAWFIXED();
|
2011-07-03 08:19:21 +02:00
|
|
|
test_WM_CONTEXTMENU();
|
2012-05-17 08:53:45 +02:00
|
|
|
test_create();
|
2018-01-25 15:23:14 +01:00
|
|
|
test_TCN_SELCHANGING();
|
2018-01-25 15:23:17 +01:00
|
|
|
test_TCM_GETROWCOUNT();
|
2007-10-30 02:32:34 +01:00
|
|
|
|
2007-10-30 00:39:10 +01:00
|
|
|
DestroyWindow(parent_wnd);
|
2003-10-31 01:06:42 +01:00
|
|
|
}
|