ReactOS 0.4.16-dev-833-g4bc97ad
treeview.c File Reference
#include <stdarg.h>
#include <stdio.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "winnls.h"
#include "winreg.h"
#include "wine/commctrl.h"
#include "wine/test.h"
#include "v6util.h"
#include "msg.h"
Include dependency graph for treeview.c:

Go to the source code of this file.

Classes

struct  _ITEM_DATA
 
struct  _ITEM_DATA_V6
 

Macros

#define NUM_MSG_SEQUENCES   3
 
#define TREEVIEW_SEQ_INDEX   0
 
#define PARENT_SEQ_INDEX   1
 
#define PARENT_CD_SEQ_INDEX   2
 
#define expect(expected, got)   ok(got == expected, "Expected %d, got %d\n", expected, got)
 
#define CHECK_ITEM(a, b)   _check_item(a, b, is_version_6, __LINE__)
 
#define X(f)   p##f = (void*)GetProcAddress(hComCtl32, #f);
 

Functions

static BOOL (WINAPI *pInitCommonControlsEx)(const INITCOMMONCONTROLSEX *)
 
static void flush_events (void)
 
static void Clear (void)
 
static void AddItem (char ch)
 
static void IdentifyItem (HTREEITEM hItem)
 
static LRESULT WINAPI TreeviewWndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
 
static HWND create_treeview_control (DWORD style)
 
static void fill_tree (HWND hTree)
 
static void test_fillroot (void)
 
static void test_callback (void)
 
static void test_select (void)
 
static void test_getitemtext (void)
 
static void test_focus (void)
 
static void test_get_set_bkcolor (void)
 
static void test_get_set_imagelist (void)
 
static void test_get_set_indent (void)
 
static void test_get_set_insertmark (void)
 
static void test_get_set_item (void)
 
static void test_get_set_itemheight (void)
 
static void test_get_set_scrolltime (void)
 
static void test_get_set_textcolor (void)
 
static void test_get_set_tooltips (void)
 
static void test_get_set_unicodeformat (void)
 
static LRESULT CALLBACK parent_wnd_proc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 
static void test_expandinvisible (void)
 
static void test_expand (void)
 
static void test_itemedit (void)
 
static void test_treeview_classinfo (void)
 
static void test_get_linecolor (void)
 
static void test_get_insertmarkcolor (void)
 
static void test_expandnotify (void)
 
static void test_expandedimage (void)
 
static void test_TVS_SINGLEEXPAND (void)
 
static void test_WM_PAINT (void)
 
static void test_delete_items (void)
 
static void test_cchildren (void)
 
static void _check_item (HWND hwnd, HTREEITEM item, BOOL is_version_6, int line)
 
static void test_htreeitem_layout (BOOL is_version_6)
 
static void test_TVS_CHECKBOXES (void)
 
static void test_TVM_GETNEXTITEM (void)
 
static void test_TVM_HITTEST (void)
 
static void test_WM_GETDLGCODE (void)
 
static void test_customdraw (void)
 
static void test_WM_KEYDOWN (void)
 
static void test_TVS_FULLROWSELECT (void)
 
static void get_item_names_string (HWND hwnd, HTREEITEM item, char *str)
 
static void fill_treeview_sort_test (HWND hwnd)
 
static void test_TVM_SORTCHILDREN (void)
 
static void test_right_click (void)
 
static void init_functions (void)
 
 START_TEST (treeview)
 

Variables

static const charTEST_CALLBACK_TEXT = "callback_text"
 
static TVITEMA g_item_expanding
 
static TVITEMA g_item_expanded
 
static BOOL g_get_from_expand
 
static BOOL g_get_rect_in_expand
 
static BOOL g_disp_A_to_W
 
static BOOL g_disp_set_stateimage
 
static BOOL g_beginedit_alter_text
 
static const charg_endedit_overwrite_contents
 
static charg_endedit_overwrite_ptr
 
static HFONT g_customdraw_font
 
static BOOL g_v6
 
static struct msg_sequencesequences [NUM_MSG_SEQUENCES]
 
static struct msg_sequenceitem_sequence [1]
 
static const struct message FillRootSeq []
 
static const struct message rootnone_select_seq []
 
static const struct message rootchild_select_seq []
 
static const struct message getitemtext_seq []
 
static const struct message focus_seq []
 
static const struct message test_get_set_bkcolor_seq []
 
static const struct message test_get_set_imagelist_seq []
 
static const struct message test_get_set_indent_seq []
 
static const struct message test_get_set_insertmarkcolor_seq []
 
static const struct message test_get_set_item_seq []
 
static const struct message test_get_set_itemheight_seq []
 
static const struct message test_get_set_scrolltime_seq []
 
static const struct message test_get_set_textcolor_seq []
 
static const struct message test_get_set_tooltips_seq []
 
static const struct message test_get_set_unicodeformat_seq []
 
static const struct message test_right_click_seq []
 
static const struct message parent_expand_seq []
 
static const struct message parent_expand_kb_seq []
 
static const struct message parent_collapse_2nd_kb_seq []
 
static const struct message parent_expand_empty_kb_seq []
 
static const struct message parent_singleexpand_seq0 []
 
static const struct message parent_singleexpand_seq1 []
 
static const struct message parent_singleexpand_seq2 []
 
static const struct message parent_singleexpand_seq3 []
 
static const struct message parent_singleexpand_seq4 []
 
static const struct message parent_singleexpand_seq5 []
 
static const struct message parent_singleexpand_seq6 []
 
static const struct message parent_singleexpand_seq7 []
 
static const struct message parent_get_dispinfo_seq []
 
static const struct message empty_seq []
 
static const struct message parent_cd_seq []
 
static const struct message parent_vk_return_seq []
 
static const struct message parent_right_click_seq []
 
static HWND hMainWnd
 
static HTREEITEM hRoot
 
static HTREEITEM hChild
 
static int pos = 0
 
static char sequence [256]
 

Macro Definition Documentation

◆ CHECK_ITEM

#define CHECK_ITEM (   a,
  b 
)    _check_item(a, b, is_version_6, __LINE__)

Definition at line 2325 of file treeview.c.

◆ expect

#define expect (   expected,
  got 
)    ok(got == expected, "Expected %d, got %d\n", expected, got)

Definition at line 55 of file treeview.c.

◆ NUM_MSG_SEQUENCES

#define NUM_MSG_SEQUENCES   3

Definition at line 50 of file treeview.c.

◆ PARENT_CD_SEQ_INDEX

#define PARENT_CD_SEQ_INDEX   2

Definition at line 53 of file treeview.c.

◆ PARENT_SEQ_INDEX

#define PARENT_SEQ_INDEX   1

Definition at line 52 of file treeview.c.

◆ TREEVIEW_SEQ_INDEX

#define TREEVIEW_SEQ_INDEX   0

Definition at line 51 of file treeview.c.

◆ X

#define X (   f)    p##f = (void*)GetProcAddress(hComCtl32, #f);

Function Documentation

◆ _check_item()

static void _check_item ( HWND  hwnd,
HTREEITEM  item,
BOOL  is_version_6,
int  line 
)
static

Definition at line 2287 of file treeview.c.

2288{
2289 struct _ITEM_DATA *data = (struct _ITEM_DATA *)item;
2291 RECT rect;
2292 BOOL ret;
2293
2298
2299 *(HTREEITEM*)&rect = item;
2301
2302 ok_(__FILE__, line)(item == root ? data->parent != NULL : data->parent == parent,
2303 "Unexpected parent item %p, got %p, %p\n", parent, data->parent, hwnd);
2304 ok_(__FILE__, line)(data->nextsibling == nextsibling, "Unexpected sibling %p, got %p\n",
2305 nextsibling, data->nextsibling);
2306 ok_(__FILE__, line)(data->firstchild == firstchild, "Unexpected first child %p, got %p\n",
2307 firstchild, data->firstchild);
2308 if (ret)
2309 {
2310 WORD width;
2311
2312 if (is_version_6)
2313 {
2314 struct _ITEM_DATA_V6 *data_v6 = (struct _ITEM_DATA_V6 *)item;
2315 width = data_v6->width;
2316 }
2317 else
2318 width = data->width;
2319 todo_wine
2320 ok_(__FILE__, line)(width == (rect.right - rect.left) || broken(is_version_6 && width == 0) /* XP */,
2321 "Width %d, rect width %d.\n", width, rect.right - rect.left);
2322 }
2323}
#define broken(x)
Definition: atltest.h:178
#define ok_(x1, x2)
Definition: atltest.h:61
struct _root root
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
r parent
Definition: btrfs.c:3010
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned short WORD
Definition: ntddk_ex.h:93
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLint GLint GLsizei width
Definition: gl.h:1546
#define todo_wine
Definition: custom.c:89
static ATOM item
Definition: dde.c:856
#define TVGN_PARENT
Definition: commctrl.h:3460
#define TVM_GETITEMRECT
Definition: commctrl.h:3433
struct _TREEITEM * HTREEITEM
Definition: commctrl.h:3269
#define TVGN_ROOT
Definition: commctrl.h:3457
#define TVGN_CHILD
Definition: commctrl.h:3461
#define TVGN_NEXT
Definition: commctrl.h:3458
#define TVM_GETNEXTITEM
Definition: commctrl.h:3454
& rect
Definition: startmenu.cpp:1413
HTREEITEM firstchild
Definition: treeview.c:2269
HTREEITEM nextsibling
Definition: treeview.c:2268
uint64_t parent
Definition: btrfs_drv.h:459
Definition: parser.c:49
int ret
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LPARAM
Definition: windef.h:208
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

◆ AddItem()

static void AddItem ( char  ch)
static

Definition at line 394 of file treeview.c.

395{
396 sequence[pos++] = ch;
397 sequence[pos] = '\0';
398}
static char sequence[256]
Definition: treeview.c:386

◆ BOOL()

static BOOL ( WINAPI pInitCommonControlsEx) const
static

◆ Clear()

◆ create_treeview_control()

static HWND create_treeview_control ( DWORD  style)
static

Definition at line 439 of file treeview.c.

