2 * Copyright 2005 Dmitry Timoshkov
3 * Copyright 2008 Jason Edmeades
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
22 #define expect(expected, got) ok(got == expected, "Expected %d, got %d\n", expected, got)
24 static void test_create_tooltip(void)
27 DWORD style
, exp_style
;
29 parent
= CreateWindowExA(0, "static", NULL
, WS_POPUP
,
32 ok(parent
!= NULL
, "failed to create parent wnd\n");
34 hwnd
= CreateWindowExA(0, TOOLTIPS_CLASSA
, NULL
, 0x7fffffff | WS_POPUP
,
36 parent
, NULL
, NULL
, 0);
37 ok(hwnd
!= NULL
, "failed to create tooltip wnd\n");
39 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
40 trace("style = %08x\n", style
);
41 exp_style
= 0x7fffffff | WS_POPUP
;
42 exp_style
&= ~(WS_CHILD
| WS_MAXIMIZE
| WS_BORDER
| WS_DLGFRAME
);
43 ok(style
== exp_style
|| broken(style
== (exp_style
| WS_BORDER
)), /* nt4 */
44 "wrong style %08x/%08x\n", style
, exp_style
);
48 hwnd
= CreateWindowExA(0, TOOLTIPS_CLASSA
, NULL
, 0,
50 parent
, NULL
, NULL
, 0);
51 ok(hwnd
!= NULL
, "failed to create tooltip wnd\n");
53 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
54 trace("style = %08x\n", style
);
55 ok(style
== (WS_POPUP
| WS_CLIPSIBLINGS
| WS_BORDER
),
56 "wrong style %08x\n", style
);
60 DestroyWindow(parent
);
63 /* try to make sure pending X events have been processed before continuing */
64 static void flush_events(int waitTime
)
68 DWORD time
= GetTickCount() + waitTime
;
72 if (MsgWaitForMultipleObjects( 0, NULL
, FALSE
, min(100,diff
), QS_ALLEVENTS
) == WAIT_TIMEOUT
) break;
73 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA( &msg
);
74 diff
= time
- GetTickCount();
79 static LRESULT CD_Result
;
82 #define TEST_CDDS_PREPAINT 0x00000001
83 #define TEST_CDDS_POSTPAINT 0x00000002
84 #define TEST_CDDS_PREERASE 0x00000004
85 #define TEST_CDDS_POSTERASE 0x00000008
86 #define TEST_CDDS_ITEMPREPAINT 0x00000010
87 #define TEST_CDDS_ITEMPOSTPAINT 0x00000020
88 #define TEST_CDDS_ITEMPREERASE 0x00000040
89 #define TEST_CDDS_ITEMPOSTERASE 0x00000080
90 #define TEST_CDDS_SUBITEM 0x00000100
92 static LRESULT CALLBACK
custom_draw_wnd_proc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
101 if (((NMHDR
*)lParam
)->code
== NM_CUSTOMDRAW
) {
102 NMTTCUSTOMDRAW
*ttcd
= (NMTTCUSTOMDRAW
*) lParam
;
103 ok(ttcd
->nmcd
.hdr
.hwndFrom
== g_hwnd
, "Unexpected hwnd source %p (%p)\n",
104 ttcd
->nmcd
.hdr
.hwndFrom
, g_hwnd
);
105 ok(ttcd
->nmcd
.hdr
.idFrom
== 0x1234ABCD, "Unexpected id %x\n", (int)ttcd
->nmcd
.hdr
.idFrom
);
107 switch (ttcd
->nmcd
.dwDrawStage
) {
108 case CDDS_PREPAINT
: CD_Stages
|= TEST_CDDS_PREPAINT
; break;
109 case CDDS_POSTPAINT
: CD_Stages
|= TEST_CDDS_POSTPAINT
; break;
110 case CDDS_PREERASE
: CD_Stages
|= TEST_CDDS_PREERASE
; break;
111 case CDDS_POSTERASE
: CD_Stages
|= TEST_CDDS_POSTERASE
; break;
112 case CDDS_ITEMPREPAINT
: CD_Stages
|= TEST_CDDS_ITEMPREPAINT
; break;
113 case CDDS_ITEMPOSTPAINT
: CD_Stages
|= TEST_CDDS_ITEMPOSTPAINT
; break;
114 case CDDS_ITEMPREERASE
: CD_Stages
|= TEST_CDDS_ITEMPREERASE
; break;
115 case CDDS_ITEMPOSTERASE
: CD_Stages
|= TEST_CDDS_ITEMPOSTERASE
; break;
116 case CDDS_SUBITEM
: CD_Stages
|= TEST_CDDS_SUBITEM
; break;
117 default: CD_Stages
= -1;
120 if (ttcd
->nmcd
.dwDrawStage
== CDDS_PREPAINT
) return CD_Result
;
125 return DefWindowProcA(hWnd
, msg
, wParam
, lParam
);
131 static void test_customdraw(void) {
133 LRESULT FirstReturnValue
;
135 } expectedResults
[] = {
136 /* Valid notification responses */
137 {CDRF_DODEFAULT
, TEST_CDDS_PREPAINT
},
138 {CDRF_SKIPDEFAULT
, TEST_CDDS_PREPAINT
},
139 {CDRF_NOTIFYPOSTPAINT
, TEST_CDDS_PREPAINT
| TEST_CDDS_POSTPAINT
},
141 /* Invalid notification responses */
142 {CDRF_NOTIFYITEMDRAW
, TEST_CDDS_PREPAINT
},
143 {CDRF_NOTIFYPOSTERASE
, TEST_CDDS_PREPAINT
},
144 {CDRF_NEWFONT
, TEST_CDDS_PREPAINT
}
147 DWORD iterationNumber
;
152 /* Create a class to use the custom draw wndproc */
153 wc
.style
= CS_HREDRAW
| CS_VREDRAW
;
156 wc
.hInstance
= GetModuleHandleA(NULL
);
158 wc
.hCursor
= LoadCursorA(NULL
, (LPCSTR
)IDC_ARROW
);
159 wc
.hbrBackground
= GetSysColorBrush(COLOR_WINDOW
);
160 wc
.lpszMenuName
= NULL
;
161 wc
.lpszClassName
= "CustomDrawClass";
162 wc
.lpfnWndProc
= custom_draw_wnd_proc
;
165 GetCursorPos(&orig_pos
);
167 for (iterationNumber
= 0;
168 iterationNumber
< sizeof(expectedResults
)/sizeof(expectedResults
[0]);
171 HWND parent
, hwndTip
;
173 TTTOOLINFOA toolInfo
= { 0 };
175 /* Create a main window */
176 parent
= CreateWindowExA(0, "CustomDrawClass", NULL
,
177 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
178 WS_MAXIMIZEBOX
| WS_VISIBLE
,
181 NULL
, NULL
, NULL
, 0);
182 ok(parent
!= NULL
, "Creation of main window failed\n");
185 ShowWindow(parent
, SW_SHOWNORMAL
);
189 hwndTip
= CreateWindowExA(WS_EX_TOPMOST
, TOOLTIPS_CLASSA
,
190 NULL
, TTS_NOPREFIX
| TTS_ALWAYSTIP
,
191 CW_USEDEFAULT
, CW_USEDEFAULT
,
192 CW_USEDEFAULT
, CW_USEDEFAULT
,
193 parent
, NULL
, GetModuleHandleA(NULL
), 0);
194 ok(hwndTip
!= NULL
, "Creation of tooltip window failed\n");
196 /* Set up parms for the wndproc to handle */
198 CD_Result
= expectedResults
[iterationNumber
].FirstReturnValue
;
201 /* Make it topmost, as per the MSDN */
202 SetWindowPos(hwndTip
, HWND_TOPMOST
, 0, 0, 0, 0,
203 SWP_NOMOVE
| SWP_NOSIZE
| SWP_NOACTIVATE
);
206 toolInfo
.cbSize
= TTTOOLINFOA_V1_SIZE
;
207 toolInfo
.hwnd
= parent
;
208 toolInfo
.hinst
= GetModuleHandleA(NULL
);
209 toolInfo
.uFlags
= TTF_SUBCLASS
;
210 toolInfo
.uId
= 0x1234ABCD;
211 toolInfo
.lpszText
= (LPSTR
)"This is a test tooltip";
212 toolInfo
.lParam
= 0xdeadbeef;
213 GetClientRect (parent
, &toolInfo
.rect
);
214 lResult
= SendMessageA(hwndTip
, TTM_ADDTOOLA
, 0, (LPARAM
)&toolInfo
);
215 ok(lResult
, "Adding the tool to the tooltip failed\n");
217 /* Make tooltip appear quickly */
218 SendMessageA(hwndTip
, TTM_SETDELAYTIME
, TTDT_INITIAL
, MAKELPARAM(1,0));
220 /* Put cursor inside window, tooltip will appear immediately */
221 GetWindowRect( parent
, &rect
);
222 SetCursorPos( (rect
.left
+ rect
.right
) / 2, (rect
.top
+ rect
.bottom
) / 2 );
227 /* Check CustomDraw results */
228 ok(CD_Stages
== expectedResults
[iterationNumber
].ExpectedCalls
||
229 broken(CD_Stages
== (expectedResults
[iterationNumber
].ExpectedCalls
& ~TEST_CDDS_POSTPAINT
)), /* nt4 */
230 "CustomDraw run %d stages %x, expected %x\n", iterationNumber
, CD_Stages
,
231 expectedResults
[iterationNumber
].ExpectedCalls
);
235 DestroyWindow(hwndTip
);
236 DestroyWindow(parent
);
239 SetCursorPos(orig_pos
.x
, orig_pos
.y
);
242 static const CHAR testcallbackA
[] = "callback";
244 static LRESULT WINAPI
parent_wnd_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
246 if (message
== WM_NOTIFY
&& lParam
)
248 NMTTDISPINFOA
*ttnmdi
= (NMTTDISPINFOA
*)lParam
;
250 if (ttnmdi
->hdr
.code
== TTN_GETDISPINFOA
)
251 lstrcpyA(ttnmdi
->lpszText
, testcallbackA
);
254 return DefWindowProcA(hwnd
, message
, wParam
, lParam
);
257 static BOOL
register_parent_wnd_class(void)
262 cls
.lpfnWndProc
= parent_wnd_proc
;
265 cls
.hInstance
= GetModuleHandleA(NULL
);
267 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
268 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
269 cls
.lpszMenuName
= NULL
;
270 cls
.lpszClassName
= "Tooltips test parent class";
271 return RegisterClassA(&cls
);
274 static HWND
create_parent_window(void)
276 if (!register_parent_wnd_class())
279 return CreateWindowExA(0, "Tooltips test parent class",
280 "Tooltips test parent window",
281 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
282 WS_MAXIMIZEBOX
| WS_VISIBLE
,
284 GetDesktopWindow(), NULL
, GetModuleHandleA(NULL
), NULL
);
287 static void test_gettext(void)
289 static const CHAR testtip2A
[] = "testtip\ttest2";
290 static const CHAR testtipA
[] = "testtip";
292 TTTOOLINFOA toolinfoA
;
293 TTTOOLINFOW toolinfoW
;
296 WCHAR bufW
[10] = { 0 };
299 notify
= create_parent_window();
300 ok(notify
!= NULL
, "Expected notification window to be created\n");
302 /* For bug 14790 - lpszText is NULL */
303 hwnd
= CreateWindowExA(0, TOOLTIPS_CLASSA
, NULL
, 0,
305 NULL
, NULL
, NULL
, 0);
306 ok(hwnd
!= NULL
, "failed to create tooltip wnd\n");
308 /* use sizeof(TTTOOLINFOA) instead of TTTOOLINFOA_V1_SIZE so that adding it fails on Win9x */
309 /* otherwise it crashes on the NULL lpszText */
310 toolinfoA
.cbSize
= sizeof(TTTOOLINFOA
);
311 toolinfoA
.hwnd
= NULL
;
312 toolinfoA
.hinst
= GetModuleHandleA(NULL
);
313 toolinfoA
.uFlags
= 0;
314 toolinfoA
.uId
= 0x1234ABCD;
315 toolinfoA
.lpszText
= NULL
;
316 toolinfoA
.lParam
= 0xdeadbeef;
317 GetClientRect(hwnd
, &toolinfoA
.rect
);
318 r
= SendMessageA(hwnd
, TTM_ADDTOOLA
, 0, (LPARAM
)&toolinfoA
);
319 ok(r
, "got %ld\n", r
);
321 toolinfoA
.hwnd
= NULL
;
322 toolinfoA
.uId
= 0x1234abcd;
323 toolinfoA
.lpszText
= bufA
;
324 r
= SendMessageA(hwnd
, TTM_GETTEXTA
, 0, (LPARAM
)&toolinfoA
);
325 ok(!r
, "got %ld\n", r
);
326 ok(!*toolinfoA
.lpszText
, "lpszText should be empty, got %s\n", toolinfoA
.lpszText
);
328 toolinfoA
.lpszText
= bufA
;
329 r
= SendMessageA(hwnd
, TTM_GETTOOLINFOA
, 0, (LPARAM
)&toolinfoA
);
331 ok(!r
, "got %ld\n", r
);
332 ok(toolinfoA
.lpszText
== NULL
, "expected NULL, got %p\n", toolinfoA
.lpszText
);
334 /* NULL hinst, valid resource id for text */
335 toolinfoA
.cbSize
= sizeof(TTTOOLINFOA
);
336 toolinfoA
.hwnd
= NULL
;
337 toolinfoA
.hinst
= NULL
;
338 toolinfoA
.uFlags
= 0;
339 toolinfoA
.uId
= 0x1233abcd;
340 toolinfoA
.lpszText
= MAKEINTRESOURCEA(IDS_TBADD1
);
341 toolinfoA
.lParam
= 0xdeadbeef;
342 GetClientRect(hwnd
, &toolinfoA
.rect
);
343 r
= SendMessageA(hwnd
, TTM_ADDTOOLA
, 0, (LPARAM
)&toolinfoA
);
344 ok(r
, "failed to add a tool\n");
346 toolinfoA
.hwnd
= NULL
;
347 toolinfoA
.uId
= 0x1233abcd;
348 toolinfoA
.lpszText
= bufA
;
349 r
= SendMessageA(hwnd
, TTM_GETTEXTA
, 0, (LPARAM
)&toolinfoA
);
350 ok(!r
, "got %ld\n", r
);
351 ok(!strcmp(toolinfoA
.lpszText
, "abc"), "got wrong text, %s\n", toolinfoA
.lpszText
);
353 toolinfoA
.hinst
= (HINSTANCE
)0xdeadbee;
354 r
= SendMessageA(hwnd
, TTM_GETTOOLINFOA
, 0, (LPARAM
)&toolinfoA
);
356 ok(!r
, "got %ld\n", r
);
357 ok(toolinfoA
.hinst
== NULL
, "expected NULL, got %p\n", toolinfoA
.hinst
);
359 r
= SendMessageA(hwnd
, TTM_DELTOOLA
, 0, (LPARAM
)&toolinfoA
);
360 ok(!r
, "got %ld\n", r
);
362 /* add another tool with text */
363 toolinfoA
.cbSize
= sizeof(TTTOOLINFOA
);
364 toolinfoA
.hwnd
= NULL
;
365 toolinfoA
.hinst
= GetModuleHandleA(NULL
);
366 toolinfoA
.uFlags
= 0;
367 toolinfoA
.uId
= 0x1235ABCD;
368 strcpy(bufA
, testtipA
);
369 toolinfoA
.lpszText
= bufA
;
370 toolinfoA
.lParam
= 0xdeadbeef;
371 GetClientRect(hwnd
, &toolinfoA
.rect
);
372 r
= SendMessageA(hwnd
, TTM_ADDTOOLA
, 0, (LPARAM
)&toolinfoA
);
373 ok(r
, "Adding the tool to the tooltip failed\n");
375 length
= SendMessageA(hwnd
, WM_GETTEXTLENGTH
, 0, 0);
376 ok(length
== 0, "Expected 0, got %d\n", length
);
378 toolinfoA
.hwnd
= NULL
;
379 toolinfoA
.uId
= 0x1235abcd;
380 toolinfoA
.lpszText
= bufA
;
381 r
= SendMessageA(hwnd
, TTM_GETTEXTA
, 0, (LPARAM
)&toolinfoA
);
382 ok(!r
, "got %ld\n", r
);
383 ok(!strcmp(toolinfoA
.lpszText
, testtipA
), "expected %s, got %p\n", testtipA
, toolinfoA
.lpszText
);
385 memset(bufA
, 0x1f, sizeof(bufA
));
386 toolinfoA
.lpszText
= bufA
;
387 r
= SendMessageA(hwnd
, TTM_GETTOOLINFOA
, 0, (LPARAM
)&toolinfoA
);
389 ok(!r
, "got %ld\n", r
);
390 ok(!strcmp(toolinfoA
.lpszText
, testtipA
), "expected %s, got %p\n", testtipA
, toolinfoA
.lpszText
);
392 length
= SendMessageA(hwnd
, WM_GETTEXTLENGTH
, 0, 0);
393 ok(length
== 0, "Expected 0, got %d\n", length
);
395 /* add another with callback text */
396 toolinfoA
.cbSize
= sizeof(TTTOOLINFOA
);
397 toolinfoA
.hwnd
= notify
;
398 toolinfoA
.hinst
= GetModuleHandleA(NULL
);
399 toolinfoA
.uFlags
= 0;
400 toolinfoA
.uId
= 0x1236ABCD;
401 toolinfoA
.lpszText
= LPSTR_TEXTCALLBACKA
;
402 toolinfoA
.lParam
= 0xdeadbeef;
403 GetClientRect(hwnd
, &toolinfoA
.rect
);
404 r
= SendMessageA(hwnd
, TTM_ADDTOOLA
, 0, (LPARAM
)&toolinfoA
);
405 ok(r
, "Adding the tool to the tooltip failed\n");
407 toolinfoA
.hwnd
= notify
;
408 toolinfoA
.uId
= 0x1236abcd;
409 toolinfoA
.lpszText
= bufA
;
410 r
= SendMessageA(hwnd
, TTM_GETTEXTA
, 0, (LPARAM
)&toolinfoA
);
411 ok(!r
, "got %ld\n", r
);
412 ok(!strcmp(toolinfoA
.lpszText
, testcallbackA
), "lpszText should be an (%s) string\n", testcallbackA
);
414 toolinfoA
.lpszText
= bufA
;
415 r
= SendMessageA(hwnd
, TTM_GETTOOLINFOA
, 0, (LPARAM
)&toolinfoA
);
417 ok(!r
, "got %ld\n", r
);
418 ok(toolinfoA
.lpszText
== LPSTR_TEXTCALLBACKA
, "expected LPSTR_TEXTCALLBACKA, got %p\n", toolinfoA
.lpszText
);
421 DestroyWindow(notify
);
423 hwnd
= CreateWindowExW(0, TOOLTIPS_CLASSW
, NULL
, 0,
425 NULL
, NULL
, NULL
, 0);
426 ok(hwnd
!= NULL
, "failed to create tooltip wnd\n");
428 toolinfoW
.cbSize
= sizeof(TTTOOLINFOW
);
429 toolinfoW
.hwnd
= NULL
;
430 toolinfoW
.hinst
= GetModuleHandleA(NULL
);
431 toolinfoW
.uFlags
= 0;
432 toolinfoW
.uId
= 0x1234ABCD;
433 toolinfoW
.lpszText
= NULL
;
434 toolinfoW
.lParam
= 0xdeadbeef;
435 GetClientRect(hwnd
, &toolinfoW
.rect
);
436 r
= SendMessageW(hwnd
, TTM_ADDTOOLW
, 0, (LPARAM
)&toolinfoW
);
437 ok(!r
, "Adding the tool to the tooltip succeeded!\n");
439 /* lpszText with an invalid address */
440 toolinfoW
.cbSize
= sizeof(TTTOOLINFOW
);
441 toolinfoW
.hwnd
= notify
;
442 toolinfoW
.hinst
= GetModuleHandleA(NULL
);
443 toolinfoW
.uFlags
= 0;
445 toolinfoW
.lpszText
= (LPWSTR
)0xdeadbeef;
446 toolinfoW
.lParam
= 0;
447 GetClientRect(hwnd
, &toolinfoW
.rect
);
448 r
= SendMessageA(hwnd
, TTM_ADDTOOLW
, 0, (LPARAM
)&toolinfoW
);
449 ok(!r
, "Adding the tool to the tooltip succeeded!\n");
451 /* lpszText with an invalid address. Crashes using TTTOOLINFOA message */
454 toolinfoA
.cbSize
= sizeof(TTTOOLINFOA
);
455 toolinfoA
.hwnd
= notify
;
456 toolinfoA
.hinst
= GetModuleHandleA(NULL
);
457 toolinfoA
.uFlags
= 0;
459 toolinfoA
.lpszText
= (LPSTR
)0xdeadbeef;
460 toolinfoA
.lParam
= 0;
461 GetClientRect(hwnd
, &toolinfoA
.rect
);
462 r
= SendMessageA(hwnd
, TTM_ADDTOOLA
, 0, (LPARAM
)&toolinfoA
);
463 ok(!r
, "Adding the tool to the tooltip succeeded!\n");
466 if (0) /* crashes on NT4 */
468 toolinfoW
.hwnd
= NULL
;
469 toolinfoW
.uId
= 0x1234ABCD;
470 toolinfoW
.lpszText
= bufW
;
471 SendMessageW(hwnd
, TTM_GETTEXTW
, 0, (LPARAM
)&toolinfoW
);
472 ok(toolinfoW
.lpszText
[0] == 0, "lpszText should be an empty string\n");
475 /* text with embedded tabs */
476 toolinfoA
.cbSize
= sizeof(TTTOOLINFOA
);
477 toolinfoA
.hwnd
= NULL
;
478 toolinfoA
.hinst
= GetModuleHandleA(NULL
);
479 toolinfoA
.uFlags
= 0;
480 toolinfoA
.uId
= 0x1235abce;
481 strcpy(bufA
, testtip2A
);
482 toolinfoA
.lpszText
= bufA
;
483 toolinfoA
.lParam
= 0xdeadbeef;
484 GetClientRect(hwnd
, &toolinfoA
.rect
);
485 r
= SendMessageA(hwnd
, TTM_ADDTOOLA
, 0, (LPARAM
)&toolinfoA
);
486 ok(r
, "got %ld\n", r
);
488 toolinfoA
.hwnd
= NULL
;
489 toolinfoA
.uId
= 0x1235abce;
490 toolinfoA
.lpszText
= bufA
;
491 r
= SendMessageA(hwnd
, TTM_GETTEXTA
, 0, (LPARAM
)&toolinfoA
);
492 ok(!r
, "got %ld\n", r
);
493 ok(!strcmp(toolinfoA
.lpszText
, testtipA
), "expected %s, got %s\n", testtipA
, toolinfoA
.lpszText
);
495 /* enable TTS_NOPREFIX, original text is retained */
496 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
497 SetWindowLongA(hwnd
, GWL_STYLE
, style
| TTS_NOPREFIX
);
499 toolinfoA
.hwnd
= NULL
;
500 toolinfoA
.uId
= 0x1235abce;
501 toolinfoA
.lpszText
= bufA
;
502 r
= SendMessageA(hwnd
, TTM_GETTEXTA
, 0, (LPARAM
)&toolinfoA
);
503 ok(!r
, "got %ld\n", r
);
504 ok(!strcmp(toolinfoA
.lpszText
, testtip2A
), "expected %s, got %s\n", testtip2A
, toolinfoA
.lpszText
);
509 static void test_ttm_gettoolinfo(void)
516 hwnd
= CreateWindowExA(0, TOOLTIPS_CLASSA
, NULL
, 0,
518 NULL
, NULL
, NULL
, 0);
520 ti
.cbSize
= TTTOOLINFOA_V2_SIZE
;
522 ti
.hinst
= GetModuleHandleA(NULL
);
526 ti
.lParam
= 0x1abe11ed;
527 GetClientRect(hwnd
, &ti
.rect
);
528 r
= SendMessageA(hwnd
, TTM_ADDTOOLA
, 0, (LPARAM
)&ti
);
529 ok(r
, "Adding the tool to the tooltip failed\n");
531 ti
.cbSize
= TTTOOLINFOA_V2_SIZE
;
532 ti
.lParam
= 0xaaaaaaaa;
533 r
= SendMessageA(hwnd
, TTM_GETTOOLINFOA
, 0, (LPARAM
)&ti
);
534 ok(r
, "Getting tooltip info failed\n");
535 ok(0x1abe11ed == ti
.lParam
||
536 broken(0x1abe11ed != ti
.lParam
), /* comctl32 < 5.81 */
537 "Expected 0x1abe11ed, got %lx\n", ti
.lParam
);
539 tiW
.cbSize
= TTTOOLINFOW_V2_SIZE
;
541 tiW
.uId
= 0x1234ABCD;
542 tiW
.lParam
= 0xaaaaaaaa;
544 r
= SendMessageA(hwnd
, TTM_GETTOOLINFOW
, 0, (LPARAM
)&tiW
);
545 ok(r
, "Getting tooltip info failed\n");
546 ok(0x1abe11ed == tiW
.lParam
||
547 broken(0x1abe11ed != tiW
.lParam
), /* comctl32 < 5.81 */
548 "Expected 0x1abe11ed, got %lx\n", tiW
.lParam
);
550 ti
.cbSize
= TTTOOLINFOA_V2_SIZE
;
552 ti
.lParam
= 0x55555555;
553 SendMessageA(hwnd
, TTM_SETTOOLINFOA
, 0, (LPARAM
)&ti
);
555 ti
.cbSize
= TTTOOLINFOA_V2_SIZE
;
556 ti
.lParam
= 0xdeadbeef;
557 r
= SendMessageA(hwnd
, TTM_GETTOOLINFOA
, 0, (LPARAM
)&ti
);
558 ok(r
, "Getting tooltip info failed\n");
559 ok(0x55555555 == ti
.lParam
||
560 broken(0x55555555 != ti
.lParam
), /* comctl32 < 5.81 */
561 "Expected 0x55555555, got %lx\n", ti
.lParam
);
565 /* 1. test size parameter validation rules (ansi messages) */
566 hwnd
= CreateWindowExA(0, TOOLTIPS_CLASSA
, NULL
, 0,
568 NULL
, NULL
, NULL
, 0);
570 ti
.cbSize
= TTTOOLINFOA_V1_SIZE
- 1;
572 ti
.hinst
= GetModuleHandleA(NULL
);
576 ti
.lParam
= 0xdeadbeef;
577 GetClientRect(hwnd
, &ti
.rect
);
578 r
= SendMessageA(hwnd
, TTM_ADDTOOLA
, 0, (LPARAM
)&ti
);
579 ok(r
, "Adding the tool to the tooltip failed\n");
580 r
= SendMessageA(hwnd
, TTM_GETTOOLCOUNT
, 0, 0);
583 ti
.cbSize
= TTTOOLINFOA_V1_SIZE
- 1;
586 SendMessageA(hwnd
, TTM_DELTOOLA
, 0, (LPARAM
)&ti
);
587 r
= SendMessageA(hwnd
, TTM_GETTOOLCOUNT
, 0, 0);
590 ti
.cbSize
= TTTOOLINFOA_V2_SIZE
- 1;
592 ti
.hinst
= GetModuleHandleA(NULL
);
596 ti
.lParam
= 0xdeadbeef;
597 GetClientRect(hwnd
, &ti
.rect
);
598 r
= SendMessageA(hwnd
, TTM_ADDTOOLA
, 0, (LPARAM
)&ti
);
599 ok(r
, "Adding the tool to the tooltip failed\n");
600 r
= SendMessageA(hwnd
, TTM_GETTOOLCOUNT
, 0, 0);
603 ti
.cbSize
= TTTOOLINFOA_V2_SIZE
- 1;
606 SendMessageA(hwnd
, TTM_DELTOOLA
, 0, (LPARAM
)&ti
);
607 r
= SendMessageA(hwnd
, TTM_GETTOOLCOUNT
, 0, 0);
610 ti
.cbSize
= TTTOOLINFOA_V2_SIZE
+ 1;
612 ti
.hinst
= GetModuleHandleA(NULL
);
616 ti
.lParam
= 0xdeadbeef;
617 GetClientRect(hwnd
, &ti
.rect
);
618 r
= SendMessageA(hwnd
, TTM_ADDTOOLA
, 0, (LPARAM
)&ti
);
619 ok(r
, "Adding the tool to the tooltip failed\n");
620 r
= SendMessageA(hwnd
, TTM_GETTOOLCOUNT
, 0, 0);
623 ti
.cbSize
= TTTOOLINFOA_V2_SIZE
+ 1;
626 SendMessageA(hwnd
, TTM_DELTOOLA
, 0, (LPARAM
)&ti
);
627 r
= SendMessageA(hwnd
, TTM_GETTOOLCOUNT
, 0, 0);
632 /* 2. test size parameter validation rules (w-messages) */
633 hwnd
= CreateWindowExW(0, TOOLTIPS_CLASSW
, NULL
, 0,
635 NULL
, NULL
, NULL
, 0);
638 win_skip("CreateWindowExW() not supported. Skipping.\n");
642 tiW
.cbSize
= TTTOOLINFOW_V1_SIZE
- 1;
644 tiW
.hinst
= GetModuleHandleA(NULL
);
646 tiW
.uId
= 0x1234ABCD;
648 tiW
.lParam
= 0xdeadbeef;
649 GetClientRect(hwnd
, &tiW
.rect
);
650 r
= SendMessageW(hwnd
, TTM_ADDTOOLW
, 0, (LPARAM
)&tiW
);
651 ok(r
, "Adding the tool to the tooltip failed\n");
652 r
= SendMessageW(hwnd
, TTM_GETTOOLCOUNT
, 0, 0);
655 tiW
.cbSize
= TTTOOLINFOW_V1_SIZE
- 1;
657 tiW
.uId
= 0x1234ABCD;
658 SendMessageW(hwnd
, TTM_DELTOOLW
, 0, (LPARAM
)&tiW
);
659 r
= SendMessageW(hwnd
, TTM_GETTOOLCOUNT
, 0, 0);
662 tiW
.cbSize
= TTTOOLINFOW_V2_SIZE
- 1;
664 tiW
.hinst
= GetModuleHandleA(NULL
);
666 tiW
.uId
= 0x1234ABCD;
668 tiW
.lParam
= 0xdeadbeef;
669 GetClientRect(hwnd
, &tiW
.rect
);
670 r
= SendMessageW(hwnd
, TTM_ADDTOOLW
, 0, (LPARAM
)&tiW
);
671 ok(r
, "Adding the tool to the tooltip failed\n");
672 r
= SendMessageW(hwnd
, TTM_GETTOOLCOUNT
, 0, 0);
675 tiW
.cbSize
= TTTOOLINFOW_V2_SIZE
- 1;
677 tiW
.uId
= 0x1234ABCD;
678 SendMessageW(hwnd
, TTM_DELTOOLW
, 0, (LPARAM
)&tiW
);
679 r
= SendMessageW(hwnd
, TTM_GETTOOLCOUNT
, 0, 0);
682 tiW
.cbSize
= TTTOOLINFOW_V2_SIZE
+ 1;
684 tiW
.hinst
= GetModuleHandleA(NULL
);
686 tiW
.uId
= 0x1234ABCD;
688 tiW
.lParam
= 0xdeadbeef;
689 GetClientRect(hwnd
, &tiW
.rect
);
690 r
= SendMessageW(hwnd
, TTM_ADDTOOLA
, 0, (LPARAM
)&tiW
);
691 ok(r
, "Adding the tool to the tooltip failed\n");
692 r
= SendMessageW(hwnd
, TTM_GETTOOLCOUNT
, 0, 0);
694 /* looks like TTM_DELTOOLW doesn't work with invalid size */
695 tiW
.cbSize
= TTTOOLINFOW_V2_SIZE
+ 1;
697 tiW
.uId
= 0x1234ABCD;
698 SendMessageW(hwnd
, TTM_DELTOOLW
, 0, (LPARAM
)&tiW
);
699 r
= SendMessageW(hwnd
, TTM_GETTOOLCOUNT
, 0, 0);
702 tiW
.cbSize
= TTTOOLINFOW_V2_SIZE
;
704 tiW
.uId
= 0x1234ABCD;
705 SendMessageW(hwnd
, TTM_DELTOOLW
, 0, (LPARAM
)&tiW
);
706 r
= SendMessageW(hwnd
, TTM_GETTOOLCOUNT
, 0, 0);
712 static void test_longtextA(void)
714 static const char longtextA
[] =
715 "According to MSDN, TTM_ENUMTOOLS claims that TOOLINFO's lpszText is maximum "
716 "80 chars including null. In fact, the buffer is not null-terminated.";
718 TTTOOLINFOA toolinfoA
= { 0 };
722 hwnd
= CreateWindowExA(0, TOOLTIPS_CLASSA
, NULL
, 0,
724 NULL
, NULL
, NULL
, 0);
725 toolinfoA
.cbSize
= sizeof(TTTOOLINFOA
);
726 toolinfoA
.hwnd
= NULL
;
727 toolinfoA
.hinst
= GetModuleHandleA(NULL
);
728 toolinfoA
.uFlags
= 0;
729 toolinfoA
.uId
= 0x1234ABCD;
730 strcpy(bufA
, longtextA
);
731 toolinfoA
.lpszText
= bufA
;
732 toolinfoA
.lParam
= 0xdeadbeef;
733 GetClientRect(hwnd
, &toolinfoA
.rect
);
734 r
= SendMessageA(hwnd
, TTM_ADDTOOLA
, 0, (LPARAM
)&toolinfoA
);
738 memset(bufA
, 0, sizeof(bufA
));
739 toolinfoA
.hwnd
= NULL
;
740 toolinfoA
.uId
= 0xABCD1234;
741 toolinfoA
.lpszText
= bufA
;
742 SendMessageA(hwnd
, TTM_ENUMTOOLSA
, 0, (LPARAM
)&toolinfoA
);
743 textlen
= lstrlenA(toolinfoA
.lpszText
);
744 ok(textlen
== 80, "lpszText has %d chars\n", textlen
);
745 ok(toolinfoA
.uId
== 0x1234ABCD,
746 "uId should be retrieved, got %p\n", (void*)toolinfoA
.uId
);
748 memset(bufA
, 0, sizeof(bufA
));
749 toolinfoA
.hwnd
= NULL
;
750 toolinfoA
.uId
= 0x1234ABCD;
751 toolinfoA
.lpszText
= bufA
;
752 SendMessageA(hwnd
, TTM_GETTOOLINFOA
, 0, (LPARAM
)&toolinfoA
);
753 textlen
= lstrlenA(toolinfoA
.lpszText
);
754 ok(textlen
== 80, "lpszText has %d chars\n", textlen
);
756 memset(bufA
, 0, sizeof(bufA
));
757 toolinfoA
.hwnd
= NULL
;
758 toolinfoA
.uId
= 0x1234ABCD;
759 toolinfoA
.lpszText
= bufA
;
760 SendMessageA(hwnd
, TTM_GETTEXTA
, 0, (LPARAM
)&toolinfoA
);
761 textlen
= lstrlenA(toolinfoA
.lpszText
);
762 ok(textlen
== 80, "lpszText has %d chars\n", textlen
);
768 static void test_longtextW(void)
770 static const char longtextA
[] =
771 "According to MSDN, TTM_ENUMTOOLS claims that TOOLINFO's lpszText is maximum "
772 "80 chars including null. Actually, this is not applied for wide version.";
774 TTTOOLINFOW toolinfoW
= { 0 };
779 hwnd
= CreateWindowExW(0, TOOLTIPS_CLASSW
, NULL
, 0,
781 NULL
, NULL
, NULL
, 0);
784 win_skip("CreateWindowExW() not supported. Skipping.\n");
788 toolinfoW
.cbSize
= TTTOOLINFOW_V2_SIZE
;
789 toolinfoW
.hwnd
= NULL
;
790 toolinfoW
.hinst
= GetModuleHandleW(NULL
);
791 toolinfoW
.uFlags
= 0;
792 toolinfoW
.uId
= 0x1234ABCD;
793 MultiByteToWideChar(CP_ACP
, 0, longtextA
, -1, bufW
, sizeof(bufW
)/sizeof(bufW
[0]));
794 lenW
= lstrlenW(bufW
);
795 toolinfoW
.lpszText
= bufW
;
796 toolinfoW
.lParam
= 0xdeadbeef;
797 GetClientRect(hwnd
, &toolinfoW
.rect
);
798 r
= SendMessageW(hwnd
, TTM_ADDTOOLW
, 0, (LPARAM
)&toolinfoW
);
802 memset(bufW
, 0, sizeof(bufW
));
803 toolinfoW
.hwnd
= NULL
;
804 toolinfoW
.uId
= 0xABCD1234;
805 toolinfoW
.lpszText
= bufW
;
806 SendMessageW(hwnd
, TTM_ENUMTOOLSW
, 0, (LPARAM
)&toolinfoW
);
807 textlen
= lstrlenW(toolinfoW
.lpszText
);
808 ok(textlen
== lenW
, "lpszText has %d chars\n", textlen
);
809 ok(toolinfoW
.uId
== 0x1234ABCD,
810 "uId should be retrieved, got %p\n", (void*)toolinfoW
.uId
);
812 memset(bufW
, 0, sizeof(bufW
));
813 toolinfoW
.hwnd
= NULL
;
814 toolinfoW
.uId
= 0x1234ABCD;
815 toolinfoW
.lpszText
= bufW
;
816 SendMessageW(hwnd
, TTM_GETTOOLINFOW
, 0, (LPARAM
)&toolinfoW
);
817 textlen
= lstrlenW(toolinfoW
.lpszText
);
818 ok(textlen
== lenW
, "lpszText has %d chars\n", textlen
);
820 memset(bufW
, 0, sizeof(bufW
));
821 toolinfoW
.hwnd
= NULL
;
822 toolinfoW
.uId
= 0x1234ABCD;
823 toolinfoW
.lpszText
= bufW
;
824 SendMessageW(hwnd
, TTM_GETTEXTW
, 0, (LPARAM
)&toolinfoW
);
825 textlen
= lstrlenW(toolinfoW
.lpszText
);
826 ok(textlen
== lenW
||
827 broken(textlen
== 0 && toolinfoW
.lpszText
== NULL
), /* nt4, kb186177 */
828 "lpszText has %d chars\n", textlen
);
834 static BOOL
almost_eq(int a
, int b
)
836 return a
-5<b
&& a
+5>b
;
839 static void test_track(void)
841 WCHAR textW
[] = {'t','e','x','t',0};
842 TTTOOLINFOW info
= { 0 };
847 parent
= CreateWindowExW(0, WC_STATICW
, NULL
, WS_CAPTION
| WS_VISIBLE
,
848 50, 50, 300, 300, NULL
, NULL
, NULL
, 0);
849 ok(parent
!= NULL
, "creation of parent window failed\n");
851 ShowWindow(parent
, SW_SHOWNORMAL
);
854 tt
= CreateWindowExW(WS_EX_TOPMOST
, TOOLTIPS_CLASSW
, NULL
, TTS_NOPREFIX
| TTS_ALWAYSTIP
,
855 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
856 parent
, NULL
, GetModuleHandleW(NULL
), 0);
857 ok(tt
!= NULL
, "creation of tooltip window failed\n");
859 info
.cbSize
= TTTOOLINFOW_V1_SIZE
;
860 info
.uFlags
= TTF_IDISHWND
| TTF_TRACK
| TTF_ABSOLUTE
;
862 info
.hinst
= GetModuleHandleW(NULL
);
863 info
.lpszText
= textW
;
864 info
.uId
= (UINT_PTR
)parent
;
865 GetClientRect(parent
, &info
.rect
);
867 res
= SendMessageW(tt
, TTM_ADDTOOLW
, 0, (LPARAM
)&info
);
868 ok(res
, "adding the tool to the tooltip failed\n");
870 SendMessageW(tt
, TTM_SETDELAYTIME
, TTDT_INITIAL
, MAKELPARAM(1,0));
871 SendMessageW(tt
, TTM_TRACKACTIVATE
, (WPARAM
)TRUE
, (LPARAM
)&info
);
872 SendMessageW(tt
, TTM_TRACKPOSITION
, 0, MAKELPARAM(10, 10));
874 GetWindowRect(tt
, &pos
);
875 ok(almost_eq(pos
.left
, 10), "pos.left = %d\n", pos
.left
);
876 ok(almost_eq(pos
.top
, 10), "pos.top = %d\n", pos
.top
);
878 info
.uFlags
= TTF_IDISHWND
| TTF_ABSOLUTE
;
879 SendMessageW(tt
, TTM_SETTOOLINFOW
, 0, (LPARAM
)&info
);
880 SendMessageW(tt
, TTM_TRACKPOSITION
, 0, MAKELPARAM(10, 10));
882 GetWindowRect(tt
, &pos
);
883 ok(!almost_eq(pos
.left
, 10), "pos.left = %d\n", pos
.left
);
884 ok(!almost_eq(pos
.top
, 10), "pos.top = %d\n", pos
.top
);
887 DestroyWindow(parent
);
890 static LRESULT CALLBACK
info_wnd_proc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
899 return DefWindowProcA(hWnd
, msg
, wParam
, lParam
);
904 static void test_setinfo(void)
908 HWND parent
, parent2
, hwndTip
, hwndTip2
;
909 TTTOOLINFOA toolInfo
= { 0 };
910 TTTOOLINFOA toolInfo2
= { 0 };
913 /* Create a class to use the custom draw wndproc */
914 wc
.style
= CS_HREDRAW
| CS_VREDRAW
;
917 wc
.hInstance
= GetModuleHandleA(NULL
);
919 wc
.hCursor
= LoadCursorA(NULL
, (LPCSTR
)IDC_ARROW
);
920 wc
.hbrBackground
= GetSysColorBrush(COLOR_WINDOW
);
921 wc
.lpszMenuName
= NULL
;
922 wc
.lpszClassName
= "SetInfoClass";
923 wc
.lpfnWndProc
= info_wnd_proc
;
926 /* Create a main window */
927 parent
= CreateWindowExA(0, "SetInfoClass", NULL
,
928 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
929 WS_MAXIMIZEBOX
| WS_VISIBLE
,
932 NULL
, NULL
, NULL
, 0);
933 ok(parent
!= NULL
, "Creation of main window failed\n");
935 parent2
= CreateWindowExA(0, "SetInfoClass", NULL
,
936 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
937 WS_MAXIMIZEBOX
| WS_VISIBLE
,
940 NULL
, NULL
, NULL
, 0);
941 ok(parent2
!= NULL
, "Creation of main window failed\n");
944 ShowWindow(parent2
, SW_SHOWNORMAL
);
948 hwndTip
= CreateWindowExA(WS_EX_TOPMOST
, TOOLTIPS_CLASSA
,
949 NULL
, TTS_NOPREFIX
| TTS_ALWAYSTIP
,
950 CW_USEDEFAULT
, CW_USEDEFAULT
,
951 CW_USEDEFAULT
, CW_USEDEFAULT
,
952 parent
, NULL
, GetModuleHandleA(NULL
), 0);
953 ok(hwndTip
!= NULL
, "Creation of tooltip window failed\n");
955 hwndTip2
= CreateWindowExA(WS_EX_TOPMOST
, TOOLTIPS_CLASSA
,
956 NULL
, TTS_NOPREFIX
| TTS_ALWAYSTIP
,
957 CW_USEDEFAULT
, CW_USEDEFAULT
,
958 CW_USEDEFAULT
, CW_USEDEFAULT
,
959 parent
, NULL
, GetModuleHandleA(NULL
), 0);
960 ok(hwndTip2
!= NULL
, "Creation of tooltip window failed\n");
963 /* Make it topmost, as per the MSDN */
964 SetWindowPos(hwndTip
, HWND_TOPMOST
, 0, 0, 0, 0,
965 SWP_NOMOVE
| SWP_NOSIZE
| SWP_NOACTIVATE
);
968 toolInfo
.cbSize
= TTTOOLINFOA_V1_SIZE
;
969 toolInfo
.hwnd
= parent
;
970 toolInfo
.hinst
= GetModuleHandleA(NULL
);
971 toolInfo
.uFlags
= TTF_SUBCLASS
;
972 toolInfo
.uId
= 0x1234ABCD;
973 toolInfo
.lpszText
= (LPSTR
)"This is a test tooltip";
974 toolInfo
.lParam
= 0xdeadbeef;
975 GetClientRect (parent
, &toolInfo
.rect
);
976 lResult
= SendMessageA(hwndTip
, TTM_ADDTOOLA
, 0, (LPARAM
)&toolInfo
);
977 ok(lResult
, "Adding the tool to the tooltip failed\n");
979 toolInfo
.cbSize
= TTTOOLINFOA_V1_SIZE
;
980 toolInfo
.hwnd
= parent2
;
981 toolInfo
.hinst
= GetModuleHandleA(NULL
);
983 toolInfo
.uId
= 0x1234ABCE;
984 toolInfo
.lpszText
= (LPSTR
)"This is a test tooltip";
985 toolInfo
.lParam
= 0xdeadbeef;
986 GetClientRect (parent
, &toolInfo
.rect
);
987 lResult
= SendMessageA(hwndTip
, TTM_ADDTOOLA
, 0, (LPARAM
)&toolInfo
);
988 ok(lResult
, "Adding the tool to the tooltip failed\n");
990 /* Try to Remove Subclass */
991 toolInfo2
.cbSize
= TTTOOLINFOA_V1_SIZE
;
992 toolInfo2
.hwnd
= parent
;
993 toolInfo2
.uId
= 0x1234ABCD;
994 lResult
= SendMessageA(hwndTip
, TTM_GETTOOLINFOA
, 0, (LPARAM
)&toolInfo2
);
995 ok(lResult
, "GetToolInfo failed\n");
996 ok(toolInfo2
.uFlags
& TTF_SUBCLASS
, "uFlags does not have subclass\n");
997 wndProc
= (WNDPROC
)GetWindowLongPtrA(parent
, GWLP_WNDPROC
);
998 ok (wndProc
!= info_wnd_proc
, "Window Proc is wrong\n");
1000 toolInfo2
.uFlags
&= ~TTF_SUBCLASS
;
1001 SendMessageA(hwndTip
, TTM_SETTOOLINFOA
, 0, (LPARAM
)&toolInfo2
);
1002 lResult
= SendMessageA(hwndTip
, TTM_GETTOOLINFOA
, 0, (LPARAM
)&toolInfo2
);
1003 ok(lResult
, "GetToolInfo failed\n");
1004 ok(!(toolInfo2
.uFlags
& TTF_SUBCLASS
), "uFlags has subclass\n");
1005 wndProc
= (WNDPROC
)GetWindowLongPtrA(parent
, GWLP_WNDPROC
);
1006 ok (wndProc
!= info_wnd_proc
, "Window Proc is wrong\n");
1008 /* Try to Add Subclass */
1010 /* Make it topmost, as per the MSDN */
1011 SetWindowPos(hwndTip2
, HWND_TOPMOST
, 0, 0, 0, 0,
1012 SWP_NOMOVE
| SWP_NOSIZE
| SWP_NOACTIVATE
);
1014 toolInfo2
.cbSize
= TTTOOLINFOA_V1_SIZE
;
1015 toolInfo2
.hwnd
= parent2
;
1016 toolInfo2
.uId
= 0x1234ABCE;
1017 lResult
= SendMessageA(hwndTip
, TTM_GETTOOLINFOA
, 0, (LPARAM
)&toolInfo2
);
1018 ok(lResult
, "GetToolInfo failed\n");
1019 ok(!(toolInfo2
.uFlags
& TTF_SUBCLASS
), "uFlags has subclass\n");
1020 wndProc
= (WNDPROC
)GetWindowLongPtrA(parent2
, GWLP_WNDPROC
);
1021 ok (wndProc
== info_wnd_proc
, "Window Proc is wrong\n");
1023 toolInfo2
.uFlags
|= TTF_SUBCLASS
;
1024 SendMessageA(hwndTip
, TTM_SETTOOLINFOA
, 0, (LPARAM
)&toolInfo2
);
1025 lResult
= SendMessageA(hwndTip
, TTM_GETTOOLINFOA
, 0, (LPARAM
)&toolInfo2
);
1026 ok(lResult
, "GetToolInfo failed\n");
1027 ok(toolInfo2
.uFlags
& TTF_SUBCLASS
, "uFlags does not have subclass\n");
1028 wndProc
= (WNDPROC
)GetWindowLongPtrA(parent2
, GWLP_WNDPROC
);
1029 ok (wndProc
== info_wnd_proc
, "Window Proc is wrong\n");
1032 DestroyWindow(hwndTip
);
1033 DestroyWindow(hwndTip2
);
1034 DestroyWindow(parent
);
1035 DestroyWindow(parent2
);
1038 static void test_margin(void)
1044 hwnd
= CreateWindowExA(0, TOOLTIPS_CLASSA
, NULL
, 0,
1046 NULL
, NULL
, NULL
, 0);
1047 ok(hwnd
!= NULL
, "failed to create tooltip wnd\n");
1049 ret
= SendMessageA(hwnd
, TTM_SETMARGIN
, 0, 0);
1050 ok(!ret
, "got %d\n", ret
);
1052 SetRect(&r
, -1, -1, 1, 1);
1053 ret
= SendMessageA(hwnd
, TTM_SETMARGIN
, 0, (LPARAM
)&r
);
1054 ok(!ret
, "got %d\n", ret
);
1057 ret
= SendMessageA(hwnd
, TTM_GETMARGIN
, 0, (LPARAM
)&r1
);
1058 ok(!ret
, "got %d\n", ret
);
1059 ok(EqualRect(&r
, &r1
), "got %s, was %s\n", wine_dbgstr_rect(&r1
), wine_dbgstr_rect(&r
));
1061 ret
= SendMessageA(hwnd
, TTM_SETMARGIN
, 0, 0);
1062 ok(!ret
, "got %d\n", ret
);
1065 ret
= SendMessageA(hwnd
, TTM_GETMARGIN
, 0, (LPARAM
)&r1
);
1066 ok(!ret
, "got %d\n", ret
);
1067 ok(EqualRect(&r
, &r1
), "got %s, was %s\n", wine_dbgstr_rect(&r1
), wine_dbgstr_rect(&r
));
1069 ret
= SendMessageA(hwnd
, TTM_GETMARGIN
, 0, 0);
1070 ok(!ret
, "got %d\n", ret
);
1072 DestroyWindow(hwnd
);
1075 START_TEST(tooltips
)
1077 InitCommonControls();
1079 test_create_tooltip();
1082 test_ttm_gettoolinfo();