ia2comproxy: Introduce new proxy stub DLL for IAccessible2.
[wine.git] / dlls / comctl32 / tests / rebar.c
blobc15b22aeca179b6b90adb7a8cec7bc849a3a3689
1 /* Unit tests for rebar.
3 * Copyright 2007 Mikolaj Zalewski
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include <assert.h>
22 #include <windows.h>
23 #include <commctrl.h>
25 #include "wine/heap.h"
26 #include "wine/test.h"
28 static BOOL (WINAPI *pImageList_Destroy)(HIMAGELIST);
29 static HIMAGELIST (WINAPI *pImageList_LoadImageA)(HINSTANCE, LPCSTR, int, int, COLORREF, UINT, UINT);
31 static RECT height_change_notify_rect;
32 static HWND hMainWnd;
33 static int system_font_height;
36 #define check_rect(name, val, exp) ok(EqualRect(&val, &exp), \
37 "invalid rect (" name ") %s - expected %s\n", wine_dbgstr_rect(&val), wine_dbgstr_rect(&exp));
39 #define check_rect_no_top(name, val, exp) { \
40 ok((val.bottom - val.top == exp.bottom - exp.top) && \
41 val.left == exp.left && val.right == exp.right, \
42 "invalid rect (" name ") %s - expected %s, ignoring top\n", \
43 wine_dbgstr_rect(&val), wine_dbgstr_rect(&exp)); }
45 #define compare(val, exp, format) ok((val) == (exp), #val " value " format " expected " format "\n", (val), (exp));
47 #define expect_eq(line, expr, value, type, format) { type ret = expr;\
48 ok((value) == ret, #expr " expected " format " got " format " from line %d\n", (value), (ret), line); }
50 static INT CALLBACK is_font_installed_proc(const LOGFONTA *elf, const TEXTMETRICA *ntm, DWORD type, LPARAM lParam)
52 return 0;
55 static BOOL is_font_installed(const char *name)
57 HDC hdc = GetDC(0);
58 BOOL ret = FALSE;
60 if(!EnumFontFamiliesA(hdc, name, is_font_installed_proc, 0))
61 ret = TRUE;
63 ReleaseDC(0, hdc);
64 return ret;
67 static void init_system_font_height(void) {
68 HDC hDC;
69 TEXTMETRICA tm;
71 hDC = CreateCompatibleDC(NULL);
72 GetTextMetricsA(hDC, &tm);
73 DeleteDC(hDC);
75 system_font_height = tm.tmHeight;
78 static HWND create_rebar_control(DWORD style)
80 HWND hwnd;
82 hwnd = CreateWindowA(REBARCLASSNAMEA, NULL, style | WS_CHILD | WS_VISIBLE, 0, 0, 0, 0,
83 hMainWnd, (HMENU)17, GetModuleHandleA(NULL), NULL);
84 ok(hwnd != NULL, "Failed to create Rebar\n");
86 SendMessageA(hwnd, WM_SETFONT, (WPARAM)GetStockObject(SYSTEM_FONT), 0);
88 return hwnd;
91 static HWND build_toolbar(int nr, HWND hParent)
93 TBBUTTON btns[8];
94 HWND hToolbar = CreateWindowExA(0, TOOLBARCLASSNAMEA, NULL, WS_CHILD | WS_VISIBLE | CCS_NORESIZE, 0, 0, 0, 0,
95 hParent, (HMENU)5, GetModuleHandleA(NULL), NULL);
96 int iBitmapId = 0;
97 int i;
99 ok(hToolbar != NULL, "Toolbar creation problem\n");
100 ok(SendMessageA(hToolbar, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0) == 0, "TB_BUTTONSTRUCTSIZE failed\n");
101 ok(SendMessageA(hToolbar, TB_AUTOSIZE, 0, 0) == 0, "TB_AUTOSIZE failed\n");
102 ok(SendMessageA(hToolbar, WM_SETFONT, (WPARAM)GetStockObject(SYSTEM_FONT), 0)==1, "WM_SETFONT\n");
104 for (i=0; i<5+nr; i++)
106 btns[i].iBitmap = i;
107 btns[i].idCommand = i;
108 btns[i].fsStyle = BTNS_BUTTON;
109 btns[i].fsState = TBSTATE_ENABLED;
110 btns[i].iString = 0;
113 switch (nr)
115 case 0: iBitmapId = IDB_HIST_SMALL_COLOR; break;
116 case 1: iBitmapId = IDB_VIEW_SMALL_COLOR; break;
117 case 2: iBitmapId = IDB_STD_SMALL_COLOR; break;
119 ok(SendMessageA(hToolbar, TB_LOADIMAGES, iBitmapId, (LPARAM)HINST_COMMCTRL) == 0, "TB_LOADIMAGES failed\n");
120 ok(SendMessageA(hToolbar, TB_ADDBUTTONSA, 5+nr, (LPARAM)btns), "TB_ADDBUTTONSA failed\n");
121 return hToolbar;
124 static int g_parent_measureitem;
126 static LRESULT CALLBACK parent_wndproc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
128 switch (msg)
130 case WM_NOTIFY:
132 NMHDR *lpnm = (NMHDR *)lParam;
133 if (lpnm->code == RBN_HEIGHTCHANGE)
134 GetClientRect(lpnm->hwndFrom, &height_change_notify_rect);
136 break;
137 case WM_MEASUREITEM:
138 g_parent_measureitem++;
139 break;
141 return DefWindowProcA(hWnd, msg, wParam, lParam);
144 #if 0 /* use this to generate more tests*/
146 static void dump_sizes(HWND hRebar)
148 SIZE sz;
149 RECT r;
150 int count;
151 int i, h;
153 GetClientRect(hRebar, &r);
154 count = SendMessageA(hRebar, RB_GETROWCOUNT, 0, 0);
155 printf(" { {%d, %d, %d, %d}, %d, %d, {", r.left, r.top, r.right, r.bottom,
156 SendMessageA(hRebar, RB_GETBARHEIGHT, 0, 0), count);
157 if (count == 0)
158 printf("0, ");
159 for (i = 0; i < count; i++) /* rows */
160 printf("%d, ", SendMessageA(hRebar, RB_GETROWHEIGHT, i, 0));
161 printf("}, ");
163 count = SendMessageA(hRebar, RB_GETBANDCOUNT, 0, 0);
164 printf("%d, {", count);
165 if (count == 0)
166 printf("{{0, 0, 0, 0}, 0, 0},");
167 for (i=0; i<count; i++)
169 REBARBANDINFOA rbi;
170 rbi.cbSize = REBARBANDINFOA_V6_SIZE;
171 rbi.fMask = RBBIM_SIZE | RBBIM_CHILDSIZE | RBBIM_STYLE;
172 ok(SendMessageA(hRebar, RB_GETBANDINFOA, i, (LPARAM)&rbi), "RB_GETBANDINFOA failed\n");
173 ok(SendMessageA(hRebar, RB_GETRECT, i, (LPARAM)&r), "RB_GETRECT failed\n");
174 printf("%s{ {%3d, %3d, %3d, %3d}, 0x%02x, %d}, ", (i%2==0 ? "\n " : ""), r.left, r.top, r.right, r.bottom,
175 rbi.fStyle, rbi.cx);
177 printf("\n }, },\n");
180 #define check_sizes() dump_sizes(hRebar);
181 #define check_sizes_todo(todomask) dump_sizes(hRebar);
183 #else
185 static int string_width(const CHAR *s) {
186 SIZE sz;
187 HDC hdc;
189 hdc = CreateCompatibleDC(NULL);
190 GetTextExtentPoint32A(hdc, s, strlen(s), &sz);
191 DeleteDC(hdc);
193 return sz.cx;
196 typedef struct {
197 RECT rc;
198 UINT fStyle;
199 UINT cx;
200 } rbband_result_t;
202 typedef struct {
203 RECT rcClient;
204 int cyBarHeight;
205 int nRows;
206 int *cyRowHeights;
207 int nBands;
208 rbband_result_t *bands;
209 } rbsize_result_t;
211 static rbsize_result_t rbsize_init(int cleft, int ctop, int cright, int cbottom, int cyBarHeight, int nRows, int nBands)
213 rbsize_result_t ret;
215 SetRect(&ret.rcClient, cleft, ctop, cright, cbottom);
216 ret.cyBarHeight = cyBarHeight;
217 ret.nRows = 0;
218 ret.cyRowHeights = heap_alloc_zero(nRows * sizeof(int));
219 ret.nBands = 0;
220 ret.bands = heap_alloc_zero(nBands * sizeof(*ret.bands));
222 return ret;
225 static void rbsize_add_row(rbsize_result_t *rbsr, int rowHeight) {
226 rbsr->cyRowHeights[rbsr->nRows] = rowHeight;
227 rbsr->nRows++;
230 static void rbsize_add_band(rbsize_result_t *rbsr, int left, int top, int right, int bottom, DWORD fStyle, UINT cx)
232 SetRect(&(rbsr->bands[rbsr->nBands].rc), left, top, right, bottom);
233 rbsr->bands[rbsr->nBands].fStyle = fStyle;
234 rbsr->bands[rbsr->nBands].cx = cx;
235 rbsr->nBands++;
238 static rbsize_result_t *rbsize_results;
240 #define rbsize_results_num 27
242 static void rbsize_results_init(void)
244 rbsize_results = heap_alloc(rbsize_results_num * sizeof(*rbsize_results));
246 rbsize_results[0] = rbsize_init(0, 0, 672, 0, 0, 0, 0);
248 rbsize_results[1] = rbsize_init(0, 0, 672, 4, 4, 1, 1);
249 rbsize_add_row(&rbsize_results[1], 4);
250 rbsize_add_band(&rbsize_results[1], 0, 0, 672, 4, 0x00, 200);
252 rbsize_results[2] = rbsize_init(0, 0, 672, 4, 4, 1, 2);
253 rbsize_add_row(&rbsize_results[2], 4);
254 rbsize_add_band(&rbsize_results[2], 0, 0, 200, 4, 0x00, 200);
255 rbsize_add_band(&rbsize_results[2], 200, 0, 672, 4, 0x04, 200);
257 rbsize_results[3] = rbsize_init(0, 0, 672, 30, 30, 1, 3);
258 rbsize_add_row(&rbsize_results[3], 30);
259 rbsize_add_band(&rbsize_results[3], 0, 0, 200, 30, 0x00, 200);
260 rbsize_add_band(&rbsize_results[3], 200, 0, 400, 30, 0x04, 200);
261 rbsize_add_band(&rbsize_results[3], 400, 0, 672, 30, 0x00, 200);
263 rbsize_results[4] = rbsize_init(0, 0, 672, 34, 34, 1, 4);
264 rbsize_add_row(&rbsize_results[4], 34);
265 rbsize_add_band(&rbsize_results[4], 0, 0, 200, 34, 0x00, 200);
266 rbsize_add_band(&rbsize_results[4], 200, 0, 400, 34, 0x04, 200);
267 rbsize_add_band(&rbsize_results[4], 400, 0, 604, 34, 0x00, 200);
268 rbsize_add_band(&rbsize_results[4], 604, 0, 672, 34, 0x04, 68);
270 rbsize_results[5] = rbsize_init(0, 0, 672, 34, 34, 1, 4);
271 rbsize_add_row(&rbsize_results[5], 34);
272 rbsize_add_band(&rbsize_results[5], 0, 0, 200, 34, 0x00, 200);
273 rbsize_add_band(&rbsize_results[5], 200, 0, 400, 34, 0x04, 200);
274 rbsize_add_band(&rbsize_results[5], 400, 0, 604, 34, 0x00, 200);
275 rbsize_add_band(&rbsize_results[5], 604, 0, 672, 34, 0x04, 68);
277 rbsize_results[6] = rbsize_init(0, 0, 672, 34, 34, 1, 4);
278 rbsize_add_row(&rbsize_results[6], 34);
279 rbsize_add_band(&rbsize_results[6], 0, 0, 200, 34, 0x00, 200);
280 rbsize_add_band(&rbsize_results[6], 202, 0, 402, 34, 0x04, 200);
281 rbsize_add_band(&rbsize_results[6], 404, 0, 604, 34, 0x00, 200);
282 rbsize_add_band(&rbsize_results[6], 606, 0, 672, 34, 0x04, 66);
284 rbsize_results[7] = rbsize_init(0, 0, 672, 70, 70, 2, 5);
285 rbsize_add_row(&rbsize_results[7], 34);
286 rbsize_add_row(&rbsize_results[7], 34);
287 rbsize_add_band(&rbsize_results[7], 0, 0, 142, 34, 0x00, 200);
288 rbsize_add_band(&rbsize_results[7], 144, 0, 557, 34, 0x00, 200);
289 rbsize_add_band(&rbsize_results[7], 559, 0, 672, 34, 0x04, 200);
290 rbsize_add_band(&rbsize_results[7], 0, 36, 200, 70, 0x00, 200);
291 rbsize_add_band(&rbsize_results[7], 202, 36, 672, 70, 0x04, 66);
293 rbsize_results[8] = rbsize_init(0, 0, 672, 34, 34, 1, 5);
294 rbsize_add_row(&rbsize_results[8], 34);
295 rbsize_add_band(&rbsize_results[8], 0, 0, 167, 34, 0x00, 200);
296 rbsize_add_band(&rbsize_results[8], 169, 0, 582, 34, 0x00, 200);
297 rbsize_add_band(&rbsize_results[8], 559, 0, 759, 34, 0x08, 200);
298 rbsize_add_band(&rbsize_results[8], 584, 0, 627, 34, 0x00, 200);
299 rbsize_add_band(&rbsize_results[8], 629, 0, 672, 34, 0x04, 66);
301 rbsize_results[9] = rbsize_init(0, 0, 672, 34, 34, 1, 4);
302 rbsize_add_row(&rbsize_results[9], 34);
303 rbsize_add_band(&rbsize_results[9], 0, 0, 167, 34, 0x00, 200);
304 rbsize_add_band(&rbsize_results[9], 169, 0, 582, 34, 0x00, 200);
305 rbsize_add_band(&rbsize_results[9], 584, 0, 627, 34, 0x00, 200);
306 rbsize_add_band(&rbsize_results[9], 629, 0, 672, 34, 0x04, 66);
308 rbsize_results[10] = rbsize_init(0, 0, 672, 34, 34, 1, 3);
309 rbsize_add_row(&rbsize_results[10], 34);
310 rbsize_add_band(&rbsize_results[10], 0, 0, 413, 34, 0x00, 200);
311 rbsize_add_band(&rbsize_results[10], 415, 0, 615, 34, 0x00, 200);
312 rbsize_add_band(&rbsize_results[10], 617, 0, 672, 34, 0x04, 66);
314 rbsize_results[11] = rbsize_init(0, 0, 672, 34, 34, 1, 2);
315 rbsize_add_row(&rbsize_results[11], 34);
316 rbsize_add_band(&rbsize_results[11], 0, 0, 604, 34, 0x00, 200);
317 rbsize_add_band(&rbsize_results[11], 606, 0, 672, 34, 0x04, 66);
319 rbsize_results[12] = rbsize_init(0, 0, 672, 8 + 2*system_font_height, 40, 2, 5);
320 rbsize_add_row(&rbsize_results[12], 4 + system_font_height);
321 rbsize_add_row(&rbsize_results[12], 4 + system_font_height);
322 rbsize_add_band(&rbsize_results[12], 0, 0, 87 + string_width("ABC"), 4 + system_font_height, 0x00, 40);
323 rbsize_add_band(&rbsize_results[12], 87 + string_width("ABC"), 0, 157 + string_width("ABC"), 4 + system_font_height, 0x00, 70);
324 rbsize_add_band(&rbsize_results[12], 157 + string_width("ABC"), 0, 397 + string_width("ABC"), 4 + system_font_height, 0x00, 240);
325 rbsize_add_band(&rbsize_results[12], 397 + string_width("ABC"), 0, 672, 4 + system_font_height, 0x00, 60);
326 rbsize_add_band(&rbsize_results[12], 0, 4 + system_font_height, 672, 8 + 2*system_font_height, 0x00, 200);
328 rbsize_results[13] = rbsize_init(0, 0, 672, 8 + 2*system_font_height, 40, 2, 5);
329 rbsize_add_row(&rbsize_results[13], 4 + system_font_height);
330 rbsize_add_row(&rbsize_results[13], 4 + system_font_height);
331 rbsize_add_band(&rbsize_results[13], 0, 0, 87 + string_width("ABC"), 4 + system_font_height, 0x00, 40);
332 rbsize_add_band(&rbsize_results[13], 87 + string_width("ABC"), 0, 200 + string_width("ABC"), 4 + system_font_height, 0x00, 113);
333 rbsize_add_band(&rbsize_results[13], 200 + string_width("ABC"), 0, 397 + string_width("ABC"), 4 + system_font_height, 0x00, 197);
334 rbsize_add_band(&rbsize_results[13], 397 + string_width("ABC"), 0, 672, 4 + system_font_height, 0x00, 60);
335 rbsize_add_band(&rbsize_results[13], 0, 4 + system_font_height, 672, 8 + 2*system_font_height, 0x00, 200);
337 rbsize_results[14] = rbsize_init(0, 0, 672, 8 + 2*system_font_height, 40, 2, 5);
338 rbsize_add_row(&rbsize_results[14], 4 + system_font_height);
339 rbsize_add_row(&rbsize_results[14], 4 + system_font_height);
340 rbsize_add_band(&rbsize_results[14], 0, 0, 87 + string_width("ABC"), 4 + system_font_height, 0x00, 40);
341 rbsize_add_band(&rbsize_results[14], 87 + string_width("ABC"), 0, 412 - string_width("MMMMMMM"), 4 + system_font_height, 0x00, 325 - string_width("ABC") - string_width("MMMMMMM"));
342 rbsize_add_band(&rbsize_results[14], 412 - string_width("MMMMMMM"), 0, 595 - string_width("MMMMMMM"), 4 + system_font_height, 0x00, 183);
343 rbsize_add_band(&rbsize_results[14], 595 - string_width("MMMMMMM"), 0, 672, 4 + system_font_height, 0x00, 77 + string_width("MMMMMMM"));
344 rbsize_add_band(&rbsize_results[14], 0, 4 + system_font_height, 672, 8 + 2*system_font_height, 0x00, 200);
346 rbsize_results[15] = rbsize_init(0, 0, 672, 8 + 2*system_font_height, 40, 2, 5);
347 rbsize_add_row(&rbsize_results[15], 4 + system_font_height);
348 rbsize_add_row(&rbsize_results[15], 4 + system_font_height);
349 rbsize_add_band(&rbsize_results[15], 0, 0, 87 + string_width("ABC"), 4 + system_font_height, 0x00, 40);
350 rbsize_add_band(&rbsize_results[15], 87 + string_width("ABC"), 0, 140 + string_width("ABC"), 4 + system_font_height, 0x00, 53);
351 rbsize_add_band(&rbsize_results[15], 140 + string_width("ABC"), 0, 595 - string_width("MMMMMMM"), 4 + system_font_height, 0x00, 455 - string_width("MMMMMMM") - string_width("ABC"));
352 rbsize_add_band(&rbsize_results[15], 595 - string_width("MMMMMMM"), 0, 672, 4 + system_font_height, 0x00, 77 + string_width("MMMMMMM"));
353 rbsize_add_band(&rbsize_results[15], 0, 4 + system_font_height, 672, 8 + 2*system_font_height, 0x00, 200);
355 rbsize_results[16] = rbsize_init(0, 0, 672, 8 + 2*system_font_height, 40, 2, 5);
356 rbsize_add_row(&rbsize_results[16], 4 + system_font_height);
357 rbsize_add_row(&rbsize_results[16], 4 + system_font_height);
358 rbsize_add_band(&rbsize_results[16], 0, 0, 87 + string_width("ABC"), 4 + system_font_height, 0x00, 40);
359 rbsize_add_band(&rbsize_results[16], 87 + string_width("ABC"), 0, 412 - string_width("MMMMMMM"), 4 + system_font_height, 0x00, 325 - string_width("ABC") - string_width("MMMMMMM"));
360 rbsize_add_band(&rbsize_results[16], 412 - string_width("MMMMMMM"), 0, 595 - string_width("MMMMMMM"), 4 + system_font_height, 0x00, 183);
361 rbsize_add_band(&rbsize_results[16], 595 - string_width("MMMMMMM"), 0, 672, 4 + system_font_height, 0x00, 77 + string_width("MMMMMMM"));
362 rbsize_add_band(&rbsize_results[16], 0, 4 + system_font_height, 672, 8 + 2*system_font_height, 0x00, 200);
364 rbsize_results[17] = rbsize_init(0, 0, 672, 8 + 2*system_font_height, 40, 2, 5);
365 rbsize_add_row(&rbsize_results[17], 4 + system_font_height);
366 rbsize_add_row(&rbsize_results[17], 4 + system_font_height);
367 rbsize_add_band(&rbsize_results[17], 0, 0, 87 + string_width("ABC"), 4 + system_font_height, 0x00, 40);
368 rbsize_add_band(&rbsize_results[17], 87 + string_width("ABC"), 0, 412 - string_width("MMMMMMM"), 4 + system_font_height, 0x00, 325 - string_width("ABC") - string_width("MMMMMMM"));
369 rbsize_add_band(&rbsize_results[17], 412 - string_width("MMMMMMM"), 0, 595 - string_width("MMMMMMM"), 4 + system_font_height, 0x00, 183);
370 rbsize_add_band(&rbsize_results[17], 595 - string_width("MMMMMMM"), 0, 672, 4 + system_font_height, 0x00, 77 + string_width("MMMMMMM"));
371 rbsize_add_band(&rbsize_results[17], 0, 4 + system_font_height, 672, 8 + 2*system_font_height, 0x00, 200);
373 rbsize_results[18] = rbsize_init(0, 0, 672, 56, 56, 2, 5);
374 rbsize_add_row(&rbsize_results[18], 28);
375 rbsize_add_row(&rbsize_results[18], 28);
376 rbsize_add_band(&rbsize_results[18], 0, 0, 87 + string_width("ABC"), 28, 0x00, 40);
377 rbsize_add_band(&rbsize_results[18], 87 + string_width("ABC"), 0, 412 - string_width("MMMMMMM"), 28, 0x00, 325 - string_width("ABC") - string_width("MMMMMMM"));
378 rbsize_add_band(&rbsize_results[18], 412 - string_width("MMMMMMM"), 0, 595 - string_width("MMMMMMM"), 28, 0x00, 183);
379 rbsize_add_band(&rbsize_results[18], 595 - string_width("MMMMMMM"), 0, 672, 28, 0x00, 77 + string_width("MMMMMMM"));
380 rbsize_add_band(&rbsize_results[18], 0, 28, 672, 56, 0x00, 200);
382 rbsize_results[19] = rbsize_init(0, 0, 672, 8 + 2*system_font_height, 40, 2, 5);
383 rbsize_add_row(&rbsize_results[19], 4 + system_font_height);
384 rbsize_add_row(&rbsize_results[19], 4 + system_font_height);
385 rbsize_add_band(&rbsize_results[19], 0, 0, 87 + string_width("ABC"), 4 + system_font_height, 0x00, 40);
386 rbsize_add_band(&rbsize_results[19], 87 + string_width("ABC"), 0, 412 - string_width("MMMMMMM"), 4 + system_font_height, 0x00, 325 - string_width("ABC") - string_width("MMMMMMM"));
387 rbsize_add_band(&rbsize_results[19], 412 - string_width("MMMMMMM"), 0, 595 - string_width("MMMMMMM"), 4 + system_font_height, 0x00, 183);
388 rbsize_add_band(&rbsize_results[19], 595 - string_width("MMMMMMM"), 0, 672, 4 + system_font_height, 0x00, 77 + string_width("MMMMMMM"));
389 rbsize_add_band(&rbsize_results[19], 0, 4 + system_font_height, 672, 8 + 2*system_font_height, 0x00, 200);
391 rbsize_results[20] = rbsize_init(0, 0, 672, 56, 56, 2, 5);
392 rbsize_add_row(&rbsize_results[20], 28);
393 rbsize_add_row(&rbsize_results[20], 28);
394 rbsize_add_band(&rbsize_results[20], 0, 0, 87 + string_width("ABC"), 28, 0x00, 40);
395 rbsize_add_band(&rbsize_results[20], 87 + string_width("ABC"), 0, 412 - string_width("MMMMMMM"), 28, 0x00, 325 - string_width("ABC") - string_width("MMMMMMM"));
396 rbsize_add_band(&rbsize_results[20], 412 - string_width("MMMMMMM"), 0, 595 - string_width("MMMMMMM"), 28, 0x00, 183);
397 rbsize_add_band(&rbsize_results[20], 595 - string_width("MMMMMMM"), 0, 672, 28, 0x00, 77 + string_width("MMMMMMM"));
398 rbsize_add_band(&rbsize_results[20], 0, 28, 672, 56, 0x00, 200);
400 rbsize_results[21] = rbsize_init(0, 0, 672, 0, 0, 0, 0);
402 rbsize_results[22] = rbsize_init(0, 0, 672, 65, 56, 1, 3);
403 rbsize_add_row(&rbsize_results[22], 65);
404 rbsize_add_band(&rbsize_results[22], 0, 0, 90, 65, 0x40, 90);
405 rbsize_add_band(&rbsize_results[22], 90, 0, 180, 65, 0x40, 90);
406 rbsize_add_band(&rbsize_results[22], 180, 0, 672, 65, 0x40, 90);
408 rbsize_results[23] = rbsize_init(0, 0, 0, 226, 0, 0, 0);
410 rbsize_results[24] = rbsize_init(0, 0, 65, 226, 65, 1, 1);
411 rbsize_add_row(&rbsize_results[24], 65);
412 rbsize_add_band(&rbsize_results[24], 0, 0, 226, 65, 0x40, 90);
414 rbsize_results[25] = rbsize_init(0, 0, 65, 226, 65, 1, 2);
415 rbsize_add_row(&rbsize_results[25], 65);
416 rbsize_add_band(&rbsize_results[25], 0, 0, 90, 65, 0x40, 90);
417 rbsize_add_band(&rbsize_results[25], 90, 0, 226, 65, 0x40, 90);
419 rbsize_results[26] = rbsize_init(0, 0, 65, 226, 65, 1, 3);
420 rbsize_add_row(&rbsize_results[26], 65);
421 rbsize_add_band(&rbsize_results[26], 0, 0, 90, 65, 0x40, 90);
422 rbsize_add_band(&rbsize_results[26], 90, 0, 163, 65, 0x40, 90);
423 rbsize_add_band(&rbsize_results[26], 163, 0, 226, 65, 0x40, 90);
426 static void rbsize_results_free(void)
428 int i;
430 for (i = 0; i < rbsize_results_num; i++) {
431 heap_free(rbsize_results[i].cyRowHeights);
432 heap_free(rbsize_results[i].bands);
434 heap_free(rbsize_results);
435 rbsize_results = NULL;
438 static int rbsize_numtests = 0;
440 #define check_sizes_todo(todomask) { \
441 RECT rc; \
442 REBARBANDINFOA rbi; \
443 int count, i/*, mask=(todomask)*/; \
444 const rbsize_result_t *res = &rbsize_results[rbsize_numtests]; \
445 GetClientRect(hRebar, &rc); \
446 check_rect("client", rc, res->rcClient); \
447 count = SendMessageA(hRebar, RB_GETROWCOUNT, 0, 0); \
448 compare(count, res->nRows, "%d"); \
449 for (i=0; i<min(count, res->nRows); i++) { \
450 int height = SendMessageA(hRebar, RB_GETROWHEIGHT, 0, 0);\
451 ok(height == res->cyRowHeights[i], "Height mismatch for row %d - %d vs %d\n", i, res->cyRowHeights[i], height); \
453 count = SendMessageA(hRebar, RB_GETBANDCOUNT, 0, 0); \
454 compare(count, res->nBands, "%d"); \
455 for (i=0; i<min(count, res->nBands); i++) { \
456 ok(SendMessageA(hRebar, RB_GETRECT, i, (LPARAM)&rc) == 1, "RB_GETRECT\n"); \
457 if (!(res->bands[i].fStyle & RBBS_HIDDEN)) \
458 check_rect("band", rc, res->bands[i].rc); \
459 rbi.cbSize = REBARBANDINFOA_V6_SIZE; \
460 rbi.fMask = RBBIM_STYLE | RBBIM_SIZE; \
461 ok(SendMessageA(hRebar, RB_GETBANDINFOA, i, (LPARAM)&rbi) == 1, "RB_GETBANDINFOA\n"); \
462 compare(rbi.fStyle, res->bands[i].fStyle, "%x"); \
463 compare(rbi.cx, res->bands[i].cx, "%d"); \
465 rbsize_numtests++; \
468 #define check_sizes() check_sizes_todo(0)
470 #endif
472 static void add_band_w(HWND hRebar, LPCSTR lpszText, int cxMinChild, int cx, int cxIdeal)
474 CHAR buffer[MAX_PATH];
475 REBARBANDINFOA rbi;
477 if (lpszText != NULL)
478 strcpy(buffer, lpszText);
479 rbi.cbSize = REBARBANDINFOA_V6_SIZE;
480 rbi.fMask = RBBIM_SIZE | RBBIM_CHILDSIZE | RBBIM_CHILD | RBBIM_IDEALSIZE | RBBIM_TEXT;
481 rbi.cx = cx;
482 rbi.cxMinChild = cxMinChild;
483 rbi.cxIdeal = cxIdeal;
484 rbi.cyMinChild = 20;
485 rbi.hwndChild = build_toolbar(1, hRebar);
486 rbi.lpText = (lpszText ? buffer : NULL);
487 SendMessageA(hRebar, RB_INSERTBANDA, -1, (LPARAM)&rbi);
490 static void test_layout(void)
492 HWND hRebar;
493 REBARBANDINFOA rbi;
494 HIMAGELIST himl;
495 REBARINFO ri;
496 int count;
498 rbsize_results_init();
500 hRebar = create_rebar_control(0);
501 check_sizes();
502 rbi.cbSize = REBARBANDINFOA_V6_SIZE;
503 rbi.fMask = RBBIM_SIZE | RBBIM_CHILDSIZE | RBBIM_CHILD;
504 rbi.cx = 200;
505 rbi.cxMinChild = 100;
506 rbi.cyMinChild = 30;
507 rbi.hwndChild = NULL;
508 SendMessageA(hRebar, RB_INSERTBANDA, -1, (LPARAM)&rbi);
509 check_sizes();
511 rbi.fMask |= RBBIM_STYLE;
512 rbi.fStyle = RBBS_CHILDEDGE;
513 SendMessageA(hRebar, RB_INSERTBANDA, -1, (LPARAM)&rbi);
514 check_sizes();
516 rbi.fStyle = 0;
517 rbi.cx = 200;
518 rbi.cxMinChild = 30;
519 rbi.cyMinChild = 30;
520 rbi.hwndChild = build_toolbar(0, hRebar);
521 SendMessageA(hRebar, RB_INSERTBANDA, -1, (LPARAM)&rbi);
522 check_sizes();
524 rbi.fStyle = RBBS_CHILDEDGE;
525 rbi.cx = 68;
526 rbi.hwndChild = build_toolbar(0, hRebar);
527 SendMessageA(hRebar, RB_INSERTBANDA, -1, (LPARAM)&rbi);
528 check_sizes();
530 SetWindowLongA(hRebar, GWL_STYLE, GetWindowLongA(hRebar, GWL_STYLE) | RBS_BANDBORDERS);
531 check_sizes(); /* a style change won't start a relayout */
532 rbi.fMask = RBBIM_SIZE;
533 rbi.cx = 66;
534 SendMessageA(hRebar, RB_SETBANDINFOA, 3, (LPARAM)&rbi);
535 check_sizes(); /* here it will be relayouted */
537 /* this will force a new row */
538 rbi.fMask = RBBIM_SIZE | RBBIM_CHILDSIZE | RBBIM_CHILD;
539 rbi.cx = 200;
540 rbi.cxMinChild = 400;
541 rbi.cyMinChild = 30;
542 rbi.hwndChild = build_toolbar(0, hRebar);
543 SendMessageA(hRebar, RB_INSERTBANDA, 1, (LPARAM)&rbi);
544 check_sizes();
546 rbi.fMask = RBBIM_STYLE;
547 rbi.fStyle = RBBS_HIDDEN;
548 SendMessageA(hRebar, RB_SETBANDINFOA, 2, (LPARAM)&rbi);
549 check_sizes();
551 SendMessageA(hRebar, RB_DELETEBAND, 2, 0);
552 check_sizes();
553 SendMessageA(hRebar, RB_DELETEBAND, 0, 0);
554 check_sizes();
555 SendMessageA(hRebar, RB_DELETEBAND, 1, 0);
556 check_sizes();
558 DestroyWindow(hRebar);
560 hRebar = create_rebar_control(0);
561 add_band_w(hRebar, "ABC", 70, 40, 100);
562 add_band_w(hRebar, NULL, 40, 70, 100);
563 add_band_w(hRebar, NULL, 170, 240, 100);
564 add_band_w(hRebar, "MMMMMMM", 60, 60, 100);
565 add_band_w(hRebar, NULL, 200, 200, 100);
566 check_sizes();
567 SendMessageA(hRebar, RB_MAXIMIZEBAND, 1, TRUE);
568 check_sizes();
569 SendMessageA(hRebar, RB_MAXIMIZEBAND, 1, TRUE);
570 check_sizes();
571 SendMessageA(hRebar, RB_MAXIMIZEBAND, 2, FALSE);
572 check_sizes();
573 SendMessageA(hRebar, RB_MINIMIZEBAND, 2, 0);
574 check_sizes();
575 SendMessageA(hRebar, RB_MINIMIZEBAND, 0, 0);
576 check_sizes();
578 /* an image will increase the band height */
579 himl = pImageList_LoadImageA(GetModuleHandleA("comctl32"), MAKEINTRESOURCEA(121), 24, 2,
580 CLR_NONE, IMAGE_BITMAP, LR_DEFAULTCOLOR);
581 ri.cbSize = sizeof(ri);
582 ri.fMask = RBIM_IMAGELIST;
583 ri.himl = himl;
584 ok(SendMessageA(hRebar, RB_SETBARINFO, 0, (LPARAM)&ri), "RB_SETBARINFO failed\n");
585 rbi.fMask = RBBIM_IMAGE;
586 rbi.iImage = 1;
587 SendMessageA(hRebar, RB_SETBANDINFOA, 1, (LPARAM)&rbi);
588 check_sizes();
590 /* after removing it everything is back to normal*/
591 rbi.iImage = -1;
592 SendMessageA(hRebar, RB_SETBANDINFOA, 1, (LPARAM)&rbi);
593 check_sizes();
595 /* Only -1 means that the image is not present. Other invalid values increase the height */
596 rbi.iImage = -2;
597 SendMessageA(hRebar, RB_SETBANDINFOA, 1, (LPARAM)&rbi);
598 check_sizes();
600 DestroyWindow(hRebar);
602 /* VARHEIGHT resizing test on a horizontal rebar */
603 hRebar = create_rebar_control(0);
604 SetWindowLongA(hRebar, GWL_STYLE, GetWindowLongA(hRebar, GWL_STYLE) | RBS_AUTOSIZE);
605 check_sizes();
606 rbi.fMask = RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_SIZE | RBBIM_STYLE;
607 rbi.fStyle = RBBS_VARIABLEHEIGHT;
608 rbi.cxMinChild = 50;
609 rbi.cyMinChild = 10;
610 rbi.cyIntegral = 11;
611 rbi.cyChild = 70;
612 rbi.cyMaxChild = 200;
613 rbi.cx = 90;
614 rbi.hwndChild = build_toolbar(0, hRebar);
615 SendMessageA(hRebar, RB_INSERTBANDA, -1, (LPARAM)&rbi);
617 rbi.cyChild = 50;
618 rbi.hwndChild = build_toolbar(0, hRebar);
619 SendMessageA(hRebar, RB_INSERTBANDA, -1, (LPARAM)&rbi);
621 rbi.cyMinChild = 40;
622 rbi.cyChild = 50;
623 rbi.cyIntegral = 5;
624 rbi.hwndChild = build_toolbar(0, hRebar);
625 SendMessageA(hRebar, RB_INSERTBANDA, -1, (LPARAM)&rbi);
626 check_sizes();
628 DestroyWindow(hRebar);
630 /* VARHEIGHT resizing on a vertical rebar */
631 hRebar = create_rebar_control(0);
632 SetWindowLongA(hRebar, GWL_STYLE, GetWindowLongA(hRebar, GWL_STYLE) | CCS_VERT | RBS_AUTOSIZE);
633 check_sizes();
634 rbi.fMask = RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_SIZE | RBBIM_STYLE;
635 rbi.fStyle = RBBS_VARIABLEHEIGHT;
636 rbi.cxMinChild = 50;
637 rbi.cyMinChild = 10;
638 rbi.cyIntegral = 11;
639 rbi.cyChild = 70;
640 rbi.cyMaxChild = 90;
641 rbi.cx = 90;
642 rbi.hwndChild = build_toolbar(0, hRebar);
643 SendMessageA(hRebar, RB_INSERTBANDA, -1, (LPARAM)&rbi);
644 check_sizes();
646 rbi.cyChild = 50;
647 rbi.hwndChild = build_toolbar(0, hRebar);
648 SendMessageA(hRebar, RB_INSERTBANDA, -1, (LPARAM)&rbi);
649 check_sizes();
651 rbi.cyMinChild = 40;
652 rbi.cyChild = 50;
653 rbi.cyIntegral = 5;
654 rbi.hwndChild = build_toolbar(0, hRebar);
655 SendMessageA(hRebar, RB_INSERTBANDA, -1, (LPARAM)&rbi);
656 check_sizes();
658 DestroyWindow(hRebar);
659 pImageList_Destroy(himl);
661 /* One hidden band. */
662 hRebar = create_rebar_control(0);
664 rbi.cbSize = REBARBANDINFOA_V6_SIZE;
665 rbi.fMask = RBBIM_STYLE | RBBIM_SIZE | RBBIM_CHILDSIZE | RBBIM_CHILD;
666 rbi.fStyle = RBBS_HIDDEN;
667 rbi.cx = 200;
668 rbi.cxMinChild = 100;
669 rbi.cyMinChild = 30;
670 rbi.hwndChild = NULL;
672 SendMessageA(hRebar, RB_INSERTBANDA, -1, (LPARAM)&rbi);
673 count = SendMessageA(hRebar, RB_GETROWCOUNT, 0, 0);
674 ok(!count, "Unexpected row count %d.\n", count);
676 DestroyWindow(hRebar);
678 rbsize_results_free();
681 #if 0 /* use this to generate more tests */
683 static void dump_client(HWND hRebar)
685 RECT r;
686 BOOL notify;
687 GetWindowRect(hRebar, &r);
688 MapWindowPoints(HWND_DESKTOP, hMainWnd, &r, 2);
689 if (height_change_notify_rect.top != -1)
691 RECT rcClient;
692 GetClientRect(hRebar, &rcClient);
693 assert(EqualRect(&rcClient, &height_change_notify_rect));
694 notify = TRUE;
696 else
697 notify = FALSE;
698 printf(" {{%d, %d, %d, %d}, %d, %s},\n", r.left, r.top, r.right, r.bottom, SendMessageA(hRebar, RB_GETROWCOUNT, 0, 0),
699 notify ? "TRUE" : "FALSE");
700 SetRect(&height_change_notify_rect, -1, -1, -1, -1);
703 #define comment(fmt, arg1) printf("/* " fmt " */\n", arg1);
704 #define check_client() dump_client(hRebar)
706 #else
708 typedef struct {
709 RECT rc;
710 INT iNumRows;
711 BOOL heightNotify;
712 } rbresize_test_result_t;
714 static const rbresize_test_result_t resize_results[] = {
715 /* style 00000001 */
716 {{0, 2, 672, 2}, 0, FALSE},
717 {{0, 2, 672, 22}, 1, TRUE},
718 {{0, 2, 672, 22}, 1, FALSE},
719 {{0, 2, 672, 22}, 1, FALSE},
720 {{0, 2, 672, 22}, 1, FALSE},
721 {{0, 2, 672, 22}, 0, FALSE},
722 /* style 00000041 */
723 {{0, 0, 672, 0}, 0, FALSE},
724 {{0, 0, 672, 20}, 1, TRUE},
725 {{0, 0, 672, 20}, 1, FALSE},
726 {{0, 0, 672, 20}, 1, FALSE},
727 {{0, 0, 672, 20}, 1, FALSE},
728 {{0, 0, 672, 20}, 0, FALSE},
729 /* style 00000003 */
730 {{0, 226, 672, 226}, 0, FALSE},
731 {{0, 206, 672, 226}, 1, TRUE},
732 {{0, 206, 672, 226}, 1, FALSE},
733 {{0, 206, 672, 226}, 1, FALSE},
734 {{0, 206, 672, 226}, 1, FALSE},
735 {{0, 206, 672, 226}, 0, FALSE},
736 /* style 00000043 */
737 {{0, 226, 672, 226}, 0, FALSE},
738 {{0, 206, 672, 226}, 1, TRUE},
739 {{0, 206, 672, 226}, 1, FALSE},
740 {{0, 206, 672, 226}, 1, FALSE},
741 {{0, 206, 672, 226}, 1, FALSE},
742 {{0, 206, 672, 226}, 0, FALSE},
743 /* style 00000080 */
744 {{2, 0, 2, 226}, 0, FALSE},
745 {{2, 0, 22, 226}, 1, TRUE},
746 {{2, 0, 22, 226}, 1, FALSE},
747 {{2, 0, 22, 226}, 1, FALSE},
748 {{2, 0, 22, 226}, 1, FALSE},
749 {{2, 0, 22, 226}, 0, FALSE},
750 /* style 00000083 */
751 {{672, 0, 672, 226}, 0, FALSE},
752 {{652, 0, 672, 226}, 1, TRUE},
753 {{652, 0, 672, 226}, 1, FALSE},
754 {{652, 0, 672, 226}, 1, FALSE},
755 {{652, 0, 672, 226}, 1, FALSE},
756 {{652, 0, 672, 226}, 0, FALSE},
757 /* style 00000008 */
758 {{10, 11, 510, 11}, 0, FALSE},
759 {{10, 15, 510, 35}, 1, TRUE},
760 {{10, 17, 510, 37}, 1, FALSE},
761 {{10, 14, 110, 54}, 2, TRUE},
762 {{0, 4, 0, 44}, 2, FALSE},
763 {{0, 6, 0, 46}, 2, FALSE},
764 {{0, 8, 0, 48}, 2, FALSE},
765 {{0, 12, 0, 32}, 1, TRUE},
766 {{0, 4, 100, 24}, 0, FALSE},
767 /* style 00000048 */
768 {{10, 5, 510, 5}, 0, FALSE},
769 {{10, 5, 510, 25}, 1, TRUE},
770 {{10, 5, 510, 25}, 1, FALSE},
771 {{10, 10, 110, 50}, 2, TRUE},
772 {{0, 0, 0, 40}, 2, FALSE},
773 {{0, 0, 0, 40}, 2, FALSE},
774 {{0, 0, 0, 40}, 2, FALSE},
775 {{0, 0, 0, 20}, 1, TRUE},
776 {{0, 0, 100, 20}, 0, FALSE},
777 /* style 00000004 */
778 {{10, 5, 510, 20}, 0, FALSE},
779 {{10, 5, 510, 20}, 1, TRUE},
780 {{10, 10, 110, 110}, 2, TRUE},
781 {{0, 0, 0, 0}, 2, FALSE},
782 {{0, 0, 0, 0}, 2, FALSE},
783 {{0, 0, 0, 0}, 2, FALSE},
784 {{0, 0, 0, 0}, 1, TRUE},
785 {{0, 0, 100, 100}, 0, FALSE},
786 /* style 00000002 */
787 {{0, 5, 672, 5}, 0, FALSE},
788 {{0, 5, 672, 25}, 1, TRUE},
789 {{0, 10, 672, 30}, 1, FALSE},
790 {{0, 0, 672, 20}, 1, FALSE},
791 {{0, 0, 672, 20}, 1, FALSE},
792 {{0, 0, 672, 20}, 0, FALSE},
793 /* style 00000082 */
794 {{10, 0, 10, 226}, 0, FALSE},
795 {{10, 0, 30, 226}, 1, TRUE},
796 {{10, 0, 30, 226}, 1, FALSE},
797 {{0, 0, 20, 226}, 1, FALSE},
798 {{0, 0, 20, 226}, 1, FALSE},
799 {{0, 0, 20, 226}, 0, FALSE},
800 /* style 00800001 */
801 {{-2, 0, 674, 4}, 0, FALSE},
802 {{-2, 0, 674, 24}, 1, TRUE},
803 {{-2, 0, 674, 24}, 1, FALSE},
804 {{-2, 0, 674, 24}, 1, FALSE},
805 {{-2, 0, 674, 24}, 1, FALSE},
806 {{-2, 0, 674, 24}, 0, FALSE},
807 /* style 00800048 */
808 {{10, 5, 510, 9}, 0, FALSE},
809 {{10, 5, 510, 29}, 1, TRUE},
810 {{10, 5, 510, 29}, 1, FALSE},
811 {{10, 10, 110, 54}, 2, TRUE},
812 {{0, 0, 0, 44}, 2, FALSE},
813 {{0, 0, 0, 44}, 2, FALSE},
814 {{0, 0, 0, 44}, 2, FALSE},
815 {{0, 0, 0, 24}, 1, TRUE},
816 {{0, 0, 100, 24}, 0, FALSE},
817 /* style 00800004 */
818 {{10, 5, 510, 20}, 0, FALSE},
819 {{10, 5, 510, 20}, 1, TRUE},
820 {{10, 10, 110, 110}, 2, TRUE},
821 {{0, 0, 0, 0}, 2, FALSE},
822 {{0, 0, 0, 0}, 2, FALSE},
823 {{0, 0, 0, 0}, 2, FALSE},
824 {{0, 0, 0, 0}, 1, TRUE},
825 {{0, 0, 100, 100}, 0, FALSE},
826 /* style 00800002 */
827 {{-2, 5, 674, 9}, 0, FALSE},
828 {{-2, 5, 674, 29}, 1, TRUE},
829 {{-2, 10, 674, 34}, 1, FALSE},
830 {{-2, 0, 674, 24}, 1, FALSE},
831 {{-2, 0, 674, 24}, 1, FALSE},
832 {{-2, 0, 674, 24}, 0, FALSE},
835 static DWORD resize_numtests = 0;
837 #define comment(fmt, arg1)
838 #define check_client() { \
839 RECT r; \
840 int value; \
841 const rbresize_test_result_t *res = &resize_results[resize_numtests++]; \
842 assert(resize_numtests <= ARRAY_SIZE(resize_results)); \
843 GetWindowRect(hRebar, &r); \
844 MapWindowPoints(HWND_DESKTOP, hMainWnd, (LPPOINT)&r, 2); \
845 if ((dwStyles[i] & (CCS_NOPARENTALIGN|CCS_NODIVIDER)) == CCS_NOPARENTALIGN) {\
846 check_rect_no_top("client", r, res->rc); /* the top coordinate changes after every layout and is very implementation-dependent */ \
847 } else { \
848 check_rect("client", r, res->rc); \
850 value = (int)SendMessageA(hRebar, RB_GETROWCOUNT, 0, 0); \
851 ok(res->iNumRows == value, "RB_GETROWCOUNT expected %d got %d\n", res->iNumRows, value); \
852 if (res->heightNotify) { \
853 RECT rcClient; \
854 GetClientRect(hRebar, &rcClient); \
855 check_rect("notify", height_change_notify_rect, rcClient); \
856 } else ok(height_change_notify_rect.top == -1, "Unexpected RBN_HEIGHTCHANGE received\n"); \
857 SetRect(&height_change_notify_rect, -1, -1, -1, -1); \
860 #endif
862 static void test_resize(void)
864 DWORD dwStyles[] = {CCS_TOP, CCS_TOP | CCS_NODIVIDER, CCS_BOTTOM, CCS_BOTTOM | CCS_NODIVIDER, CCS_VERT, CCS_RIGHT,
865 CCS_NOPARENTALIGN, CCS_NOPARENTALIGN | CCS_NODIVIDER, CCS_NORESIZE, CCS_NOMOVEY, CCS_NOMOVEY | CCS_VERT,
866 CCS_TOP | WS_BORDER, CCS_NOPARENTALIGN | CCS_NODIVIDER | WS_BORDER, CCS_NORESIZE | WS_BORDER,
867 CCS_NOMOVEY | WS_BORDER};
869 const int styles_count = ARRAY_SIZE(dwStyles);
870 int i;
872 for (i = 0; i < styles_count; i++)
874 HWND hRebar;
876 comment("style %08x", dwStyles[i]);
877 SetRect(&height_change_notify_rect, -1, -1, -1, -1);
878 hRebar = CreateWindowA(REBARCLASSNAMEA, "A", dwStyles[i] | WS_CHILD | WS_VISIBLE, 10, 5, 500, 15, hMainWnd, NULL, GetModuleHandleA(NULL), 0);
879 check_client();
880 add_band_w(hRebar, NULL, 70, 100, 0);
881 if (dwStyles[i] & CCS_NOPARENTALIGN) /* the window drifts downward for CCS_NOPARENTALIGN without CCS_NODIVIDER */
882 check_client();
883 add_band_w(hRebar, NULL, 70, 100, 0);
884 check_client();
885 MoveWindow(hRebar, 10, 10, 100, 100, TRUE);
886 check_client();
887 MoveWindow(hRebar, 0, 0, 0, 0, TRUE);
888 check_client();
889 /* try to fool the rebar by sending invalid width/height - won't work */
890 if (dwStyles[i] & (CCS_NORESIZE | CCS_NOPARENTALIGN))
892 WINDOWPOS pos;
893 pos.hwnd = hRebar;
894 pos.hwndInsertAfter = NULL;
895 pos.cx = 500;
896 pos.cy = 500;
897 pos.x = 10;
898 pos.y = 10;
899 pos.flags = 0;
900 SendMessageA(hRebar, WM_WINDOWPOSCHANGING, 0, (LPARAM)&pos);
901 SendMessageA(hRebar, WM_WINDOWPOSCHANGED, 0, (LPARAM)&pos);
902 check_client();
903 SendMessageA(hRebar, WM_SIZE, SIZE_RESTORED, MAKELONG(500, 500));
904 check_client();
906 SendMessageA(hRebar, RB_DELETEBAND, 0, 0);
907 check_client();
908 SendMessageA(hRebar, RB_DELETEBAND, 0, 0);
909 MoveWindow(hRebar, 0, 0, 100, 100, TRUE);
910 check_client();
911 DestroyWindow(hRebar);
915 static void expect_band_content_(int line, HWND hRebar, UINT uBand, INT fStyle, COLORREF clrFore,
916 COLORREF clrBack, LPCSTR lpText, int iImage, HWND hwndChild,
917 INT cxMinChild, INT cyMinChild, INT cx, HBITMAP hbmBack, INT wID,
918 INT cyChild, INT cyMaxChild, INT cyIntegral, INT cxIdeal, LPARAM lParam,
919 UINT cxHeader, UINT cxHeader_broken)
921 CHAR buf[MAX_PATH] = "abc";
922 REBARBANDINFOA rb;
924 memset(&rb, 0xdd, sizeof(rb));
925 rb.cbSize = REBARBANDINFOA_V6_SIZE;
926 rb.fMask = RBBIM_BACKGROUND | RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_COLORS
927 | RBBIM_HEADERSIZE | RBBIM_ID | RBBIM_IDEALSIZE | RBBIM_IMAGE | RBBIM_LPARAM
928 | RBBIM_SIZE | RBBIM_STYLE | RBBIM_TEXT;
929 rb.lpText = buf;
930 rb.cch = MAX_PATH;
931 ok(SendMessageA(hRebar, RB_GETBANDINFOA, uBand, (LPARAM)&rb), "RB_GETBANDINFOA failed from line %d\n", line);
932 expect_eq(line, rb.fStyle, fStyle, int, "%x");
933 expect_eq(line, rb.clrFore, clrFore, COLORREF, "%lx");
934 expect_eq(line, rb.clrBack, clrBack, COLORREF, "%lx");
935 expect_eq(line, strcmp(rb.lpText, lpText), 0, int, "%d");
936 expect_eq(line, rb.iImage, iImage, int, "%x");
937 expect_eq(line, rb.hwndChild, hwndChild, HWND, "%p");
938 expect_eq(line, rb.cxMinChild, cxMinChild, int, "%d");
939 expect_eq(line, rb.cyMinChild, cyMinChild, int, "%d");
940 expect_eq(line, rb.cx, cx, int, "%d");
941 expect_eq(line, rb.hbmBack, hbmBack, HBITMAP, "%p");
942 expect_eq(line, rb.wID, wID, int, "%d");
943 /* the values of cyChild, cyMaxChild and cyIntegral can't be read unless the band is RBBS_VARIABLEHEIGHT */
944 expect_eq(line, rb.cyChild, cyChild, int, "%x");
945 expect_eq(line, rb.cyMaxChild, cyMaxChild, int, "%x");
946 expect_eq(line, rb.cyIntegral, cyIntegral, int, "%x");
947 expect_eq(line, rb.cxIdeal, cxIdeal, int, "%d");
948 expect_eq(line, rb.lParam, lParam, LPARAM, "%Id");
949 ok(rb.cxHeader == cxHeader || rb.cxHeader == cxHeader + 1 || broken(rb.cxHeader == cxHeader_broken),
950 "expected %d for %d from line %d\n", cxHeader, rb.cxHeader, line);
953 #define expect_band_content(hRebar, uBand, fStyle, clrFore, clrBack,\
954 lpText, iImage, hwndChild, cxMinChild, cyMinChild, cx, hbmBack, wID,\
955 cyChild, cyMaxChild, cyIntegral, cxIdeal, lParam, cxHeader, cxHeader_broken) \
956 expect_band_content_(__LINE__, hRebar, uBand, fStyle, clrFore, clrBack,\
957 lpText, iImage, hwndChild, cxMinChild, cyMinChild, cx, hbmBack, wID,\
958 cyChild, cyMaxChild, cyIntegral, cxIdeal, lParam, cxHeader, cxHeader_broken)
960 static void test_bandinfo(void)
962 REBARBANDINFOA rb;
963 CHAR szABC[] = "ABC";
964 CHAR szABCD[] = "ABCD";
965 HWND hRebar;
967 hRebar = create_rebar_control(0);
968 rb.cbSize = REBARBANDINFOA_V6_SIZE;
969 rb.fMask = 0;
970 if (!SendMessageA(hRebar, RB_INSERTBANDA, 0, (LPARAM)&rb))
972 win_skip( "V6 info not supported\n" );
973 DestroyWindow(hRebar);
974 return;
976 expect_band_content(hRebar, 0, 0, 0, GetSysColor(COLOR_3DFACE), "", -1, NULL, 0, 0, 0, NULL, 0, 0xdddddddd, 0xdddddddd, 0xdddddddd, 0, 0, 0, -1);
978 rb.fMask = RBBIM_CHILDSIZE;
979 rb.cxMinChild = 15;
980 rb.cyMinChild = 20;
981 rb.cyChild = 30;
982 rb.cyMaxChild = 20;
983 rb.cyIntegral = 10;
984 ok(SendMessageA(hRebar, RB_SETBANDINFOA, 0, (LPARAM)&rb), "RB_SETBANDINFOA failed\n");
985 expect_band_content(hRebar, 0, 0, 0, GetSysColor(COLOR_3DFACE), "", -1, NULL, 15, 20, 0, NULL, 0, 0xdddddddd, 0xdddddddd, 0xdddddddd, 0, 0, 0, -1);
987 rb.fMask = RBBIM_TEXT;
988 rb.lpText = szABC;
989 ok(SendMessageA(hRebar, RB_SETBANDINFOA, 0, (LPARAM)&rb), "RB_SETBANDINFOA failed\n");
990 expect_band_content(hRebar, 0, 0, 0, GetSysColor(COLOR_3DFACE), "ABC", -1, NULL, 15, 20, 0, NULL, 0, 0xdddddddd, 0xdddddddd, 0xdddddddd, 0, 0, 3 + 2*system_font_height, -1);
992 rb.cbSize = REBARBANDINFOA_V6_SIZE;
993 rb.fMask = 0;
994 ok(SendMessageA(hRebar, RB_INSERTBANDA, 1, (LPARAM)&rb), "RB_INSERTBANDA failed\n");
995 expect_band_content(hRebar, 1, 0, 0, GetSysColor(COLOR_3DFACE), "", -1, NULL, 0, 0, 0, NULL, 0, 0xdddddddd, 0xdddddddd, 0xdddddddd, 0, 0, 9, -1);
996 expect_band_content(hRebar, 0, 0, 0, GetSysColor(COLOR_3DFACE), "ABC", -1, NULL, 15, 20, 0, NULL, 0, 0xdddddddd, 0xdddddddd, 0xdddddddd, 0, 0, 8 + 2*system_font_height, -1);
998 rb.fMask = RBBIM_HEADERSIZE;
999 rb.cxHeader = 50;
1000 ok(SendMessageA(hRebar, RB_SETBANDINFOA, 0, (LPARAM)&rb), "RB_SETBANDINFOA failed\n");
1001 expect_band_content(hRebar, 0, 0x40000000, 0, GetSysColor(COLOR_3DFACE), "ABC", -1, NULL, 15, 20, 0, NULL, 0, 0xdddddddd, 0xdddddddd, 0xdddddddd, 0, 0, 50, -1);
1003 rb.cxHeader = 5;
1004 ok(SendMessageA(hRebar, RB_SETBANDINFOA, 0, (LPARAM)&rb), "RB_SETBANDINFOA failed\n");
1005 expect_band_content(hRebar, 0, 0x40000000, 0, GetSysColor(COLOR_3DFACE), "ABC", -1, NULL, 15, 20, 0, NULL, 0, 0xdddddddd, 0xdddddddd, 0xdddddddd, 0, 0, 5, -1);
1007 rb.fMask = RBBIM_TEXT;
1008 rb.lpText = szABCD;
1009 ok(SendMessageA(hRebar, RB_SETBANDINFOA, 0, (LPARAM)&rb), "RB_SETBANDINFOA failed\n");
1010 expect_band_content(hRebar, 0, 0x40000000, 0, GetSysColor(COLOR_3DFACE), "ABCD", -1, NULL, 15, 20, 0, NULL, 0, 0xdddddddd, 0xdddddddd, 0xdddddddd, 0, 0, 5, -1);
1011 rb.fMask = RBBIM_STYLE | RBBIM_TEXT;
1012 rb.fStyle = RBBS_VARIABLEHEIGHT;
1013 rb.lpText = szABC;
1014 ok(SendMessageA(hRebar, RB_SETBANDINFOA, 0, (LPARAM)&rb), "RB_SETBANDINFOA failed\n");
1015 expect_band_content(hRebar, 0, RBBS_VARIABLEHEIGHT, 0, GetSysColor(COLOR_3DFACE), "ABC", -1, NULL, 15, 20, 0, NULL, 0, 20, 0x7fffffff, 0, 0, 0, 8 + 2*system_font_height, 5);
1017 DestroyWindow(hRebar);
1020 static void test_colors(void)
1022 COLORSCHEME scheme;
1023 COLORREF clr;
1024 BOOL ret;
1025 HWND hRebar;
1026 REBARBANDINFOA bi;
1028 hRebar = create_rebar_control(0);
1030 /* test default colors */
1031 clr = SendMessageA(hRebar, RB_GETTEXTCOLOR, 0, 0);
1032 compare(clr, CLR_NONE, "%lx");
1033 clr = SendMessageA(hRebar, RB_GETBKCOLOR, 0, 0);
1034 compare(clr, CLR_NONE, "%lx");
1036 scheme.dwSize = sizeof(scheme);
1037 scheme.clrBtnHighlight = 0;
1038 scheme.clrBtnShadow = 0;
1039 ret = SendMessageA(hRebar, RB_GETCOLORSCHEME, 0, (LPARAM)&scheme);
1040 if (ret)
1042 compare(scheme.clrBtnHighlight, CLR_DEFAULT, "%lx");
1043 compare(scheme.clrBtnShadow, CLR_DEFAULT, "%lx");
1045 else
1046 skip("RB_GETCOLORSCHEME not supported\n");
1048 /* check default band colors */
1049 add_band_w(hRebar, "", 0, 10, 10);
1050 bi.cbSize = REBARBANDINFOA_V6_SIZE;
1051 bi.fMask = RBBIM_COLORS;
1052 bi.clrFore = bi.clrBack = 0xc0ffe;
1053 ret = SendMessageA(hRebar, RB_GETBANDINFOA, 0, (LPARAM)&bi);
1054 ok(ret, "RB_GETBANDINFOA failed\n");
1055 compare(bi.clrFore, RGB(0, 0, 0), "%lx");
1056 compare(bi.clrBack, GetSysColor(COLOR_3DFACE), "%lx");
1058 SendMessageA(hRebar, RB_SETTEXTCOLOR, 0, RGB(255, 0, 0));
1059 bi.clrFore = bi.clrBack = 0xc0ffe;
1060 ret = SendMessageA(hRebar, RB_GETBANDINFOA, 0, (LPARAM)&bi);
1061 ok(ret, "RB_GETBANDINFOA failed\n");
1062 compare(bi.clrFore, RGB(0, 0, 0), "%lx");
1064 DestroyWindow(hRebar);
1068 static BOOL register_parent_wnd_class(void)
1070 WNDCLASSA wc;
1072 wc.style = CS_HREDRAW | CS_VREDRAW;
1073 wc.cbClsExtra = 0;
1074 wc.cbWndExtra = 0;
1075 wc.hInstance = GetModuleHandleA(NULL);
1076 wc.hIcon = NULL;
1077 wc.hCursor = LoadCursorA(NULL, (LPCSTR)IDC_IBEAM);
1078 wc.hbrBackground = GetSysColorBrush(COLOR_WINDOW);
1079 wc.lpszMenuName = NULL;
1080 wc.lpszClassName = "MyTestWnd";
1081 wc.lpfnWndProc = parent_wndproc;
1083 return RegisterClassA(&wc);
1086 static HWND create_parent_window(void)
1088 HWND hwnd;
1090 if (!register_parent_wnd_class()) return NULL;
1092 hwnd = CreateWindowExA(0, "MyTestWnd", "Blah", WS_OVERLAPPEDWINDOW,
1093 CW_USEDEFAULT, CW_USEDEFAULT, 672+2*GetSystemMetrics(SM_CXSIZEFRAME),
1094 226+GetSystemMetrics(SM_CYCAPTION)+2*GetSystemMetrics(SM_CYSIZEFRAME),
1095 NULL, NULL, GetModuleHandleA(NULL), 0);
1097 ShowWindow(hwnd, SW_SHOW);
1098 return hwnd;
1101 static void test_showband(void)
1103 HWND hRebar;
1104 REBARBANDINFOA rbi;
1105 BOOL ret;
1107 hRebar = create_rebar_control(0);
1109 /* no bands */
1110 ret = SendMessageA(hRebar, RB_SHOWBAND, 0, TRUE);
1111 ok(ret == FALSE, "got %d\n", ret);
1113 rbi.cbSize = REBARBANDINFOA_V6_SIZE;
1114 rbi.fMask = RBBIM_SIZE | RBBIM_CHILDSIZE | RBBIM_CHILD;
1115 rbi.cx = 200;
1116 rbi.cxMinChild = 100;
1117 rbi.cyMinChild = 30;
1118 rbi.hwndChild = NULL;
1119 SendMessageA(hRebar, RB_INSERTBANDA, -1, (LPARAM)&rbi);
1121 /* index out of range */
1122 ret = SendMessageA(hRebar, RB_SHOWBAND, 1, TRUE);
1123 ok(ret == FALSE, "got %d\n", ret);
1125 ret = SendMessageA(hRebar, RB_SHOWBAND, 0, TRUE);
1126 ok(ret == TRUE, "got %d\n", ret);
1128 DestroyWindow(hRebar);
1131 static void test_notification(void)
1133 MEASUREITEMSTRUCT mis;
1134 HWND rebar;
1136 rebar = create_rebar_control(0);
1138 g_parent_measureitem = 0;
1139 SendMessageA(rebar, WM_MEASUREITEM, 0, (LPARAM)&mis);
1140 ok(g_parent_measureitem == 1, "got %d\n", g_parent_measureitem);
1142 DestroyWindow(rebar);
1145 static void test_style(void)
1147 STYLESTRUCT style_struct;
1148 LONG style;
1149 HWND hwnd;
1150 RECT rect;
1152 /* WS_BORDER */
1153 hwnd = create_rebar_control(WS_BORDER);
1154 ok(GetWindowLongW(hwnd, GWL_STYLE) & WS_BORDER, "Expected WS_BORDER.\n");
1156 GetClientRect(hwnd, &rect);
1157 SendMessageW(hwnd, WM_NCCALCSIZE, 0, (LPARAM)&rect);
1158 ok(GetWindowLongW(hwnd, GWL_STYLE) & WS_BORDER, "Expected WS_BORDER.\n");
1160 SendMessageW(hwnd, WM_THEMECHANGED, 0, 0);
1161 style = GetWindowLongW(hwnd, GWL_STYLE);
1162 ok(style & WS_BORDER, "Expected WS_BORDER.\n");
1164 style_struct.styleOld = style;
1165 style_struct.styleNew = style | WS_DLGFRAME;
1166 SendMessageW(hwnd, WM_STYLECHANGED, (WPARAM)GWL_STYLE, (LPARAM)&style_struct);
1167 ok(GetWindowLongW(hwnd, GWL_STYLE) & WS_BORDER, "Expected WS_BORDER.\n");
1169 DestroyWindow(hwnd);
1172 static void init_functions(void)
1174 HMODULE hComCtl32 = LoadLibraryA("comctl32.dll");
1176 #define X(f) p##f = (void*)GetProcAddress(hComCtl32, #f);
1177 X(ImageList_Destroy);
1178 X(ImageList_LoadImageA);
1179 #undef X
1182 START_TEST(rebar)
1184 MSG msg;
1186 init_system_font_height();
1187 init_functions();
1189 hMainWnd = create_parent_window();
1191 test_bandinfo();
1192 test_colors();
1193 test_showband();
1194 test_notification();
1196 if(!is_font_installed("System") || !is_font_installed("Tahoma"))
1198 skip("Missing System or Tahoma font\n");
1199 goto out;
1202 test_layout();
1203 test_resize();
1204 test_style();
1206 out:
1207 PostQuitMessage(0);
1208 while(GetMessageA(&msg,0,0,0)) {
1209 TranslateMessage(&msg);
1210 DispatchMessageA(&msg);
1212 DestroyWindow(hMainWnd);