440{
442 HWND hTree;
443
446 0, 0, 120, 100, hMainWnd, (HMENU)100, GetModuleHandleA(0), 0);
447
449
450 /* Record the old WNDPROC so we can call it after recording the messages */
453
454 return hTree;
455}
Arabic default style
Definition: afstyles.h:94
static WNDPROC pOldWndProc
Definition: dateandtime.c:14
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
static HWND hMainWnd
Definition: treeview.c:381
static LRESULT WINAPI TreeviewWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: treeview.c:418
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:63
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define WS_CHILD
Definition: pedump.c:617
#define WS_VISIBLE
Definition: pedump.c:620
#define TVS_LINESATROOT
Definition: commctrl.h:3254
#define TVS_HASLINES
Definition: commctrl.h:3253
#define WC_TREEVIEWA
Definition: commctrl.h:3247
#define TVS_HASBUTTONS
Definition: commctrl.h:3252
#define TVS_EDITLABELS
Definition: commctrl.h:3255
static HWND hTree
Definition: systempage.cpp:52
#define GWLP_WNDPROC
Definition: treelist.c:66
#define GWLP_USERDATA
Definition: treelist.c:63
#define SetWindowLongPtrA
Definition: winuser.h:5357
HWND WINAPI CreateWindowExA(_In_ DWORD dwExStyle, _In_opt_ LPCSTR lpClassName, _In_opt_ LPCSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
HWND WINAPI SetFocus(_In_opt_ HWND)
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2909

Referenced by test_callback(), test_cchildren(), test_customdraw(), test_delete_items(), test_expand(), test_expandedimage(), test_expandinvisible(), test_expandnotify(), test_fillroot(), test_focus(), test_get_insertmarkcolor(), test_get_linecolor(), test_get_set_bkcolor(), test_get_set_imagelist(), test_get_set_indent(), test_get_set_insertmark(), test_get_set_item(), test_get_set_itemheight(), test_get_set_scrolltime(), test_get_set_textcolor(), test_get_set_tooltips(), test_get_set_unicodeformat(), test_getitemtext(), test_htreeitem_layout(), test_itemedit(), test_right_click(), test_select(), test_TVM_GETNEXTITEM(), test_TVM_HITTEST(), test_TVM_SORTCHILDREN(), test_TVS_CHECKBOXES(), test_TVS_FULLROWSELECT(), test_TVS_SINGLEEXPAND(), test_WM_GETDLGCODE(), test_WM_KEYDOWN(), and test_WM_PAINT().

◆ fill_tree()

static void fill_tree ( HWND  hTree)
static

Definition at line 457 of file treeview.c.

458{
459 TVINSERTSTRUCTA ins;
460 static CHAR root[] = "Root",
461 child[] = "Child";
462
463 ins.hParent = TVI_ROOT;
465 U(ins).item.mask = TVIF_TEXT;
466 U(ins).item.pszText = root;
468
469 ins.hParent = hRoot;
471 U(ins).item.mask = TVIF_TEXT;
472 U(ins).item.pszText = child;
474}
#define U(x)
Definition: wordpad.c:45
static HTREEITEM hRoot
Definition: treeview.c:383
static HTREEITEM hChild
Definition: treeview.c:383
static HWND child
Definition: cursoricon.c:298
#define TVIF_TEXT
Definition: commctrl.h:3271
#define TVI_FIRST
Definition: commctrl.h:3374
#define TVI_ROOT
Definition: commctrl.h:3373
#define TreeView_InsertItemA(hwnd, phdi)
Definition: commctrl.h:86
HTREEITEM hParent
Definition: commctrl.h:3389
HTREEITEM hInsertAfter
Definition: commctrl.h:3390
char CHAR
Definition: xmlstorage.h:175

Referenced by test_cchildren(), test_customdraw(), test_delete_items(), test_expandedimage(), test_expandnotify(), test_fillroot(), test_focus(), test_get_set_bkcolor(), test_get_set_imagelist(), test_get_set_indent(), test_get_set_insertmark(), test_get_set_item(), test_get_set_itemheight(), test_get_set_scrolltime(), test_get_set_textcolor(), test_get_set_tooltips(), test_get_set_unicodeformat(), test_getitemtext(), test_htreeitem_layout(), test_itemedit(), test_right_click(), test_select(), test_TVM_GETNEXTITEM(), test_TVM_HITTEST(), test_TVS_CHECKBOXES(), and test_TVS_SINGLEEXPAND().

◆ fill_treeview_sort_test()

static void fill_treeview_sort_test ( HWND  hwnd)
static

Definition at line 2737 of file treeview.c.

2738{
2739 static const char *itemnames[] =
2740 {
2741 "root", "Wasp", "Caribou", "Vacuum",
2742 "Ocelot", "Newspaper", "Litter bin"
2743 };
2744
2745 HTREEITEM root, children[2];
2746 TVINSERTSTRUCTA ins;
2747 unsigned i = 0;
2748
2750
2751 /* root, two children, with two children each */
2752 ins.hParent = TVI_ROOT;
2753 ins.hInsertAfter = TVI_ROOT;
2754 U(ins).item.mask = TVIF_TEXT;
2755 U(ins).item.pszText = (char *)itemnames[i++];
2757
2758 ins.hParent = root;
2759 ins.hInsertAfter = TVI_LAST;
2760 U(ins).item.mask = TVIF_TEXT;
2761 U(ins).item.pszText = (char *)itemnames[i++];
2762 children[0] = (HTREEITEM)SendMessageA(hwnd, TVM_INSERTITEMA, 0, (LPARAM)&ins);
2763
2764 U(ins).item.pszText = (char *)itemnames[i++];
2765 children[1] = (HTREEITEM)SendMessageA(hwnd, TVM_INSERTITEMA, 0, (LPARAM)&ins);
2766
2767 ins.hParent = children[0];
2768 U(ins).item.pszText = (char *)itemnames[i++];
2770
2771 U(ins).item.pszText = (char *)itemnames[i++];
2773
2774 ins.hParent = children[1];
2775 U(ins).item.pszText = (char *)itemnames[i++];
2777
2778 U(ins).item.pszText = (char *)itemnames[i++];
2780}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define TVI_LAST
Definition: commctrl.h:3375
#define TVM_DELETEITEM
Definition: commctrl.h:3419
#define TVM_INSERTITEMA
Definition: commctrl.h:3412

Referenced by test_TVM_SORTCHILDREN().

◆ flush_events()

static void flush_events ( void  )
static

Definition at line 60 of file treeview.c.

61{
62 MSG msg;
63 int diff = 200;
64 int min_timeout = 100;
65 DWORD time = GetTickCount() + diff;
66
67 while (diff > 0)
68 {
69 if (MsgWaitForMultipleObjects(0, NULL, FALSE, min_timeout, QS_ALLINPUT) == WAIT_TIMEOUT) break;
70 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
71 diff = time - GetTickCount();
72 }
73}
#define msg(x)
Definition: auth_time.c:54
#define WAIT_TIMEOUT
Definition: dderror.h:14
#define FALSE
Definition: types.h:117
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
unsigned long DWORD
Definition: ntddk_ex.h:95
__u16 time
Definition: mkdosfs.c:8
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
LRESULT WINAPI DispatchMessageA(_In_ const MSG *)
#define QS_ALLINPUT
Definition: winuser.h:906
DWORD WINAPI MsgWaitForMultipleObjects(_In_ DWORD nCount, _In_reads_opt_(nCount) CONST HANDLE *pHandles, _In_ BOOL fWaitAll, _In_ DWORD dwMilliseconds, _In_ DWORD dwWakeMask)
#define PM_REMOVE
Definition: winuser.h:1199
BOOL WINAPI PeekMessageA(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)

Referenced by test_right_click().

◆ get_item_names_string()

static void get_item_names_string ( HWND  hwnd,
HTREEITEM  item,
char str 
)
static

Definition at line 2709 of file treeview.c.

2710{
2711 TVITEMA tvitem = { 0 };
2713 char name[16];
2714
2715 if (!item)
2716 {
2718 str[0] = 0;
2719 }
2720
2722
2723 tvitem.mask = TVIF_TEXT;
2724 tvitem.hItem = item;
2725 tvitem.pszText = name;
2726 tvitem.cchTextMax = sizeof(name);
2727 SendMessageA(hwnd, TVM_GETITEMA, 0, (LPARAM)&tvitem);
2728 strcat(str, tvitem.pszText);
2729
2730 while (child != NULL)
2731 {
2734 }
2735}
static void get_item_names_string(HWND hwnd, HTREEITEM item, char *str)
Definition: treeview.c:2709
#define TVM_GETITEMA
Definition: commctrl.h:3490
const WCHAR * str
strcat
Definition: string.h:92
Definition: name.c:39
UINT mask
Definition: commctrl.h:3308
LPSTR pszText
Definition: commctrl.h:3312
HTREEITEM hItem
Definition: commctrl.h:3309
int cchTextMax
Definition: commctrl.h:3313

Referenced by get_item_names_string(), and test_TVM_SORTCHILDREN().

◆ IdentifyItem()

static void IdentifyItem ( HTREEITEM  hItem)
static

Definition at line 400 of file treeview.c.

401{
402 if (hItem == hRoot) {
403 AddItem('R');
404 return;
405 }
406 if (hItem == hChild) {
407 AddItem('C');
408 return;
409 }
410 if (hItem == NULL) {
411 AddItem('n');
412 return;
413 }
414 AddItem('?');
415}
#define AddItem
Definition: userenv.h:209

Referenced by parent_wnd_proc().

◆ init_functions()

static void init_functions ( void  )
static

Definition at line 2944 of file treeview.c.

2945{
2946 HMODULE hComCtl32 = LoadLibraryA("comctl32.dll");
2947
2948#define X(f) p##f = (void*)GetProcAddress(hComCtl32, #f);
2950#undef X
2951}
BOOL WINAPI InitCommonControlsEx(const INITCOMMONCONTROLSEX *lpInitCtrls)
Definition: commctrl.c:900
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
#define X(f)

Referenced by START_TEST().

◆ parent_wnd_proc()

static LRESULT CALLBACK parent_wnd_proc ( HWND  hWnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 1229 of file treeview.c.

1230{
1231 static LONG defwndproc_counter = 0;
1232 struct message msg = { 0 };
1233 LRESULT ret;
1234 RECT rect;
1235 HTREEITEM visibleItem;
1236
1237 msg.message = message;
1238 msg.flags = sent|wparam|lparam;
1239 if (defwndproc_counter) msg.flags |= defwinproc;
1240 msg.wParam = wParam;
1241 msg.lParam = lParam;
1242 if (message == WM_NOTIFY && lParam)
1243 msg.id = ((NMHDR*)lParam)->code;
1244
1245 /* log system messages, except for painting */
1246 if (message < WM_USER &&
1247 message != WM_PAINT &&
1249 message != WM_NCPAINT &&
1250 message != WM_NCHITTEST &&
1251 message != WM_GETTEXT &&
1252 message != WM_GETICON &&
1254 {
1256 }
1257
1258 switch(message) {
1259 case WM_NOTIFYFORMAT:
1260 {
1261 /* Make NF_QUERY return an invalid format to show that it defaults to ANSI */
1262 if (lParam == NF_QUERY) return 0;
1263 break;
1264 }
1265
1266 case WM_NOTIFY:
1267 {
1268 NMHDR *pHdr = (NMHDR *)lParam;
1269
1270 ok(pHdr->code != NM_TOOLTIPSCREATED, "Treeview should not send NM_TOOLTIPSCREATED\n");
1271 if (pHdr->idFrom == 100)
1272 {
1273 NMTREEVIEWA *pTreeView = (LPNMTREEVIEWA) lParam;
1274 switch(pHdr->code)
1275 {
1276 case TVN_SELCHANGINGA:
1277 AddItem('(');
1278 IdentifyItem(pTreeView->itemOld.hItem);
1279 IdentifyItem(pTreeView->itemNew.hItem);
1280 break;
1281 case TVN_SELCHANGEDA:
1282 AddItem(')');
1283 IdentifyItem(pTreeView->itemOld.hItem);
1284 IdentifyItem(pTreeView->itemNew.hItem);
1285 break;
1286 case TVN_GETDISPINFOA: {
1288 if (disp->item.mask & TVIF_TEXT) {
1290 }
1291
1292 if (g_disp_A_to_W && (disp->item.mask & TVIF_TEXT)) {
1293 static const WCHAR testW[] = {'T','E','S','T','2',0};
1294
1295 disp->hdr.code = TVN_GETDISPINFOW;
1296 memcpy(disp->item.pszText, testW, sizeof(testW));
1297 }
1298
1300 {
1301 ok(disp->item.mask == TVIF_IMAGE, "got %x\n", disp->item.mask);
1302 /* both masks set here are necessary to change state bits */
1303 disp->item.mask |= TVIF_STATE;
1306 }
1307
1308 break;
1309 }
1311 {
1313 {
1314 static const char* textA = "<edittextaltered>";
1315 HWND edit;
1316
1317 edit = (HWND)SendMessageA(pHdr->hwndFrom, TVM_GETEDITCONTROL, 0, 0);
1318 ok(IsWindow(edit), "failed to get edit handle\n");
1319 SetWindowTextA(edit, textA);
1320 }
1321
1322 break;
1323 }
1324
1325 case TVN_ENDLABELEDITA:
1326 {
1328 if (disp->item.mask & TVIF_TEXT)
1329 {
1330 ok(disp->item.cchTextMax == MAX_PATH, "cchTextMax is %d\n", disp->item.cchTextMax);
1335 }
1336 return TRUE;
1337 }
1338 case TVN_ITEMEXPANDINGA:
1339 {
1340 UINT newmask = pTreeView->itemNew.mask & ~TVIF_CHILDREN;
1341 ok(newmask ==
1343 "got wrong mask %x\n", pTreeView->itemNew.mask);
1344 ok(pTreeView->itemOld.mask == 0,
1345 "got wrong mask %x\n", pTreeView->itemOld.mask);
1346
1348 {
1352 ok(ret == TRUE, "got %lu\n", ret);
1353 }
1354 break;
1355 }
1356 case TVN_ITEMEXPANDEDA:
1357 ok(pTreeView->itemNew.mask & TVIF_STATE, "got wrong mask %x\n", pTreeView->itemNew.mask);
1359 "got wrong mask %x\n", pTreeView->itemNew.mask);
1360 ok(pTreeView->itemOld.mask == 0,
1361 "got wrong mask %x\n", pTreeView->itemOld.mask);
1362
1364 {
1368 ok(ret == TRUE, "got %lu\n", ret);
1369 }
1371 {
1372 visibleItem = (HTREEITEM)SendMessageA(pHdr->hwndFrom, TVM_GETNEXTITEM,
1374 ok(pTreeView->itemNew.hItem == visibleItem, "expanded item == first visible item\n");
1375 *(HTREEITEM*)&rect = visibleItem;
1377 "Failed to get rect for first visible item.\n");
1378 visibleItem = (HTREEITEM)SendMessageA(pHdr->hwndFrom, TVM_GETNEXTITEM,
1379 TVGN_NEXTVISIBLE, (LPARAM)visibleItem);
1380 *(HTREEITEM*)&rect = visibleItem;
1381 ok(visibleItem != NULL, "There must be a visible item after the first one.\n");
1383 "Failed to get rect for second visible item.\n");
1384 }
1385 break;
1386 case TVN_DELETEITEMA:
1387 {
1388 struct message item;
1389
1390 ok(pTreeView->itemNew.mask == 0, "got wrong mask 0x%x\n", pTreeView->itemNew.mask);
1391
1392 ok(pTreeView->itemOld.mask == (TVIF_HANDLE | TVIF_PARAM), "got wrong mask 0x%x\n", pTreeView->itemOld.mask);
1393 ok(pTreeView->itemOld.hItem != NULL, "got %p\n", pTreeView->itemOld.hItem);
1394
1395 memset(&item, 0, sizeof(item));
1396 item.lParam = (LPARAM)pTreeView->itemOld.hItem;
1398
1399 break;
1400 }
1401 case NM_CUSTOMDRAW:
1402 {
1404 COLORREF c0ffee = RGB(0xc0,0xff,0xee), cafe = RGB(0xca,0xfe,0x00);
1405 COLORREF text = GetTextColor(nmcd->nmcd.hdc), bkgnd = GetBkColor(nmcd->nmcd.hdc);
1406
1407 msg.flags |= custdraw;
1408 msg.stage = nmcd->nmcd.dwDrawStage;
1410
1411 switch (msg.stage)
1412 {
1413 case CDDS_PREPAINT:
1415 case CDDS_ITEMPREPAINT:
1416 ok(text == nmcd->clrText || (g_v6 && nmcd->clrText == 0xffffffff),
1417 "got %08x vs %08x\n", text, nmcd->clrText);
1418 ok(bkgnd == nmcd->clrTextBk || (g_v6 && nmcd->clrTextBk == 0xffffffff),
1419 "got %08x vs %08x\n", bkgnd, nmcd->clrTextBk);
1420 nmcd->clrText = cafe;
1421 nmcd->clrTextBk = c0ffee;
1422 SetTextColor(nmcd->nmcd.hdc, c0ffee);
1423 SetBkColor(nmcd->nmcd.hdc, cafe);
1427 case CDDS_ITEMPOSTPAINT:
1428 /* at the point of post paint notification colors are already restored */
1429 ok(nmcd->clrText == cafe, "got 0%x\n", nmcd->clrText);
1430 ok(nmcd->clrTextBk == c0ffee, "got 0%x\n", nmcd->clrTextBk);
1431 ok(text != cafe, "got 0%x\n", text);
1432 ok(bkgnd != c0ffee, "got 0%x\n", bkgnd);
1434 ok(GetCurrentObject(nmcd->nmcd.hdc, OBJ_FONT) != g_customdraw_font, "got %p\n",
1436 break;
1437 default:
1438 ;
1439 }
1440 break;
1441 }
1442 case NM_RCLICK:
1443 {
1446 ok(selected == hChild, "child item should still be selected\n");
1447 break;
1448 }
1449 }
1450 }
1451 break;
1452 }
1453
1454 }
1455
1456 defwndproc_counter++;
1458 defwndproc_counter--;
1459
1460 return ret;
1461}
@ sent
Definition: SystemMenu.c:27
@ defwinproc
Definition: SystemMenu.c:32
@ lparam
Definition: SystemMenu.c:31
@ wparam
Definition: SystemMenu.c:30
#define add_message(msg)
Definition: SystemMenu.c:98
#define ok(value,...)
Definition: atltest.h:57
HWND hWnd
Definition: settings.c:17
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
@ custdraw
Definition: msg.h:47
static char selected[MAX_PATH+1]
Definition: dirdlg.c:7
#define lstrcpynA
Definition: compat.h:751
HANDLE HWND
Definition: compat.h:19
#define MAX_PATH
Definition: compat.h:34
const WCHAR * text
Definition: package.c:1794
#define RGB(r, g, b)
Definition: precomp.h:71
static const WCHAR testW[]
Definition: jsregexp.c:44
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static const char textA[]
Definition: registrar.c:40
static const char * TEST_CALLBACK_TEXT
Definition: treeview.c:37
static TVITEMA g_item_expanded
Definition: treeview.c:39
static struct msg_sequence * item_sequence[1]
Definition: treeview.c:58
static HFONT g_customdraw_font
Definition: treeview.c:47
static char * g_endedit_overwrite_ptr
Definition: treeview.c:46
static TVITEMA g_item_expanding
Definition: treeview.c:39
static const char * g_endedit_overwrite_contents
Definition: treeview.c:45
static struct msg_sequence * sequences[NUM_MSG_SEQUENCES]
Definition: treeview.c:57
static BOOL g_disp_A_to_W
Definition: treeview.c:42
#define PARENT_SEQ_INDEX
Definition: treeview.c:52
static BOOL g_v6
Definition: treeview.c:48
static void IdentifyItem(HTREEITEM hItem)
Definition: treeview.c:400
static BOOL g_beginedit_alter_text
Definition: treeview.c:44
#define PARENT_CD_SEQ_INDEX
Definition: treeview.c:53
static BOOL g_get_rect_in_expand
Definition: treeview.c:41
static BOOL g_disp_set_stateimage
Definition: treeview.c:43
static BOOL g_get_from_expand
Definition: treeview.c:40
unsigned int UINT
Definition: ndis.h:50
#define OBJ_FONT
Definition: objidl.idl:1414
long LONG
Definition: pedump.c:60
#define CDDS_ITEMPOSTPAINT
Definition: commctrl.h:286
#define TVN_ENDLABELEDITA
Definition: commctrl.h:3716
#define CDRF_NOTIFYITEMERASE
Definition: commctrl.h:278
#define CDDS_ITEMPREPAINT
Definition: commctrl.h:285
#define TVGN_FIRSTVISIBLE
Definition: commctrl.h:3462
#define TVN_ITEMEXPANDINGA
Definition: commctrl.h:3704
#define TVN_BEGINLABELEDITA
Definition: commctrl.h:3714
#define TVIF_IMAGE
Definition: commctrl.h:3272
#define TVIS_EXPANDEDONCE
Definition: commctrl.h:3290
#define CDRF_NOTIFYITEMDRAW
Definition: commctrl.h:275
#define TVIS_SELECTED
Definition: commctrl.h:3285
#define NM_TOOLTIPSCREATED
Definition: commctrl.h:144
#define CDRF_NOTIFYPOSTPAINT
Definition: commctrl.h:274
#define TVN_ITEMEXPANDEDA
Definition: commctrl.h:3706
#define NM_CUSTOMDRAW
Definition: commctrl.h:137
#define TVN_GETDISPINFOW
Definition: commctrl.h:3660
#define TVM_GETEDITCONTROL
Definition: commctrl.h:3511
#define TVN_SELCHANGINGA
Definition: commctrl.h:3650
struct tagNMTREEVIEWA * LPNMTREEVIEWA
#define TVN_DELETEITEMA
Definition: commctrl.h:3712
#define TVIS_STATEIMAGEMASK
Definition: commctrl.h:3293
#define CDRF_NEWFONT
Definition: commctrl.h:269
#define TVIF_HANDLE
Definition: commctrl.h:3275
#define TVGN_NEXTVISIBLE
Definition: commctrl.h:3463
#define TVIS_EXPANDED
Definition: commctrl.h:3289
#define CDDS_PREPAINT
Definition: commctrl.h:280
#define TVN_GETDISPINFOA
Definition: commctrl.h:3659
#define NM_RCLICK
Definition: commctrl.h:133
#define TVIS_OVERLAYMASK
Definition: commctrl.h:3292
#define TVGN_CARET
Definition: commctrl.h:3466
#define INDEXTOSTATEIMAGEMASK(i)
Definition: commctrl.h:2333
#define INDEXTOOVERLAYMASK(i)
Definition: commctrl.h:425
#define TVIF_PARAM
Definition: commctrl.h:3273
#define TVN_SELCHANGEDA
Definition: commctrl.h:3652
#define TVIF_SELECTEDIMAGE
Definition: commctrl.h:3276
#define TVIF_STATE
Definition: commctrl.h:3274
#define WM_NOTIFY
Definition: richedit.h:61
strcpy
Definition: string.h:131
#define memset(x, y, z)
Definition: compat.h:39
Definition: tftpd.h:60
UINT message
Definition: SystemMenu.c:42
UINT_PTR idFrom
Definition: winuser.h:3161
UINT code
Definition: winuser.h:3162
HWND hwndFrom
Definition: winuser.h:3160
TVITEMA itemOld
Definition: commctrl.h:3634
TVITEMA itemNew
Definition: commctrl.h:3635
COLORREF clrText
Definition: commctrl.h:3755
NMCUSTOMDRAW nmcd
Definition: commctrl.h:3754
COLORREF clrTextBk
Definition: commctrl.h:3756
TVITEMA item
Definition: commctrl.h:3672
UINT stateMask
Definition: commctrl.h:3311
UINT state
Definition: commctrl.h:3310
LONG_PTR LRESULT
Definition: windef.h:209
DWORD COLORREF
Definition: windef.h:300
COLORREF WINAPI SetBkColor(_In_ HDC, _In_ COLORREF)
Definition: dc.c:999
COLORREF WINAPI GetTextColor(_In_ HDC)
Definition: text.c:861
HGDIOBJ WINAPI GetCurrentObject(_In_ HDC, _In_ UINT)
Definition: dc.c:428
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
COLORREF WINAPI GetBkColor(_In_ HDC)
Definition: dc.c:978
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:918
#define WM_PAINT
Definition: winuser.h:1623
#define WM_ERASEBKGND
Definition: winuser.h:1628
BOOL WINAPI IsWindow(_In_opt_ HWND)
BOOL WINAPI SetWindowTextA(_In_ HWND, _In_opt_ LPCSTR)
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_NCHITTEST
Definition: winuser.h:1689
#define WM_GETTEXT
Definition: winuser.h:1621
#define WM_DEVICECHANGE
Definition: winuser.h:1814
#define WM_USER
Definition: winuser.h:1898
#define NF_QUERY
Definition: winuser.h:2463
#define WM_NCPAINT
Definition: winuser.h:1690
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( treeview  )

Definition at line 2953 of file treeview.c.

2954{
2956 ULONG_PTR ctx_cookie;
2957 HANDLE hCtx;
2958 WNDCLASSA wc;
2959
2961
2962 iccex.dwSize = sizeof(iccex);
2964 pInitCommonControlsEx(&iccex);
2965
2968
2970 wc.cbClsExtra = 0;
2971 wc.cbWndExtra = 0;
2973 wc.hIcon = NULL;
2976 wc.lpszMenuName = NULL;
2977 wc.lpszClassName = "MyTestWnd";
2979 RegisterClassA(&wc);
2980
2981 hMainWnd = CreateWindowExA(0, "MyTestWnd", "Blah", WS_OVERLAPPEDWINDOW,
2983
2984 ok(hMainWnd != NULL, "Failed to create parent window. Tests aborted.\n");
2985 if (!hMainWnd) return;
2986
2987 test_fillroot();
2988 test_select();
2990 test_focus();
3003 test_callback();
3005 test_itemedit();
3009 test_WM_PAINT();
3022
3023 if (!load_v6_module(&ctx_cookie, &hCtx))
3024 {
3026 return;
3027 }
3028
3029 /* comctl32 version 6 tests start here */
3030 g_v6 = TRUE;
3031
3032 test_fillroot();
3044 test_expand();
3045 test_itemedit();
3057
3058 unload_v6_module(ctx_cookie, hCtx);
3059}
static void init_msg_sequences(struct msg_sequence **seq, int n)
Definition: msg.h:393
static void test_get_set_imagelist(void)
Definition: treeview.c:815
static void test_TVS_SINGLEEXPAND(void)
Definition: treeview.c:2021
static void test_expandnotify(void)
Definition: treeview.c:1810
static void test_delete_items(void)
Definition: treeview.c:2154
static void test_expandinvisible(void)
Definition: treeview.c:1463
static void test_get_set_item(void)
Definition: treeview.c:886
static void test_get_insertmarkcolor(void)
Definition: treeview.c:1793
#define NUM_MSG_SEQUENCES
Definition: treeview.c:50
static void test_customdraw(void)
Definition: treeview.c:2639
static void test_TVS_FULLROWSELECT(void)
Definition: treeview.c:2685
static void test_cchildren(void)
Definition: treeview.c:2216
static void test_TVM_HITTEST(void)
Definition: treeview.c:2585
static void test_WM_KEYDOWN(void)
Definition: treeview.c:2662
static void test_WM_PAINT(void)
Definition: treeview.c:2121
static void test_TVM_GETNEXTITEM(void)
Definition: treeview.c:2547
static void test_focus(void)
Definition: treeview.c:741
static void test_get_set_itemheight(void)
Definition: treeview.c:957
static void test_get_set_insertmark(void)
Definition: treeview.c:866
static void test_itemedit(void)
Definition: treeview.c:1588
static void test_TVM_SORTCHILDREN(void)
Definition: treeview.c:2782
static void test_get_set_tooltips(void)
Definition: treeview.c:1072
static void test_treeview_classinfo(void)
Definition: treeview.c:1765
static void test_select(void)
Definition: treeview.c:641
static void test_get_set_unicodeformat(void)
Definition: treeview.c:1195
static void test_get_linecolor(void)
Definition: treeview.c:1776
static void test_fillroot(void)
Definition: treeview.c:476
static LRESULT CALLBACK parent_wnd_proc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: treeview.c:1229
static void test_getitemtext(void)
Definition: treeview.c:703
static void test_WM_GETDLGCODE(void)
Definition: treeview.c:2626
static void test_expand(void)
Definition: treeview.c:1545
static void test_get_set_indent(void)
Definition: treeview.c:838
static void test_callback(void)
Definition: treeview.c:506
static void test_get_set_scrolltime(void)
Definition: treeview.c:1018
static void init_functions(void)
Definition: treeview.c:2944
static void test_right_click(void)
Definition: treeview.c:2898
static void test_TVS_CHECKBOXES(void)
Definition: treeview.c:2362
static void test_htreeitem_layout(BOOL is_version_6)
Definition: treeview.c:2327
static void test_expandedimage(void)
Definition: treeview.c:1982
static void test_get_set_textcolor(void)
Definition: treeview.c:1039
static void test_get_set_bkcolor(void)
Definition: treeview.c:782
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define ICC_TREEVIEW_CLASSES
Definition: commctrl.h:59
HBRUSH hbrBackground
Definition: winuser.h:3173
HICON hIcon
Definition: winuser.h:3171
HINSTANCE hInstance
Definition: winuser.h:3170
HCURSOR hCursor
Definition: winuser.h:3172
int cbWndExtra
Definition: winuser.h:3169
UINT style
Definition: winuser.h:3166
LPCSTR lpszMenuName
Definition: winuser.h:3174
LPCSTR lpszClassName
Definition: winuser.h:3175
WNDPROC lpfnWndProc
Definition: winuser.h:3167
int cbClsExtra
Definition: winuser.h:3168
uint32_t ULONG_PTR
Definition: typedefs.h:65
static BOOL load_v6_module(ULONG_PTR *pcookie, HANDLE *hCtx)
Definition: v6util.h:73
static void unload_v6_module(ULONG_PTR cookie, HANDLE hCtx)
Definition: v6util.h:65
#define CS_VREDRAW
Definition: winuser.h:658
#define COLOR_WINDOW
Definition: winuser.h:921
HBRUSH WINAPI GetSysColorBrush(_In_ int)
#define CS_HREDRAW
Definition: winuser.h:653
ATOM WINAPI RegisterClassA(_In_ CONST WNDCLASSA *)
#define IDC_IBEAM
Definition: winuser.h:688
#define CW_USEDEFAULT
Definition: winuser.h:225
BOOL WINAPI DestroyWindow(_In_ HWND)
HCURSOR WINAPI LoadCursorA(_In_opt_ HINSTANCE, _In_ LPCSTR)
Definition: cursoricon.c:2176
const char * LPCSTR
Definition: xmlstorage.h:183

◆ test_callback()

static void test_callback ( void  )
static

Definition at line 506 of file treeview.c.

507{
509 HTREEITEM hItem1, hItem2;
510 TVINSERTSTRUCTA ins;
511 TVITEMA tvi;
512 CHAR test_string[] = "Test_string";
513 static const CHAR test2A[] = "TEST2";
514 CHAR buf[128];
515 HWND hTree;
516 DWORD ret;
517
519
521 expect(TRUE, ret);
522 ins.hParent = TVI_ROOT;
524 U(ins).item.mask = TVIF_TEXT;
525 U(ins).item.pszText = LPSTR_TEXTCALLBACKA;
527 ok(hRoot != NULL, "failed to set root\n");
528
529 tvi.hItem = hRoot;
530 tvi.mask = TVIF_TEXT;
531 tvi.pszText = buf;
533 ret = TreeView_GetItemA(hTree, &tvi);
534 expect(TRUE, ret);
535 ok(strcmp(tvi.pszText, TEST_CALLBACK_TEXT) == 0, "Callback item text mismatch %s vs %s\n",
537
538 ins.hParent = hRoot;
540 U(ins).item.mask = TVIF_TEXT;
541 U(ins).item.pszText = test_string;
542 hItem1 = TreeView_InsertItemA(hTree, &ins);
543 ok(hItem1 != NULL, "failed to set Item1\n");
544
545 tvi.hItem = hItem1;
546 ret = TreeView_GetItemA(hTree, &tvi);
547 expect(TRUE, ret);
548 ok(strcmp(tvi.pszText, test_string) == 0, "Item text mismatch %s vs %s\n",
549 tvi.pszText, test_string);
550
551 /* undocumented: pszText of NULL also means LPSTR_CALLBACK: */
552 tvi.pszText = NULL;
553 ret = TreeView_SetItemA(hTree, &tvi);
554 expect(TRUE, ret);
555 tvi.pszText = buf;
556 ret = TreeView_GetItemA(hTree, &tvi);
557 expect(TRUE, ret);
558 ok(strcmp(tvi.pszText, TEST_CALLBACK_TEXT) == 0, "Item text mismatch %s vs %s\n",
560
561 U(ins).item.pszText = NULL;
562 hItem2 = TreeView_InsertItemA(hTree, &ins);
563 ok(hItem2 != NULL, "failed to set Item2\n");
564 tvi.hItem = hItem2;
565 memset(buf, 0, sizeof(buf));
566 ret = TreeView_GetItemA(hTree, &tvi);
567 expect(TRUE, ret);
568 ok(strcmp(tvi.pszText, TEST_CALLBACK_TEXT) == 0, "Item text mismatch %s vs %s\n",
570
571 /* notification handler changed A->W */
573 tvi.hItem = hItem2;
574 memset(buf, 0, sizeof(buf));
575 ret = TreeView_GetItemA(hTree, &tvi);
576 expect(TRUE, ret);
577 ok(strcmp(tvi.pszText, test2A) == 0, "got %s, expected %s\n",
578 tvi.pszText, test2A);
580
581 /* handler changes state image index */
583
584 /* clear selection, handler will set selected state */
586 expect(TRUE, ret);
587
589
590 tvi.hItem = hRoot;
591 tvi.mask = TVIF_STATE;
592 tvi.state = TVIS_SELECTED;
593 ret = TreeView_GetItemA(hTree, &tvi);
594 expect(TRUE, ret);
595 ok(tvi.state == INDEXTOSTATEIMAGEMASK(1), "got 0x%x\n", tvi.state);
596
598 "no TVN_GETDISPINFO for a state seq", FALSE);
599
600 tvi.hItem = hRoot;
601 tvi.mask = TVIF_IMAGE | TVIF_STATE;
602 tvi.state = TVIS_FOCUSED;
605 ret = TreeView_SetItemA(hTree, &tvi);
606 expect(TRUE, ret);
607
608 /* ask for item image index through callback - state is also set with state image index */
610
611 tvi.hItem = hRoot;
612 tvi.mask = TVIF_IMAGE;
613 tvi.state = 0;
614 ret = TreeView_GetItemA(hTree, &tvi);
615 expect(TRUE, ret);
616 ok(tvi.state == (INDEXTOSTATEIMAGEMASK(1) | TVIS_FOCUSED), "got 0x%x\n", tvi.state);
617
619 "callback for state/overlay image index, noop seq", FALSE);
620
621 /* ask for image again and overwrite state to some value in handler */
623
625 tvi.hItem = hRoot;
626 tvi.mask = TVIF_IMAGE;
628 tvi.stateMask = 0;
629 ret = TreeView_GetItemA(hTree, &tvi);
630 expect(TRUE, ret);
631 /* handler sets TVIS_SELECTED as well */
632 ok(tvi.state == (TVIS_FOCUSED | TVIS_SELECTED | INDEXTOSTATEIMAGEMASK(2) | INDEXTOOVERLAYMASK(3)), "got 0x%x\n", tvi.state);
634
636 "callback for state/overlay image index seq", FALSE);
637
639}
#define ok_sequence(exp, contx, todo)
Definition: SystemMenu.c:275
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define ARRAY_SIZE(A)
Definition: main.h:20
static void flush_sequences(struct msg_sequence **seq, int n)
Definition: msg.h:99
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define expect(expected, got)
Definition: treeview.c:55
static const struct message parent_get_dispinfo_seq[]
Definition: treeview.c:347
static const struct message empty_seq[]
Definition: treeview.c:352
static HWND create_treeview_control(DWORD style)
Definition: treeview.c:439
#define I_IMAGECALLBACK
Definition: commctrl.h:2390
#define LPSTR_TEXTCALLBACKA
Definition: commctrl.h:2386
#define TVS_CHECKBOXES
Definition: commctrl.h:3260
#define TVM_SELECTITEM
Definition: commctrl.h:3483
#define TreeView_GetItemA(hwnd, pitem)
Definition: commctrl.h:83
#define TreeView_SetItemA(hwnd, pitem)
Definition: commctrl.h:90
int iImage
Definition: commctrl.h:3314
void test_string()
Definition: test_string.cpp:38
#define TVIS_FOCUSED
Definition: treelist.c:125
LONG WINAPI GetWindowLongA(_In_ HWND, _In_ int)
LONG WINAPI SetWindowLongA(_In_ HWND, _In_ int, _In_ LONG)
#define GWL_STYLE
Definition: winuser.h:855

Referenced by START_TEST().

◆ test_cchildren()

static void test_cchildren ( void  )
static

Definition at line 2216 of file treeview.c.

2217{
2218 HWND hTree;
2219 INT ret;
2220 TVITEMA item;
2221
2224
2226 expect(TRUE, ret);
2227
2228 /* check cChildren - automatic mode */
2229 item.hItem = hRoot;
2230 item.mask = TVIF_CHILDREN;
2231
2233 expect(TRUE, ret);
2234 expect(0, item.cChildren);
2235
2237
2238 /* start over */
2241
2242 /* turn off automatic mode by setting cChildren explicitly */
2243 item.hItem = hRoot;
2244 item.mask = TVIF_CHILDREN;
2245
2247 expect(TRUE, ret);
2248 expect(1, item.cChildren);
2249
2251 expect(TRUE, ret);
2252
2254 expect(TRUE, ret);
2255
2256 /* check cChildren */
2258 expect(TRUE, ret);
2260 expect(1, item.cChildren);
2261
2263}
static void fill_tree(HWND hTree)
Definition: treeview.c:457
#define TVM_SETITEMA
Definition: commctrl.h:3497
#define TVIF_CHILDREN
Definition: commctrl.h:3277
int32_t INT
Definition: typedefs.h:58

Referenced by START_TEST().

◆ test_customdraw()

static void test_customdraw ( void  )
static

Definition at line 2639 of file treeview.c.

2640{
2641 LOGFONTA lf;
2642 HWND hwnd;
2643
2645 fill_tree(hwnd);
2647
2648 /* create additional font, custom draw handler will select it */
2650 lf.lfHeight *= 2;
2655 ok_sequence(sequences, PARENT_CD_SEQ_INDEX, parent_cd_seq, "custom draw notifications", FALSE);
2658
2660}
pKey DeleteObject()
static const struct message parent_cd_seq[]
Definition: treeview.c:356
#define TVE_EXPAND
Definition: commctrl.h:3428
#define TVM_EXPAND
Definition: commctrl.h:3424
LONG lfHeight
Definition: dimm.idl:42
UINT_PTR WPARAM
Definition: windef.h:207
HFONT WINAPI CreateFontIndirectA(_In_ const LOGFONTA *)
#define SPI_GETICONTITLELOGFONT
Definition: winuser.h:1383
BOOL WINAPI UpdateWindow(_In_ HWND)
BOOL WINAPI SystemParametersInfoA(_In_ UINT uiAction, _In_ UINT uiParam, _Inout_opt_ PVOID pvParam, _In_ UINT fWinIni)
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)

Referenced by START_TEST().

◆ test_delete_items()

static void test_delete_items ( void  )
static

Definition at line 2154 of file treeview.c.

2155{
2156 const struct message *msg;
2157 HWND hTree;
2158 HTREEITEM hItem1, hItem2;
2159 TVINSERTSTRUCTA ins;
2160 INT ret;
2161
2162 static CHAR item1[] = "Item 1";
2163 static CHAR item2[] = "Item 2";
2164
2167
2168 /* check delete order */
2171 ok(ret == TRUE, "got %d\n", ret);
2172
2173 msg = item_sequence[0]->sequence;
2174 ok(item_sequence[0]->count == 2, "expected 2 items, got %d\n", item_sequence[0]->count);
2175
2176 if (item_sequence[0]->count == 2)
2177 {
2178 ok(msg[0].lParam == (LPARAM)hChild, "expected %p, got 0x%lx\n", hChild, msg[0].lParam);
2179 ok(msg[1].lParam == (LPARAM)hRoot, "expected %p, got 0x%lx\n", hRoot, msg[1].lParam);
2180 }
2181
2183 ok(ret == 0, "got %d\n", ret);
2184
2186
2187 /* Regression test for a crash when deleting the first visible item while bRedraw == false. */
2189
2191 ok(ret == 0, "got %d\n", ret);
2192
2193 ins.hParent = TVI_ROOT;
2194 ins.hInsertAfter = TVI_ROOT;
2195 U(ins).item.mask = TVIF_TEXT;
2196 U(ins).item.pszText = item1;
2197 hItem1 = TreeView_InsertItemA(hTree, &ins);
2198 ok(hItem1 != NULL, "InsertItem failed\n");
2199
2200 ins.hParent = TVI_ROOT;
2201 ins.hInsertAfter = hItem1;
2202 U(ins).item.mask = TVIF_TEXT;
2203 U(ins).item.pszText = item2;
2204 hItem2 = TreeView_InsertItemA(hTree, &ins);
2205 ok(hItem2 != NULL, "InsertItem failed\n");
2206
2207 ret = SendMessageA(hTree, TVM_DELETEITEM, 0, (LPARAM)hItem1);
2208 ok(ret == TRUE, "got %d\n", ret);
2209
2211 ok(ret == 0, "got %d\n", ret);
2212
2214}
GLuint GLuint GLsizei count
Definition: gl.h:1545
static const struct metadata_item item1[]
Definition: metadata.c:3603
static const struct metadata_item item2[]
Definition: metadata.c:3608
#define TVM_GETCOUNT
Definition: commctrl.h:3436
#define WM_SETREDRAW
Definition: winuser.h:1619

Referenced by START_TEST().

◆ test_expand()

static void test_expand ( void  )
static

Definition at line 1545 of file treeview.c.

1546{
1547 HTREEITEM first, second, last, child;
1548 TVINSERTSTRUCTA ins;
1549 BOOL visible;
1550 RECT rect;
1551 HWND tv;
1552 int i;
1553
1555
1556 ins.hParent = TVI_ROOT;
1557 ins.hInsertAfter = TVI_LAST;
1558 U(ins).item.mask = 0;
1559 first = TreeView_InsertItemA(tv, &ins);
1560 ok(first != NULL, "failed to insert first node\n");
1561 second = TreeView_InsertItemA(tv, &ins);
1562 ok(second != NULL, "failed to insert second node\n");
1563 for (i=0; i<100; i++)
1564 {
1565 last = TreeView_InsertItemA(tv, &ins);
1566 ok(last != NULL, "failed to insert %d node\n", i);
1567 }
1568
1569 ins.hParent = second;
1570 child = TreeView_InsertItemA(tv, &ins);
1571 ok(child != NULL, "failed to insert child node\n");
1572
1573 ok(SendMessageA(tv, TVM_SELECTITEM, TVGN_CARET, (LPARAM)last), "last node selection failed\n");
1574 ok(SendMessageA(tv, TVM_EXPAND, TVE_EXPAND, (LPARAM)second), "expand of second node failed\n");
1575 ok(SendMessageA(tv, TVM_SELECTITEM, TVGN_CARET, (LPARAM)first), "first node selection failed\n");
1576
1577 *(HTREEITEM *)&rect = first;
1578 visible = SendMessageA(tv, TVM_GETITEMRECT, FALSE, (LPARAM)&rect);
1579 ok(visible, "first node should be visible\n");
1580 ok(!rect.left, "rect.left = %d\n", rect.left);
1581 ok(!rect.top, "rect.top = %d\n", rect.top);
1582 ok(rect.right, "rect.right = 0\n");
1583 ok(rect.bottom, "rect.bottom = 0\n");
1584
1585 DestroyWindow(tv);
1586}
const GLint * first
Definition: glext.h:5794
static UINT UINT last
Definition: font.c:45

Referenced by START_TEST().

◆ test_expandedimage()

static void test_expandedimage ( void  )
static

Definition at line 1982 of file treeview.c.

1983{
1985 HWND hTree;
1986 BOOL ret;
1987
1990
1991 item.mask = TVIF_EXPANDEDIMAGE;
1992 item.iExpandedImage = 1;
1993 item.hItem = hRoot;
1995 ok(ret, "got %d\n", ret);
1996
1997 item.mask = TVIF_EXPANDEDIMAGE;
1998 item.iExpandedImage = -1;
1999 item.hItem = hRoot;
2001 ok(ret, "got %d\n", ret);
2002
2003 if (item.iExpandedImage != 1)
2004 {
2005 win_skip("TVIF_EXPANDEDIMAGE not supported\n");
2007 return;
2008 }
2009
2010 /* test for default iExpandedImage value */
2011 item.mask = TVIF_EXPANDEDIMAGE;
2012 item.iExpandedImage = -1;
2013 item.hItem = hChild;
2015 ok(ret, "got %d\n", ret);
2016 ok(item.iExpandedImage == (WORD)I_IMAGENONE, "got %d\n", item.iExpandedImage);
2017
2019}
#define TVIF_EXPANDEDIMAGE
Definition: commctrl.h:3284
#define I_IMAGENONE
Definition: commctrl.h:2391
#define win_skip
Definition: test.h:164

Referenced by START_TEST().

◆ test_expandinvisible()

static void test_expandinvisible ( void  )
static

Definition at line 1463 of file treeview.c.

1464{
1465 static CHAR nodeText[][5] = {"0", "1", "2", "3", "4"};
1466 TVINSERTSTRUCTA ins;
1467 HTREEITEM node[5];
1468 RECT dummyRect;
1469 BOOL nodeVisible;
1470 LRESULT ret;
1471 HWND hTree;
1472
1474
1475 /* The test builds the following tree and expands node 1, while node 0 is collapsed.
1476 *
1477 * 0
1478 * |- 1
1479 * | |- 2
1480 * | |- 3
1481 * |- 4
1482 *
1483 */
1484
1486 ok(ret == TRUE, "ret\n");
1487 ins.hParent = TVI_ROOT;
1488 ins.hInsertAfter = TVI_ROOT;
1489 U(ins).item.mask = TVIF_TEXT;
1490 U(ins).item.pszText = nodeText[0];
1491 node[0] = TreeView_InsertItemA(hTree, &ins);
1492 ok(node[0] != NULL, "failed to set node[0]\n");
1493
1494 ins.hInsertAfter = TVI_LAST;
1495 U(ins).item.mask = TVIF_TEXT;
1496 ins.hParent = node[0];
1497
1498 U(ins).item.pszText = nodeText[1];
1499 node[1] = TreeView_InsertItemA(hTree, &ins);
1500 ok(node[1] != NULL, "failed to set node[1]\n");
1501 U(ins).item.pszText = nodeText[4];
1502 node[4] = TreeView_InsertItemA(hTree, &ins);
1503 ok(node[4] != NULL, "failed to set node[4]\n");
1504
1505 ins.hParent = node[1];
1506
1507 U(ins).item.pszText = nodeText[2];
1508 node[2] = TreeView_InsertItemA(hTree, &ins);
1509 ok(node[2] != NULL, "failed to set node[2]\n");
1510 U(ins).item.pszText = nodeText[3];
1511 node[3] = TreeView_InsertItemA(hTree, &ins);
1512 ok(node[3] != NULL, "failed to set node[3]\n");
1513
1514 *(HTREEITEM *)&dummyRect = node[1];
1515 nodeVisible = SendMessageA(hTree, TVM_GETITEMRECT, FALSE, (LPARAM)&dummyRect);
1516 ok(!nodeVisible, "Node 1 should not be visible.\n");
1517 *(HTREEITEM *)&dummyRect = node[2];
1518 nodeVisible = SendMessageA(hTree, TVM_GETITEMRECT, FALSE, (LPARAM)&dummyRect);
1519 ok(!nodeVisible, "Node 2 should not be visible.\n");
1520 *(HTREEITEM *)&dummyRect = node[3];
1521 nodeVisible = SendMessageA(hTree, TVM_GETITEMRECT, FALSE, (LPARAM)&dummyRect);
1522 ok(!nodeVisible, "Node 3 should not be visible.\n");
1523 *(HTREEITEM *)&dummyRect = node[4];
1524 nodeVisible = SendMessageA(hTree, TVM_GETITEMRECT, FALSE, (LPARAM)&dummyRect);
1525 ok(!nodeVisible, "Node 4 should not be visible.\n");
1526
1527 ok(SendMessageA(hTree, TVM_EXPAND, TVE_EXPAND, (LPARAM)node[1]), "Expand of node 1 failed.\n");
1528
1529 *(HTREEITEM *)&dummyRect = node[1];
1530 nodeVisible = SendMessageA(hTree, TVM_GETITEMRECT, FALSE, (LPARAM)&dummyRect);
1531 ok(!nodeVisible, "Node 1 should not be visible.\n");
1532 *(HTREEITEM *)&dummyRect = node[2];
1533 nodeVisible = SendMessageA(hTree, TVM_GETITEMRECT, FALSE, (LPARAM)&dummyRect);
1534 ok(!nodeVisible, "Node 2 should not be visible.\n");
1535 *(HTREEITEM *)&dummyRect = node[3];
1536 nodeVisible = SendMessageA(hTree, TVM_GETITEMRECT, FALSE, (LPARAM)&dummyRect);
1537 ok(!nodeVisible, "Node 3 should not be visible.\n");
1538 *(HTREEITEM *)&dummyRect = node[4];
1539 nodeVisible = SendMessageA(hTree, TVM_GETITEMRECT, FALSE, (LPARAM)&dummyRect);
1540 ok(!nodeVisible, "Node 4 should not be visible.\n");
1541
1543}
Definition: dlist.c:348

Referenced by START_TEST().

◆ test_expandnotify()

static void test_expandnotify ( void  )
static

Definition at line 1810 of file treeview.c.

1811{
1812 HTREEITEM hitem;
1813 HWND hTree;
1814 BOOL ret;
1815 TVITEMA item;
1816
1819
1820 item.hItem = hRoot;
1821 item.mask = TVIF_STATE;
1822
1823 item.state = TVIS_EXPANDED;
1825 expect(TRUE, ret);
1826 ok((item.state & TVIS_EXPANDED) == 0, "expected collapsed\n");
1827
1828 /* preselect root node here */
1830 expect(TRUE, ret);
1831
1834 expect(FALSE, ret);
1835 ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "no collapse notifications", FALSE);
1836
1838 /* expand */
1840 g_item_expanding.state = 0xdeadbeef;
1841 g_item_expanded.state = 0xdeadbeef;
1843 expect(TRUE, ret);
1844 ok(g_item_expanding.state == TVIS_SELECTED, "got state on TVN_ITEMEXPANDING 0x%08x\n",
1846 ok(g_item_expanded.state == (TVIS_SELECTED|TVIS_EXPANDED), "got state on TVN_ITEMEXPANDED 0x%08x\n",
1848 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_expand_seq, "expand notifications", FALSE);
1850
1851 /* check that it's expanded */
1852 item.state = TVIS_EXPANDED;
1854 expect(TRUE, ret);
1855 ok((item.state & TVIS_EXPANDED) == TVIS_EXPANDED, "expected expanded\n");
1856
1857 /* collapse */
1860 expect(TRUE, ret);
1861 item.state = TVIS_EXPANDED;
1863 expect(TRUE, ret);
1864 ok((item.state & TVIS_EXPANDED) == 0, "expected collapsed\n");
1865 /* all further collapse/expand attempts won't produce any notifications,
1866 the only way is to reset with all children removed */
1867 ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "collapse after expand notifications", FALSE);
1868
1869 /* try to toggle child that doesn't have children itself */
1872 expect(FALSE, ret);
1873 ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "toggle node without children", FALSE);
1874
1876
1877 /* test TVM_GETITEMRECT inside TVN_ITEMEXPANDED notification */
1882 expect(TRUE, ret);
1884
1886
1887 /* TVE_TOGGLE acts as any other TVM_EXPAND */
1890
1893 expect(TRUE, ret);
1894 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_expand_seq, "toggle node (expand)", FALSE);
1895
1896 /* toggle again - no notifications */
1899 expect(TRUE, ret);
1900 ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "toggle node (collapse)", FALSE);
1901
1903
1904 /* some keyboard events are also translated to expand */
1907
1908 /* preselect root node here */
1910 expect(TRUE, ret);
1911
1915 expect(FALSE, ret);
1917 ok(g_item_expanding.state == TVIS_SELECTED, "got state on TVN_ITEMEXPANDING 0x%08x\n",
1919 ok(g_item_expanded.state == (TVIS_SELECTED|TVIS_EXPANDED), "got state on TVN_ITEMEXPANDED 0x%08x\n",
1921
1924 expect(FALSE, ret);
1926 ok(g_item_expanding.state == (TVIS_SELECTED|TVIS_EXPANDED|TVIS_EXPANDEDONCE), "got state on TVN_ITEMEXPANDING 0x%08x\n",
1928 ok(g_item_expanded.state == (TVIS_SELECTED|TVIS_EXPANDED|TVIS_EXPANDEDONCE), "got state on TVN_ITEMEXPANDED 0x%08x\n",
1930
1933 expect(FALSE, ret);
1935 ok(g_item_expanding.state == (TVIS_SELECTED|TVIS_EXPANDED|TVIS_EXPANDEDONCE), "got state on TVN_ITEMEXPANDING 0x%08x\n",
1937 ok(g_item_expanded.state == (TVIS_SELECTED|TVIS_EXPANDEDONCE), "got state on TVN_ITEMEXPANDED 0x%08x\n",
1939
1942 expect(FALSE, ret);
1944 ok(g_item_expanding.state == (TVIS_SELECTED|TVIS_EXPANDEDONCE), "got state on TVN_ITEMEXPANDING 0x%08x\n",
1947
1950 expect(FALSE, ret);
1952
1953 /* go to child */
1955 expect(FALSE, ret);
1956
1957 /* try to expand child that doesn't have children itself */
1960 expect(FALSE, ret);
1961 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_expand_empty_kb_seq, "expand node with no children", FALSE);
1962
1963 /* stay on current selection and set non-zero children count */
1965 ok(hitem != NULL, "got %p\n", hitem);
1966
1967 item.hItem = hitem;
1968 item.mask = TVIF_CHILDREN;
1969 item.cChildren = 0x80000000;
1970
1972 expect(TRUE, ret);
1973
1976 expect(FALSE, ret);
1978
1980}
static const struct message parent_expand_seq[]
Definition: treeview.c:232
static const struct message parent_expand_empty_kb_seq[]
Definition: treeview.c:253
static const struct message parent_collapse_2nd_kb_seq[]
Definition: treeview.c:246
static const struct message parent_expand_kb_seq[]
Definition: treeview.c:238
#define TVE_TOGGLE
Definition: commctrl.h:3429
#define TVE_COLLAPSE
Definition: commctrl.h:3427
#define VK_ADD
Definition: winuser.h:2253
#define VK_RIGHT
Definition: winuser.h:2229
#define WM_KEYDOWN
Definition: winuser.h:1718
#define VK_SUBTRACT
Definition: winuser.h:2255

Referenced by START_TEST().

◆ test_fillroot()

static void test_fillroot ( void  )
static

Definition at line 476 of file treeview.c.

477{
478 TVITEMA tvi;
479 HWND hTree;
480
482
484
486
487 Clear();
488 AddItem('A');
489 ok(hRoot != NULL, "failed to set root\n");
490 AddItem('B');
491 ok(hChild != NULL, "failed to set child\n");
492 AddItem('.');
494 ok(!strcmp(sequence, "AB."), "Item creation\n");
495
496 /* UMLPad 1.15 depends on this being not -1 (I_IMAGECALLBACK) */
497 tvi.hItem = hRoot;
500 ok(tvi.iImage == 0, "tvi.iImage=%d\n", tvi.iImage);
501 ok(tvi.iSelectedImage == 0, "tvi.iSelectedImage=%d\n", tvi.iSelectedImage);
502
504}
static const struct message FillRootSeq[]
Definition: treeview.c:75
#define TREEVIEW_SEQ_INDEX
Definition: treeview.c:51
static void Clear(void)
Definition: treeview.c:388
int iSelectedImage
Definition: commctrl.h:3315

Referenced by START_TEST().

◆ test_focus()

static void test_focus ( void  )
static

Definition at line 741 of file treeview.c.

742{
743 TVINSERTSTRUCTA ins;
744 static CHAR child1[] = "Edit",
745 child2[] = "A really long string";
746 HTREEITEM hChild1, hChild2;
747 HWND hTree;
748 HWND hEdit;
749
752
754
755 /* This test verifies that when a label is being edited, scrolling
756 * the treeview does not cause the label to lose focus. To test
757 * this, first some additional entries are added to generate
758 * scrollbars.
759 */
760 ins.hParent = hRoot;
761 ins.hInsertAfter = hChild;
762 U(ins).item.mask = TVIF_TEXT;
763 U(ins).item.pszText = child1;
764 hChild1 = TreeView_InsertItemA(hTree, &ins);
765 ok(hChild1 != NULL, "failed to set hChild1\n");
766 ins.hInsertAfter = hChild1;
767 U(ins).item.mask = TVIF_TEXT;
768 U(ins).item.pszText = child2;
769 hChild2 = TreeView_InsertItemA(hTree, &ins);
770 ok(hChild2 != NULL, "failed to set hChild2\n");
771
776 ok(GetFocus() == hEdit, "Edit control should have focus\n");
778
780}
static const struct message focus_seq[]
Definition: treeview.c:108
#define TVM_EDITLABELA
Definition: commctrl.h:3504
static HWND hEdit
Definition: autocomplete.c:34
HWND WINAPI GetFocus(void)
Definition: window.c:1875
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define SW_SCROLLCHILDREN
Definition: winuser.h:2581
#define SW_SHOW
Definition: winuser.h:778
int WINAPI ScrollWindowEx(_In_ HWND, _In_ int, _In_ int, _In_opt_ LPCRECT, _In_opt_ LPCRECT, _In_opt_ HRGN, _Out_opt_ LPRECT, _In_ UINT)

Referenced by START_TEST().

◆ test_get_insertmarkcolor()

static void test_get_insertmarkcolor ( void  )
static

Definition at line 1793 of file treeview.c.

1794{
1795 COLORREF clr;
1796 HWND hTree;
1797
1799
1800 /* newly created control has default color */
1802 if (clr == 0)
1803 win_skip("TVM_GETINSERTMARKCOLOR is not supported on comctl32 < 5.80\n");
1804 else
1805 expect(CLR_DEFAULT, clr);
1806
1808}
#define CLR_DEFAULT
Definition: commctrl.h:320
#define TVM_GETINSERTMARKCOLOR
Definition: commctrl.h:3594

Referenced by START_TEST().

◆ test_get_linecolor()

static void test_get_linecolor ( void  )
static

Definition at line 1776 of file treeview.c.

1777{
1778 COLORREF clr;
1779 HWND hTree;
1780
1782
1783 /* newly created control has default color */
1784 clr = SendMessageA(hTree, TVM_GETLINECOLOR, 0, 0);
1785 if (clr == 0)
1786 win_skip("TVM_GETLINECOLOR is not supported on comctl32 < 5.80\n");
1787 else
1788 expect(CLR_DEFAULT, clr);
1789
1791}
#define TVM_GETLINECOLOR
Definition: treelist.h:345

Referenced by START_TEST().

◆ test_get_set_bkcolor()

static void test_get_set_bkcolor ( void  )
static

Definition at line 782 of file treeview.c.

783{
784 COLORREF crColor;
785 HWND hTree;
786
789
791
792 /* If the value is -1, the control is using the system color for the background color. */
793 crColor = SendMessageA(hTree, TVM_GETBKCOLOR, 0, 0);
794 ok(crColor == ~0u, "Default background color reported as 0x%.8x\n", crColor);
795
796 /* Test for black background */
798 crColor = SendMessageA(hTree, TVM_GETBKCOLOR, 0, 0);
799 ok(crColor == RGB(0,0,0), "Black background color reported as 0x%.8x\n", crColor);
800
801 /* Test for white background */
802 SendMessageA(hTree, TVM_SETBKCOLOR, 0, RGB(255,255,255));
803 crColor = SendMessageA(hTree, TVM_GETBKCOLOR, 0, 0);
804 ok(crColor == RGB(255,255,255), "White background color reported as 0x%.8x\n", crColor);
805
806 /* Reset the default background */
808
810 "test get set bkcolor", FALSE);
811
813}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
static const struct message test_get_set_bkcolor_seq[]
Definition: treeview.c:138
#define TVM_SETBKCOLOR
Definition: commctrl.h:3580
#define TVM_GETBKCOLOR
Definition: commctrl.h:3584

Referenced by START_TEST().

◆ test_get_set_imagelist()

static void test_get_set_imagelist ( void  )
static

Definition at line 815 of file treeview.c.

816{
818 HWND hTree;
819
822
824
825 /* Test a NULL HIMAGELIST */
828 ok(himl == NULL, "NULL image list, reported as %p, expected 0.\n", himl);
829
830 /* TODO: Test an actual image list */
831
833 "test get imagelist", FALSE);
834
836}
HIMAGELIST himl
static const struct message test_get_set_imagelist_seq[]
Definition: treeview.c:148
#define TVSIL_NORMAL
Definition: commctrl.h:3448
struct _IMAGELIST * HIMAGELIST
Definition: commctrl.h:324
#define TVM_SETIMAGELIST
Definition: commctrl.h:3451
#define TVM_GETIMAGELIST
Definition: commctrl.h:3445

Referenced by START_TEST().

◆ test_get_set_indent()

static void test_get_set_indent ( void  )
static

Definition at line 838 of file treeview.c.

839{
840 int ulIndent;
841 int ulMinIndent;
842 int ulMoreThanTwiceMin;
843 HWND hTree;
844
847
849
850 /* Finding the minimum indent */
852 ulMinIndent = SendMessageA(hTree, TVM_GETINDENT, 0, 0);
853
854 /* Checking an indent that is more than twice the default indent */
855 ulMoreThanTwiceMin = 2*ulMinIndent+1;
856 SendMessageA(hTree, TVM_SETINDENT, ulMoreThanTwiceMin, 0);
857 ulIndent = SendMessageA(hTree, TVM_GETINDENT, 0, 0);
858 ok(ulIndent == ulMoreThanTwiceMin, "Indent reported as %d, expected %d\n", ulIndent, ulMoreThanTwiceMin);
859
861 "test get set indent", FALSE);
862
864}
static const struct message test_get_set_indent_seq[]
Definition: treeview.c:154
#define TVM_SETINDENT
Definition: commctrl.h:3442
#define TVM_GETINDENT
Definition: commctrl.h:3439

Referenced by START_TEST().

◆ test_get_set_insertmark()

static void test_get_set_insertmark ( void  )
static

Definition at line 866 of file treeview.c.

867{
868 COLORREF crColor = RGB(0,0,0);
869 HWND hTree;
870
873
875
877 crColor = SendMessageA(hTree, TVM_GETINSERTMARKCOLOR, 0, 0);
878 ok(crColor == RGB(0,0,0), "Insert mark color reported as 0x%.8x, expected 0x00000000\n", crColor);
879
881 "test get set insertmark color", FALSE);
882
884}
static const struct message test_get_set_insertmarkcolor_seq[]
Definition: treeview.c:163
#define TVM_SETINSERTMARKCOLOR
Definition: commctrl.h:3592

Referenced by START_TEST().

◆ test_get_set_item()

static void test_get_set_item ( void  )
static

Definition at line 886 of file treeview.c.

887{
888 TVITEMA tviRoot = {0};
889 int nBufferSize = 80;
890 char szBuffer[80] = {0};
891 HWND hTree, hTree2;
892 DWORD ret;
893
896
897 tviRoot.hItem = hRoot;
898 tviRoot.mask = TVIF_STATE;
899 tviRoot.state = TVIS_FOCUSED;
900 tviRoot.stateMask = TVIS_FOCUSED;
901 ret = SendMessageA(hTree, TVM_SETITEMA, 0, (LPARAM)&tviRoot);
902 expect(TRUE, ret);
903
905
906 /* Test the root item, state is set even when not requested */
907 tviRoot.hItem = hRoot;
908 tviRoot.mask = TVIF_TEXT;
909 tviRoot.state = 0;
910 tviRoot.stateMask = 0;
911 tviRoot.cchTextMax = nBufferSize;
912 tviRoot.pszText = szBuffer;
913 ret = SendMessageA(hTree, TVM_GETITEMA, 0, (LPARAM)&tviRoot);
914 expect(TRUE, ret);
915 ok(!strcmp("Root", szBuffer), "GetItem: szBuffer=\"%s\", expected \"Root\"\n", szBuffer);
916 ok(tviRoot.state == TVIS_FOCUSED, "got 0x%0x\n", tviRoot.state);
917
918 /* Change the root text */
919 lstrcpynA(szBuffer, "Testing123", nBufferSize);
920 ret = SendMessageA(hTree, TVM_SETITEMA, 0, (LPARAM)&tviRoot);
921 expect(TRUE, ret);
922 memset(szBuffer, 0, nBufferSize);
923 ret = SendMessageA(hTree, TVM_GETITEMA, 0, (LPARAM)&tviRoot);
924 expect(TRUE, ret);
925 ok(!strcmp("Testing123", szBuffer), "GetItem: szBuffer=\"%s\", expected \"Testing123\"\n", szBuffer);
926
927 /* Reset the root text */
928 memset(szBuffer, 0, nBufferSize);
929 lstrcpynA(szBuffer, "Root", nBufferSize);
930 ret = SendMessageA(hTree, TVM_SETITEMA, 0, (LPARAM)&tviRoot);
931 expect(TRUE, ret);
932
934 "test get set item", FALSE);
935
936 /* get item from a different tree */
937 hTree2 = create_treeview_control(0);
938
939 tviRoot.hItem = hRoot;
940 tviRoot.mask = TVIF_STATE;
941 tviRoot.state = 0;
942 ret = SendMessageA(hTree2, TVM_GETITEMA, 0, (LPARAM)&tviRoot);
943 expect(TRUE, ret);
944 ok(tviRoot.state == TVIS_FOCUSED, "got state 0x%0x\n", tviRoot.state);
945
946 /* invalid item pointer, nt4 crashes here but later versions just return 0 */
947 tviRoot.hItem = (HTREEITEM)0xdeadbeef;
948 tviRoot.mask = TVIF_STATE;
949 tviRoot.state = 0;
950 ret = SendMessageA(hTree2, TVM_GETITEMA, 0, (LPARAM)&tviRoot);
951 expect(FALSE, ret);
952
954 DestroyWindow(hTree2);
955}
static const struct message test_get_set_item_seq[]
Definition: treeview.c:169

