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 {%d,%d, %d,%d}\n", \
34 _left, _top, _right, _bottom, \
35 (got).left, (got).top, (got).right, (got).bottom); } while (0)
37 static HINSTANCE hinst
;
38 static WNDPROC g_status_wndproc
;
39 static RECT g_rcCreated
;
40 static HWND g_hMainWnd
;
41 static int g_wmsize_count
= 0;
44 static int g_wmdrawitm_ctr
;
45 static WNDPROC g_wndproc_saved
;
47 static HWND
create_status_control(DWORD style
, DWORD exstyle
)
51 /* make the control */
52 hWndStatus
= CreateWindowExA(exstyle
, STATUSCLASSNAMEA
, NULL
, style
,
56 NULL
, NULL
, hinst
, NULL
);
57 ok(hWndStatus
!= NULL
, "failed to create status wnd\n");
61 static LRESULT WINAPI
create_test_wndproc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
67 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lParam
;
68 ret
= CallWindowProcA(g_status_wndproc
, hwnd
, msg
, wParam
, lParam
);
69 GetWindowRect(hwnd
, &g_rcCreated
);
70 MapWindowPoints(HWND_DESKTOP
, g_hMainWnd
, (LPPOINT
)&g_rcCreated
, 2);
71 ok(cs
->x
== g_rcCreated
.left
, "CREATESTRUCT.x modified\n");
72 ok(cs
->y
== g_rcCreated
.top
, "CREATESTRUCT.y modified\n");
73 } else if (msg
== WM_SIZE
)
76 ret
= CallWindowProcA(g_status_wndproc
, hwnd
, msg
, wParam
, lParam
);
79 ret
= CallWindowProcA(g_status_wndproc
, hwnd
, msg
, wParam
, lParam
);
84 static void register_subclass(void)
88 cls
.cbSize
= sizeof(WNDCLASSEXA
);
89 GetClassInfoExA(NULL
, STATUSCLASSNAMEA
, &cls
);
90 g_status_wndproc
= cls
.lpfnWndProc
;
91 cls
.lpfnWndProc
= create_test_wndproc
;
92 cls
.lpszClassName
= SUBCLASS_NAME
;
94 ok(RegisterClassExA(&cls
), "RegisterClassEx failed\n");
97 static void test_create(void)
102 ok((hwnd
= CreateWindowA(SUBCLASS_NAME
, "", WS_CHILD
|WS_VISIBLE
|SBARS_SIZEGRIP
, 0, 0, 100, 100,
103 g_hMainWnd
, NULL
, NULL
, 0)) != NULL
, "CreateWindowA failed\n");
104 MapWindowPoints(HWND_DESKTOP
, g_hMainWnd
, (LPPOINT
)&rc
, 2);
105 GetWindowRect(hwnd
, &rc
);
106 MapWindowPoints(HWND_DESKTOP
, g_hMainWnd
, (LPPOINT
)&rc
, 2);
107 expect_rect(0, 0, 100, 100, g_rcCreated
);
109 expect(672, rc
.right
);
110 expect(226, rc
.bottom
);
111 /* we don't check rc.top as this may depend on user font settings */
115 static int CALLBACK
check_height_font_enumproc(ENUMLOGFONTEXA
*enumlf
, NEWTEXTMETRICEXA
*ntm
, DWORD type
, LPARAM lParam
)
117 HWND hwndStatus
= (HWND
)lParam
;
118 HDC hdc
= GetDC(NULL
);
119 static const int sizes
[] = { 6, 7, 8, 9, 10, 11, 12, 13, 15, 16,
120 20, 22, 28, 36, 48, 72};
123 LPSTR facename
= (CHAR
*)enumlf
->elfFullName
;
125 /* on win9x, enumlf->elfFullName is only valid for truetype fonts */
126 if (type
!= TRUETYPE_FONTTYPE
)
127 facename
= enumlf
->elfLogFont
.lfFaceName
;
129 for (i
= 0; i
< sizeof(sizes
)/sizeof(sizes
[0]); i
++)
137 enumlf
->elfLogFont
.lfHeight
= sizes
[i
];
138 hFont
= CreateFontIndirectA(&enumlf
->elfLogFont
);
139 hCtrlFont
= (HFONT
)SendMessageA(hwndStatus
, WM_SETFONT
, (WPARAM
)hFont
, TRUE
);
140 hOldFont
= SelectObject(hdc
, hFont
);
142 GetClientRect(hwndStatus
, &rcCtrl
);
143 GetTextMetricsA(hdc
, &tm
);
144 y
= tm
.tmHeight
+ (tm
.tmInternalLeading
? tm
.tmInternalLeading
: 2) + 4;
146 ok( (rcCtrl
.bottom
== max(y
, g_ysize
)) || (rcCtrl
.bottom
== max(y
, g_dpisize
)),
147 "got %d (expected %d or %d) for %s #%d\n",
148 rcCtrl
.bottom
, max(y
, g_ysize
), max(y
, g_dpisize
), facename
, sizes
[i
]);
150 SelectObject(hdc
, hOldFont
);
151 SendMessageA(hwndStatus
, WM_SETFONT
, (WPARAM
)hCtrlFont
, TRUE
);
154 ReleaseDC(NULL
, hdc
);
158 static int CALLBACK
check_height_family_enumproc(ENUMLOGFONTEXA
*enumlf
, NEWTEXTMETRICEXA
*ntm
, DWORD type
, LPARAM lParam
)
160 HDC hdc
= GetDC(NULL
);
161 enumlf
->elfLogFont
.lfHeight
= 0;
162 EnumFontFamiliesExA(hdc
, &enumlf
->elfLogFont
, (FONTENUMPROCA
)check_height_font_enumproc
, lParam
, 0);
163 ReleaseDC(NULL
, hdc
);
167 static void test_height(void)
170 HFONT hFont
, hFontSm
;
172 HWND hwndStatus
= CreateWindowA(SUBCLASS_NAME
, NULL
, WS_CHILD
|WS_VISIBLE
,
173 0, 0, 300, 20, g_hMainWnd
, NULL
, NULL
, NULL
);
176 GetClientRect(hwndStatus
, &rc1
);
177 hFont
= CreateFontA(32, 0, 0, 0, FW_DONTCARE
, FALSE
, FALSE
, FALSE
, ANSI_CHARSET
,
178 OUT_DEFAULT_PRECIS
, CLIP_DEFAULT_PRECIS
, DEFAULT_QUALITY
, FF_DONTCARE
, "Tahoma");
181 SendMessageA(hwndStatus
, WM_SETFONT
, (WPARAM
)hFont
, TRUE
);
184 skip("Status control not resized in win95, skipping broken tests.\n");
187 ok(g_wmsize_count
> 0, "WM_SETFONT should issue WM_SIZE\n");
189 GetClientRect(hwndStatus
, &rc2
);
190 expect_rect(0, 0, 672, 42, rc2
); /* GetTextMetrics returns invalid tmInternalLeading for this font */
193 SendMessageA(hwndStatus
, WM_SETFONT
, (WPARAM
)hFont
, TRUE
);
194 ok(g_wmsize_count
> 0, "WM_SETFONT should issue WM_SIZE\n");
196 GetClientRect(hwndStatus
, &rc2
);
197 expect_rect(0, 0, 672, 42, rc2
);
199 /* minheight < fontsize - no effects*/
200 SendMessageA(hwndStatus
, SB_SETMINHEIGHT
, 12, 0);
201 SendMessageA(hwndStatus
, WM_SIZE
, 0, 0);
202 GetClientRect(hwndStatus
, &rc2
);
203 expect_rect(0, 0, 672, 42, rc2
);
205 /* minheight > fontsize - has an effect after WM_SIZE */
206 SendMessageA(hwndStatus
, SB_SETMINHEIGHT
, 60, 0);
207 GetClientRect(hwndStatus
, &rc2
);
208 expect_rect(0, 0, 672, 42, rc2
);
209 SendMessageA(hwndStatus
, WM_SIZE
, 0, 0);
210 GetClientRect(hwndStatus
, &rc2
);
211 expect_rect(0, 0, 672, 62, rc2
);
213 /* font changed to smaller than minheight - has an effect */
214 SendMessageA(hwndStatus
, SB_SETMINHEIGHT
, 30, 0);
215 expect_rect(0, 0, 672, 62, rc2
);
216 SendMessageA(hwndStatus
, WM_SIZE
, 0, 0);
217 GetClientRect(hwndStatus
, &rc2
);
218 expect_rect(0, 0, 672, 42, rc2
);
219 hFontSm
= CreateFontA(9, 0, 0, 0, FW_DONTCARE
, FALSE
, FALSE
, FALSE
, ANSI_CHARSET
,
220 OUT_DEFAULT_PRECIS
, CLIP_DEFAULT_PRECIS
, DEFAULT_QUALITY
, FF_DONTCARE
, "Tahoma");
221 SendMessageA(hwndStatus
, WM_SETFONT
, (WPARAM
)hFontSm
, TRUE
);
222 GetClientRect(hwndStatus
, &rc2
);
223 expect_rect(0, 0, 672, 32, rc2
);
225 /* test the height formula */
226 ZeroMemory(&lf
, sizeof(lf
));
227 SendMessageA(hwndStatus
, SB_SETMINHEIGHT
, 0, 0);
230 /* used only for some fonts (tahoma as example) */
231 g_ysize
= GetSystemMetrics(SM_CYSIZE
) + 2;
232 if (g_ysize
& 1) g_ysize
--; /* The min height is always even */
234 g_dpisize
= MulDiv(18, GetDeviceCaps(hdc
, LOGPIXELSY
), 96) + 2;
235 if (g_dpisize
& 1) g_dpisize
--; /* The min height is always even */
238 trace("dpi=%d (min height: %d or %d) SM_CYSIZE: %d\n",
239 GetDeviceCaps(hdc
, LOGPIXELSY
), g_ysize
, g_dpisize
,
240 GetSystemMetrics(SM_CYSIZE
));
242 EnumFontFamiliesExA(hdc
, &lf
, (FONTENUMPROCA
)check_height_family_enumproc
, (LPARAM
)hwndStatus
, 0);
243 ReleaseDC(NULL
, hdc
);
245 DestroyWindow(hwndStatus
);
247 DeleteObject(hFontSm
);
250 static void test_status_control(void)
254 int nParts
[] = {50, 150, -1};
255 int checkParts
[] = {0, 0, 0};
256 int borders
[] = {0, 0, 0};
261 char chstr
[10] = "Inval id";
262 COLORREF crColor
= RGB(0,0,0);
264 hWndStatus
= create_status_control(WS_VISIBLE
| SBT_TOOLTIPS
, 0);
266 /* Divide into parts and set text */
267 r
= SendMessageA(hWndStatus
, SB_SETPARTS
, 3, (LPARAM
)nParts
);
269 r
= SendMessageA(hWndStatus
, SB_SETTEXTA
, SBT_POPOUT
|0, (LPARAM
)"First");
271 r
= SendMessageA(hWndStatus
, SB_SETTEXTA
, SBT_OWNERDRAW
|1, (LPARAM
)"Second");
273 r
= SendMessageA(hWndStatus
, SB_SETTEXTA
, SBT_NOBORDERS
|2, (LPARAM
)"Third");
276 /* Get RECT Information */
277 r
= SendMessageA(hWndStatus
, SB_GETRECT
, 0, (LPARAM
)&rc
);
280 /* The rc.bottom test is system dependent
281 expect(22,rc.bottom); */
284 r
= SendMessageA(hWndStatus
, SB_GETRECT
, -1, (LPARAM
)&rc
);
286 r
= SendMessageA(hWndStatus
, SB_GETRECT
, 3, (LPARAM
)&rc
);
288 /* Get text length and text */
289 r
= SendMessageA(hWndStatus
, SB_GETTEXTLENGTHA
, 0, 0);
291 expect(SBT_POPOUT
,HIWORD(r
));
292 r
= SendMessageW(hWndStatus
, WM_GETTEXTLENGTH
, 0, 0);
293 ok(r
== 5 || broken(0x02000005 /* NT4 */), "Expected 5, got %d\n", r
);
294 r
= SendMessageA(hWndStatus
, SB_GETTEXTLENGTHA
, 1, 0);
296 expect(SBT_OWNERDRAW
,HIWORD(r
));
297 r
= SendMessageA(hWndStatus
, SB_GETTEXTLENGTHA
, 2, 0);
299 expect(SBT_NOBORDERS
,HIWORD(r
));
300 r
= SendMessageA(hWndStatus
, SB_GETTEXTA
, 2, (LPARAM
) charArray
);
301 ok(strcmp(charArray
,"Third") == 0, "Expected Third, got %s\n", charArray
);
303 expect(SBT_NOBORDERS
,HIWORD(r
));
305 /* Get parts and borders */
306 r
= SendMessageA(hWndStatus
, SB_GETPARTS
, 3, (LPARAM
)checkParts
);
307 ok(r
== 3, "Expected 3, got %d\n", r
);
308 expect(50,checkParts
[0]);
309 expect(150,checkParts
[1]);
310 expect(-1,checkParts
[2]);
311 r
= SendMessageA(hWndStatus
, SB_GETBORDERS
, 0, (LPARAM
)borders
);
312 ok(r
== TRUE
, "Expected TRUE, got %d\n", r
);
313 expect(0,borders
[0]);
314 expect(2,borders
[1]);
315 expect(2,borders
[2]);
317 /* Test resetting text with different characters */
318 r
= SendMessageA(hWndStatus
, SB_SETTEXTA
, 0, (LPARAM
)"First@Again");
320 r
= SendMessageA(hWndStatus
, SB_SETTEXTA
, 1, (LPARAM
)"Invalid\tChars\\7\7");
322 r
= SendMessageA(hWndStatus
, SB_SETTEXTA
, 2, (LPARAM
)"InvalidChars\\n\n");
326 r
= SendMessageA(hWndStatus
, SB_GETTEXTA
, 0, (LPARAM
) charArray
);
327 ok(strcmp(charArray
,"First@Again") == 0, "Expected First@Again, got %s\n", charArray
);
328 expect(11,LOWORD(r
));
330 r
= SendMessageA(hWndStatus
, SB_GETTEXTA
, 1, (LPARAM
) charArray
);
331 ok(strcmp(charArray
,"Invalid\tChars\\7 ") == 0, "Expected Invalid\tChars\\7 , got %s\n", charArray
);
333 expect(16,LOWORD(r
));
335 r
= SendMessageA(hWndStatus
, SB_GETTEXTA
, 2, (LPARAM
) charArray
);
336 ok(strcmp(charArray
,"InvalidChars\\n ") == 0, "Expected InvalidChars\\n , got %s\n", charArray
);
338 expect(15,LOWORD(r
));
341 /* test more nonprintable chars */
342 for(ch
= 0x00; ch
< 0x7F; ch
++) {
344 r
= SendMessageA(hWndStatus
, SB_SETTEXTA
, 0, (LPARAM
)chstr
);
346 r
= SendMessageA(hWndStatus
, SB_GETTEXTA
, 0, (LPARAM
)charArray
);
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();