1 /* Unit tests for toolbar.
3 * Copyright 2005 Krzysztof Foltman
4 * Copyright 2007 Mikolaj Zalewski
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 "resources.h"
34 #include "wine/test.h"
38 #define PARENT_SEQ_INDEX 0
39 #define NUM_MSG_SEQUENCES 1
41 static struct msg_sequence *sequences[NUM_MSG_SEQUENCES];
44 static BOOL g_fBlockHotItemChange;
45 static BOOL g_fReceivedHotItemChange;
46 static BOOL g_fExpectedHotItemOld;
47 static BOOL g_fExpectedHotItemNew;
48 static DWORD g_dwExpectedDispInfoMask;
49 static BOOL g_ResetDispTextPtr;
51 static const struct message ttgetdispinfo_parent_seq[] = {
52 { WM_NOTIFY, sent|id, 0, 0, TBN_GETINFOTIPA },
53 /* next line is todo, currently TTN_GETDISPINFOW is raised here */
54 { WM_NOTIFY, sent|id, 0, 0, TTN_GETDISPINFOA },
58 #define expect(EXPECTED,GOT) ok((GOT)==(EXPECTED), "Expected %d, got %d\n", (EXPECTED), (GOT))
60 #define check_rect(name, val, exp, ...) ok(val.top == exp.top && val.bottom == exp.bottom && \
61 val.left == exp.left && val.right == exp.right, "invalid rect (%d,%d) (%d,%d) - expected (%d,%d) (%d,%d) - (" name ")\n", \
62 val.left, val.top, val.right, val.bottom, exp.left, exp.top, exp.right, exp.bottom, __VA_ARGS__);
64 #define compare(val, exp, format) ok((val) == (exp), #val " value " format " expected " format "\n", (val), (exp));
66 #define check_button_size(handle, width, height, ...) {\
67 DWORD bsize = SendMessageA(handle, TB_GETBUTTONSIZE, 0, 0);\
68 ok(bsize == MAKELONG(width, height), "Unexpected button size - got size (%d, %d), expected (%d, %d)\n", LOWORD(bsize), HIWORD(bsize), width, height);\
71 static void MakeButton(TBBUTTON *p, int idCommand, int fsStyle, int nString) {
73 p->idCommand = idCommand;
74 p->fsState = TBSTATE_ENABLED;
79 static LRESULT parent_wnd_notify(LPARAM lParam)
81 NMHDR *hdr = (NMHDR *)lParam;
86 case TBN_HOTITEMCHANGE:
87 nmhi = (NMTBHOTITEM *)lParam;
88 g_fReceivedHotItemChange = TRUE;
89 if (g_fExpectedHotItemOld != g_fExpectedHotItemNew)
91 compare(nmhi->idOld, g_fExpectedHotItemOld, "%d");
92 compare(nmhi->idNew, g_fExpectedHotItemNew, "%d");
94 if (g_fBlockHotItemChange)
98 case TBN_GETDISPINFOA:
99 ok(FALSE, "TBN_GETDISPINFOA received\n");
102 case TBN_GETINFOTIPA:
104 NMTBGETINFOTIPA *tbgit = (NMTBGETINFOTIPA*)lParam;
106 if (g_ResetDispTextPtr)
108 tbgit->pszText = NULL;
113 case TBN_GETDISPINFOW:
114 nmdisp = (NMTBDISPINFOA *)lParam;
116 compare(nmdisp->dwMask, g_dwExpectedDispInfoMask, "%x");
117 ok(nmdisp->pszText == NULL, "pszText is not NULL\n");
123 static LRESULT CALLBACK parent_wnd_proc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
125 static LONG defwndproc_counter = 0;
129 msg.message = message;
130 msg.flags = sent|wparam|lparam;
131 if (defwndproc_counter) msg.flags |= defwinproc;
134 if (message == WM_NOTIFY && lParam) msg.id = ((NMHDR*)lParam)->code;
136 /* log system messages, except for painting */
137 if (message < WM_USER &&
138 message != WM_PAINT &&
139 message != WM_ERASEBKGND &&
140 message != WM_NCPAINT &&
141 message != WM_NCHITTEST &&
142 message != WM_GETTEXT &&
143 message != WM_GETICON &&
144 message != WM_DEVICECHANGE)
146 trace("parent: %p, %04x, %08lx, %08lx\n", hWnd, message, wParam, lParam);
147 add_message(sequences, PARENT_SEQ_INDEX, &msg);
153 return parent_wnd_notify(lParam);
156 defwndproc_counter++;
157 ret = DefWindowProcA(hWnd, message, wParam, lParam);
158 defwndproc_counter--;
163 static void basic_test(void)
169 MakeButton(buttons+i, 1000+i, TBSTYLE_CHECKGROUP, 0);
170 MakeButton(buttons+3, 1003, TBSTYLE_SEP|TBSTYLE_GROUP, 0);
171 MakeButton(buttons+6, 1006, TBSTYLE_SEP, 0);
173 hToolbar = CreateToolbarEx(hMainWnd,
174 WS_VISIBLE | WS_CLIPCHILDREN | CCS_TOP |
175 WS_CHILD | TBSTYLE_LIST,
178 buttons, sizeof(buttons)/sizeof(buttons[0]),
179 0, 0, 20, 16, sizeof(TBBUTTON));
180 ok(hToolbar != NULL, "Toolbar creation\n");
181 SendMessage(hToolbar, TB_ADDSTRINGA, 0, (LPARAM)"test\000");
183 /* test for exclusion working inside a separator-separated :-) group */
184 SendMessage(hToolbar, TB_CHECKBUTTON, 1000, 1); /* press A1 */
185 ok(SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1000, 0), "A1 pressed\n");
186 ok(!SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1001, 0), "A2 not pressed\n");
188 SendMessage(hToolbar, TB_CHECKBUTTON, 1004, 1); /* press A5, release A1 */
189 ok(SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1004, 0), "A5 pressed\n");
190 ok(!SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1000, 0), "A1 not pressed anymore\n");
192 SendMessage(hToolbar, TB_CHECKBUTTON, 1005, 1); /* press A6, release A5 */
193 ok(SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1005, 0), "A6 pressed\n");
194 ok(!SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1004, 0), "A5 not pressed anymore\n");
196 /* test for inter-group crosstalk, ie. two radio groups interfering with each other */
197 SendMessage(hToolbar, TB_CHECKBUTTON, 1007, 1); /* press B2 */
198 ok(SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1005, 0), "A6 still pressed, no inter-group crosstalk\n");
199 ok(!SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1000, 0), "A1 still not pressed\n");
200 ok(SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1007, 0), "B2 pressed\n");
202 SendMessage(hToolbar, TB_CHECKBUTTON, 1000, 1); /* press A1 and ensure B group didn't suffer */
203 ok(!SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1005, 0), "A6 not pressed anymore\n");
204 ok(SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1000, 0), "A1 pressed\n");
205 ok(SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1007, 0), "B2 still pressed\n");
207 SendMessage(hToolbar, TB_CHECKBUTTON, 1008, 1); /* press B3, and ensure A group didn't suffer */
208 ok(!SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1005, 0), "A6 pressed\n");
209 ok(SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1000, 0), "A1 pressed\n");
210 ok(!SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1007, 0), "B2 not pressed\n");
211 ok(SendMessage(hToolbar, TB_ISBUTTONCHECKED, 1008, 0), "B3 pressed\n");
213 /* tests with invalid index */
214 compare(SendMessage(hToolbar, TB_ISBUTTONCHECKED, 0xdeadbeef, 0), -1L, "%ld");
215 compare(SendMessage(hToolbar, TB_ISBUTTONPRESSED, 0xdeadbeef, 0), -1L, "%ld");
216 compare(SendMessage(hToolbar, TB_ISBUTTONENABLED, 0xdeadbeef, 0), -1L, "%ld");
217 compare(SendMessage(hToolbar, TB_ISBUTTONINDETERMINATE, 0xdeadbeef, 0), -1L, "%ld");
218 compare(SendMessage(hToolbar, TB_ISBUTTONHIGHLIGHTED, 0xdeadbeef, 0), -1L, "%ld");
219 compare(SendMessage(hToolbar, TB_ISBUTTONHIDDEN, 0xdeadbeef, 0), -1L, "%ld");
221 DestroyWindow(hToolbar);
224 static void rebuild_toolbar(HWND *hToolbar)
227 DestroyWindow(*hToolbar);
228 *hToolbar = CreateWindowEx(0, TOOLBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE, 0, 0, 0, 0,
229 hMainWnd, (HMENU)5, GetModuleHandle(NULL), NULL);
230 ok(*hToolbar != NULL, "Toolbar creation problem\n");
231 ok(SendMessage(*hToolbar, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0) == 0, "TB_BUTTONSTRUCTSIZE failed\n");
232 ok(SendMessage(*hToolbar, TB_AUTOSIZE, 0, 0) == 0, "TB_AUTOSIZE failed\n");
233 ok(SendMessage(*hToolbar, WM_SETFONT, (WPARAM)GetStockObject(SYSTEM_FONT), 0)==1, "WM_SETFONT\n");
236 static void rebuild_toolbar_with_buttons(HWND *hToolbar)
239 rebuild_toolbar(hToolbar);
241 ZeroMemory(&buttons, sizeof(buttons));
242 buttons[0].idCommand = 1;
243 buttons[0].fsStyle = BTNS_BUTTON;
244 buttons[0].fsState = TBSTATE_ENABLED;
245 buttons[0].iString = -1;
246 buttons[1].idCommand = 3;
247 buttons[1].fsStyle = BTNS_BUTTON;
248 buttons[1].fsState = TBSTATE_ENABLED;
249 buttons[1].iString = -1;
250 buttons[2].idCommand = 5;
251 buttons[2].fsStyle = BTNS_SEP;
252 buttons[2].fsState = TBSTATE_ENABLED;
253 buttons[2].iString = -1;
254 buttons[3].idCommand = 7;
255 buttons[3].fsStyle = BTNS_BUTTON;
256 buttons[3].fsState = TBSTATE_ENABLED;
257 buttons[3].iString = -1;
258 buttons[4].idCommand = 9;
259 buttons[4].fsStyle = BTNS_BUTTON;
260 buttons[4].fsState = 0; /* disabled */
261 buttons[4].iString = -1;
262 ok(SendMessage(*hToolbar, TB_ADDBUTTONS, 5, (LPARAM)buttons) == 1, "TB_ADDBUTTONS failed\n");
263 ok(SendMessage(*hToolbar, TB_AUTOSIZE, 0, 0) == 0, "TB_AUTOSIZE failed\n");
266 static void add_128x15_bitmap(HWND hToolbar, int nCmds)
269 bmp128.hInst = GetModuleHandle(NULL);
270 bmp128.nID = IDB_BITMAP_128x15;
271 ok(SendMessageA(hToolbar, TB_ADDBITMAP, nCmds, (LPARAM)&bmp128) == 0, "TB_ADDBITMAP - unexpected return\n");
274 #define CHECK_IMAGELIST(count, dx, dy) { \
276 HIMAGELIST himl = (HIMAGELIST)SendMessageA(hToolbar, TB_GETIMAGELIST, 0, 0); \
277 ok(himl != NULL, "No image list\n"); \
279 ok(ImageList_GetImageCount(himl) == count, "Images count mismatch - %d vs %d\n", count, ImageList_GetImageCount(himl)); \
280 ImageList_GetIconSize(himl, &cx, &cy); \
281 ok(cx == dx && cy == dy, "Icon size mismatch - %dx%d vs %dx%d\n", dx, dy, cx, cy); \
285 static void test_add_bitmap(void)
287 HWND hToolbar = NULL;
290 TBADDBITMAP stdsmall;
295 /* empty 128x15 bitmap */
296 bmp128.hInst = GetModuleHandle(NULL);
297 bmp128.nID = IDB_BITMAP_128x15;
299 /* empty 80x15 bitmap */
300 bmp80.hInst = GetModuleHandle(NULL);
301 bmp80.nID = IDB_BITMAP_80x15;
303 /* standard bitmap - 240x15 pixels */
304 stdsmall.hInst = HINST_COMMCTRL;
305 stdsmall.nID = IDB_STD_SMALL_COLOR;
307 rebuild_toolbar(&hToolbar);
308 ok(SendMessageA(hToolbar, TB_ADDBITMAP, 8, (LPARAM)&bmp128) == 0, "TB_ADDBITMAP - unexpected return\n");
309 CHECK_IMAGELIST(8, 16, 16);
311 /* adding more bitmaps */
312 ok(SendMessageA(hToolbar, TB_ADDBITMAP, 5, (LPARAM)&bmp80) == 8, "TB_ADDBITMAP - unexpected return\n");
313 CHECK_IMAGELIST(13, 16, 16);
314 /* adding the same bitmap will simply return the index of the already loaded block */
315 ret = SendMessageA(hToolbar, TB_ADDBITMAP, 8, (LPARAM)&bmp128);
316 ok(ret == 0, "TB_ADDBITMAP - unexpected return %d\n", ret);
317 CHECK_IMAGELIST(13, 16, 16);
318 ret = SendMessageA(hToolbar, TB_ADDBITMAP, 5, (LPARAM)&bmp80);
319 ok(ret == 8, "TB_ADDBITMAP - unexpected return %d\n", ret);
320 CHECK_IMAGELIST(13, 16, 16);
321 /* even if we increase the wParam */
322 ret = SendMessageA(hToolbar, TB_ADDBITMAP, 55, (LPARAM)&bmp80);
323 ok(ret == 8, "TB_ADDBITMAP - unexpected return %d\n", ret);
324 CHECK_IMAGELIST(13, 16, 16);
326 /* when the wParam is smaller than the bitmaps count but non-zero, all the bitmaps will be added*/
327 rebuild_toolbar(&hToolbar);
328 ok(SendMessageA(hToolbar, TB_ADDBITMAP, 3, (LPARAM)&bmp128) == 0, "TB_ADDBITMAP - unexpected return\n");
329 CHECK_IMAGELIST(8, 16, 16);
330 ret = SendMessageA(hToolbar, TB_ADDBITMAP, 5, (LPARAM)&bmp80);
331 ok(ret == 3, "TB_ADDBITMAP - unexpected return %d\n", ret);
332 /* the returned value is misleading - id 8 is the id of the first icon from bmp80 */
333 CHECK_IMAGELIST(13, 16, 16);
335 /* the same for negative wParam */
336 rebuild_toolbar(&hToolbar);
337 ret = SendMessageA(hToolbar, TB_ADDBITMAP, -143, (LPARAM)&bmp128);
338 ok(ret == 0, "TB_ADDBITMAP - unexpected return %d\n", ret);
339 CHECK_IMAGELIST(8, 16, 16);
340 ret = SendMessageA(hToolbar, TB_ADDBITMAP, 1, (LPARAM)&bmp80);
341 ok(ret == -143, "TB_ADDBITMAP - unexpected return %d\n", ret);
342 CHECK_IMAGELIST(13, 16, 16);
344 /* for zero only one bitmap will be added */
345 rebuild_toolbar(&hToolbar);
346 ret = SendMessageA(hToolbar, TB_ADDBITMAP, 0, (LPARAM)&bmp80);
347 ok(ret == 0, "TB_ADDBITMAP - unexpected return %d\n", ret);
348 CHECK_IMAGELIST(1, 16, 16);
350 /* if wParam is larger than the amount of icons, the list is grown */
351 rebuild_toolbar(&hToolbar);
352 ok(SendMessageA(hToolbar, TB_ADDBITMAP, 100, (LPARAM)&bmp80) == 0, "TB_ADDBITMAP - unexpected return\n");
353 CHECK_IMAGELIST(100, 16, 16);
354 ret = SendMessageA(hToolbar, TB_ADDBITMAP, 100, (LPARAM)&bmp128);
355 ok(ret == 100, "TB_ADDBITMAP - unexpected return %d\n", ret);
356 CHECK_IMAGELIST(200, 16, 16);
358 /* adding built-in items - the wParam is ignored */
359 rebuild_toolbar(&hToolbar);
360 ok(SendMessageA(hToolbar, TB_ADDBITMAP, 5, (LPARAM)&bmp80) == 0, "TB_ADDBITMAP - unexpected return\n");
361 CHECK_IMAGELIST(5, 16, 16);
362 ok(SendMessageA(hToolbar, TB_ADDBITMAP, 0, (LPARAM)&stdsmall) == 5, "TB_ADDBITMAP - unexpected return\n");
363 CHECK_IMAGELIST(20, 16, 16);
364 ok(SendMessageA(hToolbar, TB_ADDBITMAP, 5, (LPARAM)&bmp128) == 20, "TB_ADDBITMAP - unexpected return\n");
365 CHECK_IMAGELIST(28, 16, 16);
367 /* when we increase the bitmap size, less icons will be created */
368 rebuild_toolbar(&hToolbar);
369 ok(SendMessageA(hToolbar, TB_SETBITMAPSIZE, 0, MAKELONG(20, 20)) == TRUE, "TB_SETBITMAPSIZE failed\n");
370 ok(SendMessageA(hToolbar, TB_ADDBITMAP, 1, (LPARAM)&bmp128) == 0, "TB_ADDBITMAP - unexpected return\n");
371 CHECK_IMAGELIST(6, 20, 20);
372 ret = SendMessageA(hToolbar, TB_ADDBITMAP, 1, (LPARAM)&bmp80);
373 ok(ret == 1, "TB_ADDBITMAP - unexpected return %d\n", ret);
374 CHECK_IMAGELIST(10, 20, 20);
375 /* the icons can be resized - an UpdateWindow is needed as this probably happens during WM_PAINT */
376 ok(SendMessageA(hToolbar, TB_SETBITMAPSIZE, 0, MAKELONG(8, 8)) == TRUE, "TB_SETBITMAPSIZE failed\n");
377 UpdateWindow(hToolbar);
378 CHECK_IMAGELIST(26, 8, 8);
379 /* loading a standard bitmaps automatically resizes the icons */
380 ok(SendMessageA(hToolbar, TB_ADDBITMAP, 1, (LPARAM)&stdsmall) == 2, "TB_ADDBITMAP - unexpected return\n");
381 UpdateWindow(hToolbar);
382 CHECK_IMAGELIST(28, 16, 16);
384 /* two more SETBITMAPSIZE tests */
385 rebuild_toolbar(&hToolbar);
386 ok(SendMessageA(hToolbar, TB_ADDBITMAP, 100, (LPARAM)&bmp128) == 0, "TB_ADDBITMAP - unexpected return\n");
387 CHECK_IMAGELIST(100, 16, 16);
388 ok(SendMessageA(hToolbar, TB_ADDBITMAP, 100, (LPARAM)&bmp80) == 100, "TB_ADDBITMAP - unexpected return\n");
389 CHECK_IMAGELIST(200, 16, 16);
390 ok(SendMessageA(hToolbar, TB_SETBITMAPSIZE, 0, MAKELONG(8, 8)) == TRUE, "TB_SETBITMAPSIZE failed\n");
391 UpdateWindow(hToolbar);
392 CHECK_IMAGELIST(200, 8, 8);
393 ok(SendMessageA(hToolbar, TB_SETBITMAPSIZE, 0, MAKELONG(30, 30)) == TRUE, "TB_SETBITMAPSIZE failed\n");
394 UpdateWindow(hToolbar);
395 CHECK_IMAGELIST(200, 30, 30);
396 rebuild_toolbar(&hToolbar);
397 ok(SendMessageA(hToolbar, TB_ADDBITMAP, 5, (LPARAM)&bmp128) == 0, "TB_ADDBITMAP - unexpected return\n");
398 CHECK_IMAGELIST(8, 16, 16);
399 ok(SendMessageA(hToolbar, TB_ADDBITMAP, 3, (LPARAM)&bmp80) == 5, "TB_ADDBITMAP - unexpected return\n");
400 CHECK_IMAGELIST(13, 16, 16);
401 ok(SendMessageA(hToolbar, TB_SETBITMAPSIZE, 0, MAKELONG(30, 30)) == TRUE, "TB_SETBITMAPSIZE failed\n");
402 UpdateWindow(hToolbar);
403 CHECK_IMAGELIST(8, 30, 30);
404 /* when the width or height is zero, set it to 1 */
405 ok(SendMessageA(hToolbar, TB_SETBITMAPSIZE, 0, MAKELONG(0, 0)) == TRUE, "TB_SETBITMAPSIZE failed\n");
406 UpdateWindow(hToolbar);
407 CHECK_IMAGELIST(208, 1, 1);
408 ok(SendMessageA(hToolbar, TB_SETBITMAPSIZE, 0, MAKELONG(0, 5)) == TRUE, "TB_SETBITMAPSIZE failed\n");
409 UpdateWindow(hToolbar);
410 CHECK_IMAGELIST(208, 1, 5);
411 ok(SendMessageA(hToolbar, TB_SETBITMAPSIZE, 0, MAKELONG(5, 0)) == TRUE, "TB_SETBITMAPSIZE failed\n");
412 UpdateWindow(hToolbar);
413 CHECK_IMAGELIST(41, 5, 1);
415 /* the control can add bitmaps to an existing image list */
416 rebuild_toolbar(&hToolbar);
417 himl = ImageList_LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_BITMAP_80x15), 20, 2, CLR_NONE, IMAGE_BITMAP, LR_DEFAULTCOLOR);
418 ok(himl != NULL, "failed to create imagelist\n");
419 ok(SendMessageA(hToolbar, TB_SETIMAGELIST, 0, (LPARAM)himl) == 0, "TB_SETIMAGELIST failed\n");
420 CHECK_IMAGELIST(4, 20, 15);
421 ok(SendMessageA(hToolbar, TB_ADDBITMAP, 1, (LPARAM)&bmp128) == 0, "TB_ADDBITMAP - unexpected return\n");
422 CHECK_IMAGELIST(10, 20, 15);
423 /* however TB_SETBITMAPSIZE/add std bitmap won't change the image size (the button size does change) */
424 ok(SendMessageA(hToolbar, TB_SETBITMAPSIZE, 0, MAKELONG(8, 8)) == TRUE, "TB_SETBITMAPSIZE failed\n");
425 UpdateWindow(hToolbar);
426 compare((int)SendMessageA(hToolbar, TB_GETBUTTONSIZE, 0, 0), MAKELONG(15, 14), "%x");
427 CHECK_IMAGELIST(10, 20, 15);
428 ok(SendMessageA(hToolbar, TB_ADDBITMAP, 0, (LPARAM)&stdsmall) == 1, "TB_SETBITMAPSIZE failed\n");
429 UpdateWindow(hToolbar);
430 compare((int)SendMessageA(hToolbar, TB_GETBUTTONSIZE, 0, 0), MAKELONG(23, 22), "%x");
431 CHECK_IMAGELIST(22, 20, 15);
433 /* check standard bitmaps */
434 addbmp.hInst = HINST_COMMCTRL;
435 addbmp.nID = IDB_STD_SMALL_COLOR;
436 rebuild_toolbar(&hToolbar);
437 ImageList_Destroy(himl);
439 ok(SendMessageA(hToolbar, TB_ADDBITMAP, 1, (LPARAM)&addbmp) == 0, "TB_ADDBITMAP - unexpected return\n");
440 CHECK_IMAGELIST(15, 16, 16);
441 compare((int)SendMessageA(hToolbar, TB_GETBUTTONSIZE, 0, 0), MAKELONG(23, 22), "%x");
442 addbmp.nID = IDB_STD_LARGE_COLOR;
443 rebuild_toolbar(&hToolbar);
444 ok(SendMessageA(hToolbar, TB_ADDBITMAP, 1, (LPARAM)&addbmp) == 0, "TB_ADDBITMAP - unexpected return\n");
445 CHECK_IMAGELIST(15, 24, 24);
446 compare((int)SendMessageA(hToolbar, TB_GETBUTTONSIZE, 0, 0), MAKELONG(31, 30), "%x");
448 addbmp.nID = IDB_VIEW_SMALL_COLOR;
449 rebuild_toolbar(&hToolbar);
450 ok(SendMessageA(hToolbar, TB_ADDBITMAP, 1, (LPARAM)&addbmp) == 0, "TB_ADDBITMAP - unexpected return\n");
451 CHECK_IMAGELIST(12, 16, 16);
452 addbmp.nID = IDB_VIEW_LARGE_COLOR;
453 rebuild_toolbar(&hToolbar);
454 ok(SendMessageA(hToolbar, TB_ADDBITMAP, 1, (LPARAM)&addbmp) == 0, "TB_ADDBITMAP - unexpected return\n");
455 CHECK_IMAGELIST(12, 24, 24);
457 addbmp.nID = IDB_HIST_SMALL_COLOR;
458 rebuild_toolbar(&hToolbar);
459 ok(SendMessageA(hToolbar, TB_ADDBITMAP, 1, (LPARAM)&addbmp) == 0, "TB_ADDBITMAP - unexpected return\n");
460 CHECK_IMAGELIST(5, 16, 16);
461 addbmp.nID = IDB_HIST_LARGE_COLOR;
462 rebuild_toolbar(&hToolbar);
463 ok(SendMessageA(hToolbar, TB_ADDBITMAP, 1, (LPARAM)&addbmp) == 0, "TB_ADDBITMAP - unexpected return\n");
464 CHECK_IMAGELIST(5, 24, 24);
467 DestroyWindow(hToolbar);
470 #define CHECK_STRING_TABLE(count, tab) { \
473 for (_i = 0; _i < (count); _i++) {\
474 ret = SendMessageA(hToolbar, TB_GETSTRING, MAKEWPARAM(260, _i), (LPARAM)_buf); \
475 ok(ret >= 0, "TB_GETSTRING - unexpected return %d while checking string %d\n", ret, _i); \
477 ok(strcmp(_buf, (tab)[_i]) == 0, "Invalid string #%d - '%s' vs '%s'\n", _i, (tab)[_i], _buf); \
479 ok(SendMessageA(hToolbar, TB_GETSTRING, MAKEWPARAM(260, (count)), (LPARAM)_buf) == -1, \
480 "Too many strings in table\n"); \
483 static void test_add_string(void)
485 LPCSTR test1 = "a\0b\0";
486 LPCSTR test2 = "|a|b||\0";
487 LPCSTR ret1[] = {"a", "b"};
488 LPCSTR ret2[] = {"a", "b", "|a|b||"};
489 LPCSTR ret3[] = {"a", "b", "|a|b||", "p", "q"};
490 LPCSTR ret4[] = {"a", "b", "|a|b||", "p", "q", "p"};
491 LPCSTR ret5[] = {"a", "b", "|a|b||", "p", "q", "p", "p", "q"};
492 LPCSTR ret6[] = {"a", "b", "|a|b||", "p", "q", "p", "p", "q", "p", "", "q"};
493 LPCSTR ret7[] = {"a", "b", "|a|b||", "p", "q", "p", "p", "q", "p", "", "q", "br", "c", "d"};
494 HWND hToolbar = NULL;
499 rebuild_toolbar(&hToolbar);
500 ret = SendMessageA(hToolbar, TB_ADDSTRINGA, 0, (LPARAM)test1);
501 ok(ret == 0, "TB_ADDSTRINGA - unexpected return %d\n", ret);
502 ret = SendMessageA(hToolbar, TB_GETSTRING, MAKEWPARAM(260, 1), (LPARAM)buf);
505 win_skip("TB_GETSTRING needs 5.80\n");
508 CHECK_STRING_TABLE(2, ret1);
509 ret = SendMessageA(hToolbar, TB_ADDSTRINGA, 0, (LPARAM)test2);
510 ok(ret == 2, "TB_ADDSTRINGA - unexpected return %d\n", ret);
511 CHECK_STRING_TABLE(3, ret2);
513 /* null instance handle */
514 ret = SendMessageA(hToolbar, TB_ADDSTRINGA, 0, IDS_TBADD1);
515 ok(ret == -1, "TB_ADDSTRINGA - unexpected return %d\n", ret);
517 /* invalid instance handle */
518 ret = SendMessageA(hToolbar, TB_ADDSTRINGA, 0xdeadbeef, IDS_TBADD1);
519 ok(ret == -1, "TB_ADDSTRINGA - unexpected return %d\n", ret);
521 ret = SendMessageA(hToolbar, TB_ADDSTRINGA, (WPARAM)GetModuleHandle(NULL), IDS_TBADD1);
522 ok(ret == 3, "TB_ADDSTRINGA - unexpected return %d\n", ret);
523 CHECK_STRING_TABLE(3, ret2);
524 ret = SendMessageA(hToolbar, TB_ADDSTRINGA, (WPARAM)GetModuleHandle(NULL), IDS_TBADD2);
525 ok(ret == 3, "TB_ADDSTRINGA - unexpected return %d\n", ret);
526 CHECK_STRING_TABLE(5, ret3);
527 ret = SendMessageA(hToolbar, TB_ADDSTRINGA, (WPARAM)GetModuleHandle(NULL), IDS_TBADD3);
528 ok(ret == 5, "TB_ADDSTRINGA - unexpected return %d\n", ret);
529 CHECK_STRING_TABLE(6, ret4);
530 ret = SendMessageA(hToolbar, TB_ADDSTRINGA, (WPARAM)GetModuleHandle(NULL), IDS_TBADD4);
531 ok(ret == 6, "TB_ADDSTRINGA - unexpected return %d\n", ret);
532 CHECK_STRING_TABLE(8, ret5);
533 ret = SendMessageA(hToolbar, TB_ADDSTRINGA, (WPARAM)GetModuleHandle(NULL), IDS_TBADD5);
534 ok(ret == 8, "TB_ADDSTRINGA - unexpected return %d\n", ret);
535 CHECK_STRING_TABLE(11, ret6);
536 ret = SendMessageA(hToolbar, TB_ADDSTRINGA, (WPARAM)GetModuleHandle(NULL), IDS_TBADD7);
537 ok(ret == 11, "TB_ADDSTRINGA - unexpected return %d\n", ret);
538 CHECK_STRING_TABLE(14, ret7);
540 ZeroMemory(&button, sizeof(button));
541 button.iString = (UINT_PTR)"Test";
542 SendMessageA(hToolbar, TB_INSERTBUTTONA, 0, (LPARAM)&button);
543 CHECK_STRING_TABLE(14, ret7);
544 SendMessageA(hToolbar, TB_ADDBUTTONSA, 1, (LPARAM)&button);
545 CHECK_STRING_TABLE(14, ret7);
547 DestroyWindow(hToolbar);
550 static void expect_hot_notify(int idold, int idnew)
552 g_fExpectedHotItemOld = idold;
553 g_fExpectedHotItemNew = idnew;
554 g_fReceivedHotItemChange = FALSE;
557 #define check_hot_notify() \
558 ok(g_fReceivedHotItemChange, "TBN_HOTITEMCHANGE not received\n"); \
559 g_fExpectedHotItemOld = g_fExpectedHotItemNew = 0;
561 static void test_hotitem(void)
563 HWND hToolbar = NULL;
567 g_fBlockHotItemChange = FALSE;
569 rebuild_toolbar_with_buttons(&hToolbar);
570 /* set TBSTYLE_FLAT. comctl5 allows hot items only for such toolbars.
571 * comctl6 doesn't have this requirement even when theme == NULL */
572 SetWindowLong(hToolbar, GWL_STYLE, TBSTYLE_FLAT | GetWindowLong(hToolbar, GWL_STYLE));
573 ret = SendMessage(hToolbar, TB_GETHOTITEM, 0, 0);
574 ok(ret == -1, "Hot item: %ld, expected -1\n", ret);
575 ret = SendMessage(hToolbar, TB_SETHOTITEM, 1, 0);
576 ok(ret == -1, "TB_SETHOTITEM returned %ld, expected -1\n", ret);
577 ret = SendMessage(hToolbar, TB_GETHOTITEM, 0, 0);
578 ok(ret == 1, "Hot item: %ld, expected 1\n", ret);
579 ret = SendMessage(hToolbar, TB_SETHOTITEM, 2, 0);
580 ok(ret == 1, "TB_SETHOTITEM returned %ld, expected 1\n", ret);
582 ret = SendMessage(hToolbar, TB_SETHOTITEM, 0xbeef, 0);
583 ok(ret == 2, "TB_SETHOTITEM returned %ld, expected 2\n", ret);
584 ret = SendMessage(hToolbar, TB_GETHOTITEM, 0, 0);
585 ok(ret == 2, "Hot item: %lx, expected 2\n", ret);
586 ret = SendMessage(hToolbar, TB_SETHOTITEM, -0xbeef, 0);
587 ok(ret == 2, "TB_SETHOTITEM returned %ld, expected 2\n", ret);
588 ret = SendMessage(hToolbar, TB_GETHOTITEM, 0, 0);
589 ok(ret == -1, "Hot item: %lx, expected -1\n", ret);
591 expect_hot_notify(0, 7);
592 ret = SendMessage(hToolbar, TB_SETHOTITEM, 3, 0);
593 ok(ret == -1, "TB_SETHOTITEM returned %ld, expected -1\n", ret);
595 ret = SendMessage(hToolbar, TB_GETHOTITEM, 0, 0);
596 ok(ret == 3, "Hot item: %lx, expected 3\n", ret);
597 g_fBlockHotItemChange = TRUE;
598 ret = SendMessage(hToolbar, TB_SETHOTITEM, 2, 0);
599 ok(ret == 3, "TB_SETHOTITEM returned %ld, expected 2\n", ret);
600 ret = SendMessage(hToolbar, TB_GETHOTITEM, 0, 0);
601 ok(ret == 3, "Hot item: %lx, expected 3\n", ret);
602 g_fBlockHotItemChange = FALSE;
604 g_fReceivedHotItemChange = FALSE;
605 ret = SendMessage(hToolbar, TB_SETHOTITEM, 0xbeaf, 0);
606 ok(ret == 3, "TB_SETHOTITEM returned %ld, expected 3\n", ret);
607 ok(g_fReceivedHotItemChange == FALSE, "TBN_HOTITEMCHANGE received for invalid parameter\n");
609 g_fReceivedHotItemChange = FALSE;
610 ret = SendMessage(hToolbar, TB_SETHOTITEM, 3, 0);
611 ok(ret == 3, "TB_SETHOTITEM returned %ld, expected 3\n", ret);
612 ok(g_fReceivedHotItemChange == FALSE, "TBN_HOTITEMCHANGE received after a duplication\n");
614 expect_hot_notify(7, 0);
615 ret = SendMessage(hToolbar, TB_SETHOTITEM, -0xbeaf, 0);
616 ok(ret == 3, "TB_SETHOTITEM returned %ld, expected 3\n", ret);
618 SendMessage(hToolbar, TB_SETHOTITEM, 3, 0);
620 /* setting disabled buttons will generate a notify with the button id but no button will be hot */
621 expect_hot_notify(7, 9);
622 ret = SendMessage(hToolbar, TB_SETHOTITEM, 4, 0);
623 ok(ret == 3, "TB_SETHOTITEM returned %ld, expected 3\n", ret);
625 ret = SendMessage(hToolbar, TB_GETHOTITEM, 0, 0);
626 ok(ret == -1, "Hot item: %lx, expected -1\n", ret);
627 /* enabling the button won't change that */
628 SendMessage(hToolbar, TB_ENABLEBUTTON, 9, TRUE);
629 ret = SendMessage(hToolbar, TB_GETHOTITEM, 0, 0);
630 ok(ret == -1, "TB_SETHOTITEM returned %ld, expected -1\n", ret);
632 /* disabling a hot button works */
633 ret = SendMessage(hToolbar, TB_SETHOTITEM, 3, 0);
634 ok(ret == -1, "TB_SETHOTITEM returned %ld, expected -1\n", ret);
635 g_fReceivedHotItemChange = FALSE;
636 SendMessage(hToolbar, TB_ENABLEBUTTON, 7, FALSE);
637 ret = SendMessage(hToolbar, TB_GETHOTITEM, 0, 0);
638 ok(ret == 3, "TB_SETHOTITEM returned %ld, expected 3\n", ret);
639 ok(g_fReceivedHotItemChange == FALSE, "Unexpected TBN_HOTITEMCHANGE\n");
641 SendMessage(hToolbar, TB_SETHOTITEM, 1, 0);
642 tbinfo.cbSize = sizeof(TBBUTTONINFO);
643 tbinfo.dwMask = TBIF_STATE;
644 tbinfo.fsState = 0; /* disabled */
645 g_fReceivedHotItemChange = FALSE;
646 ok(SendMessage(hToolbar, TB_SETBUTTONINFO, 1, (LPARAM)&tbinfo) == TRUE, "TB_SETBUTTONINFO failed\n");
647 ret = SendMessage(hToolbar, TB_GETHOTITEM, 0, 0);
648 ok(ret == 1, "TB_SETHOTITEM returned %ld, expected 1\n", ret);
649 ok(g_fReceivedHotItemChange == FALSE, "Unexpected TBN_HOTITEMCHANGE\n");
651 DestroyWindow(hToolbar);
654 #if 0 /* use this to generate more tests*/
656 static void dump_sizes(HWND hToolbar)
660 int count = SendMessage(hToolbar, TB_BUTTONCOUNT, 0, 0);
663 GetClientRect(hToolbar, &r);
664 SendMessageA(hToolbar, TB_GETMAXSIZE, 0, &sz);
665 printf(" { {%d, %d, %d, %d}, {%d, %d}, %d, {", r.left, r.top, r.right, r.bottom,
666 sz.cx, sz.cy, count);
667 for (i=0; i<count; i++)
669 SendMessageA(hToolbar, TB_GETITEMRECT, i, &r);
670 printf("%s{%3d, %3d, %3d, %3d}, ", (i%3==0 ? "\n " : ""), r.left, r.top, r.right, r.bottom);
672 printf("\n }, },\n");
675 #define check_sizes() dump_sizes(hToolbar);
676 #define check_sizes_todo(todomask) dump_sizes(hToolbar);
680 static int system_font_height(void) {
684 hDC = CreateCompatibleDC(NULL);
685 GetTextMetrics(hDC, &tm);
691 static int string_width(const CHAR *s) {
695 hdc = CreateCompatibleDC(NULL);
696 GetTextExtentPoint32A(hdc, s, strlen(s), &sz);
710 tbsize_result_t init_tbsize_result(int nButtonsAlloc, int cleft, int ctop, int cright, int cbottom, int minx, int miny) {
711 tbsize_result_t *temp;
713 temp = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(tbsize_result_t));
714 SetRect(&temp->rcClient, cleft, ctop, cright, cbottom);
715 temp->szMin.cx = minx;
716 temp->szMin.cy = miny;
718 temp->prcButtons = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nButtonsAlloc*sizeof(RECT));
723 void tbsize_addbutton(tbsize_result_t *tbsr, int left, int top, int right, int bottom) {
724 SetRect(&tbsr->prcButtons[tbsr->nButtons], left, top, right, bottom);
729 #define STRING1 "MMMMMMMMMMMMM"
730 #define STRING2 "Tst"
732 tbsize_result_t *tbsize_results = NULL;
734 #define tbsize_results_num 24
736 static void init_tbsize_results(void) {
737 int fontheight = system_font_height();
740 tbsize_results = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, tbsize_results_num*sizeof(tbsize_result_t));
742 tbsize_results[0] = init_tbsize_result(5, 0, 0 ,672 ,26, 100 ,22);
743 tbsize_addbutton(&tbsize_results[0], 0, 2, 23, 24);
744 tbsize_addbutton(&tbsize_results[0], 23, 2, 46, 24);
745 tbsize_addbutton(&tbsize_results[0], 46, 2, 54, 24);
746 tbsize_addbutton(&tbsize_results[0], 54, 2, 77, 24);
747 tbsize_addbutton(&tbsize_results[0], 77, 2, 100, 24);
749 tbsize_results[1] = init_tbsize_result(7, 0, 0, 672, 26, 146, 22);
750 tbsize_addbutton(&tbsize_results[1], 0, 2, 23, 24);
751 tbsize_addbutton(&tbsize_results[1], 23, 2, 46, 24);
752 tbsize_addbutton(&tbsize_results[1], 46, 2, 54, 24);
753 tbsize_addbutton(&tbsize_results[1], 54, 2, 77, 24);
754 tbsize_addbutton(&tbsize_results[1], 77, 2, 100, 24);
755 tbsize_addbutton(&tbsize_results[1], 100, 2, 123, 24);
756 tbsize_addbutton(&tbsize_results[1], 0, 24, 23, 46);
758 tbsize_results[2] = init_tbsize_result(7, 0, 0, 672, 26, 146, 22);
759 tbsize_addbutton(&tbsize_results[2], 0, 2, 23, 24);
760 tbsize_addbutton(&tbsize_results[2], 23, 2, 46, 24);
761 tbsize_addbutton(&tbsize_results[2], 46, 2, 54, 24);
762 tbsize_addbutton(&tbsize_results[2], 54, 2, 77, 24);
763 tbsize_addbutton(&tbsize_results[2], 77, 2, 100, 24);
764 tbsize_addbutton(&tbsize_results[2], 100, 2, 123, 24);
765 tbsize_addbutton(&tbsize_results[2], 0, 24, 23, 46);
767 tbsize_results[3] = init_tbsize_result(7, 0, 0, 672, 26, 146, 22);
768 tbsize_addbutton(&tbsize_results[3], 0, 2, 23, 24);
769 tbsize_addbutton(&tbsize_results[3], 23, 2, 46, 24);
770 tbsize_addbutton(&tbsize_results[3], 46, 2, 54, 24);
771 tbsize_addbutton(&tbsize_results[3], 54, 2, 77, 24);
772 tbsize_addbutton(&tbsize_results[3], 77, 2, 100, 24);
773 tbsize_addbutton(&tbsize_results[3], 100, 2, 123, 24);
774 tbsize_addbutton(&tbsize_results[3], 123, 2, 146, 24);
776 tbsize_results[4] = init_tbsize_result(9, 0, 0, 672, 26, 192, 22);
777 tbsize_addbutton(&tbsize_results[4], 0, 2, 23, 24);
778 tbsize_addbutton(&tbsize_results[4], 23, 2, 46, 24);
779 tbsize_addbutton(&tbsize_results[4], 46, 2, 54, 24);
780 tbsize_addbutton(&tbsize_results[4], 54, 2, 77, 24);
781 tbsize_addbutton(&tbsize_results[4], 77, 2, 100, 24);
782 tbsize_addbutton(&tbsize_results[4], 100, 2, 123, 24);
783 tbsize_addbutton(&tbsize_results[4], 123, 2, 146, 24);
784 tbsize_addbutton(&tbsize_results[4], 146, 2, 169, 24);
785 tbsize_addbutton(&tbsize_results[4], 169, 2, 192, 24);
787 tbsize_results[5] = init_tbsize_result(39, 0, 0, 672, 92, 882, 22);
788 tbsize_addbutton(&tbsize_results[5], 0, 2, 23, 24);
789 tbsize_addbutton(&tbsize_results[5], 23, 2, 46, 24);
790 tbsize_addbutton(&tbsize_results[5], 0, 2, 8, 29);
791 tbsize_addbutton(&tbsize_results[5], 0, 29, 23, 51);
792 tbsize_addbutton(&tbsize_results[5], 23, 29, 46, 51);
793 tbsize_addbutton(&tbsize_results[5], 46, 29, 69, 51);
794 tbsize_addbutton(&tbsize_results[5], 69, 29, 92, 51);
795 tbsize_addbutton(&tbsize_results[5], 92, 29, 115, 51);
796 tbsize_addbutton(&tbsize_results[5], 115, 29, 138, 51);
797 tbsize_addbutton(&tbsize_results[5], 138, 29, 161, 51);
798 tbsize_addbutton(&tbsize_results[5], 161, 29, 184, 51);
799 tbsize_addbutton(&tbsize_results[5], 184, 29, 207, 51);
800 tbsize_addbutton(&tbsize_results[5], 207, 29, 230, 51);
801 tbsize_addbutton(&tbsize_results[5], 230, 29, 253, 51);
802 tbsize_addbutton(&tbsize_results[5], 253, 29, 276, 51);
803 tbsize_addbutton(&tbsize_results[5], 276, 29, 299, 51);
804 tbsize_addbutton(&tbsize_results[5], 299, 29, 322, 51);
805 tbsize_addbutton(&tbsize_results[5], 322, 29, 345, 51);
806 tbsize_addbutton(&tbsize_results[5], 345, 29, 368, 51);
807 tbsize_addbutton(&tbsize_results[5], 368, 29, 391, 51);
808 tbsize_addbutton(&tbsize_results[5], 391, 29, 414, 51);
809 tbsize_addbutton(&tbsize_results[5], 414, 29, 437, 51);
810 tbsize_addbutton(&tbsize_results[5], 437, 29, 460, 51);
811 tbsize_addbutton(&tbsize_results[5], 460, 29, 483, 51);
812 tbsize_addbutton(&tbsize_results[5], 483, 29, 506, 51);
813 tbsize_addbutton(&tbsize_results[5], 506, 29, 529, 51);
814 tbsize_addbutton(&tbsize_results[5], 529, 29, 552, 51);
815 tbsize_addbutton(&tbsize_results[5], 552, 29, 575, 51);
816 tbsize_addbutton(&tbsize_results[5], 575, 29, 598, 51);
817 tbsize_addbutton(&tbsize_results[5], 598, 29, 621, 51);
818 tbsize_addbutton(&tbsize_results[5], 621, 29, 644, 51);
819 tbsize_addbutton(&tbsize_results[5], 644, 29, 667, 51);
820 tbsize_addbutton(&tbsize_results[5], 0, 51, 23, 73);
821 tbsize_addbutton(&tbsize_results[5], 23, 51, 46, 73);
822 tbsize_addbutton(&tbsize_results[5], 46, 51, 69, 73);
823 tbsize_addbutton(&tbsize_results[5], 69, 51, 92, 73);
824 tbsize_addbutton(&tbsize_results[5], 92, 51, 115, 73);
825 tbsize_addbutton(&tbsize_results[5], 115, 51, 138, 73);
826 tbsize_addbutton(&tbsize_results[5], 138, 51, 161, 73);
828 tbsize_results[6] = init_tbsize_result(7, 0, 0, 48, 226, 23, 140);
829 tbsize_addbutton(&tbsize_results[6], 0, 2, 23, 24);
830 tbsize_addbutton(&tbsize_results[6], 23, 2, 46, 24);
831 tbsize_addbutton(&tbsize_results[6], 46, 2, 94, 24);
832 tbsize_addbutton(&tbsize_results[6], 94, 2, 117, 24);
833 tbsize_addbutton(&tbsize_results[6], 117, 2, 140, 24);
834 tbsize_addbutton(&tbsize_results[6], 140, 2, 163, 24);
835 tbsize_addbutton(&tbsize_results[6], 0, 24, 23, 46);
837 tbsize_results[7] = init_tbsize_result(7, 0, 0, 92, 226, 23, 140);
838 tbsize_addbutton(&tbsize_results[7], 0, 2, 23, 24);
839 tbsize_addbutton(&tbsize_results[7], 23, 2, 46, 24);
840 tbsize_addbutton(&tbsize_results[7], 0, 24, 92, 32);
841 tbsize_addbutton(&tbsize_results[7], 0, 32, 23, 54);
842 tbsize_addbutton(&tbsize_results[7], 23, 32, 46, 54);
843 tbsize_addbutton(&tbsize_results[7], 46, 32, 69, 54);
844 tbsize_addbutton(&tbsize_results[7], 69, 32, 92, 54);
846 tbsize_results[8] = init_tbsize_result(7, 0, 0, 672, 26, 194, 30);
847 tbsize_addbutton(&tbsize_results[8], 0, 2, 31, 32);
848 tbsize_addbutton(&tbsize_results[8], 31, 2, 62, 32);
849 tbsize_addbutton(&tbsize_results[8], 62, 2, 70, 32);
850 tbsize_addbutton(&tbsize_results[8], 70, 2, 101, 32);
851 tbsize_addbutton(&tbsize_results[8], 101, 2, 132, 32);
852 tbsize_addbutton(&tbsize_results[8], 132, 2, 163, 32);
853 tbsize_addbutton(&tbsize_results[8], 0, 32, 31, 62);
855 tbsize_results[9] = init_tbsize_result(7, 0, 0, 672, 64, 194, 30);
856 tbsize_addbutton(&tbsize_results[9], 0, 2, 31, 32);
857 tbsize_addbutton(&tbsize_results[9], 31, 2, 62, 32);
858 tbsize_addbutton(&tbsize_results[9], 62, 2, 70, 32);
859 tbsize_addbutton(&tbsize_results[9], 70, 2, 101, 32);
860 tbsize_addbutton(&tbsize_results[9], 101, 2, 132, 32);
861 tbsize_addbutton(&tbsize_results[9], 132, 2, 163, 32);
862 tbsize_addbutton(&tbsize_results[9], 0, 32, 31, 62);
864 tbsize_results[10] = init_tbsize_result(7, 0, 0, 672, 64, 194, 30);
865 tbsize_addbutton(&tbsize_results[10], 0, 0, 31, 30);
866 tbsize_addbutton(&tbsize_results[10], 31, 0, 62, 30);
867 tbsize_addbutton(&tbsize_results[10], 62, 0, 70, 30);
868 tbsize_addbutton(&tbsize_results[10], 70, 0, 101, 30);
869 tbsize_addbutton(&tbsize_results[10], 101, 0, 132, 30);
870 tbsize_addbutton(&tbsize_results[10], 132, 0, 163, 30);
871 tbsize_addbutton(&tbsize_results[10], 0, 30, 31, 60);
873 tbsize_results[11] = init_tbsize_result(7, 0, 0, 124, 226, 31, 188);
874 tbsize_addbutton(&tbsize_results[11], 0, 0, 31, 30);
875 tbsize_addbutton(&tbsize_results[11], 31, 0, 62, 30);
876 tbsize_addbutton(&tbsize_results[11], 0, 30, 124, 38);
877 tbsize_addbutton(&tbsize_results[11], 0, 38, 31, 68);
878 tbsize_addbutton(&tbsize_results[11], 31, 38, 62, 68);
879 tbsize_addbutton(&tbsize_results[11], 62, 38, 93, 68);
880 tbsize_addbutton(&tbsize_results[11], 93, 38, 124, 68);
882 tbsize_results[12] = init_tbsize_result(7, 0, 0, 672, 26, 146, 22);
883 tbsize_addbutton(&tbsize_results[12], 0, 2, 23, 24);
884 tbsize_addbutton(&tbsize_results[12], 23, 2, 46, 24);
885 tbsize_addbutton(&tbsize_results[12], 46, 2, 54, 24);
886 tbsize_addbutton(&tbsize_results[12], 54, 2, 77, 24);
887 tbsize_addbutton(&tbsize_results[12], 77, 2, 100, 24);
888 tbsize_addbutton(&tbsize_results[12], 100, 2, 123, 24);
889 tbsize_addbutton(&tbsize_results[12], 123, 2, 146, 24);
891 tbsize_results[13] = init_tbsize_result(7, 0, 0, 672, 26, 146, 100);
892 tbsize_addbutton(&tbsize_results[13], 0, 0, 23, 100);
893 tbsize_addbutton(&tbsize_results[13], 23, 0, 46, 100);
894 tbsize_addbutton(&tbsize_results[13], 46, 0, 54, 100);
895 tbsize_addbutton(&tbsize_results[13], 54, 0, 77, 100);
896 tbsize_addbutton(&tbsize_results[13], 77, 0, 100, 100);
897 tbsize_addbutton(&tbsize_results[13], 100, 0, 123, 100);
898 tbsize_addbutton(&tbsize_results[13], 123, 0, 146, 100);
900 tbsize_results[14] = init_tbsize_result(10, 0, 0, 672, 26, 146, 100);
901 tbsize_addbutton(&tbsize_results[14], 0, 0, 23, 100);
902 tbsize_addbutton(&tbsize_results[14], 23, 0, 46, 100);
903 tbsize_addbutton(&tbsize_results[14], 46, 0, 54, 100);
904 tbsize_addbutton(&tbsize_results[14], 54, 0, 77, 100);
905 tbsize_addbutton(&tbsize_results[14], 77, 0, 100, 100);
906 tbsize_addbutton(&tbsize_results[14], 100, 0, 123, 100);
907 tbsize_addbutton(&tbsize_results[14], 123, 0, 146, 100);
908 tbsize_addbutton(&tbsize_results[14], 146, 0, 169, 100);
909 tbsize_addbutton(&tbsize_results[14], 169, 0, 192, 100);
910 tbsize_addbutton(&tbsize_results[14], 192, 0, 215, 100);
912 tbsize_results[15] = init_tbsize_result(11, 0, 0, 672, 26, 238, 39);
913 tbsize_addbutton(&tbsize_results[15], 0, 0, 23, 23 + fontheight);
914 tbsize_addbutton(&tbsize_results[15], 23, 0, 46, 23 + fontheight);
915 tbsize_addbutton(&tbsize_results[15], 46, 0, 54, 23 + fontheight);
916 tbsize_addbutton(&tbsize_results[15], 54, 0, 77, 23 + fontheight);
917 tbsize_addbutton(&tbsize_results[15], 77, 0, 100, 23 + fontheight);
918 tbsize_addbutton(&tbsize_results[15], 100, 0, 123, 23 + fontheight);
919 tbsize_addbutton(&tbsize_results[15], 123, 0, 146, 23 + fontheight);
920 tbsize_addbutton(&tbsize_results[15], 146, 0, 169, 23 + fontheight);
921 tbsize_addbutton(&tbsize_results[15], 169, 0, 192, 23 + fontheight);
922 tbsize_addbutton(&tbsize_results[15], 192, 0, 215, 23 + fontheight);
923 tbsize_addbutton(&tbsize_results[15], 215, 0, 238, 23 + fontheight);
925 tbsize_results[16] = init_tbsize_result(11, 0, 0, 672, 26, 239, 22);
926 tbsize_addbutton(&tbsize_results[16], 0, 0, 23, 22);
927 tbsize_addbutton(&tbsize_results[16], 23, 0, 46, 22);
928 tbsize_addbutton(&tbsize_results[16], 46, 0, 54, 22);
929 tbsize_addbutton(&tbsize_results[16], 54, 0, 77, 22);
930 tbsize_addbutton(&tbsize_results[16], 77, 0, 100, 22);
931 tbsize_addbutton(&tbsize_results[16], 100, 0, 123, 22);
932 tbsize_addbutton(&tbsize_results[16], 123, 0, 146, 22);
933 tbsize_addbutton(&tbsize_results[16], 146, 0, 169, 22);
934 tbsize_addbutton(&tbsize_results[16], 169, 0, 192, 22);
935 tbsize_addbutton(&tbsize_results[16], 192, 0, 215, 22);
936 tbsize_addbutton(&tbsize_results[16], 215, 0, 238, 22);
938 buttonwidth = 7 + string_width(STRING1);
940 tbsize_results[17] = init_tbsize_result(3, 0, 0, 672, 26, 489, 39);
941 tbsize_addbutton(&tbsize_results[17], 0, 2, buttonwidth, 25 + fontheight);
942 tbsize_addbutton(&tbsize_results[17], buttonwidth, 2, 2*buttonwidth + 4, 25 + fontheight);
943 tbsize_addbutton(&tbsize_results[17], 2*buttonwidth + 4, 2, 3*buttonwidth + 4, 25 + fontheight);
945 tbsize_results[18] = init_tbsize_result(6, 0, 0, 672, 104, 978, 24);
946 tbsize_addbutton(&tbsize_results[18], 0, 2, buttonwidth, 10 + fontheight);
947 tbsize_addbutton(&tbsize_results[18], buttonwidth, 2, 2*buttonwidth, 10 + fontheight);
948 tbsize_addbutton(&tbsize_results[18], 2*buttonwidth, 2, 3*buttonwidth, 10 + fontheight);
949 tbsize_addbutton(&tbsize_results[18], 3*buttonwidth, 2, 4*buttonwidth, 10 + fontheight);
950 tbsize_addbutton(&tbsize_results[18], 4*buttonwidth, 2, 5*buttonwidth + 4, 10 + fontheight);
951 tbsize_addbutton(&tbsize_results[18], 5*buttonwidth + 4, 2, 5*buttonwidth + 4 + string_width(STRING2) + 11, 10 + fontheight);
953 tbsize_results[19] = init_tbsize_result(6, 0, 0, 672, 28, 978, 38);
954 tbsize_addbutton(&tbsize_results[19], 0, 0, buttonwidth, 22 + fontheight);
955 tbsize_addbutton(&tbsize_results[19], buttonwidth, 0, 2*buttonwidth, 22 + fontheight);
956 tbsize_addbutton(&tbsize_results[19], 2*buttonwidth, 0, 3*buttonwidth, 22 + fontheight);
957 tbsize_addbutton(&tbsize_results[19], 3*buttonwidth, 0, 4*buttonwidth, 22 + fontheight);
958 tbsize_addbutton(&tbsize_results[19], 4*buttonwidth, 0, 5*buttonwidth + 4, 22 + fontheight);
959 tbsize_addbutton(&tbsize_results[19], 5*buttonwidth + 4, 0, 5*buttonwidth + 4 + string_width(STRING2) + 11, 22 + fontheight);
961 tbsize_results[20] = init_tbsize_result(3, 0, 0, 672, 100, 239, 102);
962 tbsize_addbutton(&tbsize_results[20], 0, 2, 100, 102);
963 tbsize_addbutton(&tbsize_results[20], 100, 2, 139, 102);
964 tbsize_addbutton(&tbsize_results[20], 139, 2, 239, 102);
966 tbsize_results[21] = init_tbsize_result(3, 0, 0, 672, 42, 185, 40);
967 tbsize_addbutton(&tbsize_results[21], 0, 2, 75, 40);
968 tbsize_addbutton(&tbsize_results[21], 75, 2, 118, 40);
969 tbsize_addbutton(&tbsize_results[21], 118, 2, 165 + string_width(STRING2), 40);
971 tbsize_results[22] = init_tbsize_result(1, 0, 0, 672, 42, 67, 40);
972 tbsize_addbutton(&tbsize_results[22], 0, 2, 47 + string_width(STRING2), 40);
974 tbsize_results[23] = init_tbsize_result(2, 0, 0, 672, 42, 67, 41);
975 tbsize_addbutton(&tbsize_results[23], 0, 2, 672, 25 + fontheight);
976 tbsize_addbutton(&tbsize_results[23], 0, 25 + fontheight, 672, 48 + 2*fontheight);
979 static void free_tbsize_results(void) {
982 for (i = 0; i < tbsize_results_num; i++)
983 HeapFree(GetProcessHeap(), 0, tbsize_results[i].prcButtons);
984 HeapFree(GetProcessHeap(), 0, tbsize_results);
985 tbsize_results = NULL;
988 static int tbsize_numtests = 0;
995 } tbsize_alt_result_t;
997 static tbsize_alt_result_t tbsize_alt_results[] =
999 { 5, 2, { 0, 24, 8, 29 } },
1000 { 20, 1, { 100, 2, 107, 102 } },
1001 { 20, 2, { 107, 2, 207, 102 } }
1004 static int tbsize_alt_numtests = 0;
1006 #define check_sizes_todo(todomask) { \
1008 int buttonCount, i, mask=(todomask); \
1009 tbsize_result_t *res = &tbsize_results[tbsize_numtests]; \
1010 GetClientRect(hToolbar, &rc); \
1011 /*check_rect("client", rc, res->rcClient);*/ \
1012 buttonCount = SendMessage(hToolbar, TB_BUTTONCOUNT, 0, 0); \
1013 compare(buttonCount, res->nButtons, "%d"); \
1014 for (i=0; i<min(buttonCount, res->nButtons); i++) { \
1015 ok(SendMessageA(hToolbar, TB_GETITEMRECT, i, (LPARAM)&rc) == 1, "TB_GETITEMRECT\n"); \
1016 if (broken(tbsize_alt_numtests < sizeof(tbsize_alt_results)/sizeof(tbsize_alt_results[0]) && \
1017 memcmp(&rc, &tbsize_alt_results[tbsize_alt_numtests].rcButton, sizeof(RECT)) == 0)) { \
1018 win_skip("Alternate rect found\n"); \
1019 tbsize_alt_numtests++; \
1020 } else if (!(mask&1)) { \
1021 check_rect("button = %d, tbsize_numtests = %d", rc, res->prcButtons[i], i, tbsize_numtests); \
1023 todo_wine { check_rect("button = %d, tbsize_numtests = %d", rc, res->prcButtons[i], i, tbsize_numtests); } \
1027 tbsize_numtests++; \
1030 #define check_sizes() check_sizes_todo(0)
1034 static TBBUTTON buttons1[] = {
1035 {0, 10, TBSTATE_WRAP|TBSTATE_ENABLED, 0, {0, }, 0, -1},
1036 {0, 11, 0, 0, {0, }, 0, -1},
1038 static TBBUTTON buttons2[] = {
1039 {0, 20, TBSTATE_ENABLED, 0, {0, }, 0, -1},
1040 {0, 21, TBSTATE_ENABLED, 0, {0, }, 0, -1},
1042 static TBBUTTON buttons3[] = {
1043 {0, 30, TBSTATE_ENABLED, 0, {0, }, 0, 0},
1044 {0, 31, TBSTATE_ENABLED, 0, {0, }, 0, 1},
1045 {0, 32, TBSTATE_ENABLED, BTNS_AUTOSIZE, {0, }, 0, 1},
1046 {0, 33, TBSTATE_ENABLED, BTNS_AUTOSIZE, {0, }, 0, (UINT_PTR)STRING2}
1049 static void test_sizes(void)
1051 HWND hToolbar = NULL;
1052 HIMAGELIST himl, himl2;
1053 TBBUTTONINFO tbinfo;
1056 int fontheight = system_font_height();
1058 init_tbsize_results();
1060 rebuild_toolbar_with_buttons(&hToolbar);
1061 style = GetWindowLong(hToolbar, GWL_STYLE);
1062 ok(style == (WS_CHILD|WS_VISIBLE|CCS_TOP), "Invalid style %x\n", style);
1064 /* the TBSTATE_WRAP makes a second row */
1065 SendMessageA(hToolbar, TB_ADDBUTTONS, 2, (LPARAM)buttons1);
1067 SendMessageA(hToolbar, TB_AUTOSIZE, 0, 0);
1069 /* after setting the TBSTYLE_WRAPABLE the TBSTATE_WRAP is ignored */
1070 SetWindowLong(hToolbar, GWL_STYLE, style|TBSTYLE_WRAPABLE);
1072 /* adding new buttons with TBSTYLE_WRAPABLE doesn't add a new row */
1073 SendMessageA(hToolbar, TB_ADDBUTTONS, 2, (LPARAM)buttons1);
1075 /* only after adding enough buttons the bar will be wrapped on a
1076 * separator and then on the first button */
1077 for (i=0; i<15; i++)
1078 SendMessageA(hToolbar, TB_ADDBUTTONS, 2, (LPARAM)buttons1);
1079 check_sizes_todo(0x4);
1081 rebuild_toolbar_with_buttons(&hToolbar);
1082 SendMessageA(hToolbar, TB_ADDBUTTONS, 2, (LPARAM)buttons1);
1083 /* setting the buttons vertical will only change the window client size */
1084 SetWindowLong(hToolbar, GWL_STYLE, style | CCS_VERT);
1085 SendMessage(hToolbar, TB_AUTOSIZE, 0, 0);
1086 check_sizes_todo(0x3c);
1087 /* with a TBSTYLE_WRAPABLE a wrapping will occur on the separator */
1088 SetWindowLong(hToolbar, GWL_STYLE, style | TBSTYLE_WRAPABLE | CCS_VERT);
1089 SendMessage(hToolbar, TB_AUTOSIZE, 0, 0);
1090 check_sizes_todo(0x7c);
1092 rebuild_toolbar_with_buttons(&hToolbar);
1093 SendMessageA(hToolbar, TB_ADDBUTTONS, 2, (LPARAM)buttons1);
1094 /* a TB_SETBITMAPSIZE changes button sizes*/
1095 SendMessageA(hToolbar, TB_SETBITMAPSIZE, 0, MAKELONG(24, 24));
1098 /* setting a TBSTYLE_FLAT doesn't change anything - even after a TB_AUTOSIZE */
1099 SetWindowLong(hToolbar, GWL_STYLE, style | TBSTYLE_FLAT);
1100 SendMessageA(hToolbar, TB_AUTOSIZE, 0, 0);
1102 /* but after a TB_SETBITMAPSIZE the top margins is changed */
1103 SendMessageA(hToolbar, TB_SETBITMAPSIZE, 0, MAKELONG(20, 20));
1104 SendMessageA(hToolbar, TB_SETBITMAPSIZE, 0, MAKELONG(24, 24));
1106 /* some vertical toolbar sizes */
1107 SetWindowLong(hToolbar, GWL_STYLE, style | TBSTYLE_FLAT | TBSTYLE_WRAPABLE | CCS_VERT);
1108 check_sizes_todo(0x7c);
1110 rebuild_toolbar_with_buttons(&hToolbar);
1111 SetWindowLong(hToolbar, GWL_STYLE, style | TBSTYLE_FLAT);
1112 /* newly added buttons will be use the previous margin */
1113 SendMessageA(hToolbar, TB_ADDBUTTONS, 2, (LPARAM)buttons2);
1115 /* TB_SETBUTTONSIZE can't be used to reduce the size of a button below the default */
1116 check_button_size(hToolbar, 23, 22);
1117 ok(SendMessageA(hToolbar, TB_SETBUTTONSIZE, 0, MAKELONG(22, 21))==1, "TB_SETBUTTONSIZE\n");
1118 check_button_size(hToolbar, 23, 22);
1119 ok(SendMessageA(hToolbar, TB_SETBUTTONSIZE, 0, MAKELONG(5, 100))==1, "TB_SETBUTTONSIZE\n");
1120 check_button_size(hToolbar, 23, 100);
1121 ok(SendMessageA(hToolbar, TB_SETBUTTONSIZE, 0, MAKELONG(3, 3))==1, "TB_SETBUTTONSIZE\n");
1122 check_button_size(hToolbar, 23, 22);
1123 ok(SendMessageA(hToolbar, TB_SETBUTTONSIZE, 0, MAKELONG(5, 100))==1, "TB_SETBUTTONSIZE\n");
1124 check_button_size(hToolbar, 23, 100);
1126 /* add some buttons with non-default sizes */
1127 SendMessageA(hToolbar, TB_ADDBUTTONS, 2, (LPARAM)buttons2);
1128 SendMessageA(hToolbar, TB_INSERTBUTTON, -1, (LPARAM)&buttons2[0]);
1130 SendMessageA(hToolbar, TB_ADDBUTTONS, 1, (LPARAM)&buttons3[0]);
1131 /* TB_ADDSTRING resets the size */
1132 SendMessageA(hToolbar, TB_ADDSTRING, 0, (LPARAM) STRING0 "\0" STRING1 "\0");
1133 check_button_size(hToolbar, 23, 23 + fontheight);
1135 /* TB_SETBUTTONSIZE can be used to crop the text */
1136 SendMessageA(hToolbar, TB_SETBUTTONSIZE, 0, MAKELONG(3, 3));
1137 check_button_size(hToolbar, 23, 22);
1139 /* the default size is bitmap size + padding */
1140 SendMessageA(hToolbar, TB_SETPADDING, 0, MAKELONG(1, 1));
1141 SendMessageA(hToolbar, TB_SETBUTTONSIZE, 0, MAKELONG(3, 3));
1142 check_button_size(hToolbar, 17, 17);
1143 SendMessageA(hToolbar, TB_SETBITMAPSIZE, 0, MAKELONG(3, 3));
1144 SendMessageA(hToolbar, TB_SETBUTTONSIZE, 0, MAKELONG(3, 3));
1145 check_button_size(hToolbar, 4, 4);
1147 rebuild_toolbar(&hToolbar);
1148 /* sending a TB_SETBITMAPSIZE with the same sizes is enough to make the button smaller */
1149 check_button_size(hToolbar, 23, 22);
1150 SendMessageA(hToolbar, TB_SETBITMAPSIZE, 0, MAKELONG(16, 15));
1151 check_button_size(hToolbar, 23, 21);
1152 /* -1 in TB_SETBITMAPSIZE is a special code meaning that the coordinate shouldn't be changed */
1153 add_128x15_bitmap(hToolbar, 16);
1154 ok(SendMessageA(hToolbar, TB_SETBITMAPSIZE, 0, MAKELONG(14, -1)), "TB_SETBITMAPSIZE failed\n");
1155 compare((int)SendMessageA(hToolbar, TB_GETBUTTONSIZE, 0, 0), MAKELONG(21, 21), "%x");
1156 ok(SendMessageA(hToolbar, TB_SETBITMAPSIZE, 0, MAKELONG(-1, 12)), "TB_SETBITMAPSIZE failed\n");
1157 compare((int)SendMessageA(hToolbar, TB_GETBUTTONSIZE, 0, 0), MAKELONG(21, 18), "%x");
1158 ok(SendMessageA(hToolbar, TB_SETBITMAPSIZE, 0, MAKELONG(-1, -1)), "TB_SETBITMAPSIZE failed\n");
1159 compare((int)SendMessageA(hToolbar, TB_GETBUTTONSIZE, 0, 0), MAKELONG(21, 18), "%x");
1160 /* check the imagelist */
1161 InvalidateRect(hToolbar, NULL, TRUE);
1162 UpdateWindow(hToolbar);
1163 CHECK_IMAGELIST(16, 14, 12);
1165 rebuild_toolbar(&hToolbar);
1166 SendMessageA(hToolbar, TB_ADDSTRINGA, 0, (LPARAM)STRING0 "\0" STRING1 "\0");
1167 /* the height is increased after a TB_ADDSTRING */
1168 check_button_size(hToolbar, 23, 23 + fontheight);
1169 SendMessageA(hToolbar, TB_SETBUTTONSIZE, 0, MAKELONG(100, 100));
1170 /* if a string is in the pool, even adding a button without a string resets the size */
1171 SendMessageA(hToolbar, TB_ADDBUTTONS, 1, (LPARAM)&buttons2[0]);
1172 check_button_size(hToolbar, 23, 22);
1173 SendMessageA(hToolbar, TB_SETBUTTONSIZE, 0, MAKELONG(100, 100));
1174 /* an BTNS_AUTOSIZE button is also considered when computing the new size */
1175 SendMessageA(hToolbar, TB_ADDBUTTONS, 1, (LPARAM)&buttons3[2]);
1176 check_button_size(hToolbar, 7 + string_width(STRING1), 23 + fontheight);
1177 SendMessageA(hToolbar, TB_ADDBUTTONS, 1, (LPARAM)&buttons3[0]);
1179 /* delete button doesn't change the buttons size */
1180 SendMessageA(hToolbar, TB_DELETEBUTTON, 2, 0);
1181 SendMessageA(hToolbar, TB_DELETEBUTTON, 1, 0);
1182 check_button_size(hToolbar, 7 + string_width(STRING1), 23 + fontheight);
1183 /* TB_INSERTBUTTONS will */
1184 SendMessageA(hToolbar, TB_INSERTBUTTON, 1, (LPARAM)&buttons2[0]);
1185 check_button_size(hToolbar, 23, 22);
1187 /* TB_HIDEBUTTON and TB_MOVEBUTTON doesn't force a recalc */
1188 SendMessageA(hToolbar, TB_SETBUTTONSIZE, 0, MAKELONG(100, 100));
1189 ok(SendMessageA(hToolbar, TB_MOVEBUTTON, 0, 1), "TB_MOVEBUTTON failed\n");
1190 check_button_size(hToolbar, 100, 100);
1191 ok(SendMessageA(hToolbar, TB_HIDEBUTTON, 20, TRUE), "TB_HIDEBUTTON failed\n");
1192 check_button_size(hToolbar, 100, 100);
1193 /* however changing the hidden flag with TB_SETSTATE does */
1194 ok(SendMessageA(hToolbar, TB_SETSTATE, 20, TBSTATE_ENABLED|TBSTATE_HIDDEN), "TB_SETSTATE failed\n");
1195 check_button_size(hToolbar, 100, 100);
1196 ok(SendMessageA(hToolbar, TB_SETSTATE, 20, TBSTATE_ENABLED), "TB_SETSTATE failed\n");
1197 check_button_size(hToolbar, 23, 22);
1199 /* TB_SETIMAGELIST always changes the height but the width only if necessary */
1200 SendMessageA(hToolbar, TB_SETBUTTONSIZE, 0, MAKELONG(100, 100));
1201 himl = ImageList_LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_BITMAP_80x15), 20, 2, CLR_NONE, IMAGE_BITMAP, LR_DEFAULTCOLOR);
1202 ok(SendMessageA(hToolbar, TB_SETIMAGELIST, 0, (LPARAM)himl) == 0, "TB_SETIMAGELIST failed\n");
1203 check_button_size(hToolbar, 100, 21);
1204 SendMessageA(hToolbar, TB_SETBUTTONSIZE, 0, MAKELONG(100, 100));
1205 check_button_size(hToolbar, 100, 100);
1206 /* But there are no update when we change imagelist, and image sizes are the same */
1207 himl2 = ImageList_LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_BITMAP_128x15), 20, 2, CLR_NONE, IMAGE_BITMAP, LR_DEFAULTCOLOR);
1208 ok(SendMessageA(hToolbar, TB_SETIMAGELIST, 0, (LRESULT)himl2) == (LRESULT)himl, "TB_SETIMAGELIST failed\n");
1209 check_button_size(hToolbar, 100, 100);
1210 SendMessageA(hToolbar, TB_SETBUTTONSIZE, 0, MAKELONG(1, 1));
1211 check_button_size(hToolbar, 27, 21);
1212 ok(SendMessageA(hToolbar, TB_SETIMAGELIST, 0, 0) == (LRESULT)himl2, "TB_SETIMAGELIST failed\n");
1213 check_button_size(hToolbar, 27, 7);
1214 SendMessageA(hToolbar, TB_SETBUTTONSIZE, 0, MAKELONG(1, 1));
1215 check_button_size(hToolbar, 8, 7)
1216 ok(SendMessageA(hToolbar, TB_SETIMAGELIST, 0, (LPARAM)himl) == 0, "TB_SETIMAGELIST failed\n");
1217 check_button_size(hToolbar, 27, 21)
1218 /* the text is taken into account */
1219 SendMessageA(hToolbar, TB_ADDSTRINGA, 0, (LPARAM)STRING0 "\0" STRING1 "\0");
1220 SendMessageA(hToolbar, TB_ADDBUTTONS, 4, (LPARAM)buttons3);
1221 check_button_size(hToolbar, 7 + string_width(STRING1), 22 + fontheight);
1222 ok(SendMessageA(hToolbar, TB_SETIMAGELIST, 0, 0) == (LRESULT)himl, "TB_SETIMAGELIST failed\n");
1223 check_button_size(hToolbar, 7 + string_width(STRING1), 8 + fontheight);
1224 /* the style change also comes into effect */
1226 SetWindowLong(hToolbar, GWL_STYLE, GetWindowLong(hToolbar, GWL_STYLE) | TBSTYLE_FLAT);
1227 ok(SendMessageA(hToolbar, TB_SETIMAGELIST, 0, (LPARAM)himl) == 0, "TB_SETIMAGELIST failed\n");
1228 check_sizes_todo(0x30); /* some small problems with BTNS_AUTOSIZE button sizes */
1230 rebuild_toolbar(&hToolbar);
1231 ImageList_Destroy(himl);
1232 ImageList_Destroy(himl2);
1234 SendMessageA(hToolbar, TB_ADDBUTTONS, 1, (LPARAM)&buttons3[3]);
1235 check_button_size(hToolbar, 7 + string_width(STRING2), 23 + fontheight);
1236 SendMessageA(hToolbar, TB_DELETEBUTTON, 0, 0);
1237 check_button_size(hToolbar, 7 + string_width(STRING2), 23 + fontheight);
1239 rebuild_toolbar(&hToolbar);
1241 ok(SendMessageA(hToolbar, TB_SETBITMAPSIZE, 0, MAKELPARAM(32, 32)) == 1, "TB_SETBITMAPSIZE failed\n");
1242 ok(SendMessageA(hToolbar, TB_SETBUTTONSIZE, 0, MAKELPARAM(100, 100)) == 1, "TB_SETBUTTONSIZE failed\n");
1243 ok(SendMessageA(hToolbar, TB_ADDBUTTONS, 1, (LPARAM)&buttons2[0]) == 1, "TB_ADDBUTTONS failed\n");
1244 ok(SendMessageA(hToolbar, TB_ADDBUTTONS, 1, (LPARAM)&buttons3[2]) == 1, "TB_ADDBUTTONS failed\n");
1245 ok(SendMessageA(hToolbar, TB_ADDBUTTONS, 1, (LPARAM)&buttons3[0]) == 1, "TB_ADDBUTTONS failed\n");
1246 SendMessageA(hToolbar, TB_AUTOSIZE, 0, 0 );
1249 rebuild_toolbar(&hToolbar);
1250 SetWindowLong(hToolbar, GWL_STYLE, TBSTYLE_LIST | GetWindowLong(hToolbar, GWL_STYLE));
1251 ok(SendMessageA(hToolbar, TB_SETBITMAPSIZE, 0, MAKELPARAM(32, 32)) == 1, "TB_SETBITMAPSIZE failed\n");
1252 ok(SendMessageA(hToolbar, TB_SETBUTTONSIZE, 0, MAKELPARAM(100, 100)) == 1, "TB_SETBUTTONSIZE failed\n");
1253 ok(SendMessageA(hToolbar, TB_ADDBUTTONS, 1, (LPARAM)&buttons2[0]) == 1, "TB_ADDBUTTONS failed\n");
1254 ok(SendMessageA(hToolbar, TB_ADDBUTTONS, 1, (LPARAM)&buttons3[2]) == 1, "TB_ADDBUTTONS failed\n");
1255 ok(SendMessageA(hToolbar, TB_ADDBUTTONS, 1, (LPARAM)&buttons3[3]) == 1, "TB_ADDBUTTONS failed\n");
1256 SendMessageA(hToolbar, TB_AUTOSIZE, 0, 0 );
1257 check_sizes_todo(0xff);
1259 rebuild_toolbar(&hToolbar);
1260 SetWindowLong(hToolbar, GWL_STYLE, TBSTYLE_LIST | GetWindowLong(hToolbar, GWL_STYLE));
1261 ok(SendMessageA(hToolbar, TB_SETBITMAPSIZE, 0, MAKELPARAM(32, 32)) == 1, "TB_SETBITMAPSIZE failed\n");
1262 ok(SendMessageA(hToolbar, TB_SETBUTTONSIZE, 0, MAKELPARAM(100, 100)) == 1, "TB_SETBUTTONSIZE failed\n");
1263 ok(SendMessageA(hToolbar, TB_ADDBUTTONS, 1, (LPARAM)&buttons3[3]) == 1, "TB_ADDBUTTONS failed\n");
1264 SendMessageA(hToolbar, TB_AUTOSIZE, 0, 0 );
1267 rebuild_toolbar(&hToolbar);
1268 SetWindowLong(hToolbar, GWL_STYLE, TBSTYLE_WRAPABLE | GetWindowLong(hToolbar, GWL_STYLE));
1269 ok(SendMessageA(hToolbar, TB_ADDBUTTONS, 1, (LPARAM)&buttons3[3]) == 1, "TB_ADDBUTTONS failed\n");
1270 ok(SendMessageA(hToolbar, TB_ADDBUTTONS, 1, (LPARAM)&buttons3[3]) == 1, "TB_ADDBUTTONS failed\n");
1272 tbinfo.cbSize = sizeof(TBBUTTONINFO);
1273 tbinfo.dwMask = TBIF_SIZE | TBIF_BYINDEX;
1274 if (SendMessageA(hToolbar, TB_SETBUTTONINFO, 0, (LPARAM)&tbinfo))
1276 ok(SendMessageA(hToolbar, TB_SETBUTTONINFO, 1, (LPARAM)&tbinfo) != 0, "TB_SETBUTTONINFO failed\n");
1277 SendMessageA(hToolbar, TB_AUTOSIZE, 0, 0);
1280 else /* TBIF_BYINDEX probably not supported, confirm that this was the reason for the failure */
1282 tbinfo.dwMask = TBIF_SIZE;
1283 ok(SendMessageA(hToolbar, TB_SETBUTTONINFO, 33, (LPARAM)&tbinfo) != 0, "TB_SETBUTTONINFO failed\n");
1286 free_tbsize_results();
1287 DestroyWindow(hToolbar);
1290 /* Toolbar control has two ways of reacting to a change. We call them a
1291 * relayout and recalc. A recalc forces a recompute of values like button size
1292 * and top margin (the latter in comctl32 <v6), while a relayout uses the cached
1293 * values. This functions creates a flat toolbar with a top margin of a non-flat
1294 * toolbar. We will notice a recalc, as it will recompte the top margin and
1295 * change it to zero*/
1296 static void prepare_recalc_test(HWND *phToolbar)
1299 rebuild_toolbar_with_buttons(phToolbar);
1300 SetWindowLong(*phToolbar, GWL_STYLE,
1301 GetWindowLong(*phToolbar, GWL_STYLE) | TBSTYLE_FLAT);
1302 SendMessage(*phToolbar, TB_GETITEMRECT, 1, (LPARAM)&rect);
1303 ok(rect.top == 2, "Test will make no sense because initial top is %d instead of 2\n",
1307 static BOOL did_recalc(HWND hToolbar)
1310 SendMessage(hToolbar, TB_GETITEMRECT, 1, (LPARAM)&rect);
1311 ok(rect.top == 2 || rect.top == 0, "Unexpected top margin %d in recalc test\n",
1313 return (rect.top == 0);
1316 /* call after a recalc did happen to return to an unstable state */
1317 static void restore_recalc_state(HWND hToolbar)
1320 /* return to style with a 2px top margin */
1321 SetWindowLong(hToolbar, GWL_STYLE,
1322 GetWindowLong(hToolbar, GWL_STYLE) & ~TBSTYLE_FLAT);
1324 SendMessage(hToolbar, TB_ADDBUTTONS, 1, (LPARAM)&buttons3[3]);
1325 /* top margin will be 0px if a recalc occurs */
1326 SetWindowLong(hToolbar, GWL_STYLE,
1327 GetWindowLong(hToolbar, GWL_STYLE) | TBSTYLE_FLAT);
1329 SendMessage(hToolbar, TB_GETITEMRECT, 1, (LPARAM)&rect);
1330 ok(rect.top == 2, "Test will make no sense because initial top is %d instead of 2\n",
1334 static void test_recalc(void)
1336 HWND hToolbar = NULL;
1338 CHAR test[] = "Test";
1339 const int EX_STYLES_COUNT = 5;
1343 /* Like TB_ADDBUTTONS tested in test_sized, inserting a button without text
1344 * results in a relayout, while adding one with text forces a recalc */
1345 prepare_recalc_test(&hToolbar);
1346 SendMessage(hToolbar, TB_INSERTBUTTON, 1, (LPARAM)&buttons3[0]);
1347 recalc = did_recalc(hToolbar);
1348 ok(!recalc, "Unexpected recalc - adding button without text\n");
1350 prepare_recalc_test(&hToolbar);
1351 SendMessage(hToolbar, TB_INSERTBUTTON, 1, (LPARAM)&buttons3[3]);
1352 recalc = did_recalc(hToolbar);
1353 ok(recalc, "Expected a recalc - adding button with text\n");
1355 /* TB_SETBUTTONINFO, even when adding a text, results only in a relayout */
1356 prepare_recalc_test(&hToolbar);
1357 bi.cbSize = sizeof(bi);
1358 bi.dwMask = TBIF_TEXT;
1360 SendMessage(hToolbar, TB_SETBUTTONINFO, 1, (LPARAM)&bi);
1361 recalc = did_recalc(hToolbar);
1362 ok(!recalc, "Unexpected recalc - setting a button text\n");
1364 /* most extended styled doesn't force a recalc (testing all the bits gives
1365 * the same results, but prints some ERRs while testing) */
1366 for (i = 0; i < EX_STYLES_COUNT; i++)
1368 if (i == 1 || i == 3) /* an undoc style and TBSTYLE_EX_MIXEDBUTTONS */
1370 prepare_recalc_test(&hToolbar);
1371 expect(0, (int)SendMessage(hToolbar, TB_GETEXTENDEDSTYLE, 0, 0));
1372 SendMessage(hToolbar, TB_SETEXTENDEDSTYLE, 0, (1 << i));
1373 recalc = did_recalc(hToolbar);
1374 ok(!recalc, "Unexpected recalc - setting bit %d\n", i);
1375 SendMessage(hToolbar, TB_SETEXTENDEDSTYLE, 0, 0);
1376 recalc = did_recalc(hToolbar);
1377 ok(!recalc, "Unexpected recalc - clearing bit %d\n", i);
1378 expect(0, (int)SendMessage(hToolbar, TB_GETEXTENDEDSTYLE, 0, 0));
1381 /* TBSTYLE_EX_MIXEDBUTTONS does a recalc on change */
1382 prepare_recalc_test(&hToolbar);
1383 SendMessage(hToolbar, TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_MIXEDBUTTONS);
1384 recalc = did_recalc(hToolbar);
1387 ok(recalc, "Expected a recalc - setting TBSTYLE_EX_MIXEDBUTTONS\n");
1388 restore_recalc_state(hToolbar);
1389 SendMessage(hToolbar, TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_MIXEDBUTTONS);
1390 recalc = did_recalc(hToolbar);
1391 ok(!recalc, "Unexpected recalc - setting TBSTYLE_EX_MIXEDBUTTONS again\n");
1392 restore_recalc_state(hToolbar);
1393 SendMessage(hToolbar, TB_SETEXTENDEDSTYLE, 0, 0);
1394 recalc = did_recalc(hToolbar);
1395 ok(recalc, "Expected a recalc - clearing TBSTYLE_EX_MIXEDBUTTONS\n");
1397 else win_skip( "No recalc on TBSTYLE_EX_MIXEDBUTTONS\n" );
1399 /* undocumented exstyle 0x2 seems to changes the top margin, what
1400 * interferes with these tests */
1402 DestroyWindow(hToolbar);
1405 static void test_getbuttoninfo(void)
1407 HWND hToolbar = NULL;
1410 rebuild_toolbar_with_buttons(&hToolbar);
1411 for (i = 0; i < 128; i++)
1417 tbi.dwMask = TBIF_COMMAND;
1418 ret = (int)SendMessage(hToolbar, TB_GETBUTTONINFO, 1, (LPARAM)&tbi);
1419 if (i == sizeof(TBBUTTONINFO)) {
1420 compare(ret, 0, "%d");
1422 compare(ret, -1, "%d");
1425 DestroyWindow(hToolbar);
1428 static void test_createtoolbarex(void)
1432 ZeroMemory(&btns, sizeof(btns));
1434 hToolbar = CreateToolbarEx(hMainWnd, WS_VISIBLE, 1, 16, GetModuleHandle(NULL), IDB_BITMAP_128x15, btns,
1435 3, 20, 20, 16, 16, sizeof(TBBUTTON));
1436 CHECK_IMAGELIST(16, 20, 20);
1437 compare((int)SendMessage(hToolbar, TB_GETBUTTONSIZE, 0, 0), 0x1a001b, "%x");
1438 DestroyWindow(hToolbar);
1440 hToolbar = CreateToolbarEx(hMainWnd, WS_VISIBLE, 1, 16, GetModuleHandle(NULL), IDB_BITMAP_128x15, btns,
1441 3, 4, 4, 16, 16, sizeof(TBBUTTON));
1442 CHECK_IMAGELIST(32, 4, 4);
1443 compare((int)SendMessage(hToolbar, TB_GETBUTTONSIZE, 0, 0), 0xa000b, "%x");
1444 DestroyWindow(hToolbar);
1446 hToolbar = CreateToolbarEx(hMainWnd, WS_VISIBLE, 1, 16, GetModuleHandle(NULL), IDB_BITMAP_128x15, btns,
1447 3, 0, 8, 12, 12, sizeof(TBBUTTON));
1448 CHECK_IMAGELIST(16, 12, 12);
1449 compare((int)SendMessage(hToolbar, TB_GETBUTTONSIZE, 0, 0), 0x120013, "%x");
1450 DestroyWindow(hToolbar);
1452 hToolbar = CreateToolbarEx(hMainWnd, WS_VISIBLE, 1, 16, GetModuleHandle(NULL), IDB_BITMAP_128x15, btns,
1453 3, -1, 8, 12, 12, sizeof(TBBUTTON));
1454 CHECK_IMAGELIST(16, 12, 8);
1455 compare((int)SendMessage(hToolbar, TB_GETBUTTONSIZE, 0, 0), 0xe0013, "%x");
1456 DestroyWindow(hToolbar);
1458 hToolbar = CreateToolbarEx(hMainWnd, WS_VISIBLE, 1, 16, GetModuleHandle(NULL), IDB_BITMAP_128x15, btns,
1459 3, -1, 8, -1, 12, sizeof(TBBUTTON));
1460 CHECK_IMAGELIST(16, 16, 8);
1461 compare((int)SendMessage(hToolbar, TB_GETBUTTONSIZE, 0, 0), 0xe0017, "%x");
1462 DestroyWindow(hToolbar);
1464 hToolbar = CreateToolbarEx(hMainWnd, WS_VISIBLE, 1, 16, GetModuleHandle(NULL), IDB_BITMAP_128x15, btns,
1465 3, 0, 0, 12, -1, sizeof(TBBUTTON));
1466 CHECK_IMAGELIST(16, 12, 16);
1467 compare((int)SendMessage(hToolbar, TB_GETBUTTONSIZE, 0, 0), 0x160013, "%x");
1468 DestroyWindow(hToolbar);
1470 hToolbar = CreateToolbarEx(hMainWnd, WS_VISIBLE, 1, 16, GetModuleHandle(NULL), IDB_BITMAP_128x15, btns,
1471 3, 0, 0, 0, 12, sizeof(TBBUTTON));
1472 CHECK_IMAGELIST(16, 16, 16);
1473 compare((int)SendMessage(hToolbar, TB_GETBUTTONSIZE, 0, 0), 0x160017, "%x");
1474 DestroyWindow(hToolbar);
1477 static void test_dispinfo(void)
1479 HWND hToolbar = NULL;
1480 const TBBUTTON buttons_disp[] = {
1481 {-1, 20, TBSTATE_ENABLED, 0, {0, }, 0, -1},
1482 {0, 21, TBSTATE_ENABLED, 0, {0, }, 0, -1},
1486 rebuild_toolbar(&hToolbar);
1487 SendMessageA(hToolbar, TB_LOADIMAGES, IDB_HIST_SMALL_COLOR, (LPARAM)HINST_COMMCTRL);
1488 SendMessageA(hToolbar, TB_ADDBUTTONS, 2, (LPARAM)buttons_disp);
1489 g_dwExpectedDispInfoMask = TBNF_IMAGE;
1490 /* Some TBN_GETDISPINFO tests will be done in MyWnd_Notify function.
1491 * We will receive TBN_GETDISPINFOW even if the control is ANSI */
1492 compare((BOOL)SendMessageA(hToolbar, CCM_GETUNICODEFORMAT, 0, 0), 0, "%d");
1493 ShowWindow(hToolbar, SW_SHOW);
1494 UpdateWindow(hToolbar);
1496 ret = (BOOL)SendMessageA(hToolbar, CCM_SETUNICODEFORMAT, TRUE, 0);
1497 compare(ret, FALSE, "%d");
1498 compare(SendMessageA(hToolbar, CCM_GETUNICODEFORMAT, 0, 0), 1L, "%ld");
1499 InvalidateRect(hToolbar, NULL, FALSE);
1500 UpdateWindow(hToolbar);
1502 ret = (BOOL)SendMessageA(hToolbar, CCM_SETUNICODEFORMAT, FALSE, 0);
1503 compare(ret, TRUE, "%d");
1504 compare(SendMessageA(hToolbar, CCM_GETUNICODEFORMAT, 0, 0), 0L, "%ld");
1505 InvalidateRect(hToolbar, NULL, FALSE);
1506 UpdateWindow(hToolbar);
1508 DestroyWindow(hToolbar);
1509 g_dwExpectedDispInfoMask = 0;
1519 static tbrows_result_t tbrows_results[] =
1521 {1, TRUE, 1}, /* 0: Simple case 9 in a row */
1522 {2, TRUE, 2}, /* 1: Another simple case 5 on one row, 4 on another*/
1523 {3, FALSE, 3}, /* 2: 3 lines - should be 3 lines of 3 buttons */
1524 {8, FALSE, 5}, /* 3: 8 lines - should be 5 lines of 2 buttons */
1525 {8, TRUE, 9}, /* 4: 8 lines but grow - should be 9 lines */
1526 {1, TRUE, 1} /* 5: Back to simple case */
1529 static void test_setrows(void)
1531 TBBUTTON buttons[9];
1536 MakeButton(buttons+i, 1000+i, TBSTYLE_FLAT | TBSTYLE_CHECKGROUP, 0);
1538 /* Test 1 - 9 buttons */
1539 hToolbar = CreateToolbarEx(hMainWnd,
1540 WS_VISIBLE | WS_CLIPCHILDREN | WS_CHILD | CCS_NORESIZE | CCS_NOPARENTALIGN
1541 | CCS_NOMOVEY | CCS_TOP,
1544 buttons, sizeof(buttons)/sizeof(buttons[0]),
1545 20, 20, 0, 0, sizeof(TBBUTTON));
1546 ok(hToolbar != NULL, "Toolbar creation\n");
1547 ok(SendMessageA(hToolbar, TB_AUTOSIZE, 0, 0) == 0, "TB_AUTOSIZE failed\n");
1549 /* test setting rows to each of 1-10 with bLarger true and false */
1550 for (i=0; i<(sizeof(tbrows_results) / sizeof(tbrows_result_t)); i++) {
1554 memset(&rc, 0xCC, sizeof(rc));
1555 SendMessageA(hToolbar, TB_SETROWS,
1556 MAKELONG(tbrows_results[i].nRows, tbrows_results[i].bLarger),
1559 rows = SendMessageA(hToolbar, TB_GETROWS, MAKELONG(0,0), MAKELONG(0,0));
1560 ok(rows == tbrows_results[i].expectedRows,
1561 "[%d] Unexpected number of rows %d (expected %d)\n", i, rows,
1562 tbrows_results[i].expectedRows);
1565 DestroyWindow(hToolbar);
1568 static void test_getstring(void)
1570 HWND hToolbar = NULL;
1573 static const char answer[] = "STR";
1574 static const WCHAR answerW[] = { 'S','T','R',0 };
1577 hToolbar = CreateWindowExA(0, TOOLBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, hMainWnd, (HMENU)5, GetModuleHandle(NULL), NULL);
1578 ok(hToolbar != NULL, "Toolbar creation problem\n");
1580 r = SendMessage(hToolbar, TB_GETSTRING, MAKEWPARAM(0, 0), 0);
1583 win_skip("TB_GETSTRING and TB_GETSTRINGW need 5.80\n");
1584 DestroyWindow(hToolbar);
1588 r = SendMessage(hToolbar, TB_GETSTRINGW, MAKEWPARAM(0, 0), 0);
1590 r = SendMessage(hToolbar, TB_ADDSTRING, 0, (LPARAM)answer);
1592 r = SendMessage(hToolbar, TB_GETSTRING, MAKEWPARAM(0, 0), 0);
1593 expect(lstrlenA(answer), r);
1594 r = SendMessage(hToolbar, TB_GETSTRINGW, MAKEWPARAM(0, 0), 0);
1595 expect(lstrlenA(answer), r);
1596 r = SendMessage(hToolbar, TB_GETSTRING, MAKEWPARAM(sizeof(str), 0), (LPARAM)str);
1597 expect(lstrlenA(answer), r);
1598 expect(0, lstrcmp(answer, str));
1599 r = SendMessage(hToolbar, TB_GETSTRINGW, MAKEWPARAM(sizeof(strW), 0), (LPARAM)strW);
1600 expect(lstrlenA(answer), r);
1601 expect(0, lstrcmpW(answerW, strW));
1603 DestroyWindow(hToolbar);
1606 static void test_tooltip(void)
1608 HWND hToolbar = NULL;
1609 const TBBUTTON buttons_disp[] = {
1610 {-1, 20, TBSTATE_ENABLED, 0, {0, }, 0, -1},
1611 {0, 21, TBSTATE_ENABLED, 0, {0, }, 0, -1},
1613 NMTTDISPINFOW nmtti;
1615 rebuild_toolbar(&hToolbar);
1617 SendMessageA(hToolbar, TB_ADDBUTTONS, 2, (LPARAM)buttons_disp);
1619 /* W used to get through toolbar code that assumes tooltip is always Unicode */
1620 memset(&nmtti, 0, sizeof(nmtti));
1621 nmtti.hdr.code = TTN_GETDISPINFOW;
1622 nmtti.hdr.idFrom = 20;
1624 SendMessageA(hToolbar, CCM_SETUNICODEFORMAT, FALSE, 0);
1626 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1627 SendMessageA(hToolbar, WM_NOTIFY, 0, (LPARAM)&nmtti);
1628 ok_sequence(sequences, PARENT_SEQ_INDEX, ttgetdispinfo_parent_seq,
1629 "dispinfo from tooltip", TRUE);
1631 g_ResetDispTextPtr = TRUE;
1632 SendMessageA(hToolbar, WM_NOTIFY, 0, (LPARAM)&nmtti);
1633 g_ResetDispTextPtr = FALSE;
1635 DestroyWindow(hToolbar);
1644 init_msg_sequences(sequences, NUM_MSG_SEQUENCES);
1646 InitCommonControls();
1648 wc.style = CS_HREDRAW | CS_VREDRAW;
1651 wc.hInstance = GetModuleHandleA(NULL);
1653 wc.hCursor = LoadCursorA(NULL, IDC_IBEAM);
1654 wc.hbrBackground = GetSysColorBrush(COLOR_WINDOW);
1655 wc.lpszMenuName = NULL;
1656 wc.lpszClassName = "Toolbar test parent";
1657 wc.lpfnWndProc = parent_wnd_proc;
1658 RegisterClassA(&wc);
1660 hMainWnd = CreateWindowExA(0, "Toolbar test parent", "Blah", WS_OVERLAPPEDWINDOW,
1661 CW_USEDEFAULT, CW_USEDEFAULT, 680, 260, NULL, NULL, GetModuleHandleA(NULL), 0);
1662 GetClientRect(hMainWnd, &rc);
1663 ShowWindow(hMainWnd, SW_SHOW);
1671 test_getbuttoninfo();
1672 test_createtoolbarex();
1679 while(GetMessageA(&msg,0,0,0)) {
1680 TranslateMessage(&msg);
1681 DispatchMessageA(&msg);
1683 DestroyWindow(hMainWnd);