Referenced by START_TEST().

◆ test_get_set_itemheight()

static void test_get_set_itemheight ( void  )
static

Definition at line 957 of file treeview.c.

958{
959 int ulOldHeight = 0;
960 int ulNewHeight = 0;
961 HWND hTree;
962
965
967
968 /* Assuming default height to begin with */
969 ulOldHeight = SendMessageA(hTree, TVM_GETITEMHEIGHT, 0, 0);
970
971 /* Explicitly setting and getting the default height */
973 ulNewHeight = SendMessageA(hTree, TVM_GETITEMHEIGHT, 0, 0);
974 ok(ulNewHeight == ulOldHeight, "Default height not set properly, reported %d, expected %d\n", ulNewHeight, ulOldHeight);
975
976 /* Explicitly setting and getting the height of twice the normal */
977 SendMessageA(hTree, TVM_SETITEMHEIGHT, 2*ulOldHeight, 0);
978 ulNewHeight = SendMessageA(hTree, TVM_GETITEMHEIGHT, 0, 0);
979 ok(ulNewHeight == 2*ulOldHeight, "New height not set properly, reported %d, expected %d\n", ulNewHeight, 2*ulOldHeight);
980
981 /* Assuming tree doesn't have TVS_NONEVENHEIGHT set, so a set of 9 will round down to 8 */
983 ulNewHeight = SendMessageA(hTree, TVM_GETITEMHEIGHT, 0, 0);
984 ok(ulNewHeight == 8, "Uneven height not set properly, reported %d, expected %d\n", ulNewHeight, 8);
985
987 "test get set item height", FALSE);
988
989 /* without TVS_NONEVENHEIGHT */
991 /* odd value */
992 ulOldHeight = SendMessageA(hTree, TVM_SETITEMHEIGHT, 3, 0);
993 ok(ulOldHeight == 8, "got %d, expected %d\n", ulOldHeight, 8);
994 ulNewHeight = SendMessageA(hTree, TVM_GETITEMHEIGHT, 0, 0);
995 ok(ulNewHeight == 2, "got %d, expected %d\n", ulNewHeight, 2);
996
997 ulOldHeight = SendMessageA(hTree, TVM_SETITEMHEIGHT, 4, 0);
998 ok(ulOldHeight == 2, "got %d, expected %d\n", ulOldHeight, 2);
999 ulNewHeight = SendMessageA(hTree, TVM_GETITEMHEIGHT, 0, 0);
1000 ok(ulNewHeight == 4, "got %d, expected %d\n", ulNewHeight, 4);
1001
1002 /* with TVS_NONEVENHEIGHT */
1004 /* odd value */
1005 ulOldHeight = SendMessageA(hTree, TVM_SETITEMHEIGHT, 3, 0);
1006 ok(ulOldHeight == 4, "got %d, expected %d\n", ulOldHeight, 4);
1007 ulNewHeight = SendMessageA(hTree, TVM_GETITEMHEIGHT, 0, 0);
1008 ok(ulNewHeight == 3, "got %d, expected %d\n", ulNewHeight, 3);
1009 /* even value */
1010 ulOldHeight = SendMessageA(hTree, TVM_SETITEMHEIGHT, 10, 0);
1011 ok(ulOldHeight == 3, "got %d, expected %d\n", ulOldHeight, 3);
1012 ulNewHeight = SendMessageA(hTree, TVM_GETITEMHEIGHT, 0, 0);
1013 ok(ulNewHeight == 10, "got %d, expected %d\n", ulNewHeight, 10);
1014
1016}
static const struct message test_get_set_itemheight_seq[]
Definition: treeview.c:177
#define TVM_GETITEMHEIGHT
Definition: commctrl.h:3578
#define TVS_NONEVENHEIGHT
Definition: commctrl.h:3266
#define TVM_SETITEMHEIGHT
Definition: commctrl.h:3576

