1 /* Unit test suite for status control.
3 * Copyright 2007 Google (Lei Zhang)
4 * Copyright 2007 Alex Arazi
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
24 #include "wine/test.h"
26 #define SUBCLASS_NAME "MyStatusBar"
28 #define expect(expected,got) ok (expected == got,"Expected %d, got %d\n",expected,got)
29 #define expect_rect(_left,_top,_right,_bottom,got) do { \
30 RECT exp = {abs(got.left - _left), abs(got.top - _top), \
31 abs(got.right - _right), abs(got.bottom - _bottom)}; \
32 ok(exp.left <= 2 && exp.top <= 2 && exp.right <= 2 && exp.bottom <= 2, \
33 "Expected rect (%d,%d)-(%d,%d), got %s\n", _left, _top, _right, _bottom, \
34 wine_dbgstr_rect(&(got))); } while (0)
36 static HINSTANCE hinst
;
37 static WNDPROC g_status_wndproc
;
38 static RECT g_rcCreated
;
39 static HWND g_hMainWnd
;
40 static int g_wmsize_count
= 0;
43 static int g_wmdrawitm_ctr
;
44 static WNDPROC g_wndproc_saved
;
46 static BOOL (WINAPI
*pInitCommonControlsEx
)(const INITCOMMONCONTROLSEX
*);
48 static HWND
create_status_control(DWORD style
, DWORD exstyle
)
52 /* make the control */
53 hWndStatus
= CreateWindowExA(exstyle
, STATUSCLASSNAMEA
, NULL
, style
,
57 NULL
, NULL
, hinst
, NULL
);
58 ok(hWndStatus
!= NULL
, "failed to create status wnd\n");
62 static LRESULT WINAPI
create_test_wndproc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
68 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lParam
;
69 ret
= CallWindowProcA(g_status_wndproc
, hwnd
, msg
, wParam
, lParam
);
70 GetWindowRect(hwnd
, &g_rcCreated
);
71 MapWindowPoints(HWND_DESKTOP
, g_hMainWnd
, (LPPOINT
)&g_rcCreated
, 2);
72 ok(cs
->x
== g_rcCreated
.left
, "CREATESTRUCT.x modified\n");
73 ok(cs
->y
== g_rcCreated
.top
, "CREATESTRUCT.y modified\n");
74 } else if (msg
== WM_SIZE
)
77 ret
= CallWindowProcA(g_status_wndproc
, hwnd
, msg
, wParam
, lParam
);
80 ret
= CallWindowProcA(g_status_wndproc
, hwnd
, msg
, wParam
, lParam
);
85 static void register_subclass(void)
89 cls
.cbSize
= sizeof(WNDCLASSEXA
);
90 GetClassInfoExA(NULL
, STATUSCLASSNAMEA
, &cls
);
91 g_status_wndproc
= cls
.lpfnWndProc
;
92 cls
.lpfnWndProc
= create_test_wndproc
;
93 cls
.lpszClassName
= SUBCLASS_NAME
;
95 ok(RegisterClassExA(&cls
), "RegisterClassEx failed\n");
98 static void test_create(void)
103 ok((hwnd
= CreateWindowA(SUBCLASS_NAME
, "", WS_CHILD
|WS_VISIBLE
|SBARS_SIZEGRIP
, 0, 0, 100, 100,
104 g_hMainWnd
, NULL
, NULL
, 0)) != NULL
, "CreateWindowA failed\n");
105 MapWindowPoints(HWND_DESKTOP
, g_hMainWnd
, (LPPOINT
)&rc
, 2);
106 GetWindowRect(hwnd
, &rc
);
107 MapWindowPoints(HWND_DESKTOP
, g_hMainWnd
, (LPPOINT
)&rc
, 2);
108 expect_rect(0, 0, 100, 100, g_rcCreated
);
110 expect(672, rc
.right
);
111 expect(226, rc
.bottom
);
112 /* we don't check rc.top as this may depend on user font settings */
116 static int CALLBACK
check_height_font_enumproc(ENUMLOGFONTEXA
*enumlf
, NEWTEXTMETRICEXA
*ntm
, DWORD type
, LPARAM lParam
)
118 HWND hwndStatus
= (HWND
)lParam
;
119 HDC hdc
= GetDC(NULL
);
120 static const int sizes
[] = { 6, 7, 8, 9, 10, 11, 12, 13, 15, 16,
121 20, 22, 28, 36, 48, 72};
124 LPSTR facename
= (CHAR
*)enumlf
->elfFullName
;
126 /* on win9x, enumlf->elfFullName is only valid for truetype fonts */
127 if (type
!= TRUETYPE_FONTTYPE
)
128 facename
= enumlf
->elfLogFont
.lfFaceName
;
130 for (i
= 0; i
< ARRAY_SIZE(sizes
); i
++)
138 enumlf
->elfLogFont
.lfHeight
= sizes
[i
];
139 hFont
= CreateFontIndirectA(&enumlf
->elfLogFont
);
140 hCtrlFont
= (HFONT
)SendMessageA(hwndStatus
, WM_SETFONT
, (WPARAM
)hFont
, TRUE
);
141 hOldFont
= SelectObject(hdc
, hFont
);
143 GetClientRect(hwndStatus
, &rcCtrl
);
144 GetTextMetricsA(hdc
, &tm
);
145 y
= tm
.tmHeight
+ (tm
.tmInternalLeading
? tm
.tmInternalLeading
: 2) + 4;
147 ok( (rcCtrl
.bottom
== max(y
, g_ysize
)) || (rcCtrl
.bottom
== max(y
, g_dpisize
)),
148 "got %d (expected %d or %d) for %s #%d\n",
149 rcCtrl
.bottom
, max(y
, g_ysize
), max(y
, g_dpisize
), facename
, sizes
[i
]);
151 SelectObject(hdc
, hOldFont
);
152 SendMessageA(hwndStatus
, WM_SETFONT
, (WPARAM
)hCtrlFont
, TRUE
);
155 ReleaseDC(NULL
, hdc
);
159 static int CALLBACK
check_height_family_enumproc(ENUMLOGFONTEXA
*enumlf
, NEWTEXTMETRICEXA
*ntm
, DWORD type
, LPARAM lParam
)
161 HDC hdc
= GetDC(NULL
);
162 enumlf
->elfLogFont
.lfHeight
= 0;
163 EnumFontFamiliesExA(hdc
, &enumlf
->elfLogFont
, (FONTENUMPROCA
)check_height_font_enumproc
, lParam
, 0);
164 ReleaseDC(NULL
, hdc
);
168 static void test_height(void)
171 HFONT hFont
, hFontSm
;
173 HWND hwndStatus
= CreateWindowA(SUBCLASS_NAME
, NULL
, WS_CHILD
|WS_VISIBLE
,
174 0, 0, 300, 20, g_hMainWnd
, NULL
, NULL
, NULL
);
177 GetClientRect(hwndStatus
, &rc1
);
178 hFont
= CreateFontA(32, 0, 0, 0, FW_DONTCARE
, FALSE
, FALSE
, FALSE
, ANSI_CHARSET
,
179 OUT_DEFAULT_PRECIS
, CLIP_DEFAULT_PRECIS
, DEFAULT_QUALITY
, FF_DONTCARE
, "Tahoma");
182 SendMessageA(hwndStatus
, WM_SETFONT
, (WPARAM
)hFont
, TRUE
);
185 skip("Status control not resized in win95, skipping broken tests.\n");
188 ok(g_wmsize_count
> 0, "WM_SETFONT should issue WM_SIZE\n");
190 GetClientRect(hwndStatus
, &rc2
);
191 expect_rect(0, 0, 672, 42, rc2
); /* GetTextMetrics returns invalid tmInternalLeading for this font */
194 SendMessageA(hwndStatus
, WM_SETFONT
, (WPARAM
)hFont
, TRUE
);
195 ok(g_wmsize_count
> 0, "WM_SETFONT should issue WM_SIZE\n");
197 GetClientRect(hwndStatus
, &rc2
);
198 expect_rect(0, 0, 672, 42, rc2
);
200 /* minheight < fontsize - no effects*/
201 SendMessageA(hwndStatus
, SB_SETMINHEIGHT
, 12, 0);
202 SendMessageA(hwndStatus
, WM_SIZE
, 0, 0);
203 GetClientRect(hwndStatus
, &rc2
);
204 expect_rect(0, 0, 672, 42, rc2
);
206 /* minheight > fontsize - has an effect after WM_SIZE */
207 SendMessageA(hwndStatus
, SB_SETMINHEIGHT
, 60, 0);
208 GetClientRect(hwndStatus
, &rc2
);
209 expect_rect(0, 0, 672, 42, rc2
);
210 SendMessageA(hwndStatus
, WM_SIZE
, 0, 0);
211 GetClientRect(hwndStatus
, &rc2
);
212 expect_rect(0, 0, 672, 62, rc2
);
214 /* font changed to smaller than minheight - has an effect */
215 SendMessageA(hwndStatus
, SB_SETMINHEIGHT
, 30, 0);
216 expect_rect(0, 0, 672, 62, rc2
);
217 SendMessageA(hwndStatus
, WM_SIZE
, 0, 0);
218 GetClientRect(hwndStatus
, &rc2
);
219 expect_rect(0, 0, 672, 42, rc2
);
220 hFontSm
= CreateFontA(9, 0, 0, 0, FW_DONTCARE
, FALSE
, FALSE
, FALSE
, ANSI_CHARSET
,
221 OUT_DEFAULT_PRECIS
, CLIP_DEFAULT_PRECIS
, DEFAULT_QUALITY
, FF_DONTCARE
, "Tahoma");
222 SendMessageA(hwndStatus
, WM_SETFONT
, (WPARAM
)hFontSm
, TRUE
);
223 GetClientRect(hwndStatus
, &rc2
);
224 expect_rect(0, 0, 672, 32, rc2
);
226 /* test the height formula */
227 ZeroMemory(&lf
, sizeof(lf
));
228 SendMessageA(hwndStatus
, SB_SETMINHEIGHT
, 0, 0);
231 /* used only for some fonts (tahoma as example) */
232 g_ysize
= GetSystemMetrics(SM_CYSIZE
) + 2;
233 if (g_ysize
& 1) g_ysize
--; /* The min height is always even */
235 g_dpisize
= MulDiv(18, GetDeviceCaps(hdc
, LOGPIXELSY
), 96) + 2;
236 if (g_dpisize
& 1) g_dpisize
--; /* The min height is always even */
239 trace("dpi=%d (min height: %d or %d) SM_CYSIZE: %d\n",
240 GetDeviceCaps(hdc
, LOGPIXELSY
), g_ysize
, g_dpisize
,
241 GetSystemMetrics(SM_CYSIZE
));
243 EnumFontFamiliesExA(hdc
, &lf
, (FONTENUMPROCA
)check_height_family_enumproc
, (LPARAM
)hwndStatus
, 0);
244 ReleaseDC(NULL
, hdc
);
246 DestroyWindow(hwndStatus
);
248 DeleteObject(hFontSm
);
251 static void test_status_control(void)
255 int nParts
[] = {50, 150, -1};
256 int checkParts
[] = {0, 0, 0};
257 int borders
[] = {0, 0, 0};
262 char chstr
[10] = "Inval id";
263 COLORREF crColor
= RGB(0,0,0);
265 hWndStatus
= create_status_control(WS_VISIBLE
| SBT_TOOLTIPS
, 0);
267 /* Divide into parts and set text */
268 r
= SendMessageA(hWndStatus
, SB_SETPARTS
, 3, (LPARAM
)nParts
);
270 r
= SendMessageA(hWndStatus
, SB_SETTEXTA
, SBT_POPOUT
|0, (LPARAM
)"First");
272 r
= SendMessageA(hWndStatus
, SB_SETTEXTA
, SBT_OWNERDRAW
|1, (LPARAM
)"Second");
274 r
= SendMessageA(hWndStatus
, SB_SETTEXTA
, SBT_NOBORDERS
|2, (LPARAM
)"Third");
277 /* Get RECT Information */
278 r
= SendMessageA(hWndStatus
, SB_GETRECT
, 0, (LPARAM
)&rc
);
281 /* The rc.bottom test is system dependent
282 expect(22,rc.bottom); */
285 r
= SendMessageA(hWndStatus
, SB_GETRECT
, -1, (LPARAM
)&rc
);
287 r
= SendMessageA(hWndStatus
, SB_GETRECT
, 3, (LPARAM
)&rc
);
289 /* Get text length and text */
290 r
= SendMessageA(hWndStatus
, SB_GETTEXTLENGTHA
, 0, 0);
292 expect(SBT_POPOUT
,HIWORD(r
));
293 r
= SendMessageW(hWndStatus
, WM_GETTEXTLENGTH
, 0, 0);
294 ok(r
== 5, "Expected 5, got %d\n", r
);
295 r
= SendMessageA(hWndStatus
, SB_GETTEXTLENGTHA
, 1, 0);
297 expect(SBT_OWNERDRAW
,HIWORD(r
));
298 r
= SendMessageA(hWndStatus
, SB_GETTEXTLENGTHA
, 2, 0);
300 expect(SBT_NOBORDERS
,HIWORD(r
));
301 r
= SendMessageA(hWndStatus
, SB_GETTEXTA
, 2, (LPARAM
) charArray
);
302 ok(strcmp(charArray
,"Third") == 0, "Expected Third, got %s\n", charArray
);
304 expect(SBT_NOBORDERS
,HIWORD(r
));
306 /* Get parts and borders */
307 r
= SendMessageA(hWndStatus
, SB_GETPARTS
, 3, (LPARAM
)checkParts
);
308 ok(r
== 3, "Expected 3, got %d\n", r
);
309 expect(50,checkParts
[0]);
310 expect(150,checkParts
[1]);
311 expect(-1,checkParts
[2]);
312 r
= SendMessageA(hWndStatus
, SB_GETBORDERS
, 0, (LPARAM
)borders
);
313 ok(r
== TRUE
, "Expected TRUE, got %d\n", r
);
314 expect(0,borders
[0]);
315 expect(2,borders
[1]);
316 expect(2,borders
[2]);
318 /* Test resetting text with different characters */
319 r
= SendMessageA(hWndStatus
, SB_SETTEXTA
, 0, (LPARAM
)"First@Again");
321 r
= SendMessageA(hWndStatus
, SB_SETTEXTA
, 1, (LPARAM
)"Invalid\tChars\\7\7");
323 r
= SendMessageA(hWndStatus
, SB_SETTEXTA
, 2, (LPARAM
)"InvalidChars\\n\n");
327 r
= SendMessageA(hWndStatus
, SB_GETTEXTA
, 0, (LPARAM
) charArray
);
328 ok(strcmp(charArray
,"First@Again") == 0, "Expected First@Again, got %s\n", charArray
);
329 expect(11,LOWORD(r
));
331 r
= SendMessageA(hWndStatus
, SB_GETTEXTA
, 1, (LPARAM
) charArray
);
332 ok(strcmp(charArray
,"Invalid\tChars\\7 ") == 0, "Expected Invalid\tChars\\7 , got %s\n", charArray
);
334 expect(16,LOWORD(r
));
336 r
= SendMessageA(hWndStatus
, SB_GETTEXTA
, 2, (LPARAM
) charArray
);
337 ok(strcmp(charArray
,"InvalidChars\\n ") == 0, "Expected InvalidChars\\n , got %s\n", charArray
);
339 expect(15,LOWORD(r
));
342 /* test more nonprintable chars */
343 for(ch
= 0x00; ch
< 0x7F; ch
++) {
345 r
= SendMessageA(hWndStatus
, SB_SETTEXTA
, 0, (LPARAM
)chstr
);
347 r
= SendMessageA(hWndStatus
, SB_GETTEXTA
, 0, (LPARAM
)charArray
);
348 ok(r
== strlen(charArray
), "got %d\n", r
);
349 /* substitution with single space */
350 if (ch
> 0x00 && ch
< 0x20 && ch
!= '\t')
352 ok(strcmp(charArray
, chstr
) == 0, "Expected %s, got %s\n", chstr
, charArray
);
355 /* Set background color */
356 crColor
= SendMessageA(hWndStatus
, SB_SETBKCOLOR
, 0, RGB(255,0,0));
357 ok(crColor
== CLR_DEFAULT
||
358 broken(crColor
== RGB(0,0,0)), /* win95 */
359 "Expected 0x%.8x, got 0x%.8x\n", CLR_DEFAULT
, crColor
);
360 crColor
= SendMessageA(hWndStatus
, SB_SETBKCOLOR
, 0, CLR_DEFAULT
);
361 ok(crColor
== RGB(255,0,0) ||
362 broken(crColor
== RGB(0,0,0)), /* win95 */
363 "Expected 0x%.8x, got 0x%.8x\n", RGB(255,0,0), crColor
);
365 /* Add an icon to the status bar */
366 hIcon
= LoadIconA(NULL
, (LPCSTR
)IDI_QUESTION
);
367 r
= SendMessageA(hWndStatus
, SB_SETICON
, 1, 0);
369 broken(r
== 0), /* win95 */
370 "Expected non-zero, got %d\n", r
);
371 r
= SendMessageA(hWndStatus
, SB_SETICON
, 1, (LPARAM
) hIcon
);
373 broken(r
== 0), /* win95 */
374 "Expected non-zero, got %d\n", r
);
375 r
= SendMessageA(hWndStatus
, SB_SETICON
, 1, 0);
377 broken(r
== 0), /* win95 */
378 "Expected non-zero, got %d\n", r
);
380 /* Set the Unicode format */
381 r
= SendMessageA(hWndStatus
, SB_SETUNICODEFORMAT
, FALSE
, 0);
383 r
= SendMessageA(hWndStatus
, SB_GETUNICODEFORMAT
, 0, 0);
385 r
= SendMessageA(hWndStatus
, SB_SETUNICODEFORMAT
, TRUE
, 0);
387 r
= SendMessageA(hWndStatus
, SB_GETUNICODEFORMAT
, 0, 0);
389 broken(r
== FALSE
), /* win95 */
390 "Expected TRUE, got %d\n", r
);
392 /* Reset number of parts */
393 r
= SendMessageA(hWndStatus
, SB_SETPARTS
, 2, (LPARAM
)nParts
);
395 r
= SendMessageA(hWndStatus
, SB_GETPARTS
, 0, 0);
396 ok(r
== 2, "Expected 2, got %d\n", r
);
397 r
= SendMessageA(hWndStatus
, SB_SETPARTS
, 0, 0);
399 r
= SendMessageA(hWndStatus
, SB_GETPARTS
, 0, 0);
400 ok(r
== 2, "Expected 2, got %d\n", r
);
402 /* Set the minimum height and get rectangle information again */
403 SendMessageA(hWndStatus
, SB_SETMINHEIGHT
, 50, 0);
404 r
= SendMessageA(hWndStatus
, WM_SIZE
, 0, 0);
406 r
= SendMessageA(hWndStatus
, SB_GETRECT
, 0, (LPARAM
)&rc
);
409 /* The rc.bottom test is system dependent
410 expect(22,rc.bottom); */
413 r
= SendMessageA(hWndStatus
, SB_GETRECT
, -1, (LPARAM
)&rc
);
415 r
= SendMessageA(hWndStatus
, SB_GETRECT
, 3, (LPARAM
)&rc
);
418 /* Set the ToolTip text */
419 SendMessageA(hWndStatus
, SB_SETTIPTEXTA
, 0,(LPARAM
) "Tooltip Text");
420 lstrcpyA(charArray
, "apple");
421 SendMessageA(hWndStatus
, SB_GETTIPTEXTA
, MAKEWPARAM (0, 20),(LPARAM
) charArray
);
422 ok(strcmp(charArray
,"Tooltip Text") == 0 ||
423 broken(!strcmp(charArray
, "apple")), /* win95 */
424 "Expected Tooltip Text, got %s\n", charArray
);
427 SendMessageA(hWndStatus
, SB_SIMPLE
, TRUE
, 0);
428 r
= SendMessageA(hWndStatus
, SB_ISSIMPLE
, 0, 0);
430 broken(r
== FALSE
), /* win95 */
431 "Expected TRUE, got %d\n", r
);
433 DestroyWindow(hWndStatus
);
436 static LRESULT WINAPI
ownerdraw_test_wndproc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
439 if (msg
== WM_DRAWITEM
)
441 ret
= CallWindowProcA(g_wndproc_saved
, hwnd
, msg
, wParam
, lParam
);
445 static void test_status_ownerdraw(void)
449 const char* statustext
= "STATUS TEXT";
452 /* subclass the main window and make sure it is visible */
453 g_wndproc_saved
= (WNDPROC
) SetWindowLongPtrA( g_hMainWnd
, GWLP_WNDPROC
,
454 (LONG_PTR
)ownerdraw_test_wndproc
);
455 ok( g_wndproc_saved
!= 0, "failed to set the WndProc\n");
456 SetWindowPos( g_hMainWnd
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
457 oldstyle
= GetWindowLongA( g_hMainWnd
, GWL_STYLE
);
458 SetWindowLongA( g_hMainWnd
, GWL_STYLE
, oldstyle
| WS_VISIBLE
);
459 /* create a status child window */
460 ok((hWndStatus
= CreateWindowA(SUBCLASS_NAME
, "", WS_CHILD
|WS_VISIBLE
, 0, 0, 100, 100,
461 g_hMainWnd
, NULL
, NULL
, 0)) != NULL
, "CreateWindowA failed\n");
464 r
= SendMessageA(hWndStatus
, SB_SETTEXTA
, 0, (LPARAM
)statustext
);
465 ok( r
== TRUE
, "Sendmessage returned %d, expected 1\n", r
);
466 ok( 0 == g_wmdrawitm_ctr
, "got %d drawitem messages expected none\n", g_wmdrawitm_ctr
);
467 /* set same text, with ownerdraw flag */
469 r
= SendMessageA(hWndStatus
, SB_SETTEXTA
, SBT_OWNERDRAW
, (LPARAM
)statustext
);
470 ok( r
== TRUE
, "Sendmessage returned %d, expected 1\n", r
);
471 ok( 1 == g_wmdrawitm_ctr
, "got %d drawitem messages expected 1\n", g_wmdrawitm_ctr
);
474 r
= SendMessageA(hWndStatus
, SB_SETTEXTA
, SBT_OWNERDRAW
, (LPARAM
)statustext
);
475 ok( r
== TRUE
, "Sendmessage returned %d, expected 1\n", r
);
476 ok( 1 == g_wmdrawitm_ctr
, "got %d drawitem messages expected 1\n", g_wmdrawitm_ctr
);
478 DestroyWindow(hWndStatus
);
479 SetWindowLongA( g_hMainWnd
, GWL_STYLE
, oldstyle
);
480 SetWindowLongPtrA( g_hMainWnd
, GWLP_WNDPROC
, (LONG_PTR
)g_wndproc_saved
);
483 static void test_gettext(void)
485 HWND hwndStatus
= CreateWindowA(SUBCLASS_NAME
, NULL
, WS_CHILD
|WS_VISIBLE
,
486 0, 0, 300, 20, g_hMainWnd
, NULL
, NULL
, NULL
);
490 r
= SendMessageA(hwndStatus
, SB_SETTEXTA
, 0, (LPARAM
)"Text");
492 r
= SendMessageA(hwndStatus
, WM_GETTEXTLENGTH
, 0, 0);
494 /* A size of 0 returns the length of the text */
495 r
= SendMessageA(hwndStatus
, WM_GETTEXT
, 0, 0);
496 ok( r
== 4 || broken(r
== 2) /* win8 */, "Expected 4 got %d\n", r
);
497 /* A size of 1 only stores the NULL terminator */
499 r
= SendMessageA(hwndStatus
, WM_GETTEXT
, 1, (LPARAM
)buf
);
500 ok( r
== 0 || broken(r
== 4), "Expected 0 got %d\n", r
);
501 if (!r
) ok(!buf
[0], "expected empty buffer\n");
502 /* A size of 2 returns a length 1 */
503 r
= SendMessageA(hwndStatus
, WM_GETTEXT
, 2, (LPARAM
)buf
);
504 ok( r
== 1 || broken(r
== 4), "Expected 1 got %d\n", r
);
505 r
= SendMessageA(hwndStatus
, WM_GETTEXT
, sizeof(buf
), (LPARAM
)buf
);
507 ok(!strcmp(buf
, "Text"), "expected Text, got %s\n", buf
);
508 DestroyWindow(hwndStatus
);
511 /* Notify events to parent */
512 static BOOL g_got_dblclk
;
513 static BOOL g_got_click
;
514 static BOOL g_got_rdblclk
;
515 static BOOL g_got_rclick
;
517 /* Messages to parent */
518 static BOOL g_got_contextmenu
;
520 static LRESULT WINAPI
test_notify_parent_proc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
526 NMHDR
*hdr
= ((LPNMHDR
)lParam
);
529 case NM_DBLCLK
: g_got_dblclk
= TRUE
; break;
530 case NM_CLICK
: g_got_click
= TRUE
; break;
531 case NM_RDBLCLK
: g_got_rdblclk
= TRUE
; break;
532 case NM_RCLICK
: g_got_rclick
= TRUE
; break;
535 /* Return zero to indicate default processing */
539 case WM_CONTEXTMENU
: g_got_contextmenu
= TRUE
; return 0;
542 return( DefWindowProcA(hwnd
, msg
, wParam
, lParam
));
548 /* Test that WM_NOTIFY messages from the status control works correctly */
549 static void test_notify(void)
554 WNDCLASSA wclass
= {0};
555 wclass
.lpszClassName
= "TestNotifyParentClass";
556 wclass
.lpfnWndProc
= test_notify_parent_proc
;
557 atom
= RegisterClassA(&wclass
);
558 ok(atom
, "RegisterClass failed\n");
561 hwndParent
= CreateWindowA(wclass
.lpszClassName
, "parent", WS_OVERLAPPEDWINDOW
,
562 CW_USEDEFAULT
, 0, 300, 20, NULL
, NULL
, NULL
, NULL
);
563 ok(hwndParent
!= NULL
, "Parent creation failed!\n");
565 /* create status bar */
566 hwndStatus
= CreateWindowA(STATUSCLASSNAMEA
, NULL
, WS_VISIBLE
| WS_CHILD
,
567 0, 0, 300, 20, hwndParent
, NULL
, NULL
, NULL
);
568 ok(hwndStatus
!= NULL
, "Status creation failed!\n");
570 /* Send various mouse event, and check that we get them */
571 g_got_dblclk
= FALSE
;
572 SendMessageA(hwndStatus
, WM_LBUTTONDBLCLK
, 0, 0);
573 ok(g_got_dblclk
, "WM_LBUTTONDBLCLK was not processed correctly!\n");
574 g_got_rdblclk
= FALSE
;
575 SendMessageA(hwndStatus
, WM_RBUTTONDBLCLK
, 0, 0);
576 ok(g_got_rdblclk
, "WM_RBUTTONDBLCLK was not processed correctly!\n");
578 SendMessageA(hwndStatus
, WM_LBUTTONUP
, 0, 0);
579 ok(g_got_click
, "WM_LBUTTONUP was not processed correctly!\n");
581 /* For R-UP, check that we also get the context menu from the default processing */
582 g_got_contextmenu
= FALSE
;
583 g_got_rclick
= FALSE
;
584 SendMessageA(hwndStatus
, WM_RBUTTONUP
, 0, 0);
585 ok(g_got_rclick
, "WM_RBUTTONUP was not processed correctly!\n");
586 ok(g_got_contextmenu
, "WM_RBUTTONUP did not activate the context menu!\n");
589 static void init_functions(void)
591 HMODULE hComCtl32
= LoadLibraryA("comctl32.dll");
593 #define X(f) p##f = (void*)GetProcAddress(hComCtl32, #f);
594 X(InitCommonControlsEx
);
600 INITCOMMONCONTROLSEX iccex
;
604 hinst
= GetModuleHandleA(NULL
);
606 iccex
.dwSize
= sizeof(iccex
);
607 iccex
.dwICC
= ICC_BAR_CLASSES
;
608 pInitCommonControlsEx(&iccex
);
610 g_hMainWnd
= CreateWindowExA(0, WC_STATICA
, "", WS_OVERLAPPEDWINDOW
,
611 CW_USEDEFAULT
, CW_USEDEFAULT
, 672+2*GetSystemMetrics(SM_CXSIZEFRAME
),
612 226+GetSystemMetrics(SM_CYCAPTION
)+2*GetSystemMetrics(SM_CYSIZEFRAME
),
613 NULL
, NULL
, GetModuleHandleA(NULL
), 0);
617 test_status_control();
620 test_status_ownerdraw();