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
21 #include <wine/test.h>
23 //#include <windows.h>
28 #define SUBCLASS_NAME "MyStatusBar"
30 #define expect(expected,got) ok (expected == got,"Expected %d, got %d\n",expected,got)
31 #define expect_rect(_left,_top,_right,_bottom,got) do { \
32 RECT exp = {abs(got.left - _left), abs(got.top - _top), \
33 abs(got.right - _right), abs(got.bottom - _bottom)}; \
34 ok(exp.left <= 2 && exp.top <= 2 && exp.right <= 2 && exp.bottom <= 2, \
35 "Expected rect {%d,%d, %d,%d}, got {%d,%d, %d,%d}\n", \
36 _left, _top, _right, _bottom, \
37 (got).left, (got).top, (got).right, (got).bottom); } while (0)
39 static HINSTANCE hinst
;
40 static WNDPROC g_status_wndproc
;
41 static RECT g_rcCreated
;
42 static HWND g_hMainWnd
;
43 static int g_wmsize_count
= 0;
46 static int g_wmdrawitm_ctr
;
47 static WNDPROC g_wndproc_saved
;
49 static HWND
create_status_control(DWORD style
, DWORD exstyle
)
53 /* make the control */
54 hWndStatus
= CreateWindowExA(exstyle
, STATUSCLASSNAMEA
, NULL
, style
,
58 NULL
, NULL
, hinst
, NULL
);
59 ok(hWndStatus
!= NULL
, "failed to create status wnd\n");
63 static LRESULT WINAPI
create_test_wndproc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
69 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lParam
;
70 ret
= CallWindowProcA(g_status_wndproc
, hwnd
, msg
, wParam
, lParam
);
71 GetWindowRect(hwnd
, &g_rcCreated
);
72 MapWindowPoints(HWND_DESKTOP
, g_hMainWnd
, (LPPOINT
)&g_rcCreated
, 2);
73 ok(cs
->x
== g_rcCreated
.left
, "CREATESTRUCT.x modified\n");
74 ok(cs
->y
== g_rcCreated
.top
, "CREATESTRUCT.y modified\n");
75 } else if (msg
== WM_SIZE
)
78 ret
= CallWindowProcA(g_status_wndproc
, hwnd
, msg
, wParam
, lParam
);
81 ret
= CallWindowProcA(g_status_wndproc
, hwnd
, msg
, wParam
, lParam
);
86 static void register_subclass(void)
90 cls
.cbSize
= sizeof(WNDCLASSEXA
);
91 GetClassInfoExA(NULL
, STATUSCLASSNAMEA
, &cls
);
92 g_status_wndproc
= cls
.lpfnWndProc
;
93 cls
.lpfnWndProc
= create_test_wndproc
;
94 cls
.lpszClassName
= SUBCLASS_NAME
;
96 ok(RegisterClassExA(&cls
), "RegisterClassEx failed\n");
99 static void test_create(void)
104 ok((hwnd
= CreateWindowA(SUBCLASS_NAME
, "", WS_CHILD
|WS_VISIBLE
|SBARS_SIZEGRIP
, 0, 0, 100, 100,
105 g_hMainWnd
, NULL
, NULL
, 0)) != NULL
, "CreateWindowA failed\n");
106 MapWindowPoints(HWND_DESKTOP
, g_hMainWnd
, (LPPOINT
)&rc
, 2);
107 GetWindowRect(hwnd
, &rc
);
108 MapWindowPoints(HWND_DESKTOP
, g_hMainWnd
, (LPPOINT
)&rc
, 2);
109 expect_rect(0, 0, 100, 100, g_rcCreated
);
111 expect(672, rc
.right
);
112 expect(226, rc
.bottom
);
113 /* we don't check rc.top as this may depend on user font settings */
117 static int CALLBACK
check_height_font_enumproc(ENUMLOGFONTEXA
*enumlf
, NEWTEXTMETRICEXA
*ntm
, DWORD type
, LPARAM lParam
)
119 HWND hwndStatus
= (HWND
)lParam
;
120 HDC hdc
= GetDC(NULL
);
121 static const int sizes
[] = { 6, 7, 8, 9, 10, 11, 12, 13, 15, 16,
122 20, 22, 28, 36, 48, 72};
125 LPSTR facename
= (CHAR
*)enumlf
->elfFullName
;
127 /* on win9x, enumlf->elfFullName is only valid for truetype fonts */
128 if (type
!= TRUETYPE_FONTTYPE
)
129 facename
= enumlf
->elfLogFont
.lfFaceName
;
131 for (i
= 0; i
< sizeof(sizes
)/sizeof(sizes
[0]); i
++)
139 enumlf
->elfLogFont
.lfHeight
= sizes
[i
];
140 hFont
= CreateFontIndirectA(&enumlf
->elfLogFont
);
141 hCtrlFont
= (HFONT
)SendMessageA(hwndStatus
, WM_SETFONT
, (WPARAM
)hFont
, TRUE
);
142 hOldFont
= SelectObject(hdc
, hFont
);
144 GetClientRect(hwndStatus
, &rcCtrl
);
145 GetTextMetricsA(hdc
, &tm
);
146 y
= tm
.tmHeight
+ (tm
.tmInternalLeading
? tm
.tmInternalLeading
: 2) + 4;
148 ok( (rcCtrl
.bottom
== max(y
, g_ysize
)) || (rcCtrl
.bottom
== max(y
, g_dpisize
)),
149 "got %d (expected %d or %d) for %s #%d\n",
150 rcCtrl
.bottom
, max(y
, g_ysize
), max(y
, g_dpisize
), facename
, sizes
[i
]);
152 SelectObject(hdc
, hOldFont
);
153 SendMessageA(hwndStatus
, WM_SETFONT
, (WPARAM
)hCtrlFont
, TRUE
);
156 ReleaseDC(NULL
, hdc
);
160 static int CALLBACK
check_height_family_enumproc(ENUMLOGFONTEXA
*enumlf
, NEWTEXTMETRICEXA
*ntm
, DWORD type
, LPARAM lParam
)
162 HDC hdc
= GetDC(NULL
);
163 enumlf
->elfLogFont
.lfHeight
= 0;
164 EnumFontFamiliesExA(hdc
, &enumlf
->elfLogFont
, (FONTENUMPROCA
)check_height_font_enumproc
, lParam
, 0);
165 ReleaseDC(NULL
, hdc
);
169 static void test_height(void)
172 HFONT hFont
, hFontSm
;
174 HWND hwndStatus
= CreateWindowA(SUBCLASS_NAME
, NULL
, WS_CHILD
|WS_VISIBLE
,
175 0, 0, 300, 20, g_hMainWnd
, NULL
, NULL
, NULL
);
178 GetClientRect(hwndStatus
, &rc1
);
179 hFont
= CreateFontA(32, 0, 0, 0, FW_DONTCARE
, FALSE
, FALSE
, FALSE
, ANSI_CHARSET
,
180 OUT_DEFAULT_PRECIS
, CLIP_DEFAULT_PRECIS
, DEFAULT_QUALITY
, FF_DONTCARE
, "Tahoma");
183 SendMessageA(hwndStatus
, WM_SETFONT
, (WPARAM
)hFont
, TRUE
);
186 skip("Status control not resized in win95, skipping broken tests.\n");
189 ok(g_wmsize_count
> 0, "WM_SETFONT should issue WM_SIZE\n");
191 GetClientRect(hwndStatus
, &rc2
);
192 expect_rect(0, 0, 672, 42, rc2
); /* GetTextMetrics returns invalid tmInternalLeading for this font */
195 SendMessageA(hwndStatus
, WM_SETFONT
, (WPARAM
)hFont
, TRUE
);
196 ok(g_wmsize_count
> 0, "WM_SETFONT should issue WM_SIZE\n");
198 GetClientRect(hwndStatus
, &rc2
);
199 expect_rect(0, 0, 672, 42, rc2
);
201 /* minheight < fontsize - no effects*/
202 SendMessageA(hwndStatus
, SB_SETMINHEIGHT
, 12, 0);
203 SendMessageA(hwndStatus
, WM_SIZE
, 0, 0);
204 GetClientRect(hwndStatus
, &rc2
);
205 expect_rect(0, 0, 672, 42, rc2
);
207 /* minheight > fontsize - has an effect after WM_SIZE */
208 SendMessageA(hwndStatus
, SB_SETMINHEIGHT
, 60, 0);
209 GetClientRect(hwndStatus
, &rc2
);
210 expect_rect(0, 0, 672, 42, rc2
);
211 SendMessageA(hwndStatus
, WM_SIZE
, 0, 0);
212 GetClientRect(hwndStatus
, &rc2
);
213 expect_rect(0, 0, 672, 62, rc2
);
215 /* font changed to smaller than minheight - has an effect */
216 SendMessageA(hwndStatus
, SB_SETMINHEIGHT
, 30, 0);
217 expect_rect(0, 0, 672, 62, rc2
);
218 SendMessageA(hwndStatus
, WM_SIZE
, 0, 0);
219 GetClientRect(hwndStatus
, &rc2
);
220 expect_rect(0, 0, 672, 42, rc2
);
221 hFontSm
= CreateFontA(9, 0, 0, 0, FW_DONTCARE
, FALSE
, FALSE
, FALSE
, ANSI_CHARSET
,
222 OUT_DEFAULT_PRECIS
, CLIP_DEFAULT_PRECIS
, DEFAULT_QUALITY
, FF_DONTCARE
, "Tahoma");
223 SendMessageA(hwndStatus
, WM_SETFONT
, (WPARAM
)hFontSm
, TRUE
);
224 GetClientRect(hwndStatus
, &rc2
);
225 expect_rect(0, 0, 672, 32, rc2
);
227 /* test the height formula */
228 ZeroMemory(&lf
, sizeof(lf
));
229 SendMessageA(hwndStatus
, SB_SETMINHEIGHT
, 0, 0);
232 /* used only for some fonts (tahoma as example) */
233 g_ysize
= GetSystemMetrics(SM_CYSIZE
) + 2;
234 if (g_ysize
& 1) g_ysize
--; /* The min height is always even */
236 g_dpisize
= MulDiv(18, GetDeviceCaps(hdc
, LOGPIXELSY
), 96) + 2;
237 if (g_dpisize
& 1) g_dpisize
--; /* The min height is always even */
240 trace("dpi=%d (min height: %d or %d) SM_CYSIZE: %d\n",
241 GetDeviceCaps(hdc
, LOGPIXELSY
), g_ysize
, g_dpisize
,
242 GetSystemMetrics(SM_CYSIZE
));
244 EnumFontFamiliesExA(hdc
, &lf
, (FONTENUMPROCA
)check_height_family_enumproc
, (LPARAM
)hwndStatus
, 0);
245 ReleaseDC(NULL
, hdc
);
247 DestroyWindow(hwndStatus
);
249 DeleteObject(hFontSm
);
252 static void test_status_control(void)
256 int nParts
[] = {50, 150, -1};
257 int checkParts
[] = {0, 0, 0};
258 int borders
[] = {0, 0, 0};
263 char chstr
[10] = "Inval id";
264 COLORREF crColor
= RGB(0,0,0);
266 hWndStatus
= create_status_control(WS_VISIBLE
| SBT_TOOLTIPS
, 0);
268 /* Divide into parts and set text */
269 r
= SendMessageA(hWndStatus
, SB_SETPARTS
, 3, (LPARAM
)nParts
);
271 r
= SendMessageA(hWndStatus
, SB_SETTEXTA
, SBT_POPOUT
|0, (LPARAM
)"First");
273 r
= SendMessageA(hWndStatus
, SB_SETTEXTA
, SBT_OWNERDRAW
|1, (LPARAM
)"Second");
275 r
= SendMessageA(hWndStatus
, SB_SETTEXTA
, SBT_NOBORDERS
|2, (LPARAM
)"Third");
278 /* Get RECT Information */
279 r
= SendMessageA(hWndStatus
, SB_GETRECT
, 0, (LPARAM
)&rc
);
282 /* The rc.bottom test is system dependent
283 expect(22,rc.bottom); */
286 r
= SendMessageA(hWndStatus
, SB_GETRECT
, -1, (LPARAM
)&rc
);
288 r
= SendMessageA(hWndStatus
, SB_GETRECT
, 3, (LPARAM
)&rc
);
290 /* Get text length and text */
291 r
= SendMessageA(hWndStatus
, SB_GETTEXTLENGTHA
, 0, 0);
293 expect(SBT_POPOUT
,HIWORD(r
));
294 r
= SendMessageW(hWndStatus
, WM_GETTEXTLENGTH
, 0, 0);
295 ok(r
== 5 || broken(0x02000005 /* NT4 */), "Expected 5, got %d\n", r
);
296 r
= SendMessageA(hWndStatus
, SB_GETTEXTLENGTHA
, 1, 0);
298 expect(SBT_OWNERDRAW
,HIWORD(r
));
299 r
= SendMessageA(hWndStatus
, SB_GETTEXTLENGTHA
, 2, 0);
301 expect(SBT_NOBORDERS
,HIWORD(r
));
302 r
= SendMessageA(hWndStatus
, SB_GETTEXTA
, 2, (LPARAM
) charArray
);
303 ok(strcmp(charArray
,"Third") == 0, "Expected Third, got %s\n", charArray
);
305 expect(SBT_NOBORDERS
,HIWORD(r
));
307 /* Get parts and borders */
308 r
= SendMessageA(hWndStatus
, SB_GETPARTS
, 3, (LPARAM
)checkParts
);
309 ok(r
== 3, "Expected 3, got %d\n", r
);
310 expect(50,checkParts
[0]);
311 expect(150,checkParts
[1]);
312 expect(-1,checkParts
[2]);
313 r
= SendMessageA(hWndStatus
, SB_GETBORDERS
, 0, (LPARAM
)borders
);
314 ok(r
== TRUE
, "Expected TRUE, got %d\n", r
);
315 expect(0,borders
[0]);
316 expect(2,borders
[1]);
317 expect(2,borders
[2]);
319 /* Test resetting text with different characters */
320 r
= SendMessageA(hWndStatus
, SB_SETTEXTA
, 0, (LPARAM
)"First@Again");
322 r
= SendMessageA(hWndStatus
, SB_SETTEXTA
, 1, (LPARAM
)"Invalid\tChars\\7\7");
324 r
= SendMessageA(hWndStatus
, SB_SETTEXTA
, 2, (LPARAM
)"InvalidChars\\n\n");
328 r
= SendMessageA(hWndStatus
, SB_GETTEXTA
, 0, (LPARAM
) charArray
);
329 ok(strcmp(charArray
,"First@Again") == 0, "Expected First@Again, got %s\n", charArray
);
330 expect(11,LOWORD(r
));
332 r
= SendMessageA(hWndStatus
, SB_GETTEXTA
, 1, (LPARAM
) charArray
);
333 ok(strcmp(charArray
,"Invalid\tChars\\7 ") == 0, "Expected Invalid\tChars\\7 , got %s\n", charArray
);
335 expect(16,LOWORD(r
));
337 r
= SendMessageA(hWndStatus
, SB_GETTEXTA
, 2, (LPARAM
) charArray
);
338 ok(strcmp(charArray
,"InvalidChars\\n ") == 0, "Expected InvalidChars\\n , got %s\n", charArray
);
340 expect(15,LOWORD(r
));
343 /* test more nonprintable chars */
344 for(ch
= 0x00; ch
< 0x7F; ch
++) {
346 r
= SendMessageA(hWndStatus
, SB_SETTEXTA
, 0, (LPARAM
)chstr
);
348 r
= SendMessageA(hWndStatus
, SB_GETTEXTA
, 0, (LPARAM
)charArray
);
349 ok(r
== strlen(charArray
), "got %d\n", r
);
350 /* substitution with single space */
351 if (ch
> 0x00 && ch
< 0x20 && ch
!= '\t')
353 ok(strcmp(charArray
, chstr
) == 0, "Expected %s, got %s\n", chstr
, charArray
);
356 /* Set background color */
357 crColor
= SendMessageA(hWndStatus
, SB_SETBKCOLOR
, 0, RGB(255,0,0));
358 ok(crColor
== CLR_DEFAULT
||
359 broken(crColor
== RGB(0,0,0)), /* win95 */
360 "Expected 0x%.8x, got 0x%.8x\n", CLR_DEFAULT
, crColor
);
361 crColor
= SendMessageA(hWndStatus
, SB_SETBKCOLOR
, 0, CLR_DEFAULT
);
362 ok(crColor
== RGB(255,0,0) ||
363 broken(crColor
== RGB(0,0,0)), /* win95 */
364 "Expected 0x%.8x, got 0x%.8x\n", RGB(255,0,0), crColor
);
366 /* Add an icon to the status bar */
367 hIcon
= LoadIconA(NULL
, (LPCSTR
)IDI_QUESTION
);
368 r
= SendMessageA(hWndStatus
, SB_SETICON
, 1, 0);
370 broken(r
== 0), /* win95 */
371 "Expected non-zero, got %d\n", r
);
372 r
= SendMessageA(hWndStatus
, SB_SETICON
, 1, (LPARAM
) hIcon
);
374 broken(r
== 0), /* win95 */
375 "Expected non-zero, got %d\n", r
);
376 r
= SendMessageA(hWndStatus
, SB_SETICON
, 1, 0);
378 broken(r
== 0), /* win95 */
379 "Expected non-zero, got %d\n", r
);
381 /* Set the Unicode format */
382 r
= SendMessageA(hWndStatus
, SB_SETUNICODEFORMAT
, FALSE
, 0);
384 r
= SendMessageA(hWndStatus
, SB_GETUNICODEFORMAT
, 0, 0);
386 r
= SendMessageA(hWndStatus
, SB_SETUNICODEFORMAT
, TRUE
, 0);
388 r
= SendMessageA(hWndStatus
, SB_GETUNICODEFORMAT
, 0, 0);
390 broken(r
== FALSE
), /* win95 */
391 "Expected TRUE, got %d\n", r
);
393 /* Reset number of parts */
394 r
= SendMessageA(hWndStatus
, SB_SETPARTS
, 2, (LPARAM
)nParts
);
396 r
= SendMessageA(hWndStatus
, SB_GETPARTS
, 0, 0);
397 ok(r
== 2, "Expected 2, got %d\n", r
);
398 r
= SendMessageA(hWndStatus
, SB_SETPARTS
, 0, 0);
400 r
= SendMessageA(hWndStatus
, SB_GETPARTS
, 0, 0);
401 ok(r
== 2, "Expected 2, got %d\n", r
);
403 /* Set the minimum height and get rectangle information again */
404 SendMessageA(hWndStatus
, SB_SETMINHEIGHT
, 50, 0);
405 r
= SendMessageA(hWndStatus
, WM_SIZE
, 0, 0);
407 r
= SendMessageA(hWndStatus
, SB_GETRECT
, 0, (LPARAM
)&rc
);
410 /* The rc.bottom test is system dependent
411 expect(22,rc.bottom); */
414 r
= SendMessageA(hWndStatus
, SB_GETRECT
, -1, (LPARAM
)&rc
);
416 r
= SendMessageA(hWndStatus
, SB_GETRECT
, 3, (LPARAM
)&rc
);
419 /* Set the ToolTip text */
420 SendMessageA(hWndStatus
, SB_SETTIPTEXTA
, 0,(LPARAM
) "Tooltip Text");
421 lstrcpyA(charArray
, "apple");
422 SendMessageA(hWndStatus
, SB_GETTIPTEXTA
, MAKEWPARAM (0, 20),(LPARAM
) charArray
);
423 ok(strcmp(charArray
,"Tooltip Text") == 0 ||
424 broken(!strcmp(charArray
, "apple")), /* win95 */
425 "Expected Tooltip Text, got %s\n", charArray
);
428 SendMessageA(hWndStatus
, SB_SIMPLE
, TRUE
, 0);
429 r
= SendMessageA(hWndStatus
, SB_ISSIMPLE
, 0, 0);
431 broken(r
== FALSE
), /* win95 */
432 "Expected TRUE, got %d\n", r
);
434 DestroyWindow(hWndStatus
);
437 static LRESULT WINAPI
ownerdraw_test_wndproc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
440 if (msg
== WM_DRAWITEM
)
442 ret
= CallWindowProcA(g_wndproc_saved
, hwnd
, msg
, wParam
, lParam
);
446 static void test_status_ownerdraw(void)
450 const char* statustext
= "STATUS TEXT";
453 /* subclass the main window and make sure it is visible */
454 g_wndproc_saved
= (WNDPROC
) SetWindowLongPtrA( g_hMainWnd
, GWLP_WNDPROC
,
455 (LONG_PTR
)ownerdraw_test_wndproc
);
456 ok( g_wndproc_saved
!= 0, "failed to set the WndProc\n");
457 SetWindowPos( g_hMainWnd
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
458 oldstyle
= GetWindowLongA( g_hMainWnd
, GWL_STYLE
);
459 SetWindowLongA( g_hMainWnd
, GWL_STYLE
, oldstyle
| WS_VISIBLE
);
460 /* create a status child window */
461 ok((hWndStatus
= CreateWindowA(SUBCLASS_NAME
, "", WS_CHILD
|WS_VISIBLE
, 0, 0, 100, 100,
462 g_hMainWnd
, NULL
, NULL
, 0)) != NULL
, "CreateWindowA failed\n");
465 r
= SendMessageA(hWndStatus
, SB_SETTEXTA
, 0, (LPARAM
)statustext
);
466 ok( r
== TRUE
, "Sendmessage returned %d, expected 1\n", r
);
467 ok( 0 == g_wmdrawitm_ctr
, "got %d drawitem messages expected none\n", g_wmdrawitm_ctr
);
468 /* set same text, with ownerdraw flag */
470 r
= SendMessageA(hWndStatus
, SB_SETTEXTA
, SBT_OWNERDRAW
, (LPARAM
)statustext
);
471 ok( r
== TRUE
, "Sendmessage returned %d, expected 1\n", r
);
472 ok( 1 == g_wmdrawitm_ctr
, "got %d drawitem messages expected 1\n", g_wmdrawitm_ctr
);
475 r
= SendMessageA(hWndStatus
, SB_SETTEXTA
, SBT_OWNERDRAW
, (LPARAM
)statustext
);
476 ok( r
== TRUE
, "Sendmessage returned %d, expected 1\n", r
);
477 ok( 1 == g_wmdrawitm_ctr
, "got %d drawitem messages expected 1\n", g_wmdrawitm_ctr
);
479 DestroyWindow(hWndStatus
);
480 SetWindowLongA( g_hMainWnd
, GWL_STYLE
, oldstyle
);
481 SetWindowLongPtrA( g_hMainWnd
, GWLP_WNDPROC
, (LONG_PTR
)g_wndproc_saved
);
484 static void test_gettext(void)
486 HWND hwndStatus
= CreateWindowA(SUBCLASS_NAME
, NULL
, WS_CHILD
|WS_VISIBLE
,
487 0, 0, 300, 20, g_hMainWnd
, NULL
, NULL
, NULL
);
491 r
= SendMessageA(hwndStatus
, SB_SETTEXTA
, 0, (LPARAM
)"Text");
493 r
= SendMessageA(hwndStatus
, WM_GETTEXTLENGTH
, 0, 0);
495 /* A size of 0 returns the length of the text */
496 r
= SendMessageA(hwndStatus
, WM_GETTEXT
, 0, 0);
497 ok( r
== 4 || broken(r
== 2) /* win8 */, "Expected 4 got %d\n", r
);
498 /* A size of 1 only stores the NULL terminator */
500 r
= SendMessageA(hwndStatus
, WM_GETTEXT
, 1, (LPARAM
)buf
);
501 ok( r
== 0 || broken(r
== 4), "Expected 0 got %d\n", r
);
502 if (!r
) ok(!buf
[0], "expected empty buffer\n");
503 /* A size of 2 returns a length 1 */
504 r
= SendMessageA(hwndStatus
, WM_GETTEXT
, 2, (LPARAM
)buf
);
505 ok( r
== 1 || broken(r
== 4), "Expected 1 got %d\n", r
);
506 r
= SendMessageA(hwndStatus
, WM_GETTEXT
, sizeof(buf
), (LPARAM
)buf
);
508 ok(!strcmp(buf
, "Text"), "expected Text, got %s\n", buf
);
509 DestroyWindow(hwndStatus
);
512 /* Notify events to parent */
513 static BOOL g_got_dblclk
;
514 static BOOL g_got_click
;
515 static BOOL g_got_rdblclk
;
516 static BOOL g_got_rclick
;
518 /* Messages to parent */
519 static BOOL g_got_contextmenu
;
521 static LRESULT WINAPI
test_notify_parent_proc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
527 NMHDR
*hdr
= ((LPNMHDR
)lParam
);
530 case NM_DBLCLK
: g_got_dblclk
= TRUE
; break;
531 case NM_CLICK
: g_got_click
= TRUE
; break;
532 case NM_RDBLCLK
: g_got_rdblclk
= TRUE
; break;
533 case NM_RCLICK
: g_got_rclick
= TRUE
; break;
536 /* Return zero to indicate default processing */
540 case WM_CONTEXTMENU
: g_got_contextmenu
= TRUE
; return 0;
543 return( DefWindowProcA(hwnd
, msg
, wParam
, lParam
));
549 /* Test that WM_NOTIFY messages from the status control works correctly */
550 static void test_notify(void)
555 WNDCLASSA wclass
= {0};
556 wclass
.lpszClassName
= "TestNotifyParentClass";
557 wclass
.lpfnWndProc
= test_notify_parent_proc
;
558 atom
= RegisterClassA(&wclass
);
559 ok(atom
, "RegisterClass failed\n");
562 hwndParent
= CreateWindowA(wclass
.lpszClassName
, "parent", WS_OVERLAPPEDWINDOW
,
563 CW_USEDEFAULT
, 0, 300, 20, NULL
, NULL
, NULL
, NULL
);
564 ok(hwndParent
!= NULL
, "Parent creation failed!\n");
566 /* create status bar */
567 hwndStatus
= CreateWindowA(STATUSCLASSNAMEA
, NULL
, WS_VISIBLE
| WS_CHILD
,
568 0, 0, 300, 20, hwndParent
, NULL
, NULL
, NULL
);
569 ok(hwndStatus
!= NULL
, "Status creation failed!\n");
571 /* Send various mouse event, and check that we get them */
572 g_got_dblclk
= FALSE
;
573 SendMessageA(hwndStatus
, WM_LBUTTONDBLCLK
, 0, 0);
574 ok(g_got_dblclk
, "WM_LBUTTONDBLCLK was not processed correctly!\n");
575 g_got_rdblclk
= FALSE
;
576 SendMessageA(hwndStatus
, WM_RBUTTONDBLCLK
, 0, 0);
577 ok(g_got_rdblclk
, "WM_RBUTTONDBLCLK was not processed correctly!\n");
579 SendMessageA(hwndStatus
, WM_LBUTTONUP
, 0, 0);
580 ok(g_got_click
, "WM_LBUTTONUP was not processed correctly!\n");
582 /* For R-UP, check that we also get the context menu from the default processing */
583 g_got_contextmenu
= FALSE
;
584 g_got_rclick
= FALSE
;
585 SendMessageA(hwndStatus
, WM_RBUTTONUP
, 0, 0);
586 ok(g_got_rclick
, "WM_RBUTTONUP was not processed correctly!\n");
587 ok(g_got_contextmenu
, "WM_RBUTTONUP did not activate the context menu!\n");
592 hinst
= GetModuleHandleA(NULL
);
594 g_hMainWnd
= CreateWindowExA(0, "static", "", WS_OVERLAPPEDWINDOW
,
595 CW_USEDEFAULT
, CW_USEDEFAULT
, 672+2*GetSystemMetrics(SM_CXSIZEFRAME
),
596 226+GetSystemMetrics(SM_CYCAPTION
)+2*GetSystemMetrics(SM_CYSIZEFRAME
),
597 NULL
, NULL
, GetModuleHandleA(NULL
), 0);
599 InitCommonControls();
603 test_status_control();
606 test_status_ownerdraw();