Referenced by START_TEST().

◆ test_get_set_scrolltime()

static void test_get_set_scrolltime ( void  )
static

Definition at line 1018 of file treeview.c.

1019{
1020 int ulExpectedTime = 20;
1021 int ulTime = 0;
1022 HWND hTree;
1023
1026
1028
1029 SendMessageA(hTree, TVM_SETSCROLLTIME, ulExpectedTime, 0);
1030 ulTime = SendMessageA(hTree, TVM_GETSCROLLTIME, 0, 0);
1031 ok(ulTime == ulExpectedTime, "Scroll time reported as %d, expected %d\n", ulTime, ulExpectedTime);
1032
1034 "test get set scroll time", FALSE);
1035
1037}
static const struct message test_get_set_scrolltime_seq[]
Definition: treeview.c:188
#define TVM_SETSCROLLTIME
Definition: commctrl.h:3588
#define TVM_GETSCROLLTIME
Definition: commctrl.h:3590

Referenced by START_TEST().

◆ test_get_set_textcolor()

static void test_get_set_textcolor ( void  )
static

Definition at line 1039 of file treeview.c.

1040{
1041 /* If the value is -1, the control is using the system color for the text color. */
1042 COLORREF crColor;
1043 HWND hTree;
1044
1047
1049
1050 crColor = SendMessageA(hTree, TVM_GETTEXTCOLOR, 0, 0);
1051 ok(crColor == ~0u, "Default text color reported as 0x%.8x\n", crColor);
1052
1053 /* Test for black text */
1055 crColor = SendMessageA(hTree, TVM_GETTEXTCOLOR, 0, 0);
1056 ok(crColor == RGB(0,0,0), "Black text color reported as 0x%.8x\n", crColor);
1057
1058 /* Test for white text */
1059 SendMessageA(hTree, TVM_SETTEXTCOLOR, 0, RGB(255,255,255));
1060 crColor = SendMessageA(hTree, TVM_GETTEXTCOLOR, 0, 0);
1061 ok(crColor == RGB(255,255,255), "White text color reported as 0x%.8x\n", crColor);
1062
1063 /* Reset the default text color */
1065
1067 "test get set text color", FALSE);
1068
1070}
static const struct message test_get_set_textcolor_seq[]
Definition: treeview.c:194
#define CLR_NONE
Definition: commctrl.h:319
#define TVM_SETTEXTCOLOR
Definition: commctrl.h:3582
#define TVM_GETTEXTCOLOR
Definition: commctrl.h:3586

