1 /* Unit tests for treeview.
3 * Copyright 2005 Krzysztof Foltman
4 * Copyright 2007 Christopher James Peterson
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
32 #include "wine/test.h"
36 static const char *TEST_CALLBACK_TEXT
= "callback_text";
38 static TVITEMA g_item_expanding
, g_item_expanded
;
39 static BOOL g_get_from_expand
;
40 static BOOL g_get_rect_in_expand
;
41 static BOOL g_disp_A_to_W
;
42 static BOOL g_disp_set_stateimage
;
44 #define NUM_MSG_SEQUENCES 2
45 #define TREEVIEW_SEQ_INDEX 0
46 #define PARENT_SEQ_INDEX 1
48 #define expect(expected, got) ok(got == expected, "Expected %d, got %d\n", expected, got)
50 static struct msg_sequence
*sequences
[NUM_MSG_SEQUENCES
];
51 static struct msg_sequence
*item_sequence
[1];
53 static const struct message FillRootSeq
[] = {
54 { TVM_INSERTITEM
, sent
},
55 { TVM_INSERTITEM
, sent
},
59 static const struct message rootnone_select_seq
[] = {
60 { TVM_SELECTITEM
, sent
|wparam
, 9 },
61 { TVM_SELECTITEM
, sent
|wparam
, 9 },
62 { TVM_SELECTITEM
, sent
|wparam
, 9 },
63 { TVM_SELECTITEM
, sent
|wparam
, 9 },
64 { TVM_SELECTITEM
, sent
|wparam
, 9 },
65 { TVM_SELECTITEM
, sent
|wparam
, 9 },
69 static const struct message rootchild_select_seq
[] = {
70 { TVM_SELECTITEM
, sent
|wparam
, 9 },
71 { TVM_SELECTITEM
, sent
|wparam
, 9 },
72 { TVM_SELECTITEM
, sent
|wparam
, 9 },
73 { TVM_SELECTITEM
, sent
|wparam
, 9 },
74 { TVM_SELECTITEM
, sent
|wparam
, 9 },
75 { TVM_SELECTITEM
, sent
|wparam
, 9 },
79 static const struct message getitemtext_seq
[] = {
80 { TVM_INSERTITEMA
, sent
},
81 { TVM_GETITEMA
, sent
},
82 { TVM_DELETEITEM
, sent
},
86 static const struct message focus_seq
[] = {
87 { TVM_INSERTITEM
, sent
},
88 { TVM_INSERTITEM
, sent
},
89 { TVM_SELECTITEM
, sent
|wparam
, 9 },
90 /* The following end up out of order in wine */
91 { WM_WINDOWPOSCHANGING
, sent
|defwinproc
},
92 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
, TRUE
},
93 { WM_WINDOWPOSCHANGED
, sent
|defwinproc
},
94 { WM_SIZE
, sent
|defwinproc
},
95 { WM_WINDOWPOSCHANGING
, sent
|defwinproc
|optional
},
96 { WM_NCCALCSIZE
, sent
|wparam
|defwinproc
|optional
, TRUE
},
97 { WM_WINDOWPOSCHANGED
, sent
|defwinproc
|optional
},
98 { WM_SIZE
, sent
|defwinproc
|optional
},
99 { WM_PAINT
, sent
|defwinproc
},
100 { WM_NCPAINT
, sent
|wparam
|defwinproc
, 1 },
101 { WM_ERASEBKGND
, sent
|defwinproc
},
102 { TVM_EDITLABEL
, sent
},
103 { WM_COMMAND
, sent
|wparam
|defwinproc
, MAKEWPARAM(0, EN_UPDATE
) },
104 { WM_COMMAND
, sent
|wparam
|defwinproc
, MAKEWPARAM(0, EN_CHANGE
) },
105 { WM_PARENTNOTIFY
, sent
|wparam
|defwinproc
, MAKEWPARAM(WM_CREATE
, 0) },
106 { WM_KILLFOCUS
, sent
|defwinproc
},
107 { WM_PAINT
, sent
|defwinproc
},
108 { WM_IME_SETCONTEXT
, sent
|defwinproc
|optional
},
109 { WM_COMMAND
, sent
|wparam
|defwinproc
, MAKEWPARAM(0, EN_SETFOCUS
) },
110 { WM_ERASEBKGND
, sent
|defwinproc
|optional
},
111 { WM_CTLCOLOREDIT
, sent
|defwinproc
|optional
},
112 { WM_CTLCOLOREDIT
, sent
|defwinproc
|optional
},
116 static const struct message test_get_set_bkcolor_seq
[] = {
117 { TVM_GETBKCOLOR
, sent
|wparam
|lparam
, 0, 0 },
118 { TVM_SETBKCOLOR
, sent
|wparam
|lparam
, 0, 0 },
119 { TVM_GETBKCOLOR
, sent
|wparam
|lparam
, 0, 0 },
120 { TVM_SETBKCOLOR
, sent
|wparam
|lparam
, 0, 0x00ffffff },
121 { TVM_GETBKCOLOR
, sent
|wparam
|lparam
, 0, 0 },
122 { TVM_SETBKCOLOR
, sent
|wparam
|lparam
, 0, -1 },
126 static const struct message test_get_set_imagelist_seq
[] = {
127 { TVM_SETIMAGELIST
, sent
|wparam
|lparam
, 0, 0 },
128 { TVM_GETIMAGELIST
, sent
|wparam
|lparam
, 0, 0 },
132 static const struct message test_get_set_indent_seq
[] = {
133 { TVM_SETINDENT
, sent
|wparam
|lparam
, 0, 0 },
134 { TVM_GETINDENT
, sent
|wparam
|lparam
, 0, 0 },
135 /* The actual amount to indent is dependent on the system for this message */
136 { TVM_SETINDENT
, sent
},
137 { TVM_GETINDENT
, sent
|wparam
|lparam
, 0, 0 },
141 static const struct message test_get_set_insertmarkcolor_seq
[] = {
142 { TVM_SETINSERTMARKCOLOR
, sent
|wparam
|lparam
, 0, 0 },
143 { TVM_GETINSERTMARKCOLOR
, sent
|wparam
|lparam
, 0, 0 },
147 static const struct message test_get_set_item_seq
[] = {
148 { TVM_GETITEMA
, sent
},
149 { TVM_SETITEMA
, sent
},
150 { TVM_GETITEMA
, sent
},
151 { TVM_SETITEMA
, sent
},
155 static const struct message test_get_set_itemheight_seq
[] = {
156 { TVM_GETITEMHEIGHT
, sent
|wparam
|lparam
, 0, 0 },
157 { TVM_SETITEMHEIGHT
, sent
|wparam
|lparam
, -1, 0 },
158 { TVM_GETITEMHEIGHT
, sent
|wparam
|lparam
, 0, 0 },
159 { TVM_SETITEMHEIGHT
, sent
|lparam
, 0xcccccccc, 0 },
160 { TVM_GETITEMHEIGHT
, sent
|wparam
|lparam
|optional
, 0, 0 },
161 { TVM_SETITEMHEIGHT
, sent
|wparam
|lparam
|optional
, 9, 0 },
162 { TVM_GETITEMHEIGHT
, sent
|wparam
|lparam
, 0, 0 },
166 static const struct message test_get_set_scrolltime_seq
[] = {
167 { TVM_SETSCROLLTIME
, sent
|wparam
|lparam
, 20, 0 },
168 { TVM_GETSCROLLTIME
, sent
|wparam
|lparam
, 0, 0 },
172 static const struct message test_get_set_textcolor_seq
[] = {
173 { TVM_GETTEXTCOLOR
, sent
|wparam
|lparam
, 0, 0 },
174 { TVM_SETTEXTCOLOR
, sent
|wparam
|lparam
, 0, 0 },
175 { TVM_GETTEXTCOLOR
, sent
|wparam
|lparam
, 0, 0 },
176 { TVM_SETTEXTCOLOR
, sent
|wparam
|lparam
, 0, RGB(255, 255, 255) },
177 { TVM_GETTEXTCOLOR
, sent
|wparam
|lparam
, 0, 0 },
178 { TVM_SETTEXTCOLOR
, sent
|wparam
|lparam
, 0, CLR_NONE
},
182 static const struct message test_get_set_tooltips_seq
[] = {
183 { WM_KILLFOCUS
, sent
},
184 { WM_IME_SETCONTEXT
, sent
|optional
},
185 { WM_IME_NOTIFY
, sent
|optional
},
186 { TVM_SETTOOLTIPS
, sent
|wparam
|lparam
, 0, 0 },
187 { TVM_GETTOOLTIPS
, sent
|wparam
|lparam
, 0, 0 },
191 static const struct message test_get_set_unicodeformat_seq
[] = {
192 { TVM_SETUNICODEFORMAT
, sent
|wparam
|lparam
, TRUE
, 0 },
193 { TVM_GETUNICODEFORMAT
, sent
|wparam
|lparam
, 0, 0 },
194 { TVM_SETUNICODEFORMAT
, sent
|wparam
|lparam
, 0, 0 },
195 { TVM_GETUNICODEFORMAT
, sent
|wparam
|lparam
, 0, 0 },
196 { TVM_SETUNICODEFORMAT
, sent
|wparam
|lparam
, 0, 0 },
200 static const struct message parent_expand_seq
[] = {
201 { WM_NOTIFY
, sent
|id
, 0, 0, TVN_ITEMEXPANDINGA
},
202 { WM_NOTIFY
, sent
|id
, 0, 0, TVN_ITEMEXPANDEDA
},
206 static const struct message parent_singleexpand_seq
[] = {
207 { WM_NOTIFY
, sent
|id
, 0, 0, TVN_SELCHANGINGA
},
208 { WM_NOTIFY
, sent
|id
, 0, 0, TVN_SELCHANGEDA
},
209 { WM_NOTIFY
, sent
|id
, 0, 0, TVN_SINGLEEXPAND
},
210 { WM_NOTIFY
, sent
|id
, 0, 0, TVN_ITEMEXPANDINGA
},
211 { WM_NOTIFY
, sent
|id
, 0, 0, TVN_ITEMEXPANDEDA
},
215 static const struct message parent_get_dispinfo_seq
[] = {
216 { WM_NOTIFY
, sent
|id
, 0, 0, TVN_GETDISPINFOA
},
220 static const struct message empty_seq
[] = {
224 static HWND hMainWnd
;
226 static HTREEITEM hRoot
, hChild
;
229 static char sequence
[256];
231 static void Clear(void)
237 static void AddItem(char ch
)
239 sequence
[pos
++] = ch
;
240 sequence
[pos
] = '\0';
243 static void IdentifyItem(HTREEITEM hItem
)
245 if (hItem
== hRoot
) {
249 if (hItem
== hChild
) {
260 /* This function hooks in and records all messages to the treeview control */
261 static LRESULT WINAPI
TreeviewWndProc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
263 static LONG defwndproc_counter
= 0;
266 WNDPROC lpOldProc
= (WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_USERDATA
);
268 msg
.message
= message
;
269 msg
.flags
= sent
|wparam
|lparam
;
270 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
273 add_message(sequences
, TREEVIEW_SEQ_INDEX
, &msg
);
275 defwndproc_counter
++;
276 ret
= CallWindowProcA(lpOldProc
, hwnd
, message
, wParam
, lParam
);
277 defwndproc_counter
--;
282 static HWND
create_treeview_control(DWORD style
)
287 hTree
= CreateWindowExA(WS_EX_CLIENTEDGE
, WC_TREEVIEWA
, NULL
, WS_CHILD
|WS_VISIBLE
|
288 TVS_LINESATROOT
|TVS_HASLINES
|TVS_HASBUTTONS
|TVS_EDITLABELS
|style
,
289 0, 0, 120, 100, hMainWnd
, (HMENU
)100, GetModuleHandleA(0), 0);
293 /* Record the old WNDPROC so we can call it after recording the messages */
294 pOldWndProc
= (WNDPROC
)SetWindowLongPtrA(hTree
, GWLP_WNDPROC
, (LONG_PTR
)TreeviewWndProc
);
295 SetWindowLongPtrA(hTree
, GWLP_USERDATA
, (LONG_PTR
)pOldWndProc
);
300 static void fill_tree(HWND hTree
)
303 static CHAR root
[] = "Root",
306 ins
.hParent
= TVI_ROOT
;
307 ins
.hInsertAfter
= TVI_ROOT
;
308 U(ins
).item
.mask
= TVIF_TEXT
;
309 U(ins
).item
.pszText
= root
;
310 hRoot
= TreeView_InsertItem(hTree
, &ins
);
313 ins
.hInsertAfter
= TVI_FIRST
;
314 U(ins
).item
.mask
= TVIF_TEXT
;
315 U(ins
).item
.pszText
= child
;
316 hChild
= TreeView_InsertItem(hTree
, &ins
);
319 static void test_fillroot(void)
324 hTree
= create_treeview_control(0);
326 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
336 ok_sequence(sequences
, TREEVIEW_SEQ_INDEX
, FillRootSeq
, "FillRoot", FALSE
);
337 ok(!strcmp(sequence
, "AB."), "Item creation\n");
339 /* UMLPad 1.15 depends on this being not -1 (I_IMAGECALLBACK) */
341 tvi
.mask
= TVIF_IMAGE
| TVIF_SELECTEDIMAGE
;
342 SendMessage( hTree
, TVM_GETITEMA
, 0, (LPARAM
)&tvi
);
343 ok(tvi
.iImage
== 0, "tvi.iImage=%d\n", tvi
.iImage
);
344 ok(tvi
.iSelectedImage
== 0, "tvi.iSelectedImage=%d\n", tvi
.iSelectedImage
);
346 DestroyWindow(hTree
);
349 static void test_callback(void)
352 HTREEITEM hItem1
, hItem2
;
355 CHAR test_string
[] = "Test_string";
356 static const CHAR test2A
[] = "TEST2";
361 hTree
= create_treeview_control(0);
363 ret
= TreeView_DeleteAllItems(hTree
);
365 ins
.hParent
= TVI_ROOT
;
366 ins
.hInsertAfter
= TVI_ROOT
;
367 U(ins
).item
.mask
= TVIF_TEXT
;
368 U(ins
).item
.pszText
= LPSTR_TEXTCALLBACK
;
369 hRoot
= TreeView_InsertItem(hTree
, &ins
);
373 tvi
.mask
= TVIF_TEXT
;
375 tvi
.cchTextMax
= sizeof(buf
)/sizeof(buf
[0]);
376 ret
= TreeView_GetItem(hTree
, &tvi
);
378 ok(strcmp(tvi
.pszText
, TEST_CALLBACK_TEXT
) == 0, "Callback item text mismatch %s vs %s\n",
379 tvi
.pszText
, TEST_CALLBACK_TEXT
);
382 ins
.hInsertAfter
= TVI_FIRST
;
383 U(ins
).item
.mask
= TVIF_TEXT
;
384 U(ins
).item
.pszText
= test_string
;
385 hItem1
= TreeView_InsertItem(hTree
, &ins
);
389 ret
= TreeView_GetItem(hTree
, &tvi
);
391 ok(strcmp(tvi
.pszText
, test_string
) == 0, "Item text mismatch %s vs %s\n",
392 tvi
.pszText
, test_string
);
394 /* undocumented: pszText of NULL also means LPSTR_CALLBACK: */
396 ret
= TreeView_SetItem(hTree
, &tvi
);
399 ret
= TreeView_GetItem(hTree
, &tvi
);
401 ok(strcmp(tvi
.pszText
, TEST_CALLBACK_TEXT
) == 0, "Item text mismatch %s vs %s\n",
402 tvi
.pszText
, TEST_CALLBACK_TEXT
);
404 U(ins
).item
.pszText
= NULL
;
405 hItem2
= TreeView_InsertItem(hTree
, &ins
);
408 memset(buf
, 0, sizeof(buf
));
409 ret
= TreeView_GetItem(hTree
, &tvi
);
411 ok(strcmp(tvi
.pszText
, TEST_CALLBACK_TEXT
) == 0, "Item text mismatch %s vs %s\n",
412 tvi
.pszText
, TEST_CALLBACK_TEXT
);
414 /* notification handler changed A->W */
415 g_disp_A_to_W
= TRUE
;
417 memset(buf
, 0, sizeof(buf
));
418 ret
= TreeView_GetItem(hTree
, &tvi
);
420 ok(strcmp(tvi
.pszText
, test2A
) == 0, "got %s, expected %s\n",
421 tvi
.pszText
, test2A
);
422 g_disp_A_to_W
= FALSE
;
424 /* handler changes state image index */
425 SetWindowLongA(hTree
, GWL_STYLE
, GetWindowLongA(hTree
, GWL_STYLE
) | TVS_CHECKBOXES
);
427 /* clear selection, handler will set selected state */
428 ret
= SendMessageA(hTree
, TVM_SELECTITEM
, TVGN_CARET
, 0);
431 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
434 tvi
.mask
= TVIF_STATE
;
435 tvi
.state
= TVIS_SELECTED
;
436 ret
= TreeView_GetItem(hTree
, &tvi
);
438 ok(tvi
.state
== INDEXTOSTATEIMAGEMASK(1), "got 0x%x\n", tvi
.state
);
440 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
,
441 "no TVN_GETDISPINFO for a state seq", FALSE
);
444 tvi
.mask
= TVIF_IMAGE
| TVIF_STATE
;
445 tvi
.state
= TVIS_FOCUSED
;
446 tvi
.stateMask
= TVIS_FOCUSED
;
447 tvi
.iImage
= I_IMAGECALLBACK
;
448 ret
= TreeView_SetItem(hTree
, &tvi
);
451 /* ask for item image index through callback - state is also set with state image index */
452 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
455 tvi
.mask
= TVIF_IMAGE
;
457 ret
= TreeView_GetItem(hTree
, &tvi
);
459 ok(tvi
.state
== (INDEXTOSTATEIMAGEMASK(1) | TVIS_FOCUSED
), "got 0x%x\n", tvi
.state
);
461 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_get_dispinfo_seq
,
462 "callback for state/overlay image index, noop seq", FALSE
);
464 /* ask for image again and overwrite state to some value in handler */
465 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
467 g_disp_set_stateimage
= TRUE
;
469 tvi
.mask
= TVIF_IMAGE
;
470 tvi
.state
= INDEXTOSTATEIMAGEMASK(1);
472 ret
= TreeView_GetItem(hTree
, &tvi
);
474 /* handler sets TVIS_SELECTED as well */
475 ok(tvi
.state
== (TVIS_FOCUSED
| TVIS_SELECTED
| INDEXTOSTATEIMAGEMASK(2) | INDEXTOOVERLAYMASK(3)), "got 0x%x\n", tvi
.state
);
476 g_disp_set_stateimage
= FALSE
;
478 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_get_dispinfo_seq
,
479 "callback for state/overlay image index seq", FALSE
);
481 DestroyWindow(hTree
);
484 static void test_select(void)
489 hTree
= create_treeview_control(0);
492 /* root-none select tests */
493 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
494 r
= TreeView_SelectItem(hTree
, NULL
);
498 r
= TreeView_SelectItem(hTree
, hRoot
);
501 r
= TreeView_SelectItem(hTree
, hRoot
);
504 r
= TreeView_SelectItem(hTree
, NULL
);
507 r
= TreeView_SelectItem(hTree
, NULL
);
510 r
= TreeView_SelectItem(hTree
, hRoot
);
513 ok(!strcmp(sequence
, "1(nR)nR23(Rn)Rn45(nR)nR."), "root-none select test\n");
514 ok_sequence(sequences
, TREEVIEW_SEQ_INDEX
, rootnone_select_seq
,
515 "root-none select seq", FALSE
);
517 /* root-child select tests */
518 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
519 r
= TreeView_SelectItem(hTree
, NULL
);
524 r
= TreeView_SelectItem(hTree
, hRoot
);
527 r
= TreeView_SelectItem(hTree
, hRoot
);
530 r
= TreeView_SelectItem(hTree
, hChild
);
533 r
= TreeView_SelectItem(hTree
, hChild
);
536 r
= TreeView_SelectItem(hTree
, hRoot
);
539 ok(!strcmp(sequence
, "1(nR)nR23(RC)RC45(CR)CR."), "root-child select test\n");
540 ok_sequence(sequences
, TREEVIEW_SEQ_INDEX
, rootchild_select_seq
,
541 "root-child select seq", FALSE
);
543 DestroyWindow(hTree
);
546 static void test_getitemtext(void)
553 CHAR szBuffer
[80] = "Blah";
554 int nBufferSize
= sizeof(szBuffer
)/sizeof(CHAR
);
556 hTree
= create_treeview_control(0);
559 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
561 /* add an item without TVIF_TEXT mask and pszText == NULL */
563 ins
.hInsertAfter
= TVI_ROOT
;
564 U(ins
).item
.mask
= 0;
565 U(ins
).item
.pszText
= NULL
;
566 U(ins
).item
.cchTextMax
= 0;
567 hChild
= TreeView_InsertItem(hTree
, &ins
);
570 /* retrieve it with TVIF_TEXT mask */
572 tvi
.mask
= TVIF_TEXT
;
573 tvi
.cchTextMax
= nBufferSize
;
574 tvi
.pszText
= szBuffer
;
576 SendMessageA( hTree
, TVM_GETITEMA
, 0, (LPARAM
)&tvi
);
577 ok(!strcmp(szBuffer
, ""), "szBuffer=\"%s\", expected \"\"\n", szBuffer
);
578 ok(SendMessageA(hTree
, TVM_DELETEITEM
, 0, (LPARAM
)hChild
), "DeleteItem failed\n");
579 ok_sequence(sequences
, TREEVIEW_SEQ_INDEX
, getitemtext_seq
, "get item text seq", FALSE
);
581 DestroyWindow(hTree
);
584 static void test_focus(void)
587 static CHAR child1
[] = "Edit",
588 child2
[] = "A really long string";
589 HTREEITEM hChild1
, hChild2
;
593 hTree
= create_treeview_control(0);
596 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
598 /* This test verifies that when a label is being edited, scrolling
599 * the treeview does not cause the label to lose focus. To test
600 * this, first some additional entries are added to generate
604 ins
.hInsertAfter
= hChild
;
605 U(ins
).item
.mask
= TVIF_TEXT
;
606 U(ins
).item
.pszText
= child1
;
607 hChild1
= TreeView_InsertItem(hTree
, &ins
);
609 ins
.hInsertAfter
= hChild1
;
610 U(ins
).item
.mask
= TVIF_TEXT
;
611 U(ins
).item
.pszText
= child2
;
612 hChild2
= TreeView_InsertItem(hTree
, &ins
);
615 ShowWindow(hMainWnd
,SW_SHOW
);
616 SendMessageA(hTree
, TVM_SELECTITEM
, TVGN_CARET
, (LPARAM
)hChild
);
617 hEdit
= TreeView_EditLabel(hTree
, hChild
);
618 ScrollWindowEx(hTree
, -10, 0, NULL
, NULL
, NULL
, NULL
, SW_SCROLLCHILDREN
);
619 ok(GetFocus() == hEdit
, "Edit control should have focus\n");
620 ok_sequence(sequences
, TREEVIEW_SEQ_INDEX
, focus_seq
, "focus test", TRUE
);
622 DestroyWindow(hTree
);
625 static void test_get_set_bkcolor(void)
627 COLORREF crColor
= RGB(0,0,0);
630 hTree
= create_treeview_control(0);
633 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
635 /* If the value is -1, the control is using the system color for the background color. */
636 crColor
= (COLORREF
)SendMessage( hTree
, TVM_GETBKCOLOR
, 0, 0 );
637 ok(crColor
== -1, "Default background color reported as 0x%.8x\n", crColor
);
639 /* Test for black background */
640 SendMessage( hTree
, TVM_SETBKCOLOR
, 0, RGB(0,0,0) );
641 crColor
= (COLORREF
)SendMessage( hTree
, TVM_GETBKCOLOR
, 0, 0 );
642 ok(crColor
== RGB(0,0,0), "Black background color reported as 0x%.8x\n", crColor
);
644 /* Test for white background */
645 SendMessage( hTree
, TVM_SETBKCOLOR
, 0, RGB(255,255,255) );
646 crColor
= (COLORREF
)SendMessage( hTree
, TVM_GETBKCOLOR
, 0, 0 );
647 ok(crColor
== RGB(255,255,255), "White background color reported as 0x%.8x\n", crColor
);
649 /* Reset the default background */
650 SendMessage( hTree
, TVM_SETBKCOLOR
, 0, -1 );
652 ok_sequence(sequences
, TREEVIEW_SEQ_INDEX
, test_get_set_bkcolor_seq
,
653 "test get set bkcolor", FALSE
);
655 DestroyWindow(hTree
);
658 static void test_get_set_imagelist(void)
660 HIMAGELIST hImageList
= NULL
;
663 hTree
= create_treeview_control(0);
666 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
668 /* Test a NULL HIMAGELIST */
669 SendMessage( hTree
, TVM_SETIMAGELIST
, TVSIL_NORMAL
, (LPARAM
)hImageList
);
670 hImageList
= (HIMAGELIST
)SendMessage( hTree
, TVM_GETIMAGELIST
, TVSIL_NORMAL
, 0 );
671 ok(hImageList
== NULL
, "NULL image list, reported as 0x%p, expected 0.\n", hImageList
);
673 /* TODO: Test an actual image list */
675 ok_sequence(sequences
, TREEVIEW_SEQ_INDEX
, test_get_set_imagelist_seq
,
676 "test get imagelist", FALSE
);
678 DestroyWindow(hTree
);
681 static void test_get_set_indent(void)
684 int ulMinIndent
= -1;
685 int ulMoreThanTwiceMin
= -1;
688 hTree
= create_treeview_control(0);
691 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
693 /* Finding the minimum indent */
694 SendMessage( hTree
, TVM_SETINDENT
, 0, 0 );
695 ulMinIndent
= (int)SendMessage( hTree
, TVM_GETINDENT
, 0, 0 );
697 /* Checking an indent that is more than twice the default indent */
698 ulMoreThanTwiceMin
= 2*ulMinIndent
+1;
699 SendMessage( hTree
, TVM_SETINDENT
, ulMoreThanTwiceMin
, 0 );
700 ulIndent
= (DWORD
)SendMessage( hTree
, TVM_GETINDENT
, 0, 0 );
701 ok(ulIndent
== ulMoreThanTwiceMin
, "Indent reported as %d, expected %d\n", ulIndent
, ulMoreThanTwiceMin
);
703 ok_sequence(sequences
, TREEVIEW_SEQ_INDEX
, test_get_set_indent_seq
,
704 "test get set indent", FALSE
);
706 DestroyWindow(hTree
);
709 static void test_get_set_insertmark(void)
711 COLORREF crColor
= RGB(0,0,0);
714 hTree
= create_treeview_control(0);
717 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
719 SendMessage( hTree
, TVM_SETINSERTMARKCOLOR
, 0, crColor
);
720 crColor
= (COLORREF
)SendMessage( hTree
, TVM_GETINSERTMARKCOLOR
, 0, 0 );
721 ok(crColor
== RGB(0,0,0), "Insert mark color reported as 0x%.8x, expected 0x00000000\n", crColor
);
723 ok_sequence(sequences
, TREEVIEW_SEQ_INDEX
, test_get_set_insertmarkcolor_seq
,
724 "test get set insertmark color", FALSE
);
726 DestroyWindow(hTree
);
729 static void test_get_set_item(void)
731 TVITEMA tviRoot
= {0};
732 int nBufferSize
= 80;
733 char szBuffer
[80] = {0};
737 hTree
= create_treeview_control(0);
740 tviRoot
.hItem
= hRoot
;
741 tviRoot
.mask
= TVIF_STATE
;
742 tviRoot
.state
= TVIS_FOCUSED
;
743 tviRoot
.stateMask
= TVIS_FOCUSED
;
744 ret
= SendMessage( hTree
, TVM_SETITEMA
, 0, (LPARAM
)&tviRoot
);
747 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
749 /* Test the root item, state is set even when not requested */
750 tviRoot
.hItem
= hRoot
;
751 tviRoot
.mask
= TVIF_TEXT
;
753 tviRoot
.stateMask
= 0;
754 tviRoot
.cchTextMax
= nBufferSize
;
755 tviRoot
.pszText
= szBuffer
;
756 ret
= SendMessage( hTree
, TVM_GETITEMA
, 0, (LPARAM
)&tviRoot
);
758 ok(!strcmp("Root", szBuffer
), "GetItem: szBuffer=\"%s\", expected \"Root\"\n", szBuffer
);
759 ok(tviRoot
.state
== TVIS_FOCUSED
, "got 0x%0x\n", tviRoot
.state
);
761 /* Change the root text */
762 strncpy(szBuffer
, "Testing123", nBufferSize
);
763 ret
= SendMessage( hTree
, TVM_SETITEMA
, 0, (LPARAM
)&tviRoot
);
765 memset(szBuffer
, 0, nBufferSize
);
766 ret
= SendMessage( hTree
, TVM_GETITEMA
, 0, (LPARAM
)&tviRoot
);
768 ok(!strcmp("Testing123", szBuffer
), "GetItem: szBuffer=\"%s\", expected \"Testing123\"\n", szBuffer
);
770 /* Reset the root text */
771 memset(szBuffer
, 0, nBufferSize
);
772 strncpy(szBuffer
, "Root", nBufferSize
);
773 ret
= SendMessage( hTree
, TVM_SETITEMA
, 0, (LPARAM
)&tviRoot
);
776 ok_sequence(sequences
, TREEVIEW_SEQ_INDEX
, test_get_set_item_seq
,
777 "test get set item", FALSE
);
779 DestroyWindow(hTree
);
782 static void test_get_set_itemheight(void)
788 hTree
= create_treeview_control(0);
791 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
793 /* Assuming default height to begin with */
794 ulOldHeight
= (int) SendMessage( hTree
, TVM_GETITEMHEIGHT
, 0, 0 );
796 /* Explicitly setting and getting the default height */
797 SendMessage( hTree
, TVM_SETITEMHEIGHT
, -1, 0 );
798 ulNewHeight
= (int) SendMessage( hTree
, TVM_GETITEMHEIGHT
, 0, 0 );
799 ok(ulNewHeight
== ulOldHeight
, "Default height not set properly, reported %d, expected %d\n", ulNewHeight
, ulOldHeight
);
801 /* Explicitly setting and getting the height of twice the normal */
802 SendMessage( hTree
, TVM_SETITEMHEIGHT
, 2*ulOldHeight
, 0 );
803 ulNewHeight
= (int) SendMessage( hTree
, TVM_GETITEMHEIGHT
, 0, 0 );
804 ok(ulNewHeight
== 2*ulOldHeight
, "New height not set properly, reported %d, expected %d\n", ulNewHeight
, 2*ulOldHeight
);
806 /* Assuming tree doesn't have TVS_NONEVENHEIGHT set, so a set of 9 will round down to 8 */
807 SendMessage( hTree
, TVM_SETITEMHEIGHT
, 9, 0 );
808 ulNewHeight
= (int) SendMessage( hTree
, TVM_GETITEMHEIGHT
, 0, 0 );
809 ok(ulNewHeight
== 8, "Uneven height not set properly, reported %d, expected %d\n", ulNewHeight
, 8);
811 ok_sequence(sequences
, TREEVIEW_SEQ_INDEX
, test_get_set_itemheight_seq
,
812 "test get set item height", FALSE
);
814 /* without TVS_NONEVENHEIGHT */
815 SetWindowLong(hTree
, GWL_STYLE
, GetWindowLong(hTree
, GWL_STYLE
) & ~TVS_NONEVENHEIGHT
);
817 ulOldHeight
= SendMessage( hTree
, TVM_SETITEMHEIGHT
, 3, 0);
818 ok(ulOldHeight
== 8, "got %d, expected %d\n", ulOldHeight
, 8);
819 ulNewHeight
= (int) SendMessage( hTree
, TVM_GETITEMHEIGHT
, 0, 0 );
820 ok(ulNewHeight
== 2, "got %d, expected %d\n", ulNewHeight
, 2);
822 ulOldHeight
= SendMessage( hTree
, TVM_SETITEMHEIGHT
, 4, 0);
823 ok(ulOldHeight
== 2, "got %d, expected %d\n", ulOldHeight
, 2);
824 ulNewHeight
= (int) SendMessage( hTree
, TVM_GETITEMHEIGHT
, 0, 0 );
825 ok(ulNewHeight
== 4, "got %d, expected %d\n", ulNewHeight
, 4);
827 /* with TVS_NONEVENHEIGHT */
828 SetWindowLong(hTree
, GWL_STYLE
, GetWindowLong(hTree
, GWL_STYLE
) | TVS_NONEVENHEIGHT
);
830 ulOldHeight
= SendMessage( hTree
, TVM_SETITEMHEIGHT
, 3, 0);
831 ok(ulOldHeight
== 4, "got %d, expected %d\n", ulOldHeight
, 4);
832 ulNewHeight
= (int) SendMessage( hTree
, TVM_GETITEMHEIGHT
, 0, 0 );
833 ok(ulNewHeight
== 3, "got %d, expected %d\n", ulNewHeight
, 3);
835 ulOldHeight
= SendMessage( hTree
, TVM_SETITEMHEIGHT
, 10, 0);
836 ok(ulOldHeight
== 3, "got %d, expected %d\n", ulOldHeight
, 3);
837 ulNewHeight
= (int) SendMessage( hTree
, TVM_GETITEMHEIGHT
, 0, 0 );
838 ok(ulNewHeight
== 10, "got %d, expected %d\n", ulNewHeight
, 10);
840 DestroyWindow(hTree
);
843 static void test_get_set_scrolltime(void)
845 int ulExpectedTime
= 20;
849 hTree
= create_treeview_control(0);
852 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
854 SendMessage( hTree
, TVM_SETSCROLLTIME
, ulExpectedTime
, 0 );
855 ulTime
= (int)SendMessage( hTree
, TVM_GETSCROLLTIME
, 0, 0 );
856 ok(ulTime
== ulExpectedTime
, "Scroll time reported as %d, expected %d\n", ulTime
, ulExpectedTime
);
858 ok_sequence(sequences
, TREEVIEW_SEQ_INDEX
, test_get_set_scrolltime_seq
,
859 "test get set scroll time", FALSE
);
861 DestroyWindow(hTree
);
864 static void test_get_set_textcolor(void)
866 /* If the value is -1, the control is using the system color for the text color. */
867 COLORREF crColor
= RGB(0,0,0);
870 hTree
= create_treeview_control(0);
873 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
875 crColor
= (COLORREF
)SendMessage( hTree
, TVM_GETTEXTCOLOR
, 0, 0 );
876 ok(crColor
== -1, "Default text color reported as 0x%.8x\n", crColor
);
878 /* Test for black text */
879 SendMessage( hTree
, TVM_SETTEXTCOLOR
, 0, RGB(0,0,0) );
880 crColor
= (COLORREF
)SendMessage( hTree
, TVM_GETTEXTCOLOR
, 0, 0 );
881 ok(crColor
== RGB(0,0,0), "Black text color reported as 0x%.8x\n", crColor
);
883 /* Test for white text */
884 SendMessage( hTree
, TVM_SETTEXTCOLOR
, 0, RGB(255,255,255) );
885 crColor
= (COLORREF
)SendMessage( hTree
, TVM_GETTEXTCOLOR
, 0, 0 );
886 ok(crColor
== RGB(255,255,255), "White text color reported as 0x%.8x\n", crColor
);
888 /* Reset the default text color */
889 SendMessage( hTree
, TVM_SETTEXTCOLOR
, 0, CLR_NONE
);
891 ok_sequence(sequences
, TREEVIEW_SEQ_INDEX
, test_get_set_textcolor_seq
,
892 "test get set text color", FALSE
);
894 DestroyWindow(hTree
);
897 static void test_get_set_tooltips(void)
899 HWND hwndLastToolTip
= NULL
;
903 hTree
= create_treeview_control(0);
906 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
908 /* show even WS_POPUP treeview don't send NM_TOOLTIPSCREATED */
909 hPopupTreeView
= CreateWindow(WC_TREEVIEW
, NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 100, 100, hMainWnd
, NULL
, NULL
, NULL
);
910 DestroyWindow(hPopupTreeView
);
912 /* Testing setting a NULL ToolTip */
913 SendMessage( hTree
, TVM_SETTOOLTIPS
, 0, 0 );
914 hwndLastToolTip
= (HWND
)SendMessage( hTree
, TVM_GETTOOLTIPS
, 0, 0 );
915 ok(hwndLastToolTip
== NULL
, "NULL tool tip, reported as 0x%p, expected 0.\n", hwndLastToolTip
);
917 ok_sequence(sequences
, TREEVIEW_SEQ_INDEX
, test_get_set_tooltips_seq
,
918 "test get set tooltips", TRUE
);
920 /* TODO: Add a test of an actual tooltip */
921 DestroyWindow(hTree
);
924 static void test_get_set_unicodeformat(void)
926 BOOL bPreviousSetting
= 0;
927 BOOL bNewSetting
= 0;
930 hTree
= create_treeview_control(0);
933 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
936 bPreviousSetting
= (BOOL
)SendMessage( hTree
, TVM_SETUNICODEFORMAT
, 1, 0 );
937 bNewSetting
= (BOOL
)SendMessage( hTree
, TVM_GETUNICODEFORMAT
, 0, 0 );
938 ok(bNewSetting
== 1, "Unicode setting did not work.\n");
941 SendMessage( hTree
, TVM_SETUNICODEFORMAT
, 0, 0 );
942 bNewSetting
= (BOOL
)SendMessage( hTree
, TVM_GETUNICODEFORMAT
, 0, 0 );
943 ok(bNewSetting
== 0, "ANSI setting did not work.\n");
945 /* Revert to original setting */
946 SendMessage( hTree
, TVM_SETUNICODEFORMAT
, bPreviousSetting
, 0 );
948 ok_sequence(sequences
, TREEVIEW_SEQ_INDEX
, test_get_set_unicodeformat_seq
,
949 "test get set unicode format", FALSE
);
951 DestroyWindow(hTree
);
954 static LRESULT CALLBACK
parent_wnd_proc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
956 static LONG defwndproc_counter
= 0;
960 HTREEITEM visibleItem
;
962 msg
.message
= message
;
963 msg
.flags
= sent
|wparam
|lparam
;
964 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
967 if (message
== WM_NOTIFY
&& lParam
) msg
.id
= ((NMHDR
*)lParam
)->code
;
969 /* log system messages, except for painting */
970 if (message
< WM_USER
&&
971 message
!= WM_PAINT
&&
972 message
!= WM_ERASEBKGND
&&
973 message
!= WM_NCPAINT
&&
974 message
!= WM_NCHITTEST
&&
975 message
!= WM_GETTEXT
&&
976 message
!= WM_GETICON
&&
977 message
!= WM_DEVICECHANGE
)
979 trace("parent: %p, %04x, %08lx, %08lx\n", hWnd
, message
, wParam
, lParam
);
980 add_message(sequences
, PARENT_SEQ_INDEX
, &msg
);
986 NMHDR
*pHdr
= (NMHDR
*)lParam
;
988 ok(pHdr
->code
!= NM_TOOLTIPSCREATED
, "Treeview should not send NM_TOOLTIPSCREATED\n");
989 if (pHdr
->idFrom
== 100)
991 NMTREEVIEWA
*pTreeView
= (LPNMTREEVIEWA
) lParam
;
994 case TVN_SELCHANGINGA
:
996 IdentifyItem(pTreeView
->itemOld
.hItem
);
997 IdentifyItem(pTreeView
->itemNew
.hItem
);
999 case TVN_SELCHANGEDA
:
1001 IdentifyItem(pTreeView
->itemOld
.hItem
);
1002 IdentifyItem(pTreeView
->itemNew
.hItem
);
1004 case TVN_GETDISPINFOA
: {
1005 NMTVDISPINFOA
*disp
= (NMTVDISPINFOA
*)lParam
;
1006 if (disp
->item
.mask
& TVIF_TEXT
) {
1007 lstrcpyn(disp
->item
.pszText
, TEST_CALLBACK_TEXT
, disp
->item
.cchTextMax
);
1010 if (g_disp_A_to_W
&& (disp
->item
.mask
& TVIF_TEXT
)) {
1011 static const WCHAR testW
[] = {'T','E','S','T','2',0};
1013 disp
->hdr
.code
= TVN_GETDISPINFOW
;
1014 memcpy(disp
->item
.pszText
, testW
, sizeof(testW
));
1017 if (g_disp_set_stateimage
)
1019 ok(disp
->item
.mask
== TVIF_IMAGE
, "got %x\n", disp
->item
.mask
);
1020 /* both masks set here are necessary to change state bits */
1021 disp
->item
.mask
|= TVIF_STATE
;
1022 disp
->item
.state
= TVIS_SELECTED
| INDEXTOSTATEIMAGEMASK(2) | INDEXTOOVERLAYMASK(3);
1023 disp
->item
.stateMask
= TVIS_SELECTED
| TVIS_OVERLAYMASK
| TVIS_STATEIMAGEMASK
;
1028 case TVN_ENDLABELEDIT
: return TRUE
;
1029 case TVN_ITEMEXPANDINGA
:
1030 ok(pTreeView
->itemNew
.mask
==
1031 (TVIF_HANDLE
| TVIF_SELECTEDIMAGE
| TVIF_IMAGE
| TVIF_PARAM
| TVIF_STATE
),
1032 "got wrong mask %x\n", pTreeView
->itemNew
.mask
);
1033 ok((pTreeView
->itemNew
.state
& TVIS_EXPANDED
) == 0,
1034 "got wrong state %x\n", pTreeView
->itemNew
.state
);
1035 ok(pTreeView
->itemOld
.mask
== 0,
1036 "got wrong mask %x\n", pTreeView
->itemOld
.mask
);
1038 if (g_get_from_expand
)
1040 g_item_expanding
.mask
= TVIF_STATE
;
1041 g_item_expanding
.hItem
= hRoot
;
1042 ret
= SendMessageA(pHdr
->hwndFrom
, TVM_GETITEMA
, 0, (LPARAM
)&g_item_expanding
);
1043 ok(ret
== TRUE
, "got %lu\n", ret
);
1046 case TVN_ITEMEXPANDEDA
:
1047 ok(pTreeView
->itemNew
.mask
& TVIF_STATE
, "got wrong mask %x\n", pTreeView
->itemNew
.mask
);
1048 ok(pTreeView
->itemNew
.state
& (TVIS_EXPANDED
|TVIS_EXPANDEDONCE
),
1049 "got wrong mask %x\n", pTreeView
->itemNew
.mask
);
1050 ok(pTreeView
->itemOld
.mask
== 0,
1051 "got wrong mask %x\n", pTreeView
->itemOld
.mask
);
1053 if (g_get_from_expand
)
1055 g_item_expanded
.mask
= TVIF_STATE
;
1056 g_item_expanded
.hItem
= hRoot
;
1057 ret
= SendMessageA(pHdr
->hwndFrom
, TVM_GETITEMA
, 0, (LPARAM
)&g_item_expanded
);
1058 ok(ret
== TRUE
, "got %lu\n", ret
);
1060 if (g_get_rect_in_expand
)
1062 visibleItem
= TreeView_GetNextItem(pHdr
->hwndFrom
, NULL
, TVGN_FIRSTVISIBLE
);
1063 ok(pTreeView
->itemNew
.hItem
== visibleItem
, "expanded item == first visible item\n");
1064 *(HTREEITEM
*)&rect
= visibleItem
;
1065 ok(SendMessage(pHdr
->hwndFrom
, TVM_GETITEMRECT
, TRUE
, (LPARAM
)&rect
), "Failed to get rect for first visible item.\n");
1066 visibleItem
= TreeView_GetNextItem(pHdr
->hwndFrom
, visibleItem
, TVGN_NEXTVISIBLE
);
1067 *(HTREEITEM
*)&rect
= visibleItem
;
1068 ok(visibleItem
!= NULL
, "There must be a visible item after the first visisble item.\n");
1069 ok(SendMessage(pHdr
->hwndFrom
, TVM_GETITEMRECT
, TRUE
, (LPARAM
)&rect
), "Failed to get rect for second visible item.\n");
1072 case TVN_DELETEITEMA
:
1074 struct message item
;
1076 ok(pTreeView
->itemNew
.mask
== 0, "got wrong mask 0x%x\n", pTreeView
->itemNew
.mask
);
1078 ok(pTreeView
->itemOld
.mask
== (TVIF_HANDLE
| TVIF_PARAM
), "got wrong mask 0x%x\n", pTreeView
->itemOld
.mask
);
1079 ok(pTreeView
->itemOld
.hItem
!= NULL
, "got %p\n", pTreeView
->itemOld
.hItem
);
1081 memset(&item
, 0, sizeof(item
));
1082 item
.lParam
= (LPARAM
)pTreeView
->itemOld
.hItem
;
1083 add_message(item_sequence
, 0, &item
);
1097 defwndproc_counter
++;
1098 ret
= DefWindowProcA(hWnd
, message
, wParam
, lParam
);
1099 defwndproc_counter
--;
1104 static void test_expandinvisible(void)
1106 static CHAR nodeText
[][5] = {"0", "1", "2", "3", "4"};
1107 TVINSERTSTRUCTA ins
;
1114 hTree
= create_treeview_control(0);
1116 /* The test builds the following tree and expands then node 1, while node 0 is collapsed.
1126 ret
= TreeView_DeleteAllItems(hTree
);
1127 ok(ret
== TRUE
, "ret\n");
1128 ins
.hParent
= TVI_ROOT
;
1129 ins
.hInsertAfter
= TVI_ROOT
;
1130 U(ins
).item
.mask
= TVIF_TEXT
;
1131 U(ins
).item
.pszText
= nodeText
[0];
1132 node
[0] = TreeView_InsertItem(hTree
, &ins
);
1135 ins
.hInsertAfter
= TVI_LAST
;
1136 U(ins
).item
.mask
= TVIF_TEXT
;
1137 ins
.hParent
= node
[0];
1139 U(ins
).item
.pszText
= nodeText
[1];
1140 node
[1] = TreeView_InsertItem(hTree
, &ins
);
1142 U(ins
).item
.pszText
= nodeText
[4];
1143 node
[4] = TreeView_InsertItem(hTree
, &ins
);
1146 ins
.hParent
= node
[1];
1148 U(ins
).item
.pszText
= nodeText
[2];
1149 node
[2] = TreeView_InsertItem(hTree
, &ins
);
1151 U(ins
).item
.pszText
= nodeText
[3];
1152 node
[3] = TreeView_InsertItem(hTree
, &ins
);
1156 nodeVisible
= TreeView_GetItemRect(hTree
, node
[1], &dummyRect
, FALSE
);
1157 ok(!nodeVisible
, "Node 1 should not be visible.\n");
1158 nodeVisible
= TreeView_GetItemRect(hTree
, node
[2], &dummyRect
, FALSE
);
1159 ok(!nodeVisible
, "Node 2 should not be visible.\n");
1160 nodeVisible
= TreeView_GetItemRect(hTree
, node
[3], &dummyRect
, FALSE
);
1161 ok(!nodeVisible
, "Node 3 should not be visible.\n");
1162 nodeVisible
= TreeView_GetItemRect(hTree
, node
[4], &dummyRect
, FALSE
);
1163 ok(!nodeVisible
, "Node 4 should not be visible.\n");
1165 ok(TreeView_Expand(hTree
, node
[1], TVE_EXPAND
), "Expand of node 1 failed.\n");
1167 nodeVisible
= TreeView_GetItemRect(hTree
, node
[1], &dummyRect
, FALSE
);
1168 ok(!nodeVisible
, "Node 1 should not be visible.\n");
1169 nodeVisible
= TreeView_GetItemRect(hTree
, node
[2], &dummyRect
, FALSE
);
1170 ok(!nodeVisible
, "Node 2 should not be visible.\n");
1171 nodeVisible
= TreeView_GetItemRect(hTree
, node
[3], &dummyRect
, FALSE
);
1172 ok(!nodeVisible
, "Node 3 should not be visible.\n");
1173 nodeVisible
= TreeView_GetItemRect(hTree
, node
[4], &dummyRect
, FALSE
);
1174 ok(!nodeVisible
, "Node 4 should not be visible.\n");
1176 DestroyWindow(hTree
);
1179 static void test_itemedit(void)
1187 hTree
= create_treeview_control(0);
1190 /* try with null item */
1191 edit
= (HWND
)SendMessage(hTree
, TVM_EDITLABEL
, 0, 0);
1192 ok(!IsWindow(edit
), "Expected valid handle\n");
1195 edit
= (HWND
)SendMessage(hTree
, TVM_EDITLABEL
, 0, (LPARAM
)hRoot
);
1196 ok(IsWindow(edit
), "Expected valid handle\n");
1197 /* item shouldn't be selected automatically after TVM_EDITLABEL */
1198 r
= SendMessage(hTree
, TVM_GETITEMSTATE
, (WPARAM
)hRoot
, TVIS_SELECTED
);
1200 /* try to cancel with wrong edit handle */
1201 r
= SendMessage(hTree
, WM_COMMAND
, MAKEWPARAM(0, EN_KILLFOCUS
), 0);
1203 ok(IsWindow(edit
), "Expected edit control to be valid\n");
1204 r
= SendMessage(hTree
, WM_COMMAND
, MAKEWPARAM(0, EN_KILLFOCUS
), (LPARAM
)edit
);
1206 ok(!IsWindow(edit
), "Expected edit control to be destroyed\n");
1207 /* try to cancel without creating edit */
1208 r
= SendMessage(hTree
, WM_COMMAND
, MAKEWPARAM(0, EN_KILLFOCUS
), 0);
1211 /* try to cancel with wrong (not null) handle */
1212 edit
= (HWND
)SendMessage(hTree
, TVM_EDITLABEL
, 0, (LPARAM
)hRoot
);
1213 ok(IsWindow(edit
), "Expected valid handle\n");
1214 r
= SendMessage(hTree
, WM_COMMAND
, MAKEWPARAM(0, EN_KILLFOCUS
), (LPARAM
)hTree
);
1216 ok(IsWindow(edit
), "Expected edit control to be valid\n");
1217 r
= SendMessage(hTree
, WM_COMMAND
, MAKEWPARAM(0, EN_KILLFOCUS
), (LPARAM
)edit
);
1220 /* remove selection after starting edit */
1221 r
= TreeView_SelectItem(hTree
, hRoot
);
1223 edit
= (HWND
)SendMessage(hTree
, TVM_EDITLABEL
, 0, (LPARAM
)hRoot
);
1224 ok(IsWindow(edit
), "Expected valid handle\n");
1225 r
= TreeView_SelectItem(hTree
, NULL
);
1228 strncpy(buff
, "x", sizeof(buff
)/sizeof(CHAR
));
1229 r
= SendMessage(edit
, WM_SETTEXT
, 0, (LPARAM
)buff
);
1231 r
= SendMessage(hTree
, WM_COMMAND
, MAKEWPARAM(0, EN_KILLFOCUS
), (LPARAM
)edit
);
1233 ok(!IsWindow(edit
), "Expected edit control to be destroyed\n");
1234 /* check that text is saved */
1235 item
.mask
= TVIF_TEXT
;
1237 item
.pszText
= buff
;
1238 item
.cchTextMax
= sizeof(buff
)/sizeof(CHAR
);
1239 r
= SendMessage(hTree
, TVM_GETITEMA
, 0, (LPARAM
)&item
);
1241 ok(!strcmp("x", buff
), "Expected item text to change\n");
1243 DestroyWindow(hTree
);
1246 static void test_treeview_classinfo(void)
1250 memset(&cls
, 0, sizeof(cls
));
1251 GetClassInfo(GetModuleHandleA("comctl32.dll"), WC_TREEVIEWA
, &cls
);
1252 ok(cls
.hbrBackground
== NULL
, "Expected NULL background brush, got %p\n", cls
.hbrBackground
);
1253 ok(cls
.style
== (CS_GLOBALCLASS
| CS_DBLCLKS
), "Expected got %x\n", cls
.style
);
1254 expect(0, cls
.cbClsExtra
);
1257 static void test_get_linecolor(void)
1262 hTree
= create_treeview_control(0);
1264 /* newly created control has default color */
1265 clr
= (COLORREF
)SendMessage(hTree
, TVM_GETLINECOLOR
, 0, 0);
1267 win_skip("TVM_GETLINECOLOR is not supported on comctl32 < 5.80\n");
1269 expect(CLR_DEFAULT
, clr
);
1271 DestroyWindow(hTree
);
1274 static void test_get_insertmarkcolor(void)
1279 hTree
= create_treeview_control(0);
1281 /* newly created control has default color */
1282 clr
= (COLORREF
)SendMessage(hTree
, TVM_GETINSERTMARKCOLOR
, 0, 0);
1284 win_skip("TVM_GETINSERTMARKCOLOR is not supported on comctl32 < 5.80\n");
1286 expect(CLR_DEFAULT
, clr
);
1288 DestroyWindow(hTree
);
1291 static void test_expandnotify(void)
1297 hTree
= create_treeview_control(0);
1301 item
.mask
= TVIF_STATE
;
1303 item
.state
= TVIS_EXPANDED
;
1304 ret
= SendMessageA(hTree
, TVM_GETITEMA
, 0, (LPARAM
)&item
);
1306 ok((item
.state
& TVIS_EXPANDED
) == 0, "expected collapsed\n");
1308 /* preselect root node here */
1309 ret
= SendMessageA(hTree
, TVM_SELECTITEM
, TVGN_CARET
, (LPARAM
)hRoot
);
1312 g_get_from_expand
= TRUE
;
1314 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1315 g_item_expanding
.state
= 0xdeadbeef;
1316 g_item_expanded
.state
= 0xdeadbeef;
1317 ret
= SendMessageA(hTree
, TVM_EXPAND
, TVE_EXPAND
, (LPARAM
)hRoot
);
1319 ok(g_item_expanding
.state
== TVIS_SELECTED
, "got state on TVN_ITEMEXPANDING 0x%08x\n",
1320 g_item_expanding
.state
);
1321 ok(g_item_expanded
.state
== (TVIS_SELECTED
|TVIS_EXPANDED
), "got state on TVN_ITEMEXPANDED 0x%08x\n",
1322 g_item_expanded
.state
);
1323 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_expand_seq
, "expand notifications", FALSE
);
1324 g_get_from_expand
= FALSE
;
1326 /* check that it's expanded */
1327 item
.state
= TVIS_EXPANDED
;
1328 ret
= SendMessageA(hTree
, TVM_GETITEMA
, 0, (LPARAM
)&item
);
1330 ok((item
.state
& TVIS_EXPANDED
) == TVIS_EXPANDED
, "expected expanded\n");
1333 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1334 ret
= SendMessageA(hTree
, TVM_EXPAND
, TVE_COLLAPSE
, (LPARAM
)hRoot
);
1336 item
.state
= TVIS_EXPANDED
;
1337 ret
= SendMessageA(hTree
, TVM_GETITEMA
, 0, (LPARAM
)&item
);
1339 ok((item
.state
& TVIS_EXPANDED
) == 0, "expected collapsed\n");
1340 /* all next collapse/expand attempts won't produce any notifications,
1341 the only way is to reset with all children removed */
1342 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
, "collapse after expand notifications", FALSE
);
1344 /* try to toggle child that doesn't have children itself */
1345 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1346 ret
= SendMessageA(hTree
, TVM_EXPAND
, TVE_TOGGLE
, (LPARAM
)hChild
);
1348 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
, "toggle node without children", FALSE
);
1350 DestroyWindow(hTree
);
1352 /* test TVM_GETITEMRECT inside TVN_ITEMEXPANDED notification */
1353 hTree
= create_treeview_control(0);
1355 g_get_rect_in_expand
= TRUE
;
1356 ret
= TreeView_Select(hTree
, hChild
, TVGN_CARET
);
1358 g_get_rect_in_expand
= FALSE
;
1360 DestroyWindow(hTree
);
1362 /* TVE_TOGGLE acts as any other TVM_EXPAND */
1363 hTree
= create_treeview_control(0);
1366 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1367 ret
= SendMessageA(hTree
, TVM_EXPAND
, TVE_TOGGLE
, (LPARAM
)hRoot
);
1369 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_expand_seq
, "toggle node (expand)", FALSE
);
1371 /* toggle again - no notifications */
1372 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1373 ret
= SendMessageA(hTree
, TVM_EXPAND
, TVE_TOGGLE
, (LPARAM
)hRoot
);
1375 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
, "toggle node (collapse)", FALSE
);
1377 DestroyWindow(hTree
);
1380 static void test_expandedimage(void)
1386 hTree
= create_treeview_control(0);
1389 item
.mask
= TVIF_EXPANDEDIMAGE
;
1390 item
.iExpandedImage
= 1;
1392 ret
= SendMessageA(hTree
, TVM_SETITEMA
, 0, (LPARAM
)&item
);
1393 ok(ret
, "got %d\n", ret
);
1395 item
.mask
= TVIF_EXPANDEDIMAGE
;
1396 item
.iExpandedImage
= -1;
1398 ret
= SendMessageA(hTree
, TVM_GETITEMA
, 0, (LPARAM
)&item
);
1399 ok(ret
, "got %d\n", ret
);
1401 if (item
.iExpandedImage
!= 1)
1403 win_skip("TVIF_EXPANDEDIMAGE not supported\n");
1404 DestroyWindow(hTree
);
1408 /* test for default iExpandedImage value */
1409 item
.mask
= TVIF_EXPANDEDIMAGE
;
1410 item
.iExpandedImage
= -1;
1411 item
.hItem
= hChild
;
1412 ret
= SendMessageA(hTree
, TVM_GETITEMA
, 0, (LPARAM
)&item
);
1413 ok(ret
, "got %d\n", ret
);
1414 ok(item
.iExpandedImage
== (WORD
)I_IMAGENONE
, "got %d\n", item
.iExpandedImage
);
1416 DestroyWindow(hTree
);
1419 static void test_TVS_SINGLEEXPAND(void)
1424 hTree
= create_treeview_control(0);
1425 SetWindowLongA(hTree
, GWL_STYLE
, GetWindowLong(hTree
, GWL_STYLE
) | TVS_SINGLEEXPAND
);
1426 /* to avoid paiting related notifications */
1427 ShowWindow(hTree
, SW_HIDE
);
1430 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1431 ret
= SendMessageA(hTree
, TVM_SELECTITEM
, TVGN_CARET
, (LPARAM
)hRoot
);
1432 ok(ret
, "got %d\n", ret
);
1433 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_singleexpand_seq
, "singleexpand notifications", FALSE
);
1435 /* a workaround for NT4 that sends expanding notification when nothing is about to expand */
1436 ret
= SendMessageA(hTree
, TVM_DELETEITEM
, 0, (LPARAM
)hRoot
);
1437 ok(ret
, "got %d\n", ret
);
1439 ret
= SendMessageA(hTree
, TVM_SELECTITEM
, TVGN_CARET
, 0);
1440 ok(ret
, "got %d\n", ret
);
1442 DestroyWindow(hTree
);
1445 static void test_WM_PAINT(void)
1453 hTree
= create_treeview_control(0);
1455 clr
= SendMessageA(hTree
, TVM_SETBKCOLOR
, 0, RGB(255, 0, 0));
1456 ok(clr
== -1, "got %d, expected -1\n", clr
);
1458 hdc
= GetDC(hMainWnd
);
1460 GetClientRect(hMainWnd
, &rc
);
1461 FillRect(hdc
, &rc
, GetStockObject(BLACK_BRUSH
));
1463 clr
= GetPixel(hdc
, 1, 1);
1464 ok(clr
== RGB(0, 0, 0), "got 0x%x\n", clr
);
1466 ret
= SendMessageA(hTree
, WM_PAINT
, (WPARAM
)hdc
, 0);
1467 ok(ret
== 0, "got %d\n", ret
);
1469 clr
= GetPixel(hdc
, 1, 1);
1470 ok(clr
== RGB(255, 0, 0) || broken(clr
== RGB(0, 0, 0)) /* win98 */,
1473 ReleaseDC(hMainWnd
, hdc
);
1475 DestroyWindow(hTree
);
1478 static void test_delete_items(void)
1480 const struct message
*msg
;
1484 hTree
= create_treeview_control(0);
1487 /* check delete order */
1488 flush_sequences(item_sequence
, 1);
1489 ret
= SendMessage(hTree
, TVM_DELETEITEM
, 0, 0);
1490 ok(ret
== TRUE
, "got %d\n", ret
);
1492 msg
= item_sequence
[0]->sequence
;
1493 ok(item_sequence
[0]->count
== 2, "expected 2 items, got %d\n", item_sequence
[0]->count
);
1495 if (item_sequence
[0]->count
== 2)
1497 ok(msg
[0].lParam
== (LPARAM
)hChild
, "expected %p, got 0x%lx\n", hChild
, msg
[0].lParam
);
1498 ok(msg
[1].lParam
== (LPARAM
)hRoot
, "expected %p, got 0x%lx\n", hRoot
, msg
[1].lParam
);
1501 ret
= SendMessageA(hTree
, TVM_GETCOUNT
, 0, 0);
1502 ok(ret
== 0, "got %d\n", ret
);
1504 DestroyWindow(hTree
);
1509 HTREEITEM parent
; /* for root value of parent field is unidetified */
1510 HTREEITEM nextsibling
;
1511 HTREEITEM firstchild
;
1514 static void _check_item(HTREEITEM item
, HTREEITEM parent
, HTREEITEM nextsibling
, HTREEITEM firstchild
, int line
)
1516 struct _ITEM_DATA
*data
= (struct _ITEM_DATA
*)item
;
1518 ok_(__FILE__
, line
)(data
->parent
== parent
, "parent %p, got %p\n", parent
, data
->parent
);
1519 ok_(__FILE__
, line
)(data
->nextsibling
== nextsibling
, "sibling %p, got %p\n", nextsibling
, data
->nextsibling
);
1520 ok_(__FILE__
, line
)(data
->firstchild
== firstchild
, "firstchild %p, got %p\n", firstchild
, data
->firstchild
);
1523 #define check_item(a, b, c, d) _check_item(a, b, c, d, __LINE__)
1525 static void test_htreeitem_layout(void)
1527 TVINSERTSTRUCTA ins
;
1528 HTREEITEM item1
, item2
;
1531 hTree
= create_treeview_control(0);
1534 /* root has some special pointer in parent field */
1535 check_item(hRoot
, ((struct _ITEM_DATA
*)hRoot
)->parent
, 0, hChild
);
1536 check_item(hChild
, hRoot
, 0, 0);
1538 ins
.hParent
= hChild
;
1539 ins
.hInsertAfter
= TVI_FIRST
;
1540 U(ins
).item
.mask
= 0;
1541 item1
= TreeView_InsertItem(hTree
, &ins
);
1543 check_item(item1
, hChild
, 0, 0);
1545 ins
.hParent
= hRoot
;
1546 ins
.hInsertAfter
= TVI_FIRST
;
1547 U(ins
).item
.mask
= 0;
1548 item2
= TreeView_InsertItem(hTree
, &ins
);
1550 check_item(item2
, hRoot
, hChild
, 0);
1552 SendMessage(hTree
, TVM_DELETEITEM
, 0, (LPARAM
)hChild
);
1554 /* without children now */
1555 check_item(hRoot
, ((struct _ITEM_DATA
*)hRoot
)->parent
, 0, item2
);
1557 DestroyWindow(hTree
);
1560 static void test_TVS_CHECKBOXES(void)
1566 hTree
= create_treeview_control(0);
1570 item
.mask
= TVIF_STATE
;
1571 item
.state
= INDEXTOSTATEIMAGEMASK(1);
1572 item
.stateMask
= TVIS_STATEIMAGEMASK
;
1573 ret
= SendMessageA(hTree
, TVM_GETITEMA
, 0, (LPARAM
)&item
);
1575 ok(item
.state
== 0, "got 0x%x\n", item
.state
);
1577 /* set some index for a child */
1578 item
.hItem
= hChild
;
1579 item
.mask
= TVIF_STATE
;
1580 item
.state
= INDEXTOSTATEIMAGEMASK(4);
1581 item
.stateMask
= TVIS_STATEIMAGEMASK
;
1582 ret
= SendMessageA(hTree
, TVM_SETITEMA
, 0, (LPARAM
)&item
);
1585 /* enabling check boxes set all items to 1 state image index */
1586 SetWindowLongA(hTree
, GWL_STYLE
, GetWindowLongA(hTree
, GWL_STYLE
) | TVS_CHECKBOXES
);
1589 item
.mask
= TVIF_STATE
;
1591 item
.stateMask
= TVIS_STATEIMAGEMASK
;
1592 ret
= SendMessageA(hTree
, TVM_GETITEMA
, 0, (LPARAM
)&item
);
1594 ok(item
.state
== INDEXTOSTATEIMAGEMASK(1), "got 0x%x\n", item
.state
);
1596 item
.hItem
= hChild
;
1597 item
.mask
= TVIF_STATE
;
1599 item
.stateMask
= TVIS_STATEIMAGEMASK
;
1600 ret
= SendMessageA(hTree
, TVM_GETITEMA
, 0, (LPARAM
)&item
);
1602 ok(item
.state
== INDEXTOSTATEIMAGEMASK(1), "got 0x%x\n", item
.state
);
1604 DestroyWindow(hTree
);
1606 /* the same, but initially created with TVS_CHECKBOXES */
1607 hTree
= create_treeview_control(TVS_CHECKBOXES
);
1611 item
.mask
= TVIF_STATE
;
1613 item
.stateMask
= TVIS_STATEIMAGEMASK
;
1614 ret
= SendMessageA(hTree
, TVM_GETITEMA
, 0, (LPARAM
)&item
);
1616 ok(item
.state
== INDEXTOSTATEIMAGEMASK(1), "got 0x%x\n", item
.state
);
1618 item
.hItem
= hChild
;
1619 item
.mask
= TVIF_STATE
;
1621 item
.stateMask
= TVIS_STATEIMAGEMASK
;
1622 ret
= SendMessageA(hTree
, TVM_GETITEMA
, 0, (LPARAM
)&item
);
1624 ok(item
.state
== INDEXTOSTATEIMAGEMASK(1), "got 0x%x\n", item
.state
);
1626 DestroyWindow(hTree
);
1629 static void test_TVM_GETNEXTITEM(void)
1634 hTree
= create_treeview_control(0);
1637 item
= (HTREEITEM
)SendMessageA(hTree
, TVM_GETNEXTITEM
, TVGN_ROOT
, 0);
1638 ok(item
== hRoot
, "got %p, expected %p\n", item
, hRoot
);
1640 item
= (HTREEITEM
)SendMessageA(hTree
, TVM_GETNEXTITEM
, TVGN_ROOT
, (LPARAM
)TVI_ROOT
);
1641 ok(item
== hRoot
, "got %p, expected %p\n", item
, hRoot
);
1643 item
= (HTREEITEM
)SendMessageA(hTree
, TVM_GETNEXTITEM
, TVGN_ROOT
, (LPARAM
)hRoot
);
1644 ok(item
== hRoot
, "got %p, expected %p\n", item
, hRoot
);
1646 item
= (HTREEITEM
)SendMessageA(hTree
, TVM_GETNEXTITEM
, TVGN_ROOT
, (LPARAM
)hChild
);
1647 ok(item
== hRoot
, "got %p, expected %p\n", item
, hRoot
);
1649 item
= (HTREEITEM
)SendMessageA(hTree
, TVM_GETNEXTITEM
, TVGN_CHILD
, 0);
1650 ok(item
== hRoot
, "got %p, expected %p\n", item
, hRoot
);
1652 item
= (HTREEITEM
)SendMessageA(hTree
, TVM_GETNEXTITEM
, TVGN_CHILD
, (LPARAM
)hRoot
);
1653 ok(item
== hChild
, "got %p, expected %p\n", item
, hChild
);
1655 item
= (HTREEITEM
)SendMessageA(hTree
, TVM_GETNEXTITEM
, TVGN_CHILD
, (LPARAM
)TVI_ROOT
);
1656 ok(item
== hRoot
, "got %p, expected %p\n", item
, hRoot
);
1658 item
= (HTREEITEM
)SendMessageA(hTree
, TVM_GETNEXTITEM
, TVGN_PARENT
, 0);
1659 ok(item
== NULL
, "got %p\n", item
);
1661 item
= (HTREEITEM
)SendMessageA(hTree
, TVM_GETNEXTITEM
, TVGN_PARENT
, (LPARAM
)hChild
);
1662 ok(item
== hRoot
, "got %p, expected %p\n", item
, hRoot
);
1664 DestroyWindow(hTree
);
1667 START_TEST(treeview
)
1670 BOOL (WINAPI
*pInitCommonControlsEx
)(const INITCOMMONCONTROLSEX
*);
1674 ULONG_PTR ctx_cookie
;
1678 hComctl32
= GetModuleHandleA("comctl32.dll");
1679 pInitCommonControlsEx
= (void*)GetProcAddress(hComctl32
, "InitCommonControlsEx");
1680 if (pInitCommonControlsEx
)
1682 INITCOMMONCONTROLSEX iccex
;
1683 iccex
.dwSize
= sizeof(iccex
);
1684 iccex
.dwICC
= ICC_TREEVIEW_CLASSES
;
1685 pInitCommonControlsEx(&iccex
);
1688 InitCommonControls();
1690 init_msg_sequences(sequences
, NUM_MSG_SEQUENCES
);
1691 init_msg_sequences(item_sequence
, 1);
1693 wc
.style
= CS_HREDRAW
| CS_VREDRAW
;
1696 wc
.hInstance
= GetModuleHandleA(NULL
);
1698 wc
.hCursor
= LoadCursorA(NULL
, IDC_IBEAM
);
1699 wc
.hbrBackground
= GetSysColorBrush(COLOR_WINDOW
);
1700 wc
.lpszMenuName
= NULL
;
1701 wc
.lpszClassName
= "MyTestWnd";
1702 wc
.lpfnWndProc
= parent_wnd_proc
;
1703 RegisterClassA(&wc
);
1705 hMainWnd
= CreateWindowExA(0, "MyTestWnd", "Blah", WS_OVERLAPPEDWINDOW
,
1706 CW_USEDEFAULT
, CW_USEDEFAULT
, 130, 105, NULL
, NULL
, GetModuleHandleA(NULL
), 0);
1708 ok(hMainWnd
!= NULL
, "Failed to create parent window. Tests aborted.\n");
1709 if (!hMainWnd
) return;
1715 test_get_set_bkcolor();
1716 test_get_set_imagelist();
1717 test_get_set_indent();
1718 test_get_set_insertmark();
1719 test_get_set_item();
1720 test_get_set_itemheight();
1721 test_get_set_scrolltime();
1722 test_get_set_textcolor();
1723 test_get_linecolor();
1724 test_get_insertmarkcolor();
1725 test_get_set_tooltips();
1726 test_get_set_unicodeformat();
1728 test_expandinvisible();
1730 test_treeview_classinfo();
1731 test_expandnotify();
1732 test_TVS_SINGLEEXPAND();
1734 test_delete_items();
1735 test_htreeitem_layout();
1736 test_TVS_CHECKBOXES();
1737 test_TVM_GETNEXTITEM();
1739 if (!load_v6_module(&ctx_cookie
, &hCtx
))
1741 DestroyWindow(hMainWnd
);
1745 /* this is a XP SP3 failure workaround */
1746 hwnd
= CreateWindowExA(0, WC_TREEVIEW
, "foo",
1747 WS_CHILD
| WS_BORDER
| WS_VISIBLE
,
1749 hMainWnd
, NULL
, GetModuleHandleA(NULL
), NULL
);
1750 if (!IsWindow(hwnd
))
1752 win_skip("FIXME: failed to create TreeView window.\n");
1753 unload_v6_module(ctx_cookie
, hCtx
);
1754 DestroyWindow(hMainWnd
);
1758 DestroyWindow(hwnd
);
1760 /* comctl32 version 6 tests start here */
1761 test_expandedimage();
1762 test_htreeitem_layout();
1764 unload_v6_module(ctx_cookie
, hCtx
);
1766 PostMessageA(hMainWnd
, WM_CLOSE
, 0, 0);
1767 while(GetMessageA(&msg
, 0, 0, 0))
1769 TranslateMessage(&msg
);
1770 DispatchMessageA(&msg
);