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 HWND
create_status_control(DWORD style
, DWORD exstyle
)
50 /* make the control */
51 hWndStatus
= CreateWindowExA(exstyle
, STATUSCLASSNAMEA
, NULL
, style
,
55 NULL
, NULL
, hinst
, NULL
);
56 ok(hWndStatus
!= NULL
, "failed to create status wnd\n");
60 static LRESULT WINAPI
create_test_wndproc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
66 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lParam
;
67 ret
= CallWindowProcA(g_status_wndproc
, hwnd
, msg
, wParam
, lParam
);
68 GetWindowRect(hwnd
, &g_rcCreated
);
69 MapWindowPoints(HWND_DESKTOP
, g_hMainWnd
, (LPPOINT
)&g_rcCreated
, 2);
70 ok(cs
->x
== g_rcCreated
.left
, "CREATESTRUCT.x modified\n");
71 ok(cs
->y
== g_rcCreated
.top
, "CREATESTRUCT.y modified\n");
72 } else if (msg
== WM_SIZE
)
75 ret
= CallWindowProcA(g_status_wndproc
, hwnd
, msg
, wParam
, lParam
);
78 ret
= CallWindowProcA(g_status_wndproc
, hwnd
, msg
, wParam
, lParam
);
83 static void register_subclass(void)
87 cls
.cbSize
= sizeof(WNDCLASSEXA
);
88 GetClassInfoExA(NULL
, STATUSCLASSNAMEA
, &cls
);
89 g_status_wndproc
= cls
.lpfnWndProc
;
90 cls
.lpfnWndProc
= create_test_wndproc
;
91 cls
.lpszClassName
= SUBCLASS_NAME
;
93 ok(RegisterClassExA(&cls
), "RegisterClassEx failed\n");
96 static void test_create(void)
101 ok((hwnd
= CreateWindowA(SUBCLASS_NAME
, "", WS_CHILD
|WS_VISIBLE
|SBARS_SIZEGRIP
, 0, 0, 100, 100,
102 g_hMainWnd
, NULL
, NULL
, 0)) != NULL
, "CreateWindowA failed\n");
103 MapWindowPoints(HWND_DESKTOP
, g_hMainWnd
, (LPPOINT
)&rc
, 2);
104 GetWindowRect(hwnd
, &rc
);
105 MapWindowPoints(HWND_DESKTOP
, g_hMainWnd
, (LPPOINT
)&rc
, 2);
106 expect_rect(0, 0, 100, 100, g_rcCreated
);
108 expect(672, rc
.right
);
109 expect(226, rc
.bottom
);
110 /* we don't check rc.top as this may depend on user font settings */
114 static int CALLBACK
check_height_font_enumproc(ENUMLOGFONTEXA
*enumlf
, NEWTEXTMETRICEXA
*ntm
, DWORD type
, LPARAM lParam
)
116 HWND hwndStatus
= (HWND
)lParam
;
117 HDC hdc
= GetDC(NULL
);
118 static const int sizes
[] = { 6, 7, 8, 9, 10, 11, 12, 13, 15, 16,
119 20, 22, 28, 36, 48, 72};
122 LPSTR facename
= (CHAR
*)enumlf
->elfFullName
;
124 /* on win9x, enumlf->elfFullName is only valid for truetype fonts */
125 if (type
!= TRUETYPE_FONTTYPE
)
126 facename
= enumlf
->elfLogFont
.lfFaceName
;
128 for (i
= 0; i
< sizeof(sizes
)/sizeof(sizes
[0]); i
++)
136 enumlf
->elfLogFont
.lfHeight
= sizes
[i
];
137 hFont
= CreateFontIndirectA(&enumlf
->elfLogFont
);
138 hCtrlFont
= (HFONT
)SendMessageA(hwndStatus
, WM_SETFONT
, (WPARAM
)hFont
, TRUE
);
139 hOldFont
= SelectObject(hdc
, hFont
);
141 GetClientRect(hwndStatus
, &rcCtrl
);
142 GetTextMetricsA(hdc
, &tm
);
143 y
= tm
.tmHeight
+ (tm
.tmInternalLeading
? tm
.tmInternalLeading
: 2) + 4;
145 ok( (rcCtrl
.bottom
== max(y
, g_ysize
)) || (rcCtrl
.bottom
== max(y
, g_dpisize
)),
146 "got %d (expected %d or %d) for %s #%d\n",
147 rcCtrl
.bottom
, max(y
, g_ysize
), max(y
, g_dpisize
), facename
, sizes
[i
]);
149 SelectObject(hdc
, hOldFont
);
150 SendMessageA(hwndStatus
, WM_SETFONT
, (WPARAM
)hCtrlFont
, TRUE
);
153 ReleaseDC(NULL
, hdc
);
157 static int CALLBACK
check_height_family_enumproc(ENUMLOGFONTEXA
*enumlf
, NEWTEXTMETRICEXA
*ntm
, DWORD type
, LPARAM lParam
)
159 HDC hdc
= GetDC(NULL
);
160 enumlf
->elfLogFont
.lfHeight
= 0;
161 EnumFontFamiliesExA(hdc
, &enumlf
->elfLogFont
, (FONTENUMPROCA
)check_height_font_enumproc
, lParam
, 0);
162 ReleaseDC(NULL
, hdc
);
166 static void test_height(void)
169 HFONT hFont
, hFontSm
;
171 HWND hwndStatus
= CreateWindowA(SUBCLASS_NAME
, NULL
, WS_CHILD
|WS_VISIBLE
,
172 0, 0, 300, 20, g_hMainWnd
, NULL
, NULL
, NULL
);
175 GetClientRect(hwndStatus
, &rc1
);
176 hFont
= CreateFontA(32, 0, 0, 0, FW_DONTCARE
, FALSE
, FALSE
, FALSE
, ANSI_CHARSET
,
177 OUT_DEFAULT_PRECIS
, CLIP_DEFAULT_PRECIS
, DEFAULT_QUALITY
, FF_DONTCARE
, "Tahoma");
180 SendMessageA(hwndStatus
, WM_SETFONT
, (WPARAM
)hFont
, TRUE
);
183 skip("Status control not resized in win95, skipping broken tests.\n");
186 ok(g_wmsize_count
> 0, "WM_SETFONT should issue WM_SIZE\n");
188 GetClientRect(hwndStatus
, &rc2
);
189 expect_rect(0, 0, 672, 42, rc2
); /* GetTextMetrics returns invalid tmInternalLeading for this font */
192 SendMessageA(hwndStatus
, WM_SETFONT
, (WPARAM
)hFont
, TRUE
);
193 ok(g_wmsize_count
> 0, "WM_SETFONT should issue WM_SIZE\n");
195 GetClientRect(hwndStatus
, &rc2
);
196 expect_rect(0, 0, 672, 42, rc2
);
198 /* minheight < fontsize - no effects*/
199 SendMessageA(hwndStatus
, SB_SETMINHEIGHT
, 12, 0);
200 SendMessageA(hwndStatus
, WM_SIZE
, 0, 0);
201 GetClientRect(hwndStatus
, &rc2
);
202 expect_rect(0, 0, 672, 42, rc2
);
204 /* minheight > fontsize - has an effect after WM_SIZE */
205 SendMessageA(hwndStatus
, SB_SETMINHEIGHT
, 60, 0);
206 GetClientRect(hwndStatus
, &rc2
);
207 expect_rect(0, 0, 672, 42, rc2
);
208 SendMessageA(hwndStatus
, WM_SIZE
, 0, 0);
209 GetClientRect(hwndStatus
, &rc2
);
210 expect_rect(0, 0, 672, 62, rc2
);
212 /* font changed to smaller than minheight - has an effect */
213 SendMessageA(hwndStatus
, SB_SETMINHEIGHT
, 30, 0);
214 expect_rect(0, 0, 672, 62, rc2
);
215 SendMessageA(hwndStatus
, WM_SIZE
, 0, 0);
216 GetClientRect(hwndStatus
, &rc2
);
217 expect_rect(0, 0, 672, 42, rc2
);
218 hFontSm
= CreateFontA(9, 0, 0, 0, FW_DONTCARE
, FALSE
, FALSE
, FALSE
, ANSI_CHARSET
,
219 OUT_DEFAULT_PRECIS
, CLIP_DEFAULT_PRECIS
, DEFAULT_QUALITY
, FF_DONTCARE
, "Tahoma");
220 SendMessageA(hwndStatus
, WM_SETFONT
, (WPARAM
)hFontSm
, TRUE
);
221 GetClientRect(hwndStatus
, &rc2
);
222 expect_rect(0, 0, 672, 32, rc2
);
224 /* test the height formula */
225 ZeroMemory(&lf
, sizeof(lf
));
226 SendMessageA(hwndStatus
, SB_SETMINHEIGHT
, 0, 0);
229 /* used only for some fonts (tahoma as example) */
230 g_ysize
= GetSystemMetrics(SM_CYSIZE
) + 2;
231 if (g_ysize
& 1) g_ysize
--; /* The min height is always even */
233 g_dpisize
= MulDiv(18, GetDeviceCaps(hdc
, LOGPIXELSY
), 96) + 2;
234 if (g_dpisize
& 1) g_dpisize
--; /* The min height is always even */
237 trace("dpi=%d (min height: %d or %d) SM_CYSIZE: %d\n",
238 GetDeviceCaps(hdc
, LOGPIXELSY
), g_ysize
, g_dpisize
,
239 GetSystemMetrics(SM_CYSIZE
));
241 EnumFontFamiliesExA(hdc
, &lf
, (FONTENUMPROCA
)check_height_family_enumproc
, (LPARAM
)hwndStatus
, 0);
242 ReleaseDC(NULL
, hdc
);
244 DestroyWindow(hwndStatus
);
246 DeleteObject(hFontSm
);
249 static void test_status_control(void)
253 int nParts
[] = {50, 150, -1};
254 int checkParts
[] = {0, 0, 0};
255 int borders
[] = {0, 0, 0};
260 char chstr
[10] = "Inval id";
261 COLORREF crColor
= RGB(0,0,0);
263 hWndStatus
= create_status_control(WS_VISIBLE
| SBT_TOOLTIPS
, 0);
265 /* Divide into parts and set text */
266 r
= SendMessageA(hWndStatus
, SB_SETPARTS
, 3, (LPARAM
)nParts
);
268 r
= SendMessageA(hWndStatus
, SB_SETTEXTA
, SBT_POPOUT
|0, (LPARAM
)"First");
270 r
= SendMessageA(hWndStatus
, SB_SETTEXTA
, SBT_OWNERDRAW
|1, (LPARAM
)"Second");
272 r
= SendMessageA(hWndStatus
, SB_SETTEXTA
, SBT_NOBORDERS
|2, (LPARAM
)"Third");
275 /* Get RECT Information */
276 r
= SendMessageA(hWndStatus
, SB_GETRECT
, 0, (LPARAM
)&rc
);
279 /* The rc.bottom test is system dependent
280 expect(22,rc.bottom); */
283 r
= SendMessageA(hWndStatus
, SB_GETRECT
, -1, (LPARAM
)&rc
);
285 r
= SendMessageA(hWndStatus
, SB_GETRECT
, 3, (LPARAM
)&rc
);
287 /* Get text length and text */
288 r
= SendMessageA(hWndStatus
, SB_GETTEXTLENGTHA
, 0, 0);
290 expect(SBT_POPOUT
,HIWORD(r
));
291 r
= SendMessageW(hWndStatus
, WM_GETTEXTLENGTH
, 0, 0);
292 ok(r
== 5, "Expected 5, got %d\n", r
);
293 r
= SendMessageA(hWndStatus
, SB_GETTEXTLENGTHA
, 1, 0);
295 expect(SBT_OWNERDRAW
,HIWORD(r
));
296 r
= SendMessageA(hWndStatus
, SB_GETTEXTLENGTHA
, 2, 0);
298 expect(SBT_NOBORDERS
,HIWORD(r
));
299 r
= SendMessageA(hWndStatus
, SB_GETTEXTA
, 2, (LPARAM
) charArray
);
300 ok(strcmp(charArray
,"Third") == 0, "Expected Third, got %s\n", charArray
);
302 expect(SBT_NOBORDERS
,HIWORD(r
));
304 /* Get parts and borders */
305 r
= SendMessageA(hWndStatus
, SB_GETPARTS
, 3, (LPARAM
)checkParts
);
306 ok(r
== 3, "Expected 3, got %d\n", r
);
307 expect(50,checkParts
[0]);
308 expect(150,checkParts
[1]);
309 expect(-1,checkParts
[2]);
310 r
= SendMessageA(hWndStatus
, SB_GETBORDERS
, 0, (LPARAM
)borders
);
311 ok(r
== TRUE
, "Expected TRUE, got %d\n", r
);
312 expect(0,borders
[0]);
313 expect(2,borders
[1]);
314 expect(2,borders
[2]);
316 /* Test resetting text with different characters */
317 r
= SendMessageA(hWndStatus
, SB_SETTEXTA
, 0, (LPARAM
)"First@Again");
319 r
= SendMessageA(hWndStatus
, SB_SETTEXTA
, 1, (LPARAM
)"Invalid\tChars\\7\7");
321 r
= SendMessageA(hWndStatus
, SB_SETTEXTA
, 2, (LPARAM
)"InvalidChars\\n\n");
325 r
= SendMessageA(hWndStatus
, SB_GETTEXTA
, 0, (LPARAM
) charArray
);
326 ok(strcmp(charArray
,"First@Again") == 0, "Expected First@Again, got %s\n", charArray
);
327 expect(11,LOWORD(r
));
329 r
= SendMessageA(hWndStatus
, SB_GETTEXTA
, 1, (LPARAM
) charArray
);
330 ok(strcmp(charArray
,"Invalid\tChars\\7 ") == 0, "Expected Invalid\tChars\\7 , got %s\n", charArray
);
332 expect(16,LOWORD(r
));
334 r
= SendMessageA(hWndStatus
, SB_GETTEXTA
, 2, (LPARAM
) charArray
);
335 ok(strcmp(charArray
,"InvalidChars\\n ") == 0, "Expected InvalidChars\\n , got %s\n", charArray
);
337 expect(15,LOWORD(r
));
340 /* test more nonprintable chars */
341 for(ch
= 0x00; ch
< 0x7F; ch
++) {
343 r
= SendMessageA(hWndStatus
, SB_SETTEXTA
, 0, (LPARAM
)chstr
);
345 r
= SendMessageA(hWndStatus
, SB_GETTEXTA
, 0, (LPARAM
)charArray
);
346 ok(r
== strlen(charArray
), "got %d\n", r
);
347 /* substitution with single space */
348 if (ch
> 0x00 && ch
< 0x20 && ch
!= '\t')
350 ok(strcmp(charArray
, chstr
) == 0, "Expected %s, got %s\n", chstr
, charArray
);
353 /* Set background color */
354 crColor
= SendMessageA(hWndStatus
, SB_SETBKCOLOR
, 0, RGB(255,0,0));
355 ok(crColor
== CLR_DEFAULT
||
356 broken(crColor
== RGB(0,0,0)), /* win95 */
357 "Expected 0x%.8x, got 0x%.8x\n", CLR_DEFAULT
, crColor
);
358 crColor
= SendMessageA(hWndStatus
, SB_SETBKCOLOR
, 0, CLR_DEFAULT
);
359 ok(crColor
== RGB(255,0,0) ||
360 broken(crColor
== RGB(0,0,0)), /* win95 */
361 "Expected 0x%.8x, got 0x%.8x\n", RGB(255,0,0), crColor
);
363 /* Add an icon to the status bar */
364 hIcon
= LoadIconA(NULL
, (LPCSTR
)IDI_QUESTION
);
365 r
= SendMessageA(hWndStatus
, SB_SETICON
, 1, 0);
367 broken(r
== 0), /* win95 */
368 "Expected non-zero, got %d\n", r
);
369 r
= SendMessageA(hWndStatus
, SB_SETICON
, 1, (LPARAM
) hIcon
);
371 broken(r
== 0), /* win95 */
372 "Expected non-zero, got %d\n", r
);
373 r
= SendMessageA(hWndStatus
, SB_SETICON
, 1, 0);
375 broken(r
== 0), /* win95 */
376 "Expected non-zero, got %d\n", r
);
378 /* Set the Unicode format */
379 r
= SendMessageA(hWndStatus
, SB_SETUNICODEFORMAT
, FALSE
, 0);
381 r
= SendMessageA(hWndStatus
, SB_GETUNICODEFORMAT
, 0, 0);
383 r
= SendMessageA(hWndStatus
, SB_SETUNICODEFORMAT
, TRUE
, 0);
385 r
= SendMessageA(hWndStatus
, SB_GETUNICODEFORMAT
, 0, 0);
387 broken(r
== FALSE
), /* win95 */
388 "Expected TRUE, got %d\n", r
);
390 /* Reset number of parts */
391 r
= SendMessageA(hWndStatus
, SB_SETPARTS
, 2, (LPARAM
)nParts
);
393 r
= SendMessageA(hWndStatus
, SB_GETPARTS
, 0, 0);
394 ok(r
== 2, "Expected 2, got %d\n", r
);
395 r
= SendMessageA(hWndStatus
, SB_SETPARTS
, 0, 0);
397 r
= SendMessageA(hWndStatus
, SB_GETPARTS
, 0, 0);
398 ok(r
== 2, "Expected 2, got %d\n", r
);
400 /* Set the minimum height and get rectangle information again */
401 SendMessageA(hWndStatus
, SB_SETMINHEIGHT
, 50, 0);
402 r
= SendMessageA(hWndStatus
, WM_SIZE
, 0, 0);
404 r
= SendMessageA(hWndStatus
, SB_GETRECT
, 0, (LPARAM
)&rc
);
407 /* The rc.bottom test is system dependent
408 expect(22,rc.bottom); */
411 r
= SendMessageA(hWndStatus
, SB_GETRECT
, -1, (LPARAM
)&rc
);
413 r
= SendMessageA(hWndStatus
, SB_GETRECT
, 3, (LPARAM
)&rc
);
416 /* Set the ToolTip text */
417 SendMessageA(hWndStatus
, SB_SETTIPTEXTA
, 0,(LPARAM
) "Tooltip Text");
418 lstrcpyA(charArray
, "apple");
419 SendMessageA(hWndStatus
, SB_GETTIPTEXTA
, MAKEWPARAM (0, 20),(LPARAM
) charArray
);
420 ok(strcmp(charArray
,"Tooltip Text") == 0 ||
421 broken(!strcmp(charArray
, "apple")), /* win95 */
422 "Expected Tooltip Text, got %s\n", charArray
);
425 SendMessageA(hWndStatus
, SB_SIMPLE
, TRUE
, 0);
426 r
= SendMessageA(hWndStatus
, SB_ISSIMPLE
, 0, 0);
428 broken(r
== FALSE
), /* win95 */
429 "Expected TRUE, got %d\n", r
);
431 DestroyWindow(hWndStatus
);
434 static LRESULT WINAPI
ownerdraw_test_wndproc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
437 if (msg
== WM_DRAWITEM
)
439 ret
= CallWindowProcA(g_wndproc_saved
, hwnd
, msg
, wParam
, lParam
);
443 static void test_status_ownerdraw(void)
447 const char* statustext
= "STATUS TEXT";
450 /* subclass the main window and make sure it is visible */
451 g_wndproc_saved
= (WNDPROC
) SetWindowLongPtrA( g_hMainWnd
, GWLP_WNDPROC
,
452 (LONG_PTR
)ownerdraw_test_wndproc
);
453 ok( g_wndproc_saved
!= 0, "failed to set the WndProc\n");
454 SetWindowPos( g_hMainWnd
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
455 oldstyle
= GetWindowLongA( g_hMainWnd
, GWL_STYLE
);
456 SetWindowLongA( g_hMainWnd
, GWL_STYLE
, oldstyle
| WS_VISIBLE
);
457 /* create a status child window */
458 ok((hWndStatus
= CreateWindowA(SUBCLASS_NAME
, "", WS_CHILD
|WS_VISIBLE
, 0, 0, 100, 100,
459 g_hMainWnd
, NULL
, NULL
, 0)) != NULL
, "CreateWindowA failed\n");
462 r
= SendMessageA(hWndStatus
, SB_SETTEXTA
, 0, (LPARAM
)statustext
);
463 ok( r
== TRUE
, "Sendmessage returned %d, expected 1\n", r
);
464 ok( 0 == g_wmdrawitm_ctr
, "got %d drawitem messages expected none\n", g_wmdrawitm_ctr
);
465 /* set same text, with ownerdraw flag */
467 r
= SendMessageA(hWndStatus
, SB_SETTEXTA
, SBT_OWNERDRAW
, (LPARAM
)statustext
);
468 ok( r
== TRUE
, "Sendmessage returned %d, expected 1\n", r
);
469 ok( 1 == g_wmdrawitm_ctr
, "got %d drawitem messages expected 1\n", g_wmdrawitm_ctr
);
472 r
= SendMessageA(hWndStatus
, SB_SETTEXTA
, SBT_OWNERDRAW
, (LPARAM
)statustext
);
473 ok( r
== TRUE
, "Sendmessage returned %d, expected 1\n", r
);
474 ok( 1 == g_wmdrawitm_ctr
, "got %d drawitem messages expected 1\n", g_wmdrawitm_ctr
);
476 DestroyWindow(hWndStatus
);
477 SetWindowLongA( g_hMainWnd
, GWL_STYLE
, oldstyle
);
478 SetWindowLongPtrA( g_hMainWnd
, GWLP_WNDPROC
, (LONG_PTR
)g_wndproc_saved
);
481 static void test_gettext(void)
483 HWND hwndStatus
= CreateWindowA(SUBCLASS_NAME
, NULL
, WS_CHILD
|WS_VISIBLE
,
484 0, 0, 300, 20, g_hMainWnd
, NULL
, NULL
, NULL
);
488 r
= SendMessageA(hwndStatus
, SB_SETTEXTA
, 0, (LPARAM
)"Text");
490 r
= SendMessageA(hwndStatus
, WM_GETTEXTLENGTH
, 0, 0);
492 /* A size of 0 returns the length of the text */
493 r
= SendMessageA(hwndStatus
, WM_GETTEXT
, 0, 0);
494 ok( r
== 4 || broken(r
== 2) /* win8 */, "Expected 4 got %d\n", r
);
495 /* A size of 1 only stores the NULL terminator */
497 r
= SendMessageA(hwndStatus
, WM_GETTEXT
, 1, (LPARAM
)buf
);
498 ok( r
== 0 || broken(r
== 4), "Expected 0 got %d\n", r
);
499 if (!r
) ok(!buf
[0], "expected empty buffer\n");
500 /* A size of 2 returns a length 1 */
501 r
= SendMessageA(hwndStatus
, WM_GETTEXT
, 2, (LPARAM
)buf
);
502 ok( r
== 1 || broken(r
== 4), "Expected 1 got %d\n", r
);
503 r
= SendMessageA(hwndStatus
, WM_GETTEXT
, sizeof(buf
), (LPARAM
)buf
);
505 ok(!strcmp(buf
, "Text"), "expected Text, got %s\n", buf
);
506 DestroyWindow(hwndStatus
);
509 /* Notify events to parent */
510 static BOOL g_got_dblclk
;
511 static BOOL g_got_click
;
512 static BOOL g_got_rdblclk
;
513 static BOOL g_got_rclick
;
515 /* Messages to parent */
516 static BOOL g_got_contextmenu
;
518 static LRESULT WINAPI
test_notify_parent_proc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
524 NMHDR
*hdr
= ((LPNMHDR
)lParam
);
527 case NM_DBLCLK
: g_got_dblclk
= TRUE
; break;
528 case NM_CLICK
: g_got_click
= TRUE
; break;
529 case NM_RDBLCLK
: g_got_rdblclk
= TRUE
; break;
530 case NM_RCLICK
: g_got_rclick
= TRUE
; break;
533 /* Return zero to indicate default processing */
537 case WM_CONTEXTMENU
: g_got_contextmenu
= TRUE
; return 0;
540 return( DefWindowProcA(hwnd
, msg
, wParam
, lParam
));
546 /* Test that WM_NOTIFY messages from the status control works correctly */
547 static void test_notify(void)
552 WNDCLASSA wclass
= {0};
553 wclass
.lpszClassName
= "TestNotifyParentClass";
554 wclass
.lpfnWndProc
= test_notify_parent_proc
;
555 atom
= RegisterClassA(&wclass
);
556 ok(atom
, "RegisterClass failed\n");
559 hwndParent
= CreateWindowA(wclass
.lpszClassName
, "parent", WS_OVERLAPPEDWINDOW
,
560 CW_USEDEFAULT
, 0, 300, 20, NULL
, NULL
, NULL
, NULL
);
561 ok(hwndParent
!= NULL
, "Parent creation failed!\n");
563 /* create status bar */
564 hwndStatus
= CreateWindowA(STATUSCLASSNAMEA
, NULL
, WS_VISIBLE
| WS_CHILD
,
565 0, 0, 300, 20, hwndParent
, NULL
, NULL
, NULL
);
566 ok(hwndStatus
!= NULL
, "Status creation failed!\n");
568 /* Send various mouse event, and check that we get them */
569 g_got_dblclk
= FALSE
;
570 SendMessageA(hwndStatus
, WM_LBUTTONDBLCLK
, 0, 0);
571 ok(g_got_dblclk
, "WM_LBUTTONDBLCLK was not processed correctly!\n");
572 g_got_rdblclk
= FALSE
;
573 SendMessageA(hwndStatus
, WM_RBUTTONDBLCLK
, 0, 0);
574 ok(g_got_rdblclk
, "WM_RBUTTONDBLCLK was not processed correctly!\n");
576 SendMessageA(hwndStatus
, WM_LBUTTONUP
, 0, 0);
577 ok(g_got_click
, "WM_LBUTTONUP was not processed correctly!\n");
579 /* For R-UP, check that we also get the context menu from the default processing */
580 g_got_contextmenu
= FALSE
;
581 g_got_rclick
= FALSE
;
582 SendMessageA(hwndStatus
, WM_RBUTTONUP
, 0, 0);
583 ok(g_got_rclick
, "WM_RBUTTONUP was not processed correctly!\n");
584 ok(g_got_contextmenu
, "WM_RBUTTONUP did not activate the context menu!\n");
589 hinst
= GetModuleHandleA(NULL
);
591 g_hMainWnd
= CreateWindowExA(0, "static", "", WS_OVERLAPPEDWINDOW
,
592 CW_USEDEFAULT
, CW_USEDEFAULT
, 672+2*GetSystemMetrics(SM_CXSIZEFRAME
),
593 226+GetSystemMetrics(SM_CYCAPTION
)+2*GetSystemMetrics(SM_CYSIZEFRAME
),
594 NULL
, NULL
, GetModuleHandleA(NULL
), 0);
596 InitCommonControls();
600 test_status_control();
603 test_status_ownerdraw();