Referenced by START_TEST().

◆ test_get_set_tooltips()

static void test_get_set_tooltips ( void  )
static

Definition at line 1072 of file treeview.c.

1073{
1074 HWND hTree, tooltips, hwnd;
1075 DWORD style;
1076 int i;
1077
1078 /* TVS_NOTOOLTIPS */
1080
1081 tooltips = (HWND)SendMessageA(hTree, TVM_GETTOOLTIPS, 0, 0);
1082 ok(tooltips == NULL, "Unexpected tooltip window %p.\n", tooltips);
1083
1084 tooltips = (HWND)SendMessageA(hTree, TVM_SETTOOLTIPS, 0, 0);
1085 ok(tooltips == NULL, "Unexpected ret value %p.\n", tooltips);
1086
1087 /* Toggle style */
1090
1091 tooltips = (HWND)SendMessageA(hTree, TVM_GETTOOLTIPS, 0, 0);
1092 ok(IsWindow(tooltips), "Unexpected tooltip window %p.\n", tooltips);
1093
1096
1097 tooltips = (HWND)SendMessageA(hTree, TVM_GETTOOLTIPS, 0, 0);
1098 ok(tooltips == NULL, "Unexpected tooltip window %p.\n", tooltips);
1099
1101
1102 /* Set some valid window, does not have to be tooltips class. */
1104
1105 hwnd = CreateWindowA(WC_STATICA, "Test", WS_VISIBLE|WS_CHILD, 5, 5, 100, 100, hMainWnd, NULL, NULL, 0);
1106 ok(hwnd != NULL, "Failed to create child window.\n");
1107
1108 tooltips = (HWND)SendMessageA(hTree, TVM_SETTOOLTIPS, (WPARAM)hwnd, 0);
1109 ok(tooltips == NULL, "Unexpected ret value %p.\n", tooltips);
1110
1111 tooltips = (HWND)SendMessageA(hTree, TVM_GETTOOLTIPS, 0, 0);
1112 ok(tooltips == hwnd, "Unexpected tooltip window %p.\n", tooltips);
1113
1114 /* Externally set tooltips window, disable style. */
1117
1118 tooltips = (HWND)SendMessageA(hTree, TVM_GETTOOLTIPS, 0, 0);
1119 ok(IsWindow(tooltips) && tooltips != hwnd, "Unexpected tooltip window %p.\n", tooltips);
1120 ok(IsWindow(hwnd), "Expected valid window.\n");
1121
1124 ok(!IsWindow(tooltips), "Unexpected tooltip window %p.\n", tooltips);
1125
1126 tooltips = (HWND)SendMessageA(hTree, TVM_GETTOOLTIPS, 0, 0);
1127 ok(tooltips == NULL, "Unexpected tooltip window %p.\n", tooltips);
1128 ok(IsWindow(hwnd), "Expected valid window.\n");
1129
1131 ok(IsWindow(hwnd), "Expected valid window.\n");
1132
1133 /* Set window, disable tooltips. */
1135
1136 tooltips = (HWND)SendMessageA(hTree, TVM_SETTOOLTIPS, (WPARAM)hwnd, 0);
1137 ok(IsWindow(tooltips), "Unexpected ret value %p.\n", tooltips);
1138
1141 ok(!IsWindow(hwnd), "Unexpected tooltip window %p.\n", tooltips);
1142 ok(IsWindow(tooltips), "Expected valid window %p.\n", tooltips);
1143
1145 ok(IsWindow(tooltips), "Expected valid window %p.\n", tooltips);
1146 DestroyWindow(tooltips);
1148
1149 for (i = 0; i < 2; i++)
1150 {
1151 DWORD style = i == 0 ? 0 : TVS_NOTOOLTIPS;
1152
1153 hwnd = CreateWindowA(WC_STATICA, "Test", WS_VISIBLE|WS_CHILD, 5, 5, 100, 100, hMainWnd, NULL, NULL, 0);
1154 ok(hwnd != NULL, "Failed to create child window.\n");
1155
1157
1158 tooltips = (HWND)SendMessageA(hTree, TVM_SETTOOLTIPS, (WPARAM)hwnd, 0);
1159 ok(style & TVS_NOTOOLTIPS ? tooltips == NULL : IsWindow(tooltips), "Unexpected ret value %p.\n", tooltips);
1160 DestroyWindow(tooltips);
1161
1162 tooltips = (HWND)SendMessageA(hTree, TVM_GETTOOLTIPS, 0, 0);
1163 ok(tooltips == hwnd, "Unexpected tooltip window %p.\n", tooltips);
1164
1165 /* TreeView is destroyed, check if set window is still around. */
1167 ok(!IsWindow(hwnd), "Unexpected window.\n");
1168 }
1169
1172
1174
1175 /* show even WS_POPUP treeview don't send NM_TOOLTIPSCREATED */
1177 hMainWnd, NULL, NULL, NULL);
1179
1180 /* Testing setting a NULL ToolTip */
1181 tooltips = (HWND)SendMessageA(hTree, TVM_SETTOOLTIPS, 0, 0);
1182 ok(IsWindow(tooltips), "Unexpected ret value %p.\n", tooltips);
1183
1185 ok(hwnd == NULL, "Unexpected tooltip window %p.\n", hwnd);
1186
1188 "test get set tooltips", TRUE);
1189
1191 ok(IsWindow(tooltips), "Expected valid window.\n");
1192 DestroyWindow(tooltips);
1193}
static const struct message test_get_set_tooltips_seq[]
Definition: treeview.c:204
#define WS_POPUP
Definition: pedump.c:616
#define TVM_GETTOOLTIPS
Definition: commctrl.h:3565
#define WC_STATICA
Definition: commctrl.h:4684
#define TVS_NOTOOLTIPS
Definition: commctrl.h:3259
#define TVM_SETTOOLTIPS
Definition: commctrl.h:3563
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4318

Referenced by START_TEST().

◆ test_get_set_unicodeformat()

static void test_get_set_unicodeformat ( void  )
static

Definition at line 1195 of file treeview.c.

1196{
1197 BOOL bPreviousSetting;
1198 BOOL bNewSetting;
1199 HWND hTree;
1200
1203
1204 /* Check that an invalid format returned by NF_QUERY defaults to ANSI */
1205 bPreviousSetting = SendMessageA(hTree, TVM_GETUNICODEFORMAT, 0, 0);
1206 ok(bPreviousSetting == FALSE, "Format should be ANSI.\n");
1207
1209
1210 /* Set to Unicode */
1211 bPreviousSetting = SendMessageA(hTree, TVM_SETUNICODEFORMAT, 1, 0);
1212 bNewSetting = SendMessageA(hTree, TVM_GETUNICODEFORMAT, 0, 0);
1213 ok(bNewSetting == TRUE, "Unicode setting did not work.\n");
1214
1215 /* Set to ANSI */
1217 bNewSetting = SendMessageA(hTree, TVM_GETUNICODEFORMAT, 0, 0);
1218 ok(bNewSetting == FALSE, "ANSI setting did not work.\n");
1219
1220 /* Revert to original setting */
1221 SendMessageA(hTree, TVM_SETUNICODEFORMAT, bPreviousSetting, 0);
1222
1224 "test get set unicode format", FALSE);
1225
1227}
static const struct message test_get_set_unicodeformat_seq[]
Definition: treeview.c:213
#define TVM_GETUNICODEFORMAT
Definition: commctrl.h:3573
#define TVM_SETUNICODEFORMAT
Definition: commctrl.h:3571

Referenced by START_TEST().

◆ test_getitemtext()

static void test_getitemtext ( void  )
static

Definition at line 703 of file treeview.c.

704{
705 TVINSERTSTRUCTA ins;
707 TVITEMA tvi;
708 HWND hTree;
709
710 CHAR szBuffer[80] = "Blah";
711 int nBufferSize = ARRAY_SIZE(szBuffer);
712
715
717
718 /* add an item without TVIF_TEXT mask and pszText == NULL */
719 ins.hParent = hRoot;
721 U(ins).item.mask = 0;
722 U(ins).item.pszText = NULL;
723 U(ins).item.cchTextMax = 0;
725 ok(hChild != NULL, "failed to set hChild\n");
726
727 /* retrieve it with TVIF_TEXT mask */
728 tvi.hItem = hChild;
729 tvi.mask = TVIF_TEXT;
730 tvi.cchTextMax = nBufferSize;
731 tvi.pszText = szBuffer;
732
734 ok(!strcmp(szBuffer, ""), "szBuffer=\"%s\", expected \"\"\n", szBuffer);
735 ok(SendMessageA(hTree, TVM_DELETEITEM, 0, (LPARAM)hChild), "DeleteItem failed\n");
737
739}
static const struct message getitemtext_seq[]
Definition: treeview.c:101

Referenced by START_TEST().

◆ test_htreeitem_layout()

static void test_htreeitem_layout ( BOOL  is_version_6)
static

Definition at line 2327 of file treeview.c.

2328{
2329 TVINSERTSTRUCTA ins;
2331 HWND hTree;
2332
2335
2336 /* root has some special pointer in parent field */
2339
2340 ins.hParent = hChild;
2341 ins.hInsertAfter = TVI_FIRST;
2342 U(ins).item.mask = 0;
2344
2346
2347 ins.hParent = hRoot;
2348 ins.hInsertAfter = TVI_FIRST;
2349 U(ins).item.mask = 0;
2351
2353
2355
2356 /* without children now */
2358
2360}
#define CHECK_ITEM(a, b)
Definition: treeview.c:2325

Referenced by START_TEST().

◆ test_itemedit()

static void test_itemedit ( void  )
static

Definition at line 1588 of file treeview.c.

1589{
1590 DWORD r;
1591 HWND edit;
1592 TVITEMA item;
1593 CHAR buffA[500];
1594 HWND hTree;
1595
1598
1599 /* try with null item */
1600 edit = (HWND)SendMessageA(hTree, TVM_EDITLABELA, 0, 0);
1601 ok(!IsWindow(edit), "Expected valid handle\n");
1602
1603 /* trigger edit */
1605 ok(IsWindow(edit), "Expected valid handle\n");
1606 /* item shouldn't be selected automatically after TVM_EDITLABELA */
1608 expect(0, r);
1609 /* try to cancel with wrong edit handle */
1611 expect(0, r);
1612 ok(IsWindow(edit), "Expected edit control to be valid\n");
1614 expect(0, r);
1615 ok(!IsWindow(edit), "Expected edit control to be destroyed\n");
1616 /* try to cancel without creating edit */
1618 expect(0, r);
1619
1620 /* try to cancel with wrong (not null) handle */
1622 ok(IsWindow(edit), "Expected valid handle\n");
1624 expect(0, r);
1625 ok(IsWindow(edit), "Expected edit control to be valid\n");
1627 expect(0, r);
1628
1629 /* remove selection after starting edit */
1631 expect(TRUE, r);
1633 ok(IsWindow(edit), "Expected valid handle\n");
1635 expect(TRUE, r);
1636 /* alter text */
1637 strcpy(buffA, "x");
1638 r = SendMessageA(edit, WM_SETTEXT, 0, (LPARAM)buffA);
1639 expect(TRUE, r);
1641 expect(0, r);
1642 ok(!IsWindow(edit), "Expected edit control to be destroyed\n");
1643 /* check that text is saved */
1644 item.mask = TVIF_TEXT;
1645 item.hItem = hRoot;
1646 item.pszText = buffA;
1647 item.cchTextMax = ARRAY_SIZE(buffA);
1649 expect(TRUE, r);
1650 ok(!strcmp("x", buffA), "Expected item text to change\n");
1651
1652 /* try A/W messages */
1654 ok(IsWindow(edit), "Expected valid handle\n");
1655 ok(IsWindowUnicode(edit), "got ansi window\n");
1657 expect(0, r);
1658 ok(!IsWindow(edit), "expected invalid handle\n");
1659
1661 ok(IsWindow(edit), "Expected valid handle\n");
1662 ok(IsWindowUnicode(edit), "got ansi window\n");
1664 expect(0, r);
1665
1666 /* alter text during TVM_BEGINLABELEDIT, check that it's preserved */
1667 strcpy(buffA, "<root>");
1668
1669 item.mask = TVIF_TEXT;
1670 item.hItem = hRoot;
1671 item.pszText = buffA;
1672 item.cchTextMax = 0;
1674 expect(TRUE, r);
1675
1678 ok(IsWindow(edit), "Expected valid handle\n");
1680
1681 GetWindowTextA(edit, buffA, ARRAY_SIZE(buffA));
1682 ok(!strcmp(buffA, "<edittextaltered>"), "got string %s\n", buffA);
1683
1685 expect(0, r);
1686
1687 /* How much text can be typed? */
1689 ok(IsWindow(edit), "Expected valid handle\n");
1690 r = SendMessageA(edit, EM_GETLIMITTEXT, 0, 0);
1691 expect(MAX_PATH - 1, r);
1692 /* WM_SETTEXT can set more... */
1693 memset(buffA, 'a', ARRAY_SIZE(buffA));
1694 buffA[ARRAY_SIZE(buffA)-1] = 0;
1695 r = SetWindowTextA(edit, buffA);
1696 expect(TRUE, r);
1697 r = GetWindowTextA(edit, buffA, ARRAY_SIZE(buffA));
1698 ok( r == ARRAY_SIZE(buffA) - 1, "got %d\n", r );
1699 /* ...but it's trimmed to MAX_PATH chars when editing ends */
1701 expect(0, r);
1702 item.mask = TVIF_TEXT;
1703 item.hItem = hRoot;
1704 item.pszText = buffA;
1705 item.cchTextMax = ARRAY_SIZE(buffA);
1707 expect(TRUE, r);
1708 expect(MAX_PATH - 1, lstrlenA(item.pszText));
1709
1710 /* We can't get around that MAX_PATH limit by increasing EM_SETLIMITTEXT */
1712 ok(IsWindow(edit), "Expected valid handle\n");
1713 SendMessageA(edit, EM_SETLIMITTEXT, ARRAY_SIZE(buffA)-1, 0);
1714 memset(buffA, 'a', ARRAY_SIZE(buffA));
1715 buffA[ARRAY_SIZE(buffA)-1] = 0;
1716 r = SetWindowTextA(edit, buffA);
1717 expect(TRUE, r);
1719 expect(0, r);
1720 item.mask = TVIF_TEXT;
1721 item.hItem = hRoot;
1722 item.pszText = buffA;
1723 item.cchTextMax = ARRAY_SIZE(buffA);
1725 expect(TRUE, r);
1726 expect(MAX_PATH - 1, lstrlenA(item.pszText));
1727
1728 /* Overwriting of pszText contents in TVN_ENDLABELEDIT */
1730 ok(IsWindow(edit), "Expected valid handle\n");
1731 r = SetWindowTextA(edit, "old");
1732 expect(TRUE, r);
1733 g_endedit_overwrite_contents = "<new_contents>";
1735 expect(0, r);
1737 item.mask = TVIF_TEXT;
1738 item.hItem = hRoot;
1739 item.pszText = buffA;
1740 item.cchTextMax = ARRAY_SIZE(buffA);
1742 expect(TRUE, r);
1743 expect(0, strcmp(item.pszText, "<new_contents>"));
1744
1745 /* Overwriting of pszText pointer in TVN_ENDLABELEDIT */
1747 ok(IsWindow(edit), "Expected valid handle\n");
1748 r = SetWindowTextA(edit, "old");
1749 expect(TRUE, r);
1750 g_endedit_overwrite_ptr = (char*) "<new_ptr>";
1752 expect(0, r);
1754 item.mask = TVIF_TEXT;
1755 item.hItem = hRoot;
1756 item.pszText = buffA;
1757 item.cchTextMax = ARRAY_SIZE(buffA);
1759 expect(TRUE, r);
1760 expect(0, strcmp(item.pszText, "<new_ptr>"));
1761
1763}
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define TVM_EDITLABELW
Definition: commctrl.h:3505
#define EM_GETLIMITTEXT
Definition: richedit.h:74
#define TVM_GETITEMSTATE
Definition: treelist.h:336
int WINAPI GetWindowTextA(HWND hWnd, LPSTR lpString, int nMaxCount)
Definition: window.c:1312
#define MAKEWPARAM(l, h)
Definition: winuser.h:4012
#define EN_KILLFOCUS
Definition: winuser.h:2028
#define WM_COMMAND
Definition: winuser.h:1743
#define WM_SETTEXT
Definition: winuser.h:1620
BOOL WINAPI IsWindowUnicode(_In_ HWND)
#define EM_SETLIMITTEXT
Definition: winuser.h:2014

Referenced by START_TEST().

◆ test_right_click()

static void test_right_click ( void  )
static

Definition at line 2898 of file treeview.c.

2899{
2900 HWND hTree;
2902 RECT rc;
2904 POINT pt, orig_pos;
2905
2908
2912 ok(selected == hChild, "child item not selected\n");
2913
2914 *(HTREEITEM *)&rc = hRoot;
2916 ok(result, "TVM_GETITEMRECT failed\n");
2917
2918 flush_events();
2919
2920 pt.x = (rc.left + rc.right) / 2;
2921 pt.y = (rc.top + rc.bottom) / 2;
2923 GetCursorPos(&orig_pos);
2924 SetCursorPos(pt.x, pt.y);
2925
2926 flush_events();
2928
2931
2932 flush_events();
2933
2935 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_right_click_seq, "parent right click sequence", FALSE);
2936
2938 ok(selected == hChild, "child item should still be selected\n");
2939
2940 SetCursorPos(orig_pos.x, orig_pos.y);
2942}
#define pt(x, y)
Definition: drawing.c:79
GLuint64EXT * result
Definition: glext.h:11304
static void flush_events(void)
Definition: treeview.c:60
static const struct message parent_right_click_seq[]
Definition: treeview.c:373
static const struct message test_right_click_seq[]
Definition: treeview.c:222
#define TVM_ENSUREVISIBLE
Definition: commctrl.h:3549
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
#define MK_RBUTTON
Definition: winuser.h:2371
#define MAKELPARAM(l, h)
Definition: winuser.h:4011
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2756
#define WM_RBUTTONUP
Definition: winuser.h:1783
BOOL WINAPI SetCursorPos(_In_ int, _In_ int)
Definition: cursoricon.c:2748
BOOL WINAPI ClientToScreen(_In_ HWND, _Inout_ LPPOINT)
#define WM_RBUTTONDOWN
Definition: winuser.h:1782
BOOL WINAPI PostMessageA(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by START_TEST().

◆ test_select()

static void test_select ( void  )
static

Definition at line 641 of file treeview.c.

642{
643 BOOL r;
644 HWND hTree;
645
648
649 /* root-none select tests */
652 expect(TRUE, r);
653 Clear();
654 AddItem('1');
656 expect(TRUE, r);
657 AddItem('2');
659 expect(TRUE, r);
660 AddItem('3');
662 expect(TRUE, r);
663 AddItem('4');
665 expect(TRUE, r);
666 AddItem('5');
668 expect(TRUE, r);
669 AddItem('.');
670 ok(!strcmp(sequence, "1(nR)nR23(Rn)Rn45(nR)nR."), "root-none select test\n");
672 "root-none select seq", FALSE);
673
674 /* root-child select tests */
677 expect(TRUE, r);
678
679 Clear();
680 AddItem('1');
682 expect(TRUE, r);
683 AddItem('2');
685 expect(TRUE, r);
686 AddItem('3');
688 expect(TRUE, r);
689 AddItem('4');
691 expect(TRUE, r);
692 AddItem('5');
694 expect(TRUE, r);
695 AddItem('.');
696 ok(!strcmp(sequence, "1(nR)nR23(RC)RC45(CR)CR."), "root-child select test\n");
698 "root-child select seq", FALSE);
699
701}
static const struct message rootnone_select_seq[]
Definition: treeview.c:81
static const struct message rootchild_select_seq[]
Definition: treeview.c:91

Referenced by START_TEST().

◆ test_treeview_classinfo()

static void test_treeview_classinfo ( void  )
static

Definition at line 1765 of file treeview.c.

1766{
1767 WNDCLASSA cls;
1768
1769 memset(&cls, 0, sizeof(cls));
1770 GetClassInfoA(GetModuleHandleA("comctl32.dll"), WC_TREEVIEWA, &cls);
1771 ok(cls.hbrBackground == NULL, "Expected NULL background brush, got %p\n", cls.hbrBackground);
1772 ok(cls.style == (CS_GLOBALCLASS | CS_DBLCLKS), "Expected got %x\n", cls.style);
1773 expect(0, cls.cbClsExtra);
1774}
#define CS_DBLCLKS
Definition: winuser.h:651
BOOL WINAPI GetClassInfoA(_In_opt_ HINSTANCE, _In_ LPCSTR, _Out_ LPWNDCLASSA)
#define CS_GLOBALCLASS
Definition: winuser.h:652

Referenced by START_TEST().

◆ test_TVM_GETNEXTITEM()

static void test_TVM_GETNEXTITEM ( void  )
static

Definition at line 2547 of file treeview.c.

2548{
2550 HWND hTree;
2551
2554
2556 ok(item == hRoot, "got %p, expected %p\n", item, hRoot);
2557
2559 ok(item == hRoot, "got %p, expected %p\n", item, hRoot);
2560
2562 ok(item == hRoot, "got %p, expected %p\n", item, hRoot);
2563
2565 ok(item == hRoot, "got %p, expected %p\n", item, hRoot);
2566
2568 ok(item == hRoot, "got %p, expected %p\n", item, hRoot);
2569
2571 ok(item == hChild, "got %p, expected %p\n", item, hChild);
2572
2574 ok(item == hRoot, "got %p, expected %p\n", item, hRoot);
2575
2577 ok(item == NULL, "got %p\n", item);
2578
2580 ok(item == hRoot, "got %p, expected %p\n", item, hRoot);
2581
2583}

Referenced by START_TEST().

◆ test_TVM_HITTEST()

static void test_TVM_HITTEST ( void  )
static

Definition at line 2585 of file treeview.c.

2586{
2587 HWND hTree;
2588 LRESULT ret;
2589 RECT rc;
2591
2594
2595 *(HTREEITEM*)&rc = hRoot;
2597 expect(TRUE, (BOOL)ret);
2598
2599 ht.pt.x = rc.left-1;
2600 ht.pt.y = rc.top;
2601
2603 ok((HTREEITEM)ret == hRoot, "got %p, expected %p\n", (HTREEITEM)ret, hRoot);
2604 ok(ht.hItem == hRoot, "got %p, expected %p\n", ht.hItem, hRoot);
2605 ok(ht.flags == TVHT_ONITEMBUTTON, "got %d, expected %d\n", ht.flags, TVHT_ONITEMBUTTON);
2606
2608 expect(TRUE, (BOOL)ret);
2609
2610 *(HTREEITEM*)&rc = hChild;
2612 expect(TRUE, (BOOL)ret);
2613
2614 ht.pt.x = rc.left-1;
2615 ht.pt.y = rc.top;
2616
2618 ok((HTREEITEM)ret == hChild, "got %p, expected %p\n", (HTREEITEM)ret, hChild);
2619 ok(ht.hItem == hChild, "got %p, expected %p\n", ht.hItem, hChild);
2620 /* Wine returns item button here, but this item has no button */
2621 todo_wine ok(ht.flags == TVHT_ONITEMINDENT, "got %d, expected %d\n", ht.flags, TVHT_ONITEMINDENT);
2622
2624}
static const struct newhuff ht[]
Definition: huffman.h:296
#define TVHT_ONITEMINDENT
Definition: commctrl.h:3533
#define TVHT_ONITEMBUTTON
Definition: commctrl.h:3534
#define TVM_HITTEST
Definition: commctrl.h:3517

Referenced by START_TEST().

◆ test_TVM_SORTCHILDREN()

static void test_TVM_SORTCHILDREN ( void  )
static

Definition at line 2782 of file treeview.c.

2783{
2784 static const char *initial_order = "rootWaspVacuumOcelotCaribouNewspaperLitter bin";
2785 static const char *sorted_order = "rootCaribouNewspaperLitter binWaspVacuumOcelot";
2786 TVINSERTSTRUCTA ins;
2787 char buff[256];
2789 HWND hwnd;
2790 BOOL ret;
2791
2793
2794 /* call on empty tree */
2796 ok(!ret, "Unexpected ret value %d\n", ret);
2797
2799 ok(!ret, "Unexpected ret value %d\n", ret);
2800
2801 /* add only root, sort from it */
2802 ins.hParent = TVI_ROOT;
2803 ins.hInsertAfter = TVI_ROOT;
2804 U(ins).item.mask = TVIF_TEXT;
2805 U(ins).item.pszText = (char *)"root";
2807 ok(root != NULL, "Expected root node\n");
2808
2810 ok(!ret, "Unexpected ret value %d\n", ret);
2811
2813 ok(!ret, "Unexpected ret value %d\n", ret);
2814
2815 /* root, two children, with two children each */
2818 ok(!strcmp(buff, initial_order), "Wrong initial order %s, expected %s\n", buff, initial_order);
2819
2820 /* with NULL item nothing is sorted */
2824 ok(ret, "Unexpected ret value %d\n", ret);
2826 ok(!strcmp(buff, initial_order), "Wrong sorted order %s, expected %s\n", buff, initial_order);
2827
2828 /* TVI_ROOT as item */
2832 ok(ret, "Unexpected ret value %d\n", ret);
2834 ok(!strcmp(buff, initial_order), "Wrong sorted order %s, expected %s\n", buff, initial_order);
2835
2836 /* zero WPARAM, item is specified */
2839 ok(root != NULL, "Failed to get root item\n");
2841 ok(ret, "Unexpected ret value %d\n", ret);
2843 ok(!strcmp(buff, sorted_order), "Wrong sorted order %s, expected %s\n", buff, sorted_order);
2844
2845 /* non-zero WPARAM, NULL item */
2849 ok(ret, "Unexpected ret value %d\n", ret);
2851 ok(!strcmp(buff, initial_order), "Wrong sorted order %s, expected %s\n", buff, sorted_order);
2852
2853 /* TVI_ROOT as item */
2857 ok(ret, "Unexpected ret value %d\n", ret);
2859 ok(!strcmp(buff, initial_order), "Wrong sorted order %s, expected %s\n", buff, sorted_order);
2860
2861 /* non-zero WPARAM, item is specified */
2864 ok(root != NULL, "Failed to get root item\n");
2866 ok(ret, "Unexpected ret value %d\n", ret);
2868 ok(!strcmp(buff, sorted_order), "Wrong sorted order %s, expected %s\n", buff, sorted_order);
2869
2870 /* case insensitive comparison */
2872
2873 ins.hParent = TVI_ROOT;
2874 ins.hInsertAfter = TVI_ROOT;
2875 U(ins).item.mask = TVIF_TEXT;
2876 U(ins).item.pszText = (char *)"root";
2878 ok(root != NULL, "Expected root node\n");
2879
2880 ins.hParent = root;
2881 ins.hInsertAfter = TVI_LAST;
2882 U(ins).item.pszText = (char *)"I1";
2884
2885 ins.hParent = root;
2886 ins.hInsertAfter = TVI_LAST;
2887 U(ins).item.pszText = (char *)"i1";
2889
2891 ok(ret, "Unexpected ret value %d\n", ret);
2893 ok(!strcmp(buff, "rootI1i1"), "Wrong sorted order %s\n", buff);
2894
2896}
static unsigned char buff[32768]
Definition: fatten.c:17
static void fill_treeview_sort_test(HWND hwnd)
Definition: treeview.c:2737
#define TVM_SORTCHILDREN
Definition: commctrl.h:3546

Referenced by START_TEST().

◆ test_TVS_CHECKBOXES()

static void test_TVS_CHECKBOXES ( void  )
static

Definition at line 2362 of file treeview.c.

2363{
2364 HIMAGELIST himl, himl2;
2365 HWND hTree, hTree2;
2366 TVITEMA item;
2367 DWORD ret;
2368 MSG msg;
2369
2372
2374 ok(himl == NULL, "got %p\n", himl);
2375
2376 item.hItem = hRoot;
2377 item.mask = TVIF_STATE;
2378 item.state = INDEXTOSTATEIMAGEMASK(1);
2379 item.stateMask = TVIS_STATEIMAGEMASK;
2381 expect(TRUE, ret);
2382 ok(item.state == 0, "got 0x%x\n", item.state);
2383
2384 /* set some index for a child */
2385 item.hItem = hChild;
2386 item.mask = TVIF_STATE;
2387 item.state = INDEXTOSTATEIMAGEMASK(4);
2388 item.stateMask = TVIS_STATEIMAGEMASK;
2390 expect(TRUE, ret);
2391
2392 /* enabling check boxes set all items to 1 state image index */
2395 ok(himl != NULL, "got %p\n", himl);
2396
2398 ok(himl2 != NULL, "got %p\n", himl2);
2399 ok(himl2 == himl, "got %p, expected %p\n", himl2, himl);
2400
2401 item.hItem = hRoot;
2402 item.mask = TVIF_STATE;
2403 item.state = 0;
2404 item.stateMask = TVIS_STATEIMAGEMASK;
2406 expect(TRUE, ret);
2407 ok(item.state == INDEXTOSTATEIMAGEMASK(1), "got 0x%x\n", item.state);
2408
2409 item.hItem = hChild;
2410 item.mask = TVIF_STATE;
2411 item.state = 0;
2412 item.stateMask = TVIS_STATEIMAGEMASK;
2414 expect(TRUE, ret);
2415 ok(item.state == INDEXTOSTATEIMAGEMASK(1), "got 0x%x\n", item.state);
2416
2417 /* create another control and check its checkbox list */
2418 hTree2 = create_treeview_control(0);
2419 fill_tree(hTree2);
2420
2421 /* set some index for a child */
2422 item.hItem = hChild;
2423 item.mask = TVIF_STATE;
2424 item.state = INDEXTOSTATEIMAGEMASK(4);
2425 item.stateMask = TVIS_STATEIMAGEMASK;
2426 ret = SendMessageA(hTree2, TVM_SETITEMA, 0, (LPARAM)&item);
2427 expect(TRUE, ret);
2428
2429 /* enabling check boxes set all items to 1 state image index */
2432 ok(himl2 != NULL, "got %p\n", himl2);
2433 ok(himl != himl2, "got %p, expected %p\n", himl2, himl);
2434
2435 DestroyWindow(hTree2);
2437
2438 /* the same, but initially created with TVS_CHECKBOXES */
2442 ok(himl == NULL, "got %p\n", himl);
2443
2444 item.hItem = hRoot;
2445 item.mask = TVIF_STATE;
2446 item.state = 0;
2447 item.stateMask = TVIS_STATEIMAGEMASK;
2449 expect(TRUE, ret);
2450 ok(item.state == INDEXTOSTATEIMAGEMASK(1), "got 0x%x\n", item.state);
2451
2452 item.hItem = hChild;
2453 item.mask = TVIF_STATE;
2454 item.state = 0;
2455 item.stateMask = TVIS_STATEIMAGEMASK;
2457 expect(TRUE, ret);
2458 ok(item.state == INDEXTOSTATEIMAGEMASK(1), "got 0x%x\n", item.state);
2459
2460 item.hItem = hChild;
2461 item.mask = TVIF_STATE;
2462 item.state = INDEXTOSTATEIMAGEMASK(2);
2463 item.stateMask = TVIS_STATEIMAGEMASK;
2465 expect(TRUE, ret);
2466
2467 item.hItem = hChild;
2468 item.mask = TVIF_STATE;
2469 item.state = 0;
2471 expect(TRUE, ret);
2472 ok(item.state == INDEXTOSTATEIMAGEMASK(2), "got 0x%x\n", item.state);
2473
2474 while(GetMessageA(&msg, 0, 0, 0))
2475 {
2478
2479 if((msg.hwnd == hTree) && (msg.message == WM_PAINT))
2480 break;
2481 }
2482
2483 item.hItem = hChild;
2484 item.mask = TVIF_STATE;
2485 item.state = 0;
2487 expect(TRUE, ret);
2488 ok(item.state == INDEXTOSTATEIMAGEMASK(1), "got 0x%x\n", item.state);
2489
2491 ok(himl != NULL, "got %p\n", himl);
2492
2494
2495 /* check what happens if TVSIL_STATE image list is removed */
2499 ok(himl == NULL, "got %p\n", himl);
2500
2503 ok(himl != NULL, "got %p\n", himl);
2504
2506 ok(himl2 == himl, "got %p\n", himl2);
2507
2509 ok(himl2 == NULL, "got %p\n", himl2);
2510
2511 item.hItem = hChild;
2512 item.mask = TVIF_STATE;
2513 item.state = INDEXTOSTATEIMAGEMASK(2);
2514 item.stateMask = TVIS_STATEIMAGEMASK;
2516 expect(TRUE, ret);
2517
2518 item.hItem = hChild;
2519 item.mask = TVIF_STATE;
2520 item.state = 0;
2522 expect(TRUE, ret);
2523 ok(item.state == INDEXTOSTATEIMAGEMASK(2), "got 0x%x\n", item.state);
2524
2525 while(GetMessageA(&msg, 0, 0, 0))
2526 {
2529
2530 if((msg.hwnd == hTree) && (msg.message == WM_PAINT))
2531 break;
2532 }
2533
2534 item.hItem = hChild;
2535 item.mask = TVIF_STATE;
2536 item.state = 0;
2538 expect(TRUE, ret);
2539 ok(item.state == INDEXTOSTATEIMAGEMASK(1), "got 0x%x\n", item.state);
2540
2542 ok(himl != NULL, "got %p\n", himl);
2543
2545}
#define TVSIL_STATE
Definition: commctrl.h:3449
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI GetMessageA(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)

Referenced by START_TEST().

◆ test_TVS_FULLROWSELECT()

static void test_TVS_FULLROWSELECT ( void  )
static

Definition at line 2685 of file treeview.c.

2686{
2687 DWORD style;
2688 HWND hwnd;
2689
2690 /* try to create both with TVS_HASLINES and TVS_FULLROWSELECT */
2692
2694 ok((style & (TVS_FULLROWSELECT | TVS_HASLINES)) == (TVS_FULLROWSELECT | TVS_HASLINES), "got style 0x%08x\n", style);
2695
2697
2698 /* create just with TVS_HASLINES, try to enable TVS_FULLROWSELECT later */
2700
2704 ok(style & TVS_FULLROWSELECT, "got style 0x%08x\n", style);
2705
2707}
#define TVS_FULLROWSELECT
Definition: commctrl.h:3264

Referenced by START_TEST().

◆ test_TVS_SINGLEEXPAND()

static void test_TVS_SINGLEEXPAND ( void  )
static

Definition at line 2021 of file treeview.c.

2022{
2023 HWND hTree;
2024 HTREEITEM alpha, bravo, charlie, delta, echo, foxtrot, golf, hotel, india, juliet;
2025 TVINSERTSTRUCTA ins;
2026 char foo[] = "foo";
2027 char context[32];
2028 int i;
2029 BOOL ret;
2030
2031 /* build a fairly complex tree
2032 * - TVI_ROOT
2033 * - alpha
2034 * - bravo
2035 * - charlie
2036 * - delta
2037 * - echo
2038 * - foxtrot
2039 * - golf
2040 * - hotel
2041 * - india
2042 * - juliet
2043 */
2044 struct
2045 {
2048 UINT final_state;
2049 }
2050 items[] =
2051 {
2053 { &bravo, &alpha, TVIS_EXPANDEDONCE },
2054 { &charlie, &bravo, 0 },
2055 { &delta, &alpha, TVIS_EXPANDEDONCE },
2056 { &echo, &delta, 0 },
2057 { &foxtrot, NULL, TVIS_EXPANDEDONCE|TVIS_EXPANDED },
2058 { &golf, &foxtrot, TVIS_EXPANDEDONCE|TVIS_EXPANDED },
2059 { &hotel, &golf, 0 },
2060 { &india, &golf, TVIS_SELECTED },
2061 { &juliet, &foxtrot, 0 }
2062 };
2063
2064 struct
2065 {
2067 const struct message *sequence;
2068 }
2069 sequence_tests[] =
2070 {
2072 { &bravo, parent_singleexpand_seq1 },
2073 { &delta, parent_singleexpand_seq2 },
2074 { &foxtrot, parent_singleexpand_seq3 },
2076 { &golf, parent_singleexpand_seq5 },
2077 { &hotel, parent_singleexpand_seq6 },
2078 { &india, parent_singleexpand_seq7 },
2079 { &india, empty_seq }
2080 };
2081
2084 /* to avoid painting related notifications */
2086 for (i = 0; i < ARRAY_SIZE(items); i++)
2087 {
2088 ins.hParent = items[i].parent ? *items[i].parent : TVI_ROOT;
2089 ins.hInsertAfter = TVI_FIRST;
2090 U(ins).item.mask = TVIF_TEXT;
2091 U(ins).item.pszText = foo;
2092 *items[i].handle = TreeView_InsertItemA(hTree, &ins);
2093 }
2094
2095 for (i = 0; i < ARRAY_SIZE(sequence_tests); i++)
2096 {
2098 ret = SendMessageA(hTree, TVM_SELECTITEM, TVGN_CARET, (LPARAM)(*sequence_tests[i].select));
2099 ok(ret, "got %d\n", ret);
2100 sprintf(context, "singleexpand notifications %d", i);
2102 }
2103
2104 for (i = 0; i < ARRAY_SIZE(items); i++)
2105 {
2107 ok(ret == items[i].final_state, "singleexpand items[%d]: expected state 0x%x got 0x%x\n",
2108 i, items[i].final_state, ret);
2109 }
2110
2111 /* a workaround for NT4 that sends expand notifications when nothing is about to expand */
2113 ok(ret, "got %d\n", ret);
2116 ok(ret, "got %d\n", ret);
2117
2119}
INT WSAAPI select(IN INT s, IN OUT LPFD_SET readfds, IN OUT LPFD_SET writefds, IN OUT LPFD_SET exceptfds, IN CONST struct timeval *timeout)
Definition: select.c:41
GLclampf GLclampf GLclampf alpha
Definition: gl.h:1740
#define sprintf(buf, format,...)
Definition: sprintf.c:55
static const struct message parent_singleexpand_seq5[]
Definition: treeview.c:317
static const struct message parent_singleexpand_seq1[]
Definition: treeview.c:269
static const struct message parent_singleexpand_seq7[]
Definition: treeview.c:339
static const struct message parent_singleexpand_seq4[]
Definition: treeview.c:305
static const struct message parent_singleexpand_seq0[]
Definition: treeview.c:259
static const struct message parent_singleexpand_seq3[]
Definition: treeview.c:291
static const struct message parent_singleexpand_seq6[]
Definition: treeview.c:331
static const struct message parent_singleexpand_seq2[]
Definition: treeview.c:279
static TCHAR * items[]
Definition: page1.c:45
#define TVS_SINGLEEXPAND
Definition: commctrl.h:3262
Definition: http.c:7252
#define SW_HIDE
Definition: winuser.h:771

Referenced by START_TEST().

◆ test_WM_GETDLGCODE()

static void test_WM_GETDLGCODE ( void  )
static

Definition at line 2626 of file treeview.c.

2627{
2628 DWORD code;
2629 HWND hTree;
2630
2632
2634 ok(code == (DLGC_WANTCHARS | DLGC_WANTARROWS), "0x%08x\n", code);
2635
2637}
Definition: inflate.c:139
#define VK_TAB
Definition: winuser.h:2202
#define DLGC_WANTCHARS
Definition: winuser.h:2621
#define DLGC_WANTARROWS
Definition: winuser.h:2613
#define WM_GETDLGCODE
Definition: winuser.h:1692

Referenced by START_TEST().

◆ test_WM_KEYDOWN()

static void test_WM_KEYDOWN ( void  )
static

Definition at line 2662 of file treeview.c.

2663{
2664 static const char *rootA = "root";
2665 TVINSERTSTRUCTA ins;
2667 HWND hwnd;
2668
2670
2671 ins.hParent = TVI_ROOT;
2672 ins.hInsertAfter = TVI_ROOT;
2673 U(ins).item.mask = TVIF_TEXT;
2674 U(ins).item.pszText = (char*)rootA;
2676 ok(hRoot != NULL, "got %p\n", hRoot);
2677
2680 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_vk_return_seq, "WM_KEYDOWN/VK_RETURN parent notification", TRUE);
2681
2683}
static const struct message parent_vk_return_seq[]
Definition: treeview.c:366
#define VK_RETURN
Definition: winuser.h:2204

Referenced by START_TEST().

◆ test_WM_PAINT()

static void test_WM_PAINT ( void  )
static

Definition at line 2121 of file treeview.c.

2122{
2123 HWND hTree;
2124 COLORREF clr;
2125 LONG ret;
2126 RECT rc;
2127 HDC hdc;
2128
2130
2131 clr = SendMessageA(hTree, TVM_SETBKCOLOR, 0, RGB(255, 0, 0));
2132 ok(clr == ~0u, "got %d, expected -1\n", clr);
2133
2134 hdc = GetDC(hMainWnd);
2135
2136 GetClientRect(hMainWnd, &rc);
2138
2139 clr = GetPixel(hdc, 1, 1);
2140 ok(clr == RGB(0, 0, 0), "got 0x%x\n", clr);
2141
2143 ok(ret == 0, "got %d\n", ret);
2144
2145 clr = GetPixel(hdc, 1, 1);
2146 ok(clr == RGB(255, 0, 0) || broken(clr == RGB(0, 0, 0)) /* win98 */,
2147 "got 0x%x\n", clr);
2148
2150
2152}
DWORD GetPixel(LPDIRECTDRAWSURFACE7 Surface, UINT x, UINT y)
Definition: blt.cpp:2
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:88
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define BLACK_BRUSH
Definition: wingdi.h:896
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
HDC WINAPI GetDC(_In_opt_ HWND)

Referenced by START_TEST().

◆ TreeviewWndProc()

static LRESULT WINAPI TreeviewWndProc ( HWND  hwnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 418 of file treeview.c.

419{
420 static LONG defwndproc_counter = 0;
421 LRESULT ret;
423 struct message msg = { 0 };
424
425 msg.message = message;
426 msg.flags = sent|wparam|lparam;
427 if (defwndproc_counter) msg.flags |= defwinproc;
428 msg.wParam = wParam;
429 msg.lParam = lParam;
431
432 defwndproc_counter++;
433 ret = CallWindowProcA(lpOldProc, hwnd, message, wParam, lParam);
434 defwndproc_counter--;
435
436 return ret;
437}
#define GetWindowLongPtrA
Definition: winuser.h:4831
LRESULT WINAPI CallWindowProcA(_In_ WNDPROC, _In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by create_treeview_control().

Variable Documentation

◆ empty_seq

const struct message empty_seq[]
static
Initial value:
= {
{ 0 }
}

Definition at line 352 of file treeview.c.

Referenced by test_callback(), test_expandnotify(), and test_TVS_SINGLEEXPAND().

◆ FillRootSeq

const struct message FillRootSeq[]
static
Initial value:
= {
{ 0 }
}

Definition at line 75 of file treeview.c.

Referenced by test_fillroot().

◆ focus_seq

const struct message focus_seq[]
static
Initial value:
= {
{ 0 }
}
@ optional
Definition: SystemMenu.c:34
#define WM_WINDOWPOSCHANGING
Definition: winuser.h:1664
#define WM_CREATE
Definition: winuser.h:1611
#define EN_SETFOCUS
Definition: winuser.h:2030
#define EN_UPDATE
Definition: winuser.h:2031
#define WM_SIZE
Definition: winuser.h:1614
#define WM_IME_SETCONTEXT
Definition: winuser.h:1832
#define WM_PARENTNOTIFY
Definition: winuser.h:1806
#define WM_NCCALCSIZE
Definition: winuser.h:1688
#define WM_CTLCOLOREDIT
Definition: winuser.h:1770
#define WM_WINDOWPOSCHANGED
Definition: winuser.h:1665
#define WM_KILLFOCUS
Definition: winuser.h:1617
#define EN_CHANGE
Definition: winuser.h:2025

Definition at line 108 of file treeview.c.

Referenced by test_focus().

◆ g_beginedit_alter_text

BOOL g_beginedit_alter_text
static

Definition at line 44 of file treeview.c.

Referenced by parent_wnd_proc(), and test_itemedit().

◆ g_customdraw_font

HFONT g_customdraw_font
static

Definition at line 47 of file treeview.c.

Referenced by parent_wnd_proc(), and test_customdraw().

◆ g_disp_A_to_W

BOOL g_disp_A_to_W
static

Definition at line 42 of file treeview.c.

Referenced by parent_wnd_proc(), and test_callback().

◆ g_disp_set_stateimage

BOOL g_disp_set_stateimage
static

Definition at line 43 of file treeview.c.

Referenced by parent_wnd_proc(), and test_callback().

◆ g_endedit_overwrite_contents

const char* g_endedit_overwrite_contents
static

Definition at line 45 of file treeview.c.

Referenced by parent_wnd_proc(), and test_itemedit().

◆ g_endedit_overwrite_ptr

char* g_endedit_overwrite_ptr
static

Definition at line 46 of file treeview.c.

Referenced by parent_wnd_proc(), and test_itemedit().

◆ g_get_from_expand

BOOL g_get_from_expand
static

Definition at line 40 of file treeview.c.

Referenced by parent_wnd_proc(), and test_expandnotify().

◆ g_get_rect_in_expand

BOOL g_get_rect_in_expand
static

Definition at line 41 of file treeview.c.

Referenced by parent_wnd_proc(), and test_expandnotify().

◆ g_item_expanded

TVITEMA g_item_expanded
static

Definition at line 39 of file treeview.c.

Referenced by parent_wnd_proc(), and test_expandnotify().

◆ g_item_expanding

TVITEMA g_item_expanding
static

Definition at line 39 of file treeview.c.

Referenced by parent_wnd_proc(), and test_expandnotify().

◆ g_v6

BOOL g_v6
static

Definition at line 48 of file treeview.c.

Referenced by parent_wnd_proc(), and START_TEST().

◆ getitemtext_seq

const struct message getitemtext_seq[]
static
Initial value:
= {
{ 0 }
}

Definition at line 101 of file treeview.c.

Referenced by test_getitemtext().

◆ hChild

◆ hMainWnd

◆ hRoot

◆ item_sequence

struct msg_sequence* item_sequence[1]
static

Definition at line 58 of file treeview.c.

Referenced by parent_wnd_proc(), START_TEST(), and test_delete_items().

◆ parent_cd_seq

const struct message parent_cd_seq[]
static
Initial value:

Definition at line 356 of file treeview.c.

Referenced by test_customdraw().

◆ parent_collapse_2nd_kb_seq

const struct message parent_collapse_2nd_kb_seq[]
static
Initial value:
= {
{ WM_CHANGEUISTATE, sent|optional },
{ 0 }
}
GLuint id
Definition: glext.h:5910
#define TVN_KEYDOWN
Definition: commctrl.h:3718

Definition at line 246 of file treeview.c.

Referenced by test_expandnotify().

◆ parent_expand_empty_kb_seq

const struct message parent_expand_empty_kb_seq[]
static
Initial value:
= {
{ WM_CHANGEUISTATE, sent|optional },
{ 0 }
}

Definition at line 253 of file treeview.c.

Referenced by test_expandnotify().

◆ parent_expand_kb_seq

const struct message parent_expand_kb_seq[]
static
Initial value:
= {
{ WM_CHANGEUISTATE, sent|optional },
{ 0 }
}

Definition at line 238 of file treeview.c.

Referenced by test_expandnotify().

◆ parent_expand_seq

const struct message parent_expand_seq[]
static
Initial value:
= {
{ 0 }
}

Definition at line 232 of file treeview.c.

Referenced by test_expandnotify().

◆ parent_get_dispinfo_seq

const struct message parent_get_dispinfo_seq[]
static
Initial value:
= {
{ 0 }
}

Definition at line 347 of file treeview.c.

Referenced by test_callback().

◆ parent_right_click_seq

const struct message parent_right_click_seq[]
static
Initial value:
= {
{ WM_NOTIFY, sent|id, 0, 0, NM_RCLICK },
{ 0 }
}
#define WM_CONTEXTMENU
Definition: richedit.h:64
#define WM_SETCURSOR
Definition: winuser.h:1639

Definition at line 373 of file treeview.c.

Referenced by test_right_click().

◆ parent_singleexpand_seq0

const struct message parent_singleexpand_seq0[]
static
Initial value:
= {
{ 0 }
}
#define TVN_SINGLEEXPAND
Definition: commctrl.h:3721

Definition at line 259 of file treeview.c.

Referenced by test_TVS_SINGLEEXPAND().

◆ parent_singleexpand_seq1

const struct message parent_singleexpand_seq1[]
static
Initial value:

Definition at line 269 of file treeview.c.

Referenced by test_TVS_SINGLEEXPAND().

◆ parent_singleexpand_seq2

const struct message parent_singleexpand_seq2[]
static
Initial value:

Definition at line 279 of file treeview.c.

Referenced by test_TVS_SINGLEEXPAND().

◆ parent_singleexpand_seq3

const struct message parent_singleexpand_seq3[]
static
Initial value:

Definition at line 291 of file treeview.c.

Referenced by test_TVS_SINGLEEXPAND().

◆ parent_singleexpand_seq4

const struct message parent_singleexpand_seq4[]
static
Initial value:

Definition at line 305 of file treeview.c.

Referenced by test_TVS_SINGLEEXPAND().

◆ parent_singleexpand_seq5

const struct message parent_singleexpand_seq5[]
static
Initial value:

Definition at line 317 of file treeview.c.

Referenced by test_TVS_SINGLEEXPAND().

◆ parent_singleexpand_seq6

const struct message parent_singleexpand_seq6[]
static
Initial value:
= {
{ 0 }
}

Definition at line 331 of file treeview.c.

Referenced by test_TVS_SINGLEEXPAND().

◆ parent_singleexpand_seq7

const struct message parent_singleexpand_seq7[]
static
Initial value:
= {
{ 0 }
}

Definition at line 339 of file treeview.c.

Referenced by test_TVS_SINGLEEXPAND().

◆ parent_vk_return_seq

const struct message parent_vk_return_seq[]
static
Initial value:
= {
{ WM_NOTIFY, sent|id, 0, 0, NM_RETURN },
{ WM_CHANGEUISTATE, sent|optional },
{ 0 }
}
#define NM_RETURN
Definition: commctrl.h:132

Definition at line 366 of file treeview.c.

Referenced by test_WM_KEYDOWN().

◆ pos

int pos = 0
static

Definition at line 385 of file treeview.c.

◆ rootchild_select_seq

const struct message rootchild_select_seq[]
static
Initial value:

Definition at line 91 of file treeview.c.

Referenced by test_select().

◆ rootnone_select_seq

const struct message rootnone_select_seq[]
static
Initial value:

Definition at line 81 of file treeview.c.

Referenced by test_select().

◆ sequence

char sequence[256]
static

Definition at line 386 of file treeview.c.

Referenced by AddItem(), Clear(), test_fillroot(), test_select(), and test_TVS_SINGLEEXPAND().

◆ sequences

◆ TEST_CALLBACK_TEXT

const char* TEST_CALLBACK_TEXT = "callback_text"
static

Definition at line 37 of file treeview.c.

Referenced by parent_wnd_proc(), and test_callback().

◆ test_get_set_bkcolor_seq

const struct message test_get_set_bkcolor_seq[]
static
Initial value:

Definition at line 138 of file treeview.c.

Referenced by test_get_set_bkcolor().

◆ test_get_set_imagelist_seq

const struct message test_get_set_imagelist_seq[]
static
Initial value:
= {
{ 0 }
}

Definition at line 148 of file treeview.c.

Referenced by test_get_set_imagelist().

◆ test_get_set_indent_seq

const struct message test_get_set_indent_seq[]
static
Initial value:

Definition at line 154 of file treeview.c.

Referenced by test_get_set_indent().

◆ test_get_set_insertmarkcolor_seq

const struct message test_get_set_insertmarkcolor_seq[]
static
Initial value:

Definition at line 163 of file treeview.c.

Referenced by test_get_set_insertmark().

◆ test_get_set_item_seq

const struct message test_get_set_item_seq[]
static
Initial value:
= {
{ 0 }
}

Definition at line 169 of file treeview.c.

Referenced by test_get_set_item().

◆ test_get_set_itemheight_seq

const struct message test_get_set_itemheight_seq[]
static
Initial value:

Definition at line 177 of file treeview.c.

Referenced by test_get_set_itemheight().

◆ test_get_set_scrolltime_seq

const struct message test_get_set_scrolltime_seq[]
static
Initial value:
= {
{ 0 }
}

Definition at line 188 of file treeview.c.

Referenced by test_get_set_scrolltime().

◆ test_get_set_textcolor_seq

const struct message test_get_set_textcolor_seq[]
static
Initial value:

Definition at line 194 of file treeview.c.

Referenced by test_get_set_textcolor().

◆ test_get_set_tooltips_seq

const struct message test_get_set_tooltips_seq[]
static
Initial value:

Definition at line 204 of file treeview.c.

Referenced by test_get_set_tooltips().

◆ test_get_set_unicodeformat_seq

const struct message test_get_set_unicodeformat_seq[]
static
Initial value:

Definition at line 213 of file treeview.c.

Referenced by test_get_set_unicodeformat().

◆ test_right_click_seq

const struct message test_right_click_seq[]
static
Initial value:

Definition at line 222 of file treeview.c.

Referenced by test_right_click().