4 * Copyright 2005 Robert Shearman
5 * Copyright 2007 Dmitry Timoshkov
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #define _WIN32_WINNT 0x0501
29 #define OEMRESOURCE /* For OBM_MNARROW */
36 #include "wine/test.h"
38 static ATOM atomMenuCheckClass
;
40 static BOOL (WINAPI
*pGetMenuInfo
)(HMENU
,LPCMENUINFO
);
41 static UINT (WINAPI
*pSendInput
)(UINT
, INPUT
*, size_t);
42 static BOOL (WINAPI
*pSetMenuInfo
)(HMENU
,LPCMENUINFO
);
43 static BOOL (WINAPI
*pEndMenu
) (void);
45 static void init_function_pointers(void)
47 HMODULE hdll
= GetModuleHandleA("user32");
49 #define GET_PROC(func) \
50 p ## func = (void*)GetProcAddress(hdll, #func); \
52 trace("GetProcAddress(%s) failed\n", #func);
62 static BOOL
correct_behavior(void)
70 memset(&info
, 0, sizeof(MENUITEMINFO
));
71 info
.cbSize
= sizeof(MENUITEMINFO
);
72 SetLastError(0xdeadbeef);
73 rc
= GetMenuItemInfo(hmenu
, 0, TRUE
, &info
);
75 * NT4 : ERROR_INVALID_PARAMETER
76 * >= W2K : ERROR_MENU_ITEM_NOT_FOUND
78 if (!rc
&& GetLastError() != ERROR_MENU_ITEM_NOT_FOUND
)
80 win_skip("NT4 and below can't handle a bigger MENUITEMINFO struct\n");
89 static LRESULT WINAPI
menu_check_wnd_proc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
93 case WM_ENTERMENULOOP
:
94 /* mark window as having entered menu loop */
95 SetWindowLongPtr(hwnd
, GWLP_USERDATA
, TRUE
);
96 /* exit menu modal loop
97 * ( A SendMessage does not work on NT3.51 here ) */
98 return PostMessage(hwnd
, WM_CANCELMODE
, 0, 0);
100 return DefWindowProc(hwnd
, msg
, wparam
, lparam
);
103 /* The MSVC headers ignore our NONAMELESSUNION requests so we have to define
116 /* globals to communicate between test and wndproc */
118 static BOOL bMenuVisible
;
119 static BOOL got_input
;
120 static HMENU hMenus
[4];
123 #define MOD_NRMENUS 8
125 /* menu texts with their sizes */
128 SIZE size
; /* size of text up to any \t */
129 SIZE sc_size
; /* size of the short-cut */
133 { "Shira&z\tAlt+S" },
138 static unsigned int MOD_maxid
;
139 static RECT MOD_rc
[MOD_NRMENUS
];
140 static int MOD_avec
, MOD_hic
;
141 static int MOD_odheight
;
142 static SIZE MODsizes
[MOD_NRMENUS
]= { {MOD_SIZE
, MOD_SIZE
},{MOD_SIZE
, MOD_SIZE
},
143 {MOD_SIZE
, MOD_SIZE
},{MOD_SIZE
, MOD_SIZE
}};
144 static int MOD_GotDrawItemMsg
= FALSE
;
145 static int gflag_initmenupopup
,
149 /* wndproc used by test_menu_ownerdraw() */
150 static LRESULT WINAPI
menu_ownerdraw_wnd_proc(HWND hwnd
, UINT msg
,
151 WPARAM wparam
, LPARAM lparam
)
153 static HMENU hmenupopup
;
156 case WM_INITMENUPOPUP
:
157 gflag_initmenupopup
++;
158 hmenupopup
= (HMENU
) wparam
;
160 case WM_ENTERMENULOOP
:
161 gflag_entermenuloop
++;
168 MEASUREITEMSTRUCT
* pmis
= (MEASUREITEMSTRUCT
*)lparam
;
170 trace("WM_MEASUREITEM received data %lx size %dx%d\n",
171 pmis
->itemData
, pmis
->itemWidth
, pmis
->itemHeight
);
172 MOD_odheight
= pmis
->itemHeight
;
173 pmis
->itemWidth
= MODsizes
[pmis
->itemData
].cx
;
174 pmis
->itemHeight
= MODsizes
[pmis
->itemData
].cy
;
179 DRAWITEMSTRUCT
* pdis
;
182 char chrs
[]="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
185 pdis
= (DRAWITEMSTRUCT
*) lparam
;
186 if( winetest_debug
) {
188 GetMenuItemRect( hwnd
, (HMENU
)pdis
->hwndItem
, pdis
->itemData
,&rc
);
189 trace("WM_DRAWITEM received hwnd %p hmenu %p itemdata %ld item %d rc %d,%d-%d,%d itemrc: %d,%d-%d,%d\n",
190 hwnd
, pdis
->hwndItem
, pdis
->itemData
, pdis
->itemID
,
191 pdis
->rcItem
.left
, pdis
->rcItem
.top
,
192 pdis
->rcItem
.right
,pdis
->rcItem
.bottom
,
193 rc
.left
,rc
.top
,rc
.right
,rc
.bottom
);
194 oldpen
=SelectObject( pdis
->hDC
, GetStockObject(
195 pdis
->itemState
& ODS_SELECTED
? WHITE_PEN
:BLACK_PEN
));
196 Rectangle( pdis
->hDC
, pdis
->rcItem
.left
,pdis
->rcItem
.top
,
197 pdis
->rcItem
.right
,pdis
->rcItem
.bottom
);
198 SelectObject( pdis
->hDC
, oldpen
);
200 /* calculate widths of some menu texts */
201 if( ! MOD_txtsizes
[0].size
.cx
)
202 for(i
= 0; MOD_txtsizes
[i
].text
; i
++) {
205 strcpy( buf
, MOD_txtsizes
[i
].text
);
206 if( ( p
= strchr( buf
, '\t'))) {
208 DrawText( pdis
->hDC
, p
+ 1, -1, &rc
,
209 DT_SINGLELINE
|DT_CALCRECT
);
210 MOD_txtsizes
[i
].sc_size
.cx
= rc
.right
- rc
.left
;
211 MOD_txtsizes
[i
].sc_size
.cy
= rc
.bottom
- rc
.top
;
213 DrawText( pdis
->hDC
, buf
, -1, &rc
,
214 DT_SINGLELINE
|DT_CALCRECT
);
215 MOD_txtsizes
[i
].size
.cx
= rc
.right
- rc
.left
;
216 MOD_txtsizes
[i
].size
.cy
= rc
.bottom
- rc
.top
;
219 if( pdis
->itemData
> MOD_maxid
) return TRUE
;
220 /* store the rectangl */
221 MOD_rc
[pdis
->itemData
] = pdis
->rcItem
;
222 /* calculate average character width */
223 GetTextExtentPoint( pdis
->hDC
, chrs
, 52, &sz
);
224 MOD_avec
= (sz
.cx
+ 26)/52;
225 GetTextMetrics( pdis
->hDC
, &tm
);
226 MOD_hic
= tm
.tmHeight
;
227 MOD_GotDrawItemMsg
= TRUE
;
232 ok( lparam
|| broken(!lparam
), /* win9x, nt4 */
233 "Menu window handle is NULL!\n");
235 HMENU hmenu
= (HMENU
)SendMessageA( (HWND
)lparam
, MN_GETHMENU
, 0, 0);
236 ok( hmenupopup
== hmenu
, "MN_GETHMENU returns %p expected %p\n",
239 PostMessage(hwnd
, WM_CANCELMODE
, 0, 0);
244 return DefWindowProc(hwnd
, msg
, wparam
, lparam
);
247 static void register_menu_check_class(void)
255 GetModuleHandle(NULL
),
257 LoadCursor(NULL
, IDC_ARROW
),
258 (HBRUSH
)(COLOR_BTNFACE
+1),
260 TEXT("WineMenuCheck"),
263 atomMenuCheckClass
= RegisterClass(&wc
);
266 /* demonstrates that windows locks the menu object so that it is still valid
267 * even after a client calls DestroyMenu on it */
268 static void test_menu_locked_by_window(void)
272 HWND hwnd
= CreateWindowEx(0, MAKEINTATOM(atomMenuCheckClass
), NULL
,
273 WS_VISIBLE
, CW_USEDEFAULT
, CW_USEDEFAULT
, 200, 200,
274 NULL
, NULL
, NULL
, NULL
);
275 ok(hwnd
!= NULL
, "CreateWindowEx failed with error %d\n", GetLastError());
276 hmenu
= CreateMenu();
277 ok(hmenu
!= NULL
, "CreateMenu failed with error %d\n", GetLastError());
278 ret
= InsertMenu(hmenu
, 0, MF_STRING
, 0, TEXT("&Test"));
279 ok(ret
, "InsertMenu failed with error %d\n", GetLastError());
280 ret
= SetMenu(hwnd
, hmenu
);
281 ok(ret
, "SetMenu failed with error %d\n", GetLastError());
282 ret
= DestroyMenu(hmenu
);
283 ok(ret
, "DestroyMenu failed with error %d\n", GetLastError());
285 ret
= DrawMenuBar(hwnd
);
287 ok(ret
, "DrawMenuBar failed with error %d\n", GetLastError());
289 ret
= IsMenu(GetMenu(hwnd
));
290 ok(!ret
|| broken(ret
) /* nt4 */, "Menu handle should have been destroyed\n");
292 SendMessage(hwnd
, WM_SYSCOMMAND
, SC_KEYMENU
, 0);
293 /* did we process the WM_INITMENU message? */
294 ret
= GetWindowLongPtr(hwnd
, GWLP_USERDATA
);
296 ok(ret
, "WM_INITMENU should have been sent\n");
302 /* demonstrates that subpopup's are locked
303 * even after a client calls DestroyMenu on it */
304 static LRESULT WINAPI
subpopuplocked_wnd_proc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
310 hwndmenu
= GetCapture();
312 PostMessage( hwndmenu
, WM_KEYDOWN
, VK_DOWN
, 0);
313 PostMessage( hwndmenu
, WM_KEYDOWN
, VK_RIGHT
, 0);
314 PostMessage( hwndmenu
, WM_KEYDOWN
, VK_RETURN
, 0);
317 return DefWindowProc(hwnd
, msg
, wparam
, lparam
);
320 static void test_subpopup_locked_by_menu(void)
324 HMENU hmenu
, hsubmenu
;
325 MENUINFO mi
= { sizeof( MENUINFO
)};
326 MENUITEMINFO mii
= { sizeof( MENUITEMINFO
)};
328 const int itemid
= 0x1234567;
331 win_skip("GetMenuInfo is not available\n");
334 /* create window, popupmenu with one subpopup */
335 hwnd
= CreateWindowEx(0, MAKEINTATOM(atomMenuCheckClass
), NULL
,
336 WS_VISIBLE
, CW_USEDEFAULT
, CW_USEDEFAULT
, 200, 200,
337 NULL
, NULL
, NULL
, NULL
);
338 ok(hwnd
!= NULL
, "CreateWindowEx failed with error %d\n", GetLastError());
339 SetWindowLongPtr( hwnd
, GWLP_WNDPROC
, (LONG_PTR
) subpopuplocked_wnd_proc
);
340 hmenu
= CreatePopupMenu();
341 ok(hmenu
!= NULL
, "CreateMenu failed with error %d\n", GetLastError());
342 hsubmenu
= CreatePopupMenu();
343 ok(hsubmenu
!= NULL
, "CreateMenu failed with error %d\n", GetLastError());
344 ret
= InsertMenu(hmenu
, 0, MF_BYPOSITION
| MF_POPUP
| MF_STRING
, (UINT_PTR
)hsubmenu
,
345 TEXT("PopUpLockTest"));
346 ok(ret
, "InsertMenu failed with error %d\n", GetLastError());
347 ret
= InsertMenu(hsubmenu
, 0, MF_BYPOSITION
| MF_STRING
, itemid
, TEXT("PopUpMenu"));
348 ok(ret
, "InsertMenu failed with error %d\n", GetLastError());
349 /* first some tests that all this functions properly */
350 mii
.fMask
= MIIM_SUBMENU
;
351 ret
= GetMenuItemInfo( hmenu
, 0, TRUE
, &mii
);
352 ok( ret
, "GetMenuItemInfo failed error %d\n", GetLastError());
353 ok( mii
.hSubMenu
== hsubmenu
, "submenu is %p\n", mii
.hSubMenu
);
354 mi
.fMask
|= MIM_STYLE
;
355 ret
= pGetMenuInfo( hsubmenu
, &mi
);
356 ok( ret
, "GetMenuInfo returned 0 with error %d\n", GetLastError());
357 ret
= IsMenu( hsubmenu
);
358 ok( ret
, "Menu handle is not valid\n");
359 SetLastError( 0xdeadbeef);
360 ret
= TrackPopupMenu( hmenu
, TPM_RETURNCMD
, 100,100, 0, hwnd
, NULL
);
361 if( ret
== (itemid
& 0xffff)) {
362 win_skip("not on 16 bit menu subsystem\n");
363 DestroyMenu( hsubmenu
);
365 gle
= GetLastError();
366 ok( ret
== itemid
, "TrackPopupMenu returned %d error is %d\n", ret
, gle
);
368 broken( gle
== 0xdeadbeef), /* win2k0 */
369 "Last error is %d\n", gle
);
370 /* then destroy the sub-popup */
371 ret
= DestroyMenu( hsubmenu
);
372 ok(ret
, "DestroyMenu failed with error %d\n", GetLastError());
373 /* and repeat the tests */
374 mii
.fMask
= MIIM_SUBMENU
;
375 ret
= GetMenuItemInfo( hmenu
, 0, TRUE
, &mii
);
376 ok( ret
, "GetMenuItemInfo failed error %d\n", GetLastError());
377 /* GetMenuInfo fails now */
378 ok( mii
.hSubMenu
== hsubmenu
, "submenu is %p\n", mii
.hSubMenu
);
379 mi
.fMask
|= MIM_STYLE
;
380 ret
= pGetMenuInfo( hsubmenu
, &mi
);
381 ok( !ret
, "GetMenuInfo should have failed\n");
382 /* IsMenu says it is not */
383 ret
= IsMenu( hsubmenu
);
384 ok( !ret
, "Menu handle should be invalid\n");
385 /* but TrackPopupMenu still works! */
386 SetLastError( 0xdeadbeef);
387 ret
= TrackPopupMenu( hmenu
, TPM_RETURNCMD
, 100,100, 0, hwnd
, NULL
);
388 gle
= GetLastError();
390 ok( ret
== itemid
, "TrackPopupMenu returned %d error is %d\n", ret
, gle
);
393 broken(gle
== 0xdeadbeef) || /* wow64 */
394 broken(gle
== ERROR_INVALID_PARAMETER
), /* win2k0 */
395 "Last error is %d\n", gle
);
402 static void test_menu_ownerdraw(void)
408 HWND hwnd
= CreateWindowEx(0, MAKEINTATOM(atomMenuCheckClass
), NULL
,
409 WS_VISIBLE
, CW_USEDEFAULT
, CW_USEDEFAULT
, 200, 200,
410 NULL
, NULL
, NULL
, NULL
);
411 ok(hwnd
!= NULL
, "CreateWindowEx failed with error %d\n", GetLastError());
413 SetWindowLongPtr( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)menu_ownerdraw_wnd_proc
);
414 hmenu
= CreatePopupMenu();
415 ok(hmenu
!= NULL
, "CreateMenu failed with error %d\n", GetLastError());
416 if( !hmenu
) { DestroyWindow(hwnd
);return;}
418 for( j
=0;j
<2;j
++) /* create columns */
419 for(i
=0;i
<2;i
++) { /* create rows */
420 ret
= AppendMenu( hmenu
, MF_OWNERDRAW
|
421 (i
==0 ? MF_MENUBREAK
: 0), k
, MAKEINTRESOURCE(k
));
423 ok( ret
, "AppendMenu failed for %d\n", k
-1);
426 assert( k
<= sizeof(MOD_rc
)/sizeof(RECT
));
427 /* display the menu */
428 TrackPopupMenu( hmenu
, TPM_RETURNCMD
, 100,100, 0, hwnd
, NULL
);
430 /* columns have a 4 pixel gap between them */
431 ok( MOD_rc
[0].right
+ 4 == MOD_rc
[2].left
,
432 "item rectangles are not separated by 4 pixels space\n");
433 /* height should be what the MEASUREITEM message has returned */
434 ok( MOD_rc
[0].bottom
- MOD_rc
[0].top
== MOD_SIZE
,
435 "menu item has wrong height: %d should be %d\n",
436 MOD_rc
[0].bottom
- MOD_rc
[0].top
, MOD_SIZE
);
437 /* no gaps between the rows */
438 ok( MOD_rc
[0].bottom
- MOD_rc
[1].top
== 0,
439 "There should not be a space between the rows, gap is %d\n",
440 MOD_rc
[0].bottom
- MOD_rc
[1].top
);
441 /* test the correct value of the item height that was sent
442 * by the WM_MEASUREITEM message */
443 ok( MOD_odheight
== HIWORD( GetDialogBaseUnits()) || /* WinNT,2k,XP */
444 MOD_odheight
== MOD_hic
, /* Win95,98,ME */
445 "Wrong height field in MEASUREITEMSTRUCT, expected %d or %d actual %d\n",
446 HIWORD( GetDialogBaseUnits()), MOD_hic
, MOD_odheight
);
447 /* test what MF_MENUBREAK did at the first position. Also show
448 * that an MF_SEPARATOR is ignored in the height calculation. */
449 leftcol
= MOD_rc
[0].left
;
450 ModifyMenu( hmenu
, 0, MF_BYCOMMAND
| MF_OWNERDRAW
| MF_SEPARATOR
, 0, 0);
451 /* display the menu */
452 TrackPopupMenu( hmenu
, TPM_RETURNCMD
, 100,100, 0, hwnd
, NULL
);
453 /* left should be 4 pixels less now */
454 ok( leftcol
== MOD_rc
[0].left
+ 4,
455 "columns should be 4 pixels to the left (actual %d).\n",
456 leftcol
- MOD_rc
[0].left
);
458 ok( MOD_rc
[0].right
- MOD_rc
[0].left
== 2 * MOD_avec
+ MOD_SIZE
,
459 "width of owner drawn menu item is wrong. Got %d expected %d\n",
460 MOD_rc
[0].right
- MOD_rc
[0].left
, 2*MOD_avec
+ MOD_SIZE
);
462 ok( MOD_rc
[0].bottom
- MOD_rc
[0].top
== MOD_SIZE
,
463 "Height is incorrect. Got %d expected %d\n",
464 MOD_rc
[0].bottom
- MOD_rc
[0].top
, MOD_SIZE
);
466 /* test width/height of an ownerdraw menu bar as well */
467 ret
= DestroyMenu(hmenu
);
468 ok(ret
, "DestroyMenu failed with error %d\n", GetLastError());
469 hmenu
= CreateMenu();
470 ok(hmenu
!= NULL
, "CreateMenu failed with error %d\n", GetLastError());
471 if( !hmenu
) { DestroyWindow(hwnd
);return;}
474 ret
= AppendMenu( hmenu
, MF_OWNERDRAW
, i
, 0);
475 ok( ret
, "AppendMenu failed for %d\n", i
);
477 ret
= SetMenu( hwnd
, hmenu
);
478 UpdateWindow( hwnd
); /* hack for wine to draw the window + menu */
479 ok(ret
, "SetMenu failed with error %d\n", GetLastError());
481 ok( MOD_rc
[0].right
- MOD_rc
[0].left
== 2 * MOD_avec
+ MOD_SIZE
,
482 "width of owner drawn menu item is wrong. Got %d expected %d\n",
483 MOD_rc
[0].right
- MOD_rc
[0].left
, 2*MOD_avec
+ MOD_SIZE
);
485 ok( MOD_rc
[0].bottom
- MOD_rc
[0].top
== GetSystemMetrics( SM_CYMENU
) - 1,
486 "Height of owner drawn menu item is wrong. Got %d expected %d\n",
487 MOD_rc
[0].bottom
- MOD_rc
[0].top
, GetSystemMetrics( SM_CYMENU
) - 1);
490 ret
= DestroyMenu(hmenu
);
491 ok(ret
, "DestroyMenu failed with error %d\n", GetLastError());
495 /* helper for test_menu_bmp_and_string() */
496 static void test_mbs_help( int ispop
, int hassub
, int mnuopt
,
497 HWND hwnd
, int arrowwidth
, int count
, HBITMAP hbmp
,
498 SIZE bmpsize
, LPCSTR text
, SIZE size
, SIZE sc_size
)
501 HMENU hmenu
, submenu
;
502 MENUITEMINFO mii
={ sizeof( MENUITEMINFO
)};
509 MOD_GotDrawItemMsg
= FALSE
;
510 mii
.fMask
= MIIM_FTYPE
| MIIM_DATA
| MIIM_STATE
;
512 /* check the menu item unless MNS_CHECKORBMP is set */
513 mii
.fState
= (mnuopt
!= 2 ? MFS_CHECKED
: MFS_UNCHECKED
);
515 MODsizes
[0] = bmpsize
;
519 mii
.fMask
|= MIIM_STRING
;
520 strcpy(text_copy
, text
);
521 mii
.dwTypeData
= text_copy
; /* structure member declared non-const */
522 if( ( p
= strchr( text
, '\t'))) {
523 hastab
= *(p
+ 1) ? 2 : 1;
526 /* tabs don't make sense in menubars */
527 if(hastab
&& !ispop
) return;
529 mii
.fMask
|= MIIM_BITMAP
;
532 submenu
= CreateMenu();
533 ok( submenu
!= 0, "CreateMenu failed with error %d\n", GetLastError());
535 hmenu
= CreatePopupMenu();
537 hmenu
= CreateMenu();
538 ok( hmenu
!= 0, "Create{Popup}Menu failed with error %d\n", GetLastError());
540 mii
.fMask
|= MIIM_SUBMENU
;
541 mii
.hSubMenu
= submenu
;
544 mi
.cbSize
= sizeof(mi
);
545 mi
.fMask
= MIM_STYLE
;
546 pGetMenuInfo( hmenu
, &mi
);
547 if( mnuopt
) mi
.dwStyle
|= mnuopt
== 1 ? MNS_NOCHECK
: MNS_CHECKORBMP
;
548 ret
= pSetMenuInfo( hmenu
, &mi
);
549 ok( ret
, "SetMenuInfo failed with error %d\n", GetLastError());
551 ret
= InsertMenuItem( hmenu
, 0, FALSE
, &mii
);
552 ok( ret
, "InsertMenuItem failed with error %d\n", GetLastError());
554 if( winetest_debug
) {
556 RECT rc
= {100, 50, 400, 70};
559 sprintf( buf
,"%d text \"%s\" mnuopt %d", count
, text
? text
: "(nil)", mnuopt
);
560 FillRect( hdc
, &rc
, (HBRUSH
) COLOR_WINDOW
);
561 TextOut( hdc
, 10, 50, buf
, strlen( buf
));
562 ReleaseDC( hwnd
, hdc
);
565 TrackPopupMenu( hmenu
, TPM_RETURNCMD
, 100,100, 0, hwnd
, NULL
);
567 ret
= SetMenu( hwnd
, hmenu
);
568 ok(ret
, "SetMenu failed with error %d\n", GetLastError());
571 ret
= GetMenuItemRect( hwnd
, hmenu
, 0, &rc
);
572 ok(ret
, "GetMenuItemRect failed with error %d\n", GetLastError());
574 if (0) /* comment out menu size checks, behavior is different in almost every Windows version */
575 /* the tests should however succeed on win2000, XP and Wine (at least up to 1.1.15) */
576 /* with a variety of dpis and desktop font sizes */
578 /* check menu width */
580 expect
= ( text
|| hbmp
?
581 4 + (mnuopt
!= 1 ? GetSystemMetrics(SM_CXMENUCHECK
) : 0)
583 arrowwidth
+ MOD_avec
+ (hbmp
?
584 ((INT_PTR
)hbmp
<0||(INT_PTR
)hbmp
>12 ? bmpsize
.cx
+ 2 : GetSystemMetrics( SM_CXMENUSIZE
) + 2)
586 (text
&& hastab
? /* TAB space */
587 MOD_avec
+ ( hastab
==2 ? sc_size
.cx
: 0) : 0) +
588 (text
? 2 + (text
[0] ? size
.cx
:0): 0) ;
590 expect
= !(text
|| hbmp
) ? 0 :
591 ( hbmp
? (text
? 2:0) + bmpsize
.cx
: 0 ) +
592 (text
? 2 * MOD_avec
+ (text
[0] ? size
.cx
:0): 0) ;
593 ok( rc
.right
- rc
.left
== expect
,
594 "menu width wrong, got %d expected %d\n", rc
.right
- rc
.left
, expect
);
595 failed
= failed
|| !(rc
.right
- rc
.left
== expect
);
596 /* check menu height */
598 expect
= max( ( !(text
|| hbmp
) ? GetSystemMetrics( SM_CYMENUSIZE
)/2 : 0),
599 max( (text
? max( 2 + size
.cy
, MOD_hic
+ 4) : 0),
601 ((INT_PTR
)hbmp
<0||(INT_PTR
)hbmp
>12 ?
603 : GetSystemMetrics( SM_CYMENUSIZE
) + 2)
606 expect
= ( !(text
|| hbmp
) ? GetSystemMetrics( SM_CYMENUSIZE
)/2 :
607 max( GetSystemMetrics( SM_CYMENU
) - 1, (hbmp
? bmpsize
.cy
: 0)));
608 ok( rc
.bottom
- rc
.top
== expect
,
609 "menu height wrong, got %d expected %d (%d)\n",
610 rc
.bottom
- rc
.top
, expect
, GetSystemMetrics( SM_CYMENU
));
611 failed
= failed
|| !(rc
.bottom
- rc
.top
== expect
);
612 if( hbmp
== HBMMENU_CALLBACK
&& MOD_GotDrawItemMsg
) {
613 /* check the position of the bitmap */
617 else if (mnuopt
== 0)
618 expect
= 4 + GetSystemMetrics(SM_CXMENUCHECK
);
619 else if (mnuopt
== 1)
621 else /* mnuopt == 2 */
623 ok( expect
== MOD_rc
[0].left
,
624 "bitmap left is %d expected %d\n", MOD_rc
[0].left
, expect
);
625 failed
= failed
|| !(expect
== MOD_rc
[0].left
);
627 expect
= (rc
.bottom
- rc
.top
- MOD_rc
[0].bottom
+ MOD_rc
[0].top
) / 2;
628 ok( expect
== MOD_rc
[0].top
,
629 "bitmap top is %d expected %d\n", MOD_rc
[0].top
, expect
);
630 failed
= failed
|| !(expect
== MOD_rc
[0].top
);
633 /* if there was a failure, report details */
635 trace("*** count %d %s text \"%s\" bitmap %p bmsize %d,%d textsize %d+%d,%d mnuopt %d hastab %d\n",
636 count
, (ispop
? "POPUP": "MENUBAR"),text
? text
: "(nil)", hbmp
, bmpsize
.cx
, bmpsize
.cy
,
637 size
.cx
, size
.cy
, sc_size
.cx
, mnuopt
, hastab
);
638 trace(" check %d,%d arrow %d avechar %d\n",
639 GetSystemMetrics(SM_CXMENUCHECK
),
640 GetSystemMetrics(SM_CYMENUCHECK
),arrowwidth
, MOD_avec
);
641 if( hbmp
== HBMMENU_CALLBACK
)
642 trace( " rc %d,%d-%d,%d bmp.rc %d,%d-%d,%d\n",
643 rc
.left
, rc
.top
, rc
.top
, rc
.bottom
, MOD_rc
[0].left
,
644 MOD_rc
[0].top
,MOD_rc
[0].right
, MOD_rc
[0].bottom
);
647 ret
= DestroyMenu(submenu
);
648 ok(ret
, "DestroyMenu failed with error %d\n", GetLastError());
649 ret
= DestroyMenu(hmenu
);
650 ok(ret
, "DestroyMenu failed with error %d\n", GetLastError());
654 static void test_menu_bmp_and_string(void)
662 MENUINFO mi
= {sizeof(MENUINFO
)};
663 MENUITEMINFOA mii
= {sizeof(MENUITEMINFOA
)};
664 int count
, szidx
, txtidx
, bmpidx
, hassub
, mnuopt
, ispop
;
669 win_skip("GetMenuInfo is not available\n");
673 memset( bmfill
, 0xcc, sizeof( bmfill
));
674 hwnd
= CreateWindowEx(0, MAKEINTATOM(atomMenuCheckClass
), NULL
, WS_SYSMENU
|
675 WS_VISIBLE
, CW_USEDEFAULT
, CW_USEDEFAULT
, 200, 200,
676 NULL
, NULL
, NULL
, NULL
);
677 hbm_arrow
=LoadBitmap( 0, (CHAR
*)OBM_MNARROW
);
678 GetObject( hbm_arrow
, sizeof(bm
), &bm
);
679 arrowwidth
= bm
.bmWidth
;
680 ok(hwnd
!= NULL
, "CreateWindowEx failed with error %d\n", GetLastError());
682 /* test system menu */
683 hsysmenu
= GetSystemMenu( hwnd
, FALSE
);
684 ok( hsysmenu
!= NULL
, "GetSystemMenu failed with error %d\n", GetLastError());
685 mi
.fMask
= MIM_STYLE
;
687 got
= pGetMenuInfo( hsysmenu
, &mi
);
688 ok( got
, "GetMenuInfo failed gle=%d\n", GetLastError());
689 ok( MNS_CHECKORBMP
== mi
.dwStyle
, "System Menu Style is %08x, without the bit %08x\n",
690 mi
.dwStyle
, MNS_CHECKORBMP
);
691 mii
.fMask
= MIIM_BITMAP
;
693 got
= GetMenuItemInfoA( hsysmenu
, SC_CLOSE
, FALSE
, &mii
);
694 ok( got
, "GetMenuItemInfoA failed gle=%d\n", GetLastError());
695 ok( HBMMENU_POPUP_CLOSE
== mii
.hbmpItem
, "Item info did not get the right hbitmap: got %p expected %p\n",
696 mii
.hbmpItem
, HBMMENU_POPUP_CLOSE
);
698 SetWindowLongPtr( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)menu_ownerdraw_wnd_proc
);
701 trace(" check %d,%d arrow %d avechar %d\n",
702 GetSystemMetrics(SM_CXMENUCHECK
),
703 GetSystemMetrics(SM_CYMENUCHECK
),arrowwidth
, MOD_avec
);
706 for( ispop
=1; ispop
>= 0; ispop
--){
707 static SIZE bmsizes
[]= {
708 {10,10},{38,38},{1,30},{55,5}};
709 for( szidx
=0; szidx
< sizeof( bmsizes
) / sizeof( SIZE
); szidx
++) {
710 HBITMAP hbm
= CreateBitmap( bmsizes
[szidx
].cx
, bmsizes
[szidx
].cy
,1,1,bmfill
);
711 HBITMAP bitmaps
[] = { HBMMENU_CALLBACK
, hbm
, HBMMENU_POPUP_CLOSE
, NULL
};
712 ok( hbm
!= 0, "CreateBitmap failed err %d\n", GetLastError());
713 for( txtidx
= 0; txtidx
< sizeof(MOD_txtsizes
)/sizeof(MOD_txtsizes
[0]); txtidx
++) {
714 for( hassub
= 0; hassub
< 2 ; hassub
++) { /* add submenu item */
715 for( mnuopt
= 0; mnuopt
< 3 ; mnuopt
++){ /* test MNS_NOCHECK/MNS_CHECKORBMP */
716 for( bmpidx
= 0; bmpidx
<sizeof(bitmaps
)/sizeof(HBITMAP
); bmpidx
++) {
717 /* no need to test NULL bitmaps of several sizes */
718 if( !bitmaps
[bmpidx
] && szidx
> 0) continue;
719 /* the HBMMENU_POPUP not to test for menu bars */
721 bitmaps
[bmpidx
] >= HBMMENU_POPUP_CLOSE
&&
722 bitmaps
[bmpidx
] <= HBMMENU_POPUP_MINIMIZE
) continue;
723 if( !ispop
&& hassub
) continue;
724 test_mbs_help( ispop
, hassub
, mnuopt
,
725 hwnd
, arrowwidth
, ++count
,
728 MOD_txtsizes
[txtidx
].text
,
729 MOD_txtsizes
[txtidx
].size
,
730 MOD_txtsizes
[txtidx
].sc_size
);
742 static void test_menu_add_string( void )
753 WCHAR strbackW
[0x80];
754 static CHAR blah
[] = "blah";
755 static const WCHAR expectedString
[] = {'D','u','m','m','y',' ','s','t','r','i','n','g', 0};
757 hmenu
= CreateMenu();
759 memset( &info
, 0, sizeof info
);
760 info
.cbSize
= sizeof info
;
761 info
.fMask
= MIIM_FTYPE
| MIIM_STRING
| MIIM_STATE
| MIIM_ID
;
762 info
.dwTypeData
= blah
;
767 InsertMenuItem(hmenu
, 0, TRUE
, &info
);
769 memset( &info
, 0, sizeof info
);
770 info
.cbSize
= sizeof info
;
771 info
.fMask
= MIIM_FTYPE
| MIIM_STRING
| MIIM_STATE
| MIIM_DATA
| MIIM_ID
;
772 info
.dwTypeData
= string
;
773 info
.cch
= sizeof string
;
775 GetMenuItemInfo( hmenu
, 0, TRUE
, &info
);
777 ok( !strcmp( string
, "blah" ), "menu item name differed\n");
779 /* Test combination of ownerdraw and strings with GetMenuItemString(A/W) */
780 strcpy(string
, "Dummy string");
781 memset(&info
, 0x00, sizeof(info
));
782 info
.cbSize
= sizeof(MENUITEMINFO
);
783 info
.fMask
= MIIM_FTYPE
| MIIM_STRING
; /* Set OwnerDraw + typeData */
784 info
.fType
= MFT_OWNERDRAW
;
785 info
.dwTypeData
= string
;
786 rc
= InsertMenuItem( hmenu
, 0, TRUE
, &info
);
787 ok (rc
, "InsertMenuItem failed\n");
789 strcpy(string
,"Garbage");
790 ok (GetMenuString( hmenu
, 0, strback
, 99, MF_BYPOSITION
), "GetMenuString on ownerdraw entry failed\n");
791 ok (!strcmp( strback
, "Dummy string" ), "Menu text from Ansi version incorrect\n");
793 SetLastError(0xdeadbeef);
794 ret
= GetMenuStringW( hmenu
, 0, strbackW
, 99, MF_BYPOSITION
);
795 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
796 win_skip("GetMenuStringW is not implemented\n");
799 ok (ret
, "GetMenuStringW on ownerdraw entry failed\n");
800 ok (!lstrcmpW( strbackW
, expectedString
), "Menu text from Unicode version incorrect\n");
803 /* Just change ftype to string and see what text is stored */
804 memset(&info
, 0x00, sizeof(info
));
805 info
.cbSize
= sizeof(MENUITEMINFO
);
806 info
.fMask
= MIIM_FTYPE
; /* Set string type */
807 info
.fType
= MFT_STRING
;
808 info
.dwTypeData
= (char *)0xdeadbeef;
809 rc
= SetMenuItemInfo( hmenu
, 0, TRUE
, &info
);
810 ok (rc
, "SetMenuItemInfo failed\n");
812 /* Did we keep the old dwTypeData? */
813 ok (GetMenuString( hmenu
, 0, strback
, 99, MF_BYPOSITION
), "GetMenuString on ownerdraw entry failed\n");
814 ok (!strcmp( strback
, "Dummy string" ), "Menu text from Ansi version incorrect\n");
816 /* Ensure change to bitmap type fails */
817 memset(&info
, 0x00, sizeof(info
));
818 info
.cbSize
= sizeof(MENUITEMINFO
);
819 info
.fMask
= MIIM_FTYPE
; /* Set as bitmap type */
820 info
.fType
= MFT_BITMAP
;
821 info
.dwTypeData
= (char *)0xdeadbee2;
822 rc
= SetMenuItemInfo( hmenu
, 0, TRUE
, &info
);
823 ok (!rc
, "SetMenuItemInfo unexpectedly worked\n");
825 /* Just change ftype back and ensure data hasn't been freed */
826 info
.fType
= MFT_OWNERDRAW
; /* Set as ownerdraw type */
827 info
.dwTypeData
= (char *)0xdeadbee3;
828 rc
= SetMenuItemInfo( hmenu
, 0, TRUE
, &info
);
829 ok (rc
, "SetMenuItemInfo failed\n");
831 /* Did we keep the old dwTypeData? */
832 ok (GetMenuString( hmenu
, 0, strback
, 99, MF_BYPOSITION
), "GetMenuString on ownerdraw entry failed\n");
833 ok (!strcmp( strback
, "Dummy string" ), "Menu text from Ansi version incorrect\n");
835 /* Just change string value (not type) */
836 memset(&info
, 0x00, sizeof(info
));
837 info
.cbSize
= sizeof(MENUITEMINFO
);
838 info
.fMask
= MIIM_STRING
; /* Set typeData */
839 strcpy(string2
, "string2");
840 info
.dwTypeData
= string2
;
841 rc
= SetMenuItemInfo( hmenu
, 0, TRUE
, &info
);
842 ok (rc
, "SetMenuItemInfo failed\n");
844 ok (GetMenuString( hmenu
, 0, strback
, 99, MF_BYPOSITION
), "GetMenuString on ownerdraw entry failed\n");
845 ok (!strcmp( strback
, "string2" ), "Menu text from Ansi version incorrect\n");
847 /* crashes with wine 0.9.5 */
848 memset(&info
, 0x00, sizeof(info
));
849 info
.cbSize
= sizeof(MENUITEMINFO
);
850 info
.fMask
= MIIM_FTYPE
| MIIM_STRING
; /* Set OwnerDraw + typeData */
851 info
.fType
= MFT_OWNERDRAW
;
852 rc
= InsertMenuItem( hmenu
, 0, TRUE
, &info
);
853 ok (rc
, "InsertMenuItem failed\n");
854 ok (!GetMenuString( hmenu
, 0, NULL
, 0, MF_BYPOSITION
),
855 "GetMenuString on ownerdraw entry succeeded.\n");
856 SetLastError(0xdeadbeef);
857 ret
= GetMenuStringW( hmenu
, 0, NULL
, 0, MF_BYPOSITION
);
858 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
859 win_skip("GetMenuStringW is not implemented\n");
861 ok (!ret
, "GetMenuStringW on ownerdraw entry succeeded.\n");
863 DestroyMenu( hmenu
);
866 /* define building blocks for the menu item info tests */
867 static int strncmpW( const WCHAR
*str1
, const WCHAR
*str2
, int n
)
869 if (n
<= 0) return 0;
870 while ((--n
> 0) && *str1
&& (*str1
== *str2
)) { str1
++; str2
++; }
871 return *str1
- *str2
;
874 static WCHAR
*strcpyW( WCHAR
*dst
, const WCHAR
*src
)
877 while ((*p
++ = *src
++));
881 static void insert_menu_item( int line
, HMENU hmenu
, BOOL ansi
, UINT mask
, UINT type
, UINT state
, UINT id
,
882 HMENU submenu
, HBITMAP checked
, HBITMAP unchecked
, ULONG_PTR data
,
883 void *type_data
, UINT len
, HBITMAP item
, BOOL expect
)
888 /* magic bitmap handle to test smaller cbSize */
889 if (item
== (HBITMAP
)(ULONG_PTR
)0xdeadbeef)
890 info
.cbSize
= FIELD_OFFSET(MENUITEMINFOA
,hbmpItem
);
892 info
.cbSize
= sizeof(info
);
897 info
.hSubMenu
= submenu
;
898 info
.hbmpChecked
= checked
;
899 info
.hbmpUnchecked
= unchecked
;
900 info
.dwItemData
= data
;
901 info
.dwTypeData
= type_data
;
903 info
.hbmpItem
= item
;
904 SetLastError( 0xdeadbeef );
905 if (ansi
) ret
= InsertMenuItemA( hmenu
, 0, TRUE
, &info
);
906 else ret
= InsertMenuItemW( hmenu
, 0, TRUE
, (MENUITEMINFOW
*)&info
);
907 if (!expect
) ok_(__FILE__
, line
)( !ret
, "InsertMenuItem should have failed.\n" );
908 else ok_(__FILE__
, line
)( ret
, "InsertMenuItem failed, err %u\n", GetLastError());
911 static void check_menu_item_info( int line
, HMENU hmenu
, BOOL ansi
, UINT mask
, UINT type
, UINT state
,
912 UINT id
, HMENU submenu
, HBITMAP checked
, HBITMAP unchecked
,
913 ULONG_PTR data
, void *type_data
, UINT in_len
, UINT out_len
,
914 HBITMAP item
, LPCSTR expname
, BOOL expect
, BOOL expstring
)
920 SetLastError( 0xdeadbeef );
921 memset( &info
, 0xcc, sizeof(info
) );
922 info
.cbSize
= sizeof(info
);
924 info
.dwTypeData
= type_data
;
927 ret
= ansi
? GetMenuItemInfoA( hmenu
, 0, TRUE
, &info
) :
928 GetMenuItemInfoW( hmenu
, 0, TRUE
, (MENUITEMINFOW
*)&info
);
931 ok_(__FILE__
, line
)( !ret
, "GetMenuItemInfo should have failed.\n" );
934 ok_(__FILE__
, line
)( ret
, "GetMenuItemInfo failed, err %u\n", GetLastError());
935 if (mask
& MIIM_TYPE
)
936 ok_(__FILE__
, line
)( info
.fType
== type
|| info
.fType
== LOWORD(type
),
937 "wrong type %x/%x\n", info
.fType
, type
);
938 if (mask
& MIIM_STATE
)
939 ok_(__FILE__
, line
)( info
.fState
== state
|| info
.fState
== LOWORD(state
),
940 "wrong state %x/%x\n", info
.fState
, state
);
942 ok_(__FILE__
, line
)( info
.wID
== id
|| info
.wID
== LOWORD(id
),
943 "wrong id %x/%x\n", info
.wID
, id
);
944 if (mask
& MIIM_SUBMENU
)
945 ok_(__FILE__
, line
)( info
.hSubMenu
== submenu
|| (ULONG_PTR
)info
.hSubMenu
== LOWORD(submenu
),
946 "wrong submenu %p/%p\n", info
.hSubMenu
, submenu
);
947 if (mask
& MIIM_CHECKMARKS
)
949 ok_(__FILE__
, line
)( info
.hbmpChecked
== checked
|| (ULONG_PTR
)info
.hbmpChecked
== LOWORD(checked
),
950 "wrong bmpchecked %p/%p\n", info
.hbmpChecked
, checked
);
951 ok_(__FILE__
, line
)( info
.hbmpUnchecked
== unchecked
|| (ULONG_PTR
)info
.hbmpUnchecked
== LOWORD(unchecked
),
952 "wrong bmpunchecked %p/%p\n", info
.hbmpUnchecked
, unchecked
);
954 if (mask
& MIIM_DATA
)
955 ok_(__FILE__
, line
)( info
.dwItemData
== data
|| info
.dwItemData
== LOWORD(data
),
956 "wrong item data %lx/%lx\n", info
.dwItemData
, data
);
957 if (mask
& MIIM_BITMAP
)
958 ok_(__FILE__
, line
)( info
.hbmpItem
== item
|| (ULONG_PTR
)info
.hbmpItem
== LOWORD(item
),
959 "wrong bmpitem %p/%p\n", info
.hbmpItem
, item
);
960 ok_(__FILE__
, line
)( info
.dwTypeData
== type_data
|| (ULONG_PTR
)info
.dwTypeData
== LOWORD(type_data
),
961 "wrong type data %p/%p\n", info
.dwTypeData
, type_data
);
962 ok_(__FILE__
, line
)( info
.cch
== out_len
||
963 broken(! ansi
&& info
.cch
== 2 * out_len
) /* East-Asian */,
964 "wrong len %x/%x\n", info
.cch
, out_len
);
968 ok_(__FILE__
, line
)( !strncmp( expname
, info
.dwTypeData
, out_len
),
969 "menu item name differed from '%s' '%s'\n", expname
, info
.dwTypeData
);
971 ok_(__FILE__
, line
)( !strncmpW( (WCHAR
*)expname
, (WCHAR
*)info
.dwTypeData
, out_len
),
972 "menu item name wrong\n" );
974 SetLastError( 0xdeadbeef );
975 ret
= ansi
? GetMenuStringA( hmenu
, 0, (char *)buffer
, 80, MF_BYPOSITION
) :
976 GetMenuStringW( hmenu
, 0, buffer
, 80, MF_BYPOSITION
);
978 ok_(__FILE__
, line
)( ret
, "GetMenuString failed, err %u\n", GetLastError());
980 ok_(__FILE__
, line
)( !ret
, "GetMenuString should have failed\n" );
984 static void modify_menu( int line
, HMENU hmenu
, BOOL ansi
, UINT flags
, UINT_PTR id
, void *data
)
988 SetLastError( 0xdeadbeef );
989 if (ansi
) ret
= ModifyMenuA( hmenu
, 0, flags
, id
, data
);
990 else ret
= ModifyMenuW( hmenu
, 0, flags
, id
, data
);
991 ok_(__FILE__
,line
)( ret
, "ModifyMenuA failed, err %u\n", GetLastError());
994 static void set_menu_item_info( int line
, HMENU hmenu
, BOOL ansi
, UINT mask
, UINT type
, UINT state
,
995 UINT id
, HMENU submenu
, HBITMAP checked
, HBITMAP unchecked
, ULONG_PTR data
,
996 void *type_data
, UINT len
, HBITMAP item
)
1002 /* magic bitmap handle to test smaller cbSize */
1003 if (item
== (HBITMAP
)(ULONG_PTR
)0xdeadbeef)
1004 info
.cbSize
= FIELD_OFFSET(MENUITEMINFOA
,hbmpItem
);
1006 info
.cbSize
= sizeof(info
);
1009 info
.fState
= state
;
1011 info
.hSubMenu
= submenu
;
1012 info
.hbmpChecked
= checked
;
1013 info
.hbmpUnchecked
= unchecked
;
1014 info
.dwItemData
= data
;
1015 info
.dwTypeData
= type_data
;
1017 info
.hbmpItem
= item
;
1018 SetLastError( 0xdeadbeef );
1019 if (ansi
) ret
= SetMenuItemInfoA( hmenu
, 0, TRUE
, &info
);
1020 else ret
= SetMenuItemInfoW( hmenu
, 0, TRUE
, (MENUITEMINFOW
*)&info
);
1021 ok_(__FILE__
, line
)( ret
, "SetMenuItemInfo failed, err %u\n", GetLastError());
1024 #define TMII_INSMI( c1,d1,e1,f1,g1,h1,i1,j1,k1,l1,m1,eret1 )\
1025 hmenu = CreateMenu();\
1026 submenu = CreateMenu();\
1027 if(ansi)strcpy( string, init );\
1028 else strcpyW( string, init );\
1029 insert_menu_item( __LINE__, hmenu, ansi, c1, d1, e1, f1, g1, h1, i1, j1, k1, l1, m1, eret1 )
1031 /* GetMenuItemInfo + GetMenuString */
1032 #define TMII_GMII( c2,l2,\
1033 d3,e3,f3,g3,h3,i3,j3,k3,l3,m3,\
1034 expname, eret2, eret3)\
1035 check_menu_item_info( __LINE__, hmenu, ansi, c2, d3, e3, f3, g3, h3, i3, j3, k3, l2, l3, m3, \
1036 expname, eret2, eret3 )
1039 RemoveMenu(hmenu, 0, TRUE );\
1040 DestroyMenu( hmenu );\
1041 DestroyMenu( submenu );
1044 #define TMII_MODM( flags, id, data ) \
1045 modify_menu( __LINE__, hmenu, ansi, flags, id, data )
1047 /* SetMenuItemInfo */
1048 #define TMII_SMII( c1,d1,e1,f1,g1,h1,i1,j1,k1,l1,m1 ) \
1049 set_menu_item_info( __LINE__, hmenu, ansi, c1, d1, e1, f1, g1, h1, i1, j1, k1, l1, m1 )
1056 static void test_menu_iteminfo( void )
1062 WCHAR txtW
[]={'W','i','n','e',0};
1063 WCHAR initW
[]={'X','Y','Z',0};
1065 void *txt
, *init
, *empty
, *string
;
1066 HBITMAP hbm
= CreateBitmap(1,1,1,1,NULL
);
1068 HMENU hmenu
, submenu
=CreateMenu();
1069 HBITMAP dummy_hbm
= (HBITMAP
)(ULONG_PTR
)0xdeadbeef;
1072 if( ansi
) {txt
=txtA
;init
=initA
;empty
=emptyA
;string
=stringA
;}
1073 else {txt
=txtW
;init
=initW
;empty
=emptyW
;string
=stringA
;}
1074 trace( "%s string %p hbm %p txt %p\n", ansi
? "ANSI tests: " : "Unicode tests:", string
, hbm
, txt
);
1075 /* test all combinations of MFT_STRING, MFT_OWNERDRAW and MFT_BITMAP */
1076 /* (since MFT_STRING is zero, there are four of them) */
1077 TMII_INSMI( MIIM_TYPE
, MFT_STRING
, 0, 0, 0, 0, 0, 0, txt
, 0, 0, OK
);
1078 TMII_GMII ( MIIM_TYPE
, 80,
1079 MFT_STRING
, 0, 0, 0, 0, 0, 0, string
, 4, 0,
1082 TMII_INSMI( MIIM_TYPE
, MFT_STRING
|MFT_OWNERDRAW
, -1, -1, 0, 0, 0, -1, txt
, 0, 0, OK
);
1083 TMII_GMII ( MIIM_TYPE
, 80,
1084 MFT_STRING
|MFT_OWNERDRAW
, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1087 TMII_INSMI( MIIM_TYPE
, MFT_BITMAP
, -1, -1, 0, 0, 0, -1, hbm
, 6, 0, OK
);
1088 TMII_GMII ( MIIM_TYPE
, 80,
1089 MFT_BITMAP
, 0, 0, 0, 0, 0, 0, hbm
, 0, hbm
,
1092 TMII_INSMI( MIIM_TYPE
, MFT_BITMAP
|MFT_OWNERDRAW
, -1, -1, 0, 0, 0, -1, hbm
, 6, 0, OK
);
1093 TMII_GMII ( MIIM_TYPE
, 80,
1094 MFT_BITMAP
|MFT_OWNERDRAW
, 0, 0, 0, 0, 0, 0, hbm
, 0, hbm
,
1097 /* not enough space for name*/
1098 TMII_INSMI( MIIM_TYPE
, MFT_STRING
, -1, -1, 0, 0, 0, -1, txt
, 6, 0, OK
);
1099 TMII_GMII ( MIIM_TYPE
, 0,
1100 MFT_STRING
, 0, 0, 0, 0, 0, 0, NULL
, 4, 0,
1103 TMII_INSMI( MIIM_TYPE
, MFT_STRING
, -1, -1, 0, 0, 0, -1, txt
, 6, 0, OK
);
1104 TMII_GMII ( MIIM_TYPE
, 5,
1105 MFT_STRING
, 0, 0, 0, 0, 0, 0, string
, 4, 0,
1108 TMII_INSMI( MIIM_TYPE
, MFT_STRING
, -1, -1, 0, 0, 0, -1, txt
, 6, 0, OK
);
1109 TMII_GMII ( MIIM_TYPE
, 4,
1110 MFT_STRING
, 0, 0, 0, 0, 0, 0, string
, 3, 0,
1113 TMII_INSMI( MIIM_FTYPE
|MIIM_STRING
, MFT_OWNERDRAW
, -1, -1, 0, 0, 0, -1, NULL
, 0, 0, OK
);
1114 TMII_GMII ( MIIM_TYPE
, 0,
1115 MFT_OWNERDRAW
, 0, 0, 0, 0, 0, 0, NULL
, 0, 0,
1118 /* cannot combine MIIM_TYPE with some other flags */
1119 TMII_INSMI( MIIM_TYPE
|MIIM_STRING
, MFT_STRING
, -1, -1, 0, 0, 0, -1, txt
, 6, 0, ER
);
1121 TMII_INSMI( MIIM_TYPE
, MFT_STRING
, -1, -1, 0, 0, 0, -1, txt
, 6, 0, OK
);
1122 TMII_GMII ( MIIM_TYPE
|MIIM_STRING
, 80,
1123 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1126 TMII_INSMI( MIIM_TYPE
|MIIM_FTYPE
, MFT_STRING
, -1, -1, 0, 0, 0, -1, txt
, 6, 0, ER
);
1128 TMII_INSMI( MIIM_TYPE
, MFT_STRING
, -1, -1, 0, 0, 0, -1, txt
, 6, 0, OK
);
1129 TMII_GMII ( MIIM_TYPE
|MIIM_FTYPE
, 80,
1130 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1133 TMII_INSMI( MIIM_TYPE
|MIIM_BITMAP
, MFT_BITMAP
, -1, -1, 0, 0, 0, -1, hbm
, 6, hbm
, ER
);
1135 /* but succeeds with some others */
1136 TMII_INSMI( MIIM_TYPE
, MFT_STRING
, -1, -1, 0, 0, 0, -1, txt
, 6, 0, OK
);
1137 TMII_GMII ( MIIM_TYPE
|MIIM_SUBMENU
, 80,
1138 MFT_STRING
, 0, 0, 0, 0, 0, 0, string
, 4, 0,
1141 TMII_INSMI( MIIM_TYPE
, MFT_STRING
, -1, -1, 0, 0, 0, -1, txt
, 6, 0, OK
);
1142 TMII_GMII ( MIIM_TYPE
|MIIM_STATE
, 80,
1143 MFT_STRING
, 0, 0, 0, 0, 0, 0, string
, 4, 0,
1146 TMII_INSMI( MIIM_TYPE
|MIIM_ID
, MFT_STRING
, -1, 888, 0, 0, 0, -1, txt
, 6, 0, OK
);
1147 TMII_GMII ( MIIM_TYPE
|MIIM_ID
, 80,
1148 MFT_STRING
, 0, 888, 0, 0, 0, 0, string
, 4, 0,
1151 TMII_INSMI( MIIM_TYPE
|MIIM_DATA
, MFT_STRING
, -1, -1, 0, 0, 0, 999, txt
, 6, 0, OK
);
1152 TMII_GMII ( MIIM_TYPE
|MIIM_DATA
, 80,
1153 MFT_STRING
, 0, 0, 0, 0, 0, 999, string
, 4, 0,
1156 /* to be continued */
1157 /* set text with MIIM_TYPE and retrieve with MIIM_STRING */
1158 TMII_INSMI( MIIM_TYPE
, MFT_STRING
, -1, -1, 0, 0, 0, -1, txt
, 6, 0, OK
);
1159 TMII_GMII ( MIIM_STRING
|MIIM_FTYPE
, 80,
1160 MFT_STRING
, 0, 0, 0, 0, 0, 0, string
, 4, 0,
1163 /* set text with MIIM_TYPE and retrieve with MIIM_STRING; MFT_OWNERDRAW causes an empty string */
1164 TMII_INSMI( MIIM_TYPE
, MFT_STRING
|MFT_OWNERDRAW
, -1, -1, 0, 0, 0, -1, txt
, 6, 0, OK
);
1165 TMII_GMII ( MIIM_STRING
|MIIM_FTYPE
, 80,
1166 MFT_STRING
|MFT_OWNERDRAW
, 0, 0, 0, 0, 0, 0, string
, 0, 0,
1169 TMII_INSMI( MIIM_TYPE
, MFT_STRING
|MFT_OWNERDRAW
, -1, -1, 0, 0, 0, -1, NULL
, 0, 0, OK
);
1170 TMII_GMII ( MIIM_STRING
|MIIM_FTYPE
, 80,
1171 MFT_OWNERDRAW
, 0, 0, 0, 0, 0, 0, string
, 0, 0,
1174 TMII_INSMI( MIIM_TYPE
, MFT_STRING
|MFT_OWNERDRAW
, -1, -1, 0, 0, 0, -1, NULL
, 0, 0, OK
);
1175 TMII_GMII ( MIIM_FTYPE
, 80,
1176 MFT_OWNERDRAW
, 0, 0, 0, 0, 0, 0, string
, 80, 0,
1179 TMII_INSMI( MIIM_TYPE
, MFT_STRING
, -1, -1, 0, 0, 0, -1, txt
, 0, 0, OK
);
1181 0, 0, 0, 0, 0, 0, 0, string
, 80, 0,
1184 /* contrary to MIIM_TYPE,you can set the text for an owner draw menu */
1185 TMII_INSMI( MIIM_STRING
|MIIM_FTYPE
, MFT_STRING
|MFT_OWNERDRAW
, -1, -1, 0, 0, 0, -1, txt
, 0, 0, OK
);
1186 TMII_GMII ( MIIM_STRING
|MIIM_FTYPE
, 80,
1187 MFT_OWNERDRAW
, 0, 0, 0, 0, 0, 0, string
, 4, 0,
1190 /* same but retrieve with MIIM_TYPE */
1191 TMII_INSMI( MIIM_STRING
|MIIM_FTYPE
, MFT_STRING
|MFT_OWNERDRAW
, -1, -1, 0, 0, 0, -1, txt
, 0, 0, OK
);
1192 TMII_GMII ( MIIM_TYPE
, 80,
1193 MFT_OWNERDRAW
, 0, 0, 0, 0, 0, 0, NULL
, 4, NULL
,
1196 TMII_INSMI( MIIM_STRING
|MIIM_FTYPE
, MFT_STRING
|MFT_OWNERDRAW
, -1, -1, 0, 0, 0, -1, NULL
, 0, 0, OK
);
1197 TMII_GMII ( MIIM_STRING
|MIIM_FTYPE
, 80,
1198 MFT_OWNERDRAW
, 0, 0, 0, 0, 0, 0, string
, 0, 0,
1201 TMII_INSMI( MIIM_STRING
|MIIM_FTYPE
, MFT_STRING
, -1, -1, 0, 0, 0, -1, NULL
, 0, 0, OK
);
1202 TMII_GMII ( MIIM_STRING
|MIIM_FTYPE
, 80,
1203 MFT_SEPARATOR
, 0, 0, 0, 0, 0, 0, string
, 0, 0,
1207 /* How is that with bitmaps? */
1208 TMII_INSMI( MIIM_BITMAP
, -1, -1, -1, 0, 0, 0, -1, 0, -1, hbm
, OK
);
1209 TMII_GMII ( MIIM_TYPE
, 80,
1210 MFT_BITMAP
, 0, 0, 0, 0, 0, 0, hbm
, 0, hbm
,
1213 TMII_INSMI( MIIM_BITMAP
, -1, -1, -1, 0, 0, 0, -1, 0, -1, hbm
, OK
);
1214 TMII_GMII ( MIIM_BITMAP
|MIIM_FTYPE
, 80,
1215 0, 0, 0, 0, 0, 0, 0, string
, 80, hbm
,
1218 /* MIIM_BITMAP does not like MFT_BITMAP */
1219 TMII_INSMI( MIIM_BITMAP
|MIIM_FTYPE
, MFT_BITMAP
, -1, -1, 0, 0, 0, -1, 0, -1, hbm
, ER
);
1221 /* no problem with OWNERDRAWN */
1222 TMII_INSMI( MIIM_BITMAP
|MIIM_FTYPE
, MFT_OWNERDRAW
, -1, -1, 0, 0, 0, -1, 0, -1, hbm
, OK
);
1223 TMII_GMII ( MIIM_BITMAP
|MIIM_FTYPE
, 80,
1224 MFT_OWNERDRAW
, 0, 0, 0, 0, 0, 0, string
, 80, hbm
,
1227 /* setting MFT_BITMAP with MFT_FTYPE fails anyway */
1228 TMII_INSMI( MIIM_FTYPE
, MFT_BITMAP
, -1, -1, 0, 0, 0, -1, 0, -1, 0, ER
);
1231 /* menu with submenu */
1232 TMII_INSMI( MIIM_SUBMENU
|MIIM_FTYPE
, MFT_STRING
, -1, -1, submenu
, 0, 0, -1, txt
, 0, 0, OK
);
1233 TMII_GMII ( MIIM_SUBMENU
, 80,
1234 0, 0, 0, submenu
, 0, 0, 0, string
, 80, 0,
1237 TMII_INSMI( MIIM_SUBMENU
|MIIM_FTYPE
, MFT_STRING
, -1, -1, submenu
, 0, 0, -1, empty
, 0, 0, OK
);
1238 TMII_GMII ( MIIM_SUBMENU
, 80,
1239 0, 0, 0, submenu
, 0, 0, 0, string
, 80, 0,
1242 /* menu with submenu, without MIIM_SUBMENU the submenufield is cleared */
1243 TMII_INSMI( MIIM_SUBMENU
|MIIM_FTYPE
, MFT_STRING
, -1, -1, submenu
, 0, 0, -1, txt
, 0, 0, OK
);
1244 TMII_GMII ( MIIM_STRING
|MIIM_FTYPE
, 80,
1245 MFT_STRING
|MFT_SEPARATOR
, 0, 0, 0, 0, 0, 0, string
, 0, 0,
1247 TMII_GMII ( MIIM_SUBMENU
|MIIM_FTYPE
, 80,
1248 MFT_SEPARATOR
, 0, 0, submenu
, 0, 0, 0, string
, 80, 0,
1251 /* menu with invalid submenu */
1252 TMII_INSMI( MIIM_SUBMENU
|MIIM_FTYPE
, MFT_STRING
, -1, -1, (HMENU
)999, 0, 0, -1, txt
, 0, 0, ER
);
1255 TMII_INSMI( MIIM_TYPE
, MFT_SEPARATOR
, 0, 0, 0, 0, 0, 0, txt
, 0, 0, OK
);
1256 TMII_GMII ( MIIM_TYPE
, 80,
1257 MFT_SEPARATOR
, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1260 TMII_INSMI( MIIM_TYPE
, MFT_BITMAP
|MFT_SEPARATOR
, -1, -1, 0, 0, 0, -1, hbm
, 6, 0, OK
);
1261 TMII_GMII ( MIIM_TYPE
, 80,
1262 MFT_BITMAP
|MFT_SEPARATOR
, 0, 0, 0, 0, 0, 0, hbm
, 0, hbm
,
1265 /* SEPARATOR and STRING go well together */
1266 /* BITMAP and STRING go well together */
1267 TMII_INSMI( MIIM_STRING
|MIIM_BITMAP
, -1, -1, -1, 0, 0, 0, -1, txt
, 6, hbm
, OK
);
1268 TMII_GMII ( MIIM_FTYPE
|MIIM_STRING
|MIIM_BITMAP
, 80,
1269 MFT_STRING
, 0, 0, 0, 0, 0, 0, string
, 4, hbm
,
1272 /* BITMAP, SEPARATOR and STRING go well together */
1273 TMII_INSMI( MIIM_FTYPE
|MIIM_STRING
|MIIM_BITMAP
, MFT_SEPARATOR
, -1, -1, 0, 0, 0, -1, txt
, 6, hbm
, OK
);
1274 TMII_GMII ( MIIM_FTYPE
|MIIM_STRING
|MIIM_BITMAP
, 80,
1275 MFT_SEPARATOR
, 0, 0, 0, 0, 0, 0, string
, 4, hbm
,
1278 /* last two tests, but use MIIM_TYPE to retrieve info */
1279 TMII_INSMI( MIIM_FTYPE
|MIIM_STRING
, MFT_SEPARATOR
, -1, -1, 0, 0, 0, -1, txt
, 6, 0, OK
);
1280 TMII_GMII ( MIIM_TYPE
, 80,
1281 MFT_SEPARATOR
, 0, 0, 0, 0, 0, 0, NULL
, 4, NULL
,
1284 TMII_INSMI( MIIM_STRING
|MIIM_BITMAP
, -1, -1, -1, 0, 0, 0, -1, txt
, 6, hbm
, OK
);
1285 TMII_GMII ( MIIM_TYPE
, 80,
1286 MFT_BITMAP
, 0, 0, 0, 0, 0, 0, hbm
, 4, hbm
,
1289 TMII_INSMI( MIIM_FTYPE
|MIIM_STRING
|MIIM_BITMAP
, MFT_SEPARATOR
, -1, -1, 0, 0, 0, -1, txt
, 6, hbm
, OK
);
1290 TMII_GMII ( MIIM_TYPE
, 80,
1291 MFT_SEPARATOR
|MFT_BITMAP
, 0, 0, 0, 0, 0, 0, hbm
, 4, hbm
,
1294 /* same three with MFT_OWNERDRAW */
1295 TMII_INSMI( MIIM_FTYPE
|MIIM_STRING
, MFT_SEPARATOR
|MFT_OWNERDRAW
, -1, -1, 0, 0, 0, -1, txt
, 6, 0, OK
);
1296 TMII_GMII ( MIIM_TYPE
, 80,
1297 MFT_SEPARATOR
|MFT_OWNERDRAW
, 0, 0, 0, 0, 0, 0, NULL
, 4, NULL
,
1300 TMII_INSMI( MIIM_FTYPE
|MIIM_STRING
|MIIM_BITMAP
, MFT_OWNERDRAW
, -1, -1, 0, 0, 0, -1, txt
, 6, hbm
, OK
);
1301 TMII_GMII ( MIIM_TYPE
, 80,
1302 MFT_BITMAP
|MFT_OWNERDRAW
, 0, 0, 0, 0, 0, 0, hbm
, 4, hbm
,
1305 TMII_INSMI( MIIM_FTYPE
|MIIM_STRING
|MIIM_BITMAP
, MFT_SEPARATOR
|MFT_OWNERDRAW
, -1, -1, 0, 0, 0, -1, txt
, 6, hbm
, OK
);
1306 TMII_GMII ( MIIM_TYPE
, 80,
1307 MFT_SEPARATOR
|MFT_BITMAP
|MFT_OWNERDRAW
, 0, 0, 0, 0, 0, 0, hbm
, 4, hbm
,
1311 TMII_INSMI( MIIM_STRING
|MIIM_FTYPE
|MIIM_ID
, MFT_STRING
|MFT_OWNERDRAW
, -1, -1, 0, 0, 0, -1, txt
, 0, 0, OK
);
1312 TMII_GMII ( MIIM_TYPE
, 80,
1313 MFT_OWNERDRAW
, 0, 0, 0, 0, 0, 0, NULL
, 4, NULL
,
1316 /* test with modifymenu: string is preserved after setting OWNERDRAW */
1317 TMII_INSMI( MIIM_STRING
, MFT_STRING
, -1, -1, 0, 0, 0, -1, txt
, 0, 0, OK
);
1318 TMII_MODM( MFT_OWNERDRAW
, -1, (void*)787 );
1319 TMII_GMII ( MIIM_FTYPE
|MIIM_STRING
|MIIM_DATA
, 80,
1320 MFT_OWNERDRAW
, 0, 0, 0, 0, 0, 787, string
, 4, 0,
1323 /* same with bitmap: now the text is cleared */
1324 TMII_INSMI( MIIM_STRING
, MFT_STRING
, -1, -1, 0, 0, 0, -1, txt
, 0, 0, OK
);
1325 TMII_MODM( MFT_BITMAP
, 545, hbm
);
1326 TMII_GMII ( MIIM_FTYPE
|MIIM_STRING
|MIIM_BITMAP
|MIIM_ID
, 80,
1327 MFT_BITMAP
, 0, 545, 0, 0, 0, 0, string
, 0, hbm
,
1330 /* start with bitmap: now setting text clears it (though he flag is raised) */
1331 TMII_INSMI( MIIM_BITMAP
, MFT_STRING
, -1, -1, 0, 0, 0, -1, 0, -1, hbm
, OK
);
1332 TMII_GMII ( MIIM_FTYPE
|MIIM_STRING
|MIIM_BITMAP
|MIIM_ID
, 80,
1333 MFT_STRING
, 0, 0, 0, 0, 0, 0, string
, 0, hbm
,
1335 TMII_MODM( MFT_STRING
, 545, txt
);
1336 TMII_GMII ( MIIM_FTYPE
|MIIM_STRING
|MIIM_BITMAP
|MIIM_ID
, 80,
1337 MFT_STRING
, 0, 545, 0, 0, 0, 0, string
, 4, 0,
1340 /*repeat with text NULL */
1341 TMII_INSMI( MIIM_BITMAP
, MFT_STRING
, -1, -1, 0, 0, 0, -1, 0, -1, hbm
, OK
);
1342 TMII_MODM( MFT_STRING
, 545, NULL
);
1343 TMII_GMII ( MIIM_FTYPE
|MIIM_STRING
|MIIM_BITMAP
|MIIM_ID
, 80,
1344 MFT_SEPARATOR
, 0, 545, 0, 0, 0, 0, string
, 0, 0,
1347 /* repeat with text "" */
1348 TMII_INSMI( MIIM_BITMAP
, -1 , -1, -1, 0, 0, 0, -1, 0, -1, hbm
, OK
);
1349 TMII_MODM( MFT_STRING
, 545, empty
);
1350 TMII_GMII ( MIIM_FTYPE
|MIIM_STRING
|MIIM_BITMAP
|MIIM_ID
, 80,
1351 MFT_STRING
, 0, 545, 0, 0, 0, 0, string
, 0, 0,
1354 /* start with bitmap: set ownerdraw */
1355 TMII_INSMI( MIIM_BITMAP
, -1, -1, -1, 0, 0, 0, -1, 0, -1, hbm
, OK
);
1356 TMII_MODM( MFT_OWNERDRAW
, -1, (void *)232 );
1357 TMII_GMII ( MIIM_FTYPE
|MIIM_STRING
|MIIM_BITMAP
|MIIM_DATA
, 80,
1358 MFT_OWNERDRAW
, 0, 0, 0, 0, 0, 232, string
, 0, hbm
,
1362 TMII_INSMI( MIIM_FTYPE
|MIIM_STRING
|MIIM_BITMAP
, MFT_SEPARATOR
, -1, -1, 0, 0, 0, -1, txt
, 6, hbm
, OK
);
1364 0, 0, 0, 0, 0, 0, 0, string
, 80, 0,
1367 /* some tests with small cbSize: the hbmpItem is to be ignored */
1368 TMII_INSMI( MIIM_BITMAP
, -1, -1, -1, 0, 0, 0, -1, 0, -1, dummy_hbm
, OK
);
1369 TMII_GMII ( MIIM_TYPE
, 80,
1370 MFT_SEPARATOR
, 0, 0, 0, 0, 0, 0, NULL
, 0, NULL
,
1373 TMII_INSMI( MIIM_BITMAP
, -1, -1, -1, 0, 0, 0, -1, 0, -1, dummy_hbm
, OK
);
1374 TMII_GMII ( MIIM_BITMAP
|MIIM_FTYPE
, 80,
1375 MFT_SEPARATOR
, 0, 0, 0, 0, 0, 0, string
, 80, NULL
,
1378 TMII_INSMI( MIIM_STRING
|MIIM_BITMAP
, -1, -1, -1, 0, 0, 0, -1, txt
, 6, dummy_hbm
, OK
);
1379 TMII_GMII ( MIIM_TYPE
, 80,
1380 MFT_STRING
, 0, 0, 0, 0, 0, 0, string
, 4, NULL
,
1383 TMII_INSMI( MIIM_FTYPE
|MIIM_STRING
|MIIM_BITMAP
, MFT_SEPARATOR
, -1, -1, 0, 0, 0, -1, txt
, 6, dummy_hbm
, OK
);
1384 TMII_GMII ( MIIM_TYPE
, 80,
1385 MFT_SEPARATOR
, 0, 0, 0, 0, 0, 0, NULL
, 4, NULL
,
1388 TMII_INSMI( MIIM_FTYPE
|MIIM_STRING
|MIIM_BITMAP
, MFT_OWNERDRAW
, -1, -1, 0, 0, 0, -1, txt
, 6, dummy_hbm
, OK
);
1389 TMII_GMII ( MIIM_TYPE
, 80,
1390 MFT_OWNERDRAW
, 0, 0, 0, 0, 0, 0, NULL
, 4, NULL
,
1393 TMII_INSMI( MIIM_FTYPE
|MIIM_STRING
|MIIM_BITMAP
, MFT_SEPARATOR
|MFT_OWNERDRAW
, -1, -1, 0, 0, 0, -1, txt
, 6, dummy_hbm
, OK
);
1394 TMII_GMII ( MIIM_TYPE
, 80,
1395 MFT_SEPARATOR
|MFT_OWNERDRAW
, 0, 0, 0, 0, 0, 0, NULL
, 4, NULL
,
1398 /* MIIM_TYPE by itself does not get/set the dwItemData for OwnerDrawn menus */
1399 TMII_INSMI( MIIM_TYPE
|MIIM_DATA
, MFT_STRING
|MFT_OWNERDRAW
, -1, -1, 0, 0, 0, 343, txt
, 0, 0, OK
);
1400 TMII_GMII ( MIIM_TYPE
|MIIM_DATA
, 80,
1401 MFT_STRING
|MFT_OWNERDRAW
, 0, 0, 0, 0, 0, 343, 0, 0, 0,
1404 TMII_INSMI( MIIM_TYPE
|MIIM_DATA
, MFT_STRING
|MFT_OWNERDRAW
, -1, -1, 0, 0, 0, 343, txt
, 0, 0, OK
);
1405 TMII_GMII ( MIIM_TYPE
, 80,
1406 MFT_STRING
|MFT_OWNERDRAW
, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1409 TMII_INSMI( MIIM_TYPE
, MFT_STRING
|MFT_OWNERDRAW
, -1, -1, 0, 0, 0, 343, txt
, 0, 0, OK
);
1410 TMII_GMII ( MIIM_TYPE
|MIIM_DATA
, 80,
1411 MFT_STRING
|MFT_OWNERDRAW
, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1414 /* set a string menu to ownerdraw with MIIM_TYPE */
1415 TMII_INSMI( MIIM_TYPE
, MFT_STRING
, -2, -2, 0, 0, 0, -2, txt
, -2, 0, OK
);
1416 TMII_SMII ( MIIM_TYPE
, MFT_OWNERDRAW
, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
1417 TMII_GMII ( MIIM_STRING
|MIIM_FTYPE
, 80,
1418 MFT_OWNERDRAW
, 0, 0, 0, 0, 0, 0, string
, 4, 0,
1421 /* test with modifymenu add submenu */
1422 TMII_INSMI( MIIM_STRING
, MFT_STRING
, -1, -1, 0, 0, 0, -1, txt
, 0, 0, OK
);
1423 TMII_MODM( MF_POPUP
, (UINT_PTR
)submenu
, txt
);
1424 TMII_GMII ( MIIM_FTYPE
|MIIM_STRING
|MIIM_SUBMENU
, 80,
1425 MFT_STRING
, 0, 0, submenu
, 0, 0, 0, string
, 4, 0,
1427 TMII_GMII ( MIIM_TYPE
, 80,
1428 MFT_STRING
, 0, 0, 0, 0, 0, 0, string
, 4, 0,
1431 /* MFT_SEPARATOR bit is kept when the text is added */
1432 TMII_INSMI( MIIM_STRING
|MIIM_FTYPE
, MFT_STRING
, -1, -1, 0, 0, 0, -1, NULL
, 0, 0, OK
);
1433 TMII_SMII( MIIM_STRING
, 0, 0, 0, 0, 0, 0, 0, txt
, 0, 0 );
1434 TMII_GMII ( MIIM_STRING
|MIIM_FTYPE
, 80,
1435 MFT_SEPARATOR
, 0, 0, 0, 0, 0, 0, string
, 4, 0,
1438 /* MFT_SEPARATOR bit is kept when bitmap is added */
1439 TMII_INSMI( MIIM_STRING
|MIIM_FTYPE
, MFT_STRING
, -1, -1, 0, 0, 0, -1, NULL
, 0, 0, OK
);
1440 TMII_SMII( MIIM_BITMAP
, 0, 0, 0, 0, 0, 0, 0, 0, 0, hbm
);
1441 TMII_GMII ( MIIM_BITMAP
|MIIM_FTYPE
, 80,
1442 MFT_SEPARATOR
, 0, 0, 0, 0, 0, 0, string
, 80, hbm
,
1445 /* Bitmaps inserted with MIIM_TYPE and MFT_BITMAP:
1446 Only the low word of the dwTypeData is used.
1447 Use a magic bitmap here (Word 95 uses this to create its MDI menu buttons) */
1448 TMII_INSMI( MIIM_TYPE
, MFT_BITMAP
| MFT_RIGHTJUSTIFY
, -1, -1, 0, 0, 0, -1,
1449 (HMENU
)MAKELONG(HBMMENU_MBAR_CLOSE
, 0x1234), -1, 0, OK
);
1450 TMII_GMII ( MIIM_TYPE
, 80,
1451 MFT_BITMAP
| MFT_RIGHTJUSTIFY
, 0, 0, 0, 0, 0, 0, HBMMENU_MBAR_CLOSE
, 0, HBMMENU_MBAR_CLOSE
,
1455 TMII_INSMI( MIIM_TYPE
, MFT_BITMAP
| MFT_MENUBARBREAK
| MFT_RADIOCHECK
| MFT_RIGHTJUSTIFY
| MFT_RIGHTORDER
, -1, -1, 0, 0, 0, -1, hbm
, -1, 0, OK
);
1456 TMII_GMII ( MIIM_TYPE
, 80,
1457 MFT_BITMAP
| MFT_MENUBARBREAK
| MFT_RADIOCHECK
| MFT_RIGHTJUSTIFY
| MFT_RIGHTORDER
, 0, 0, 0, 0, 0, 0, hbm
, 0, hbm
,
1461 TMII_INSMI( MIIM_TYPE
, MFT_BITMAP
, -1, -1, 0, 0, 0, -1, hbm
, -1, 0, OK
);
1462 TMII_SMII( MIIM_STATE
, -1, MFS_CHECKED
| MFS_DEFAULT
| MFS_GRAYED
| MFS_HILITE
, 0, 0, 0, 0, 0, 0, 0, 0 );
1463 TMII_GMII ( MIIM_STATE
, 80,
1464 0, MFS_CHECKED
| MFS_DEFAULT
| MFS_GRAYED
| MFS_HILITE
, 0, 0, 0, 0, 0, 0, 80, 0,
1467 /* The style MFT_RADIOCHECK cannot be set with MIIM_CHECKMARKS only */
1468 TMII_INSMI( MIIM_TYPE
, MFT_BITMAP
, -1, -1, 0, 0, 0, -1, hbm
, -1, 0, OK
);
1469 TMII_SMII( MIIM_CHECKMARKS
, MFT_RADIOCHECK
, 0, 0, 0, hbm
, hbm
, 0, 0, 0, 0 );
1470 TMII_GMII ( MIIM_CHECKMARKS
| MIIM_TYPE
, 80,
1471 MFT_BITMAP
, 0, 0, 0, hbm
, hbm
, 0, hbm
, 0, hbm
,
1474 /* MFT_BITMAP is added automatically by GetMenuItemInfo() for MIIM_TYPE */
1475 TMII_INSMI( MIIM_TYPE
, MFT_BITMAP
, -1, -1, 0, 0, 0, -1, hbm
, -1, 0, OK
);
1476 TMII_SMII( MIIM_FTYPE
, MFT_OWNERDRAW
, 0, 0, 0, 0, 0, 0, (HBITMAP
)0x1234, 0, 0 );
1477 TMII_GMII ( MIIM_FTYPE
, 80,
1478 MFT_OWNERDRAW
, 0, 0, 0, 0, 0, 0, 0, 80, 0,
1480 TMII_GMII ( MIIM_TYPE
, 80,
1481 MFT_BITMAP
| MFT_OWNERDRAW
, 0, 0, 0, 0, 0, 0, hbm
, 0, hbm
,
1483 TMII_GMII ( MIIM_FTYPE
, 80,
1484 MFT_OWNERDRAW
, 0, 0, 0, 0, 0, 0, 0, 80, 0,
1486 TMII_SMII( MIIM_BITMAP
, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL
);
1487 TMII_GMII ( MIIM_TYPE
, 80,
1488 MFT_OWNERDRAW
, 0, 0, 0, 0, 0, 0, NULL
, 0, NULL
,
1491 /* Bitmaps inserted with MIIM_TYPE and MFT_BITMAP:
1492 Only the low word of the dwTypeData is used.
1493 Use a magic bitmap here (Word 95 uses this to create its MDI menu buttons) */
1494 TMII_INSMI( MIIM_TYPE
, MFT_BITMAP
| MFT_RIGHTJUSTIFY
, -1, -1, 0, 0, 0, -1,
1495 (HMENU
)MAKELONG(HBMMENU_MBAR_CLOSE
, 0x1234), -1, 0, OK
);
1496 TMII_GMII ( MIIM_TYPE
, 80,
1497 MFT_BITMAP
| MFT_RIGHTJUSTIFY
, 0, 0, 0, 0, 0, 0, HBMMENU_MBAR_CLOSE
, 0, HBMMENU_MBAR_CLOSE
,
1501 TMII_INSMI( MIIM_TYPE
, MFT_BITMAP
| MFT_MENUBARBREAK
| MFT_RADIOCHECK
| MFT_RIGHTJUSTIFY
| MFT_RIGHTORDER
, -1, -1, 0, 0, 0, -1, hbm
, -1, 0, OK
);
1502 TMII_GMII ( MIIM_TYPE
, 80,
1503 MFT_BITMAP
| MFT_MENUBARBREAK
| MFT_RADIOCHECK
| MFT_RIGHTJUSTIFY
| MFT_RIGHTORDER
, 0, 0, 0, 0, 0, 0, hbm
, 0, hbm
,
1507 TMII_INSMI( MIIM_TYPE
, MFT_BITMAP
, -1, -1, 0, 0, 0, -1, hbm
, -1, 0, OK
);
1508 TMII_SMII( MIIM_STATE
, -1, MFS_CHECKED
| MFS_DEFAULT
| MFS_GRAYED
| MFS_HILITE
, 0, 0, 0, 0, 0, 0, 0, 0 );
1509 TMII_GMII ( MIIM_STATE
, 80,
1510 0, MFS_CHECKED
| MFS_DEFAULT
| MFS_GRAYED
| MFS_HILITE
, 0, 0, 0, 0, 0, 0, 80, 0,
1513 /* The style MFT_RADIOCHECK cannot be set with MIIM_CHECKMARKS only */
1514 TMII_INSMI( MIIM_TYPE
, MFT_BITMAP
, -1, -1, 0, 0, 0, -1, hbm
, -1, 0, OK
);
1515 TMII_SMII( MIIM_CHECKMARKS
, MFT_RADIOCHECK
, 0, 0, 0, hbm
, hbm
, 0, 0, 0, 0 );
1516 TMII_GMII ( MIIM_CHECKMARKS
| MIIM_TYPE
, 80,
1517 MFT_BITMAP
, 0, 0, 0, hbm
, hbm
, 0, hbm
, 0, hbm
,
1520 /* MFT_BITMAP is added automatically by GetMenuItemInfo() for MIIM_TYPE */
1521 TMII_INSMI( MIIM_TYPE
, MFT_BITMAP
, -1, -1, 0, 0, 0, -1, hbm
, -1, 0, OK
);
1522 TMII_SMII( MIIM_FTYPE
, MFT_OWNERDRAW
, 0, 0, 0, 0, 0, 0, (HBITMAP
)0x1234, 0, 0 );
1523 TMII_GMII ( MIIM_FTYPE
, 80,
1524 MFT_OWNERDRAW
, 0, 0, 0, 0, 0, 0, 0, 80, 0,
1526 TMII_GMII ( MIIM_TYPE
, 80,
1527 MFT_BITMAP
| MFT_OWNERDRAW
, 0, 0, 0, 0, 0, 0, hbm
, 0, hbm
,
1529 TMII_GMII ( MIIM_FTYPE
, 80,
1530 MFT_OWNERDRAW
, 0, 0, 0, 0, 0, 0, 0, 80, 0,
1532 TMII_SMII( MIIM_BITMAP
, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL
);
1533 TMII_GMII ( MIIM_TYPE
, 80,
1534 MFT_OWNERDRAW
, 0, 0, 0, 0, 0, 0, NULL
, 0, NULL
,
1537 } while( !(ansi
= !ansi
) );
1542 The following tests try to confirm the algorithm used to return the menu items
1543 when there is a collision between a menu item and a popup menu
1545 static void test_menu_search_bycommand( void )
1547 HMENU hmenu
, hmenuSub
, hmenuSub2
;
1553 static CHAR menuitem
[] = "MenuItem",
1554 menuitem2
[] = "MenuItem 2";
1556 /* Case 1: Menu containing a menu item */
1557 hmenu
= CreateMenu();
1559 memset( &info
, 0, sizeof info
);
1560 info
.cbSize
= sizeof info
;
1561 info
.fMask
= MIIM_FTYPE
| MIIM_STRING
| MIIM_ID
;
1562 info
.fType
= MFT_STRING
;
1563 strcpy(strIn
, "Case 1 MenuItem");
1564 info
.dwTypeData
= strIn
;
1565 info
.wID
= (UINT
) 0x1234;
1567 rc
= InsertMenuItem(hmenu
, 0, TRUE
, &info
);
1568 ok (rc
, "Inserting the menuitem failed\n");
1570 id
= GetMenuItemID(hmenu
, 0);
1571 ok (id
== 0x1234, "Getting the menuitem id failed(gave %x)\n", id
);
1573 /* Confirm the menuitem was given the id supplied (getting by position) */
1574 memset( &info
, 0, sizeof info
);
1576 info
.cbSize
= sizeof(MENUITEMINFO
);
1577 info
.fMask
= MIIM_FTYPE
| MIIM_ID
| MIIM_STRING
;
1578 info
.dwTypeData
= strback
;
1579 info
.cch
= sizeof(strback
);
1581 rc
= GetMenuItemInfo(hmenu
, 0, TRUE
, &info
); /* Get by position */
1582 ok (rc
, "Getting the menu items info failed\n");
1583 ok (info
.wID
== 0x1234, "IDs differ for the menuitem\n");
1584 ok (!strcmp(info
.dwTypeData
, "Case 1 MenuItem"), "Returned item has wrong label\n");
1586 /* Search by id - Should return the item */
1587 memset( &info
, 0, sizeof info
);
1589 info
.cbSize
= sizeof(MENUITEMINFO
);
1590 info
.fMask
= MIIM_FTYPE
| MIIM_ID
| MIIM_STRING
;
1591 info
.dwTypeData
= strback
;
1592 info
.cch
= sizeof(strback
);
1593 rc
= GetMenuItemInfo(hmenu
, 0x1234, FALSE
, &info
); /* Get by ID */
1595 ok (rc
, "Getting the menu items info failed\n");
1596 ok (info
.wID
== 0x1234, "IDs differ for the menuitem\n");
1597 ok (!strcmp(info
.dwTypeData
, "Case 1 MenuItem"), "Returned item has wrong label\n");
1599 DestroyMenu( hmenu
);
1601 /* Case 2: Menu containing a popup menu */
1602 hmenu
= CreateMenu();
1603 hmenuSub
= CreateMenu();
1605 strcpy(strIn
, "Case 2 SubMenu");
1606 rc
= InsertMenu(hmenu
, 0, MF_BYPOSITION
| MF_POPUP
| MF_STRING
, (UINT_PTR
)hmenuSub
, strIn
);
1607 ok (rc
, "Inserting the popup menu into the main menu failed\n");
1609 id
= GetMenuItemID(hmenu
, 0);
1610 ok (id
== -1, "Getting the menuitem id unexpectedly worked (gave %x)\n", id
);
1612 /* Confirm the menuitem itself was given an id the same as the HMENU, (getting by position) */
1613 memset( &info
, 0, sizeof info
);
1615 info
.cbSize
= sizeof(MENUITEMINFO
);
1616 info
.fMask
= MIIM_FTYPE
| MIIM_ID
| MIIM_STRING
;
1617 info
.dwTypeData
= strback
;
1618 info
.cch
= sizeof(strback
);
1619 info
.wID
= 0xdeadbeef;
1621 rc
= GetMenuItemInfo(hmenu
, 0, TRUE
, &info
); /* Get by position */
1622 ok (rc
, "Getting the menu items info failed\n");
1623 ok (info
.wID
== (UINT_PTR
)hmenuSub
, "IDs differ for the menuitem\n");
1624 ok (!strcmp(info
.dwTypeData
, "Case 2 SubMenu"), "Returned item has wrong label\n");
1626 /* Search by id - returns the popup menu itself */
1627 memset( &info
, 0, sizeof info
);
1629 info
.cbSize
= sizeof(MENUITEMINFO
);
1630 info
.fMask
= MIIM_FTYPE
| MIIM_ID
| MIIM_STRING
;
1631 info
.dwTypeData
= strback
;
1632 info
.cch
= sizeof(strback
);
1633 rc
= GetMenuItemInfo(hmenu
, (UINT_PTR
)hmenuSub
, FALSE
, &info
); /* Get by ID */
1635 ok (rc
, "Getting the menu items info failed\n");
1636 ok (info
.wID
== (UINT_PTR
)hmenuSub
, "IDs differ for the popup menu\n");
1637 ok (!strcmp(info
.dwTypeData
, "Case 2 SubMenu"), "Returned item has wrong label\n");
1640 Now add an item after it with the same id
1642 memset( &info
, 0, sizeof info
);
1643 info
.cbSize
= sizeof info
;
1644 info
.fMask
= MIIM_FTYPE
| MIIM_STRING
| MIIM_ID
;
1645 info
.fType
= MFT_STRING
;
1646 strcpy(strIn
, "Case 2 MenuItem 1");
1647 info
.dwTypeData
= strIn
;
1648 info
.wID
= (UINT_PTR
) hmenuSub
;
1649 rc
= InsertMenuItem(hmenu
, -1, TRUE
, &info
);
1650 ok (rc
, "Inserting the menuitem failed\n");
1652 /* Search by id - returns the item which follows the popup menu */
1653 memset( &info
, 0, sizeof info
);
1655 info
.cbSize
= sizeof(MENUITEMINFO
);
1656 info
.fMask
= MIIM_FTYPE
| MIIM_ID
| MIIM_STRING
;
1657 info
.dwTypeData
= strback
;
1658 info
.cch
= sizeof(strback
);
1659 rc
= GetMenuItemInfo(hmenu
, (UINT_PTR
)hmenuSub
, FALSE
, &info
); /* Get by ID */
1661 ok (rc
, "Getting the menu items info failed\n");
1662 ok (info
.wID
== (UINT_PTR
)hmenuSub
, "IDs differ for the popup menu\n");
1663 ok (!strcmp(info
.dwTypeData
, "Case 2 MenuItem 1"), "Returned item has wrong label (%s)\n", info
.dwTypeData
);
1666 Now add an item before the popup (with the same id)
1668 memset( &info
, 0, sizeof info
);
1669 info
.cbSize
= sizeof info
;
1670 info
.fMask
= MIIM_FTYPE
| MIIM_STRING
| MIIM_ID
;
1671 info
.fType
= MFT_STRING
;
1672 strcpy(strIn
, "Case 2 MenuItem 2");
1673 info
.dwTypeData
= strIn
;
1674 info
.wID
= (UINT_PTR
) hmenuSub
;
1675 rc
= InsertMenuItem(hmenu
, 0, TRUE
, &info
);
1676 ok (rc
, "Inserting the menuitem failed\n");
1678 /* Search by id - returns the item which precedes the popup menu */
1679 memset( &info
, 0, sizeof info
);
1681 info
.cbSize
= sizeof(MENUITEMINFO
);
1682 info
.fMask
= MIIM_FTYPE
| MIIM_ID
| MIIM_STRING
;
1683 info
.dwTypeData
= strback
;
1684 info
.cch
= sizeof(strback
);
1685 rc
= GetMenuItemInfo(hmenu
, (UINT_PTR
)hmenuSub
, FALSE
, &info
); /* Get by ID */
1687 ok (rc
, "Getting the menu items info failed\n");
1688 ok (info
.wID
== (UINT_PTR
)hmenuSub
, "IDs differ for the popup menu\n");
1689 ok (!strcmp(info
.dwTypeData
, "Case 2 MenuItem 2"), "Returned item has wrong label (%s)\n", info
.dwTypeData
);
1691 DestroyMenu( hmenu
);
1692 DestroyMenu( hmenuSub
);
1695 Case 3: Menu containing a popup menu which in turn
1696 contains 2 items with the same id as the popup itself
1699 hmenu
= CreateMenu();
1700 hmenuSub
= CreateMenu();
1702 memset( &info
, 0, sizeof info
);
1703 info
.cbSize
= sizeof info
;
1704 info
.fMask
= MIIM_FTYPE
| MIIM_STRING
| MIIM_ID
;
1705 info
.fType
= MFT_STRING
;
1706 info
.dwTypeData
= menuitem
;
1707 info
.wID
= (UINT_PTR
) hmenuSub
; /* Enforce id collisions with the hmenu of the popup submenu*/
1709 rc
= InsertMenu(hmenu
, 0, MF_BYPOSITION
| MF_POPUP
| MF_STRING
, (UINT_PTR
)hmenuSub
, "Submenu");
1710 ok (rc
, "Inserting the popup menu into the main menu failed\n");
1712 rc
= InsertMenuItem(hmenuSub
, 0, TRUE
, &info
);
1713 ok (rc
, "Inserting the sub menu menuitem failed\n");
1715 memset( &info
, 0, sizeof info
);
1716 info
.cbSize
= sizeof info
;
1717 info
.fMask
= MIIM_FTYPE
| MIIM_STRING
| MIIM_ID
;
1718 info
.fType
= MFT_STRING
;
1719 info
.dwTypeData
= menuitem2
;
1720 info
.wID
= (UINT_PTR
) hmenuSub
; /* Enforce id collisions with the hmenu of the popup submenu*/
1722 rc
= InsertMenuItem(hmenuSub
, 1, TRUE
, &info
);
1723 ok (rc
, "Inserting the sub menu menuitem 2 failed\n");
1725 /* Prove that you can't query the id of a popup directly (By position) */
1726 id
= GetMenuItemID(hmenu
, 0);
1727 ok (id
== -1, "Getting the sub menu id should have failed because its a popup (gave %x)\n", id
);
1729 /* Prove getting the item info via ID returns the first item (not the popup or 2nd item)*/
1730 memset( &info
, 0, sizeof info
);
1732 info
.cbSize
= sizeof(MENUITEMINFO
);
1733 info
.fMask
= MIIM_STRING
| MIIM_ID
;
1734 info
.dwTypeData
= strback
;
1735 info
.cch
= sizeof(strback
);
1737 rc
= GetMenuItemInfo(hmenu
, (UINT_PTR
)hmenuSub
, FALSE
, &info
);
1738 ok (rc
, "Getting the menus info failed\n");
1739 ok (info
.wID
== (UINT_PTR
)hmenuSub
, "IDs differ for popup menu\n");
1740 ok (!strcmp(info
.dwTypeData
, "MenuItem"), "Returned item has wrong label (%s)\n", info
.dwTypeData
);
1741 DestroyMenu( hmenu
);
1742 DestroyMenu( hmenuSub
);
1745 Case 4: Menu containing 2 popup menus, the second
1746 contains 2 items with the same id as the first popup menu
1748 hmenu
= CreateMenu();
1749 hmenuSub
= CreateMenu();
1750 hmenuSub2
= CreateMenu();
1752 rc
= InsertMenu(hmenu
, 0, MF_BYPOSITION
| MF_POPUP
| MF_STRING
, (UINT_PTR
)hmenuSub
, "Submenu");
1753 ok (rc
, "Inserting the popup menu into the main menu failed\n");
1755 rc
= InsertMenu(hmenu
, 1, MF_BYPOSITION
| MF_POPUP
| MF_STRING
, (UINT_PTR
)hmenuSub2
, "Submenu2");
1756 ok (rc
, "Inserting the popup menu into the main menu failed\n");
1758 memset( &info
, 0, sizeof info
);
1759 info
.cbSize
= sizeof info
;
1760 info
.fMask
= MIIM_FTYPE
| MIIM_STRING
| MIIM_ID
;
1761 info
.fType
= MFT_STRING
;
1762 info
.dwTypeData
= menuitem
;
1763 info
.wID
= (UINT_PTR
) hmenuSub
; /* Enforce id collisions with the hmenu of the popup submenu*/
1765 rc
= InsertMenuItem(hmenuSub2
, 0, TRUE
, &info
);
1766 ok (rc
, "Inserting the sub menu menuitem failed\n");
1768 memset( &info
, 0, sizeof info
);
1769 info
.cbSize
= sizeof info
;
1770 info
.fMask
= MIIM_FTYPE
| MIIM_STRING
| MIIM_ID
;
1771 info
.fType
= MFT_STRING
;
1772 info
.dwTypeData
= menuitem2
;
1773 info
.wID
= (UINT_PTR
) hmenuSub
; /* Enforce id collisions with the hmenu of the popup submenu*/
1775 rc
= InsertMenuItem(hmenuSub2
, 1, TRUE
, &info
);
1776 ok (rc
, "Inserting the sub menu menuitem 2 failed\n");
1778 /* Prove getting the item info via ID returns the first item (not the popup or 2nd item)*/
1779 memset( &info
, 0, sizeof info
);
1781 info
.cbSize
= sizeof(MENUITEMINFO
);
1782 info
.fMask
= MIIM_STRING
| MIIM_ID
;
1783 info
.dwTypeData
= strback
;
1784 info
.cch
= sizeof(strback
);
1786 rc
= GetMenuItemInfo(hmenu
, (UINT_PTR
)hmenuSub
, FALSE
, &info
);
1787 ok (rc
, "Getting the menus info failed\n");
1788 ok (info
.wID
== (UINT_PTR
)hmenuSub
, "IDs differ for popup menu\n");
1789 ok (!strcmp(info
.dwTypeData
, "MenuItem"), "Returned item has wrong label (%s)\n", info
.dwTypeData
);
1791 memset( &info
, 0, sizeof info
);
1793 info
.cbSize
= sizeof(MENUITEMINFO
);
1794 info
.fMask
= MIIM_STRING
| MIIM_ID
;
1795 info
.dwTypeData
= strback
;
1796 info
.cch
= sizeof(strback
);
1798 rc
= GetMenuItemInfo(hmenu
, (UINT_PTR
)hmenuSub2
, FALSE
, &info
);
1799 ok (rc
, "Getting the menus info failed\n");
1800 ok (info
.wID
== (UINT_PTR
)hmenuSub2
, "IDs differ for popup menu\n");
1801 ok (!strcmp(info
.dwTypeData
, "Submenu2"), "Returned item has wrong label (%s)\n", info
.dwTypeData
);
1803 DestroyMenu( hmenu
);
1804 DestroyMenu( hmenuSub
);
1805 DestroyMenu( hmenuSub2
);
1809 Case 5: Menu containing a popup menu which in turn
1810 contains an item with a different id than the popup menu.
1811 This tests the fallback to a popup menu ID.
1814 hmenu
= CreateMenu();
1815 hmenuSub
= CreateMenu();
1817 rc
= AppendMenu(hmenu
, MF_POPUP
| MF_STRING
, (UINT_PTR
)hmenuSub
, "Submenu");
1818 ok (rc
, "Appending the popup menu to the main menu failed\n");
1820 rc
= AppendMenu(hmenuSub
, MF_STRING
, 102, "Item");
1821 ok (rc
, "Appending the item to the popup menu failed\n");
1823 /* Set the ID for hmenuSub */
1824 info
.cbSize
= sizeof(info
);
1825 info
.fMask
= MIIM_ID
;
1828 rc
= SetMenuItemInfo(hmenu
, 0, TRUE
, &info
);
1829 ok(rc
, "Setting the ID for the popup menu failed\n");
1831 /* Check if the ID has been set */
1833 rc
= GetMenuItemInfo(hmenu
, 0, TRUE
, &info
);
1834 ok(rc
, "Getting the ID for the popup menu failed\n");
1835 ok(info
.wID
== 101, "The ID for the popup menu has not been set\n");
1837 /* Prove getting the item info via ID returns the popup menu */
1838 memset( &info
, 0, sizeof(info
));
1840 info
.cbSize
= sizeof(MENUITEMINFO
);
1841 info
.fMask
= MIIM_STRING
| MIIM_ID
;
1842 info
.dwTypeData
= strback
;
1843 info
.cch
= sizeof(strback
);
1845 rc
= GetMenuItemInfo(hmenu
, 101, FALSE
, &info
);
1846 ok (rc
, "Getting the menu info failed\n");
1847 ok (info
.wID
== 101, "IDs differ\n");
1848 ok (!strcmp(info
.dwTypeData
, "Submenu"), "Returned item has wrong label (%s)\n", info
.dwTypeData
);
1850 /* Also look for the menu item */
1851 memset( &info
, 0, sizeof(info
));
1853 info
.cbSize
= sizeof(MENUITEMINFO
);
1854 info
.fMask
= MIIM_STRING
| MIIM_ID
;
1855 info
.dwTypeData
= strback
;
1856 info
.cch
= sizeof(strback
);
1858 rc
= GetMenuItemInfo(hmenu
, 102, FALSE
, &info
);
1859 ok (rc
, "Getting the menu info failed\n");
1860 ok (info
.wID
== 102, "IDs differ\n");
1861 ok (!strcmp(info
.dwTypeData
, "Item"), "Returned item has wrong label (%s)\n", info
.dwTypeData
);
1864 DestroyMenu(hmenuSub
);
1867 struct menu_item_pair_s
{
1868 UINT uMenu
; /* 1 - top level menu, [0-Menu 1-Enabled 2-Disabled]
1869 * 2 - 2nd level menu, [0-Popup 1-Enabled 2-Disabled]
1870 * 3 - 3rd level menu, [0-Enabled 1-Disabled] */
1874 static struct menu_mouse_tests_s
{
1876 struct menu_item_pair_s menu_item_pairs
[5]; /* for mousing */
1877 WORD wVk
[5]; /* keys */
1881 /* for each test, send keys or clicks and check for menu visibility */
1882 { INPUT_KEYBOARD
, {{0}}, {VK_MENU
, 0}, TRUE
, FALSE
}, /* test 0 */
1883 { INPUT_KEYBOARD
, {{0}}, {VK_ESCAPE
, 0}, FALSE
, FALSE
},
1884 { INPUT_KEYBOARD
, {{0}}, {VK_MENU
, 0}, TRUE
, FALSE
},
1885 { INPUT_KEYBOARD
, {{0}}, {'D', 0}, FALSE
, FALSE
},
1886 { INPUT_KEYBOARD
, {{0}}, {VK_MENU
, 0}, TRUE
, FALSE
},
1887 { INPUT_KEYBOARD
, {{0}}, {'E', 0}, FALSE
, FALSE
},
1888 { INPUT_KEYBOARD
, {{0}}, {VK_MENU
, 'M', 0}, TRUE
, FALSE
},
1889 { INPUT_KEYBOARD
, {{0}}, {VK_ESCAPE
, VK_ESCAPE
, 0}, FALSE
, FALSE
},
1890 { INPUT_KEYBOARD
, {{0}}, {VK_MENU
, 'M', VK_ESCAPE
, 0}, TRUE
, FALSE
},
1891 { INPUT_KEYBOARD
, {{0}}, {VK_ESCAPE
, 0}, FALSE
, FALSE
},
1892 { INPUT_KEYBOARD
, {{0}}, {VK_MENU
, 'M', 0}, TRUE
, FALSE
},
1893 { INPUT_KEYBOARD
, {{0}}, {'D', 0}, FALSE
, FALSE
},
1894 { INPUT_KEYBOARD
, {{0}}, {VK_MENU
, 'M', 0}, TRUE
, FALSE
},
1895 { INPUT_KEYBOARD
, {{0}}, {'E', 0}, FALSE
, FALSE
},
1896 { INPUT_KEYBOARD
, {{0}}, {VK_MENU
, 'M', 'P', 0}, TRUE
, FALSE
},
1897 { INPUT_KEYBOARD
, {{0}}, {'D', 0}, FALSE
, FALSE
},
1898 { INPUT_KEYBOARD
, {{0}}, {VK_MENU
, 'M', 'P', 0}, TRUE
, FALSE
},
1899 { INPUT_KEYBOARD
, {{0}}, {'E', 0}, FALSE
, FALSE
},
1900 { INPUT_KEYBOARD
, {{0}}, {VK_F10
, 0}, TRUE
, FALSE
},
1901 { INPUT_KEYBOARD
, {{0}}, {VK_F10
, 0}, FALSE
, FALSE
},
1903 { INPUT_MOUSE
, {{1, 2}, {0}}, {0}, TRUE
, TRUE
}, /* test 20 */
1904 { INPUT_MOUSE
, {{1, 1}, {0}}, {0}, FALSE
, FALSE
},
1905 { INPUT_MOUSE
, {{1, 0}, {0}}, {0}, TRUE
, TRUE
},
1906 { INPUT_MOUSE
, {{1, 1}, {0}}, {0}, FALSE
, FALSE
},
1907 { INPUT_MOUSE
, {{1, 0}, {2, 2}, {0}}, {0}, TRUE
, TRUE
},
1908 { INPUT_MOUSE
, {{2, 1}, {0}}, {0}, FALSE
, FALSE
},
1909 { INPUT_MOUSE
, {{1, 0}, {2, 0}, {0}}, {0}, TRUE
, TRUE
},
1910 { INPUT_MOUSE
, {{3, 0}, {0}}, {0}, FALSE
, FALSE
},
1911 { INPUT_MOUSE
, {{1, 0}, {2, 0}, {0}}, {0}, TRUE
, TRUE
},
1912 { INPUT_MOUSE
, {{3, 1}, {0}}, {0}, TRUE
, TRUE
},
1913 { INPUT_MOUSE
, {{1, 1}, {0}}, {0}, FALSE
, FALSE
},
1917 static void send_key(WORD wVk
)
1920 memset(i
, 0, sizeof(i
));
1921 i
[0].type
= i
[1].type
= INPUT_KEYBOARD
;
1922 i
[0].u
.ki
.wVk
= i
[1].u
.ki
.wVk
= wVk
;
1923 i
[1].u
.ki
.dwFlags
= KEYEVENTF_KEYUP
;
1924 pSendInput(2, (INPUT
*) i
, sizeof(INPUT
));
1927 static BOOL
click_menu(HANDLE hWnd
, struct menu_item_pair_s
*mi
)
1929 HMENU hMenu
= hMenus
[mi
->uMenu
];
1933 int screen_w
= GetSystemMetrics(SM_CXSCREEN
);
1934 int screen_h
= GetSystemMetrics(SM_CYSCREEN
);
1935 BOOL ret
= GetMenuItemRect(mi
->uMenu
> 2 ? NULL
: hWnd
, hMenu
, mi
->uItem
, &r
);
1936 if(!ret
) return FALSE
;
1938 memset(i
, 0, sizeof(i
));
1939 i
[0].type
= i
[1].type
= i
[2].type
= INPUT_MOUSE
;
1940 i
[0].u
.mi
.dx
= i
[1].u
.mi
.dx
= i
[2].u
.mi
.dx
1941 = ((r
.left
+ 5) * 65535) / screen_w
;
1942 i
[0].u
.mi
.dy
= i
[1].u
.mi
.dy
= i
[2].u
.mi
.dy
1943 = ((r
.top
+ 5) * 65535) / screen_h
;
1944 i
[0].u
.mi
.dwFlags
= i
[1].u
.mi
.dwFlags
= i
[2].u
.mi
.dwFlags
1945 = MOUSEEVENTF_ABSOLUTE
;
1946 i
[0].u
.mi
.dwFlags
|= MOUSEEVENTF_MOVE
;
1947 i
[1].u
.mi
.dwFlags
|= MOUSEEVENTF_LEFTDOWN
;
1948 i
[2].u
.mi
.dwFlags
|= MOUSEEVENTF_LEFTUP
;
1949 ret
= pSendInput(3, (INPUT
*) i
, sizeof(INPUT
));
1951 /* hack to prevent mouse message buildup in Wine */
1952 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA( &msg
);
1956 static DWORD WINAPI
test_menu_input_thread(LPVOID lpParameter
)
1959 HANDLE hWnd
= lpParameter
;
1962 /* mixed keyboard/mouse test */
1963 for (i
= 0; menu_tests
[i
].type
!= -1; i
++)
1965 int ret
= TRUE
, elapsed
= 0;
1967 got_input
= i
&& menu_tests
[i
-1].bMenuVisible
;
1969 if (menu_tests
[i
].type
== INPUT_KEYBOARD
)
1970 for (j
= 0; menu_tests
[i
].wVk
[j
] != 0; j
++)
1971 send_key(menu_tests
[i
].wVk
[j
]);
1973 for (j
= 0; menu_tests
[i
].menu_item_pairs
[j
].uMenu
!= 0; j
++)
1974 if (!(ret
= click_menu(hWnd
, &menu_tests
[i
].menu_item_pairs
[j
]))) break;
1978 skip( "test %u: failed to send input\n", i
);
1979 PostMessage( hWnd
, WM_CANCELMODE
, 0, 0 );
1982 while (menu_tests
[i
].bMenuVisible
!= bMenuVisible
)
1992 skip( "test %u: didn't receive input\n", i
);
1993 PostMessage( hWnd
, WM_CANCELMODE
, 0, 0 );
1997 if (menu_tests
[i
]._todo_wine
)
2000 ok(menu_tests
[i
].bMenuVisible
== bMenuVisible
, "test %d\n", i
);
2004 ok(menu_tests
[i
].bMenuVisible
== bMenuVisible
, "test %d\n", i
);
2009 static LRESULT CALLBACK
WndProc(HWND hWnd
, UINT msg
, WPARAM wParam
,
2013 case WM_ENTERMENULOOP
:
2014 bMenuVisible
= TRUE
;
2016 case WM_EXITMENULOOP
:
2017 bMenuVisible
= FALSE
;
2022 case WM_LBUTTONDOWN
:
2024 case WM_NCMOUSEMOVE
:
2025 case WM_NCLBUTTONDOWN
:
2026 case WM_NCLBUTTONUP
:
2030 return( DefWindowProcA( hWnd
, msg
, wParam
, lParam
) );
2035 static void test_menu_input(void) {
2038 HINSTANCE hInstance
= GetModuleHandleA( NULL
);
2039 HANDLE hThread
, hWnd
;
2044 win_skip("SendInput is not available\n");
2048 wclass
.lpszClassName
= "MenuTestClass";
2049 wclass
.style
= CS_HREDRAW
| CS_VREDRAW
;
2050 wclass
.lpfnWndProc
= WndProc
;
2051 wclass
.hInstance
= hInstance
;
2052 wclass
.hIcon
= LoadIconA( 0, IDI_APPLICATION
);
2053 wclass
.hCursor
= LoadCursorA( NULL
, IDC_ARROW
);
2054 wclass
.hbrBackground
= (HBRUSH
)( COLOR_WINDOW
+ 1 );
2055 wclass
.lpszMenuName
= 0;
2056 wclass
.cbClsExtra
= 0;
2057 wclass
.cbWndExtra
= 0;
2058 assert (RegisterClassA( &wclass
));
2059 assert (hWnd
= CreateWindowA( wclass
.lpszClassName
, "MenuTest",
2060 WS_OVERLAPPEDWINDOW
, CW_USEDEFAULT
, 0,
2061 400, 200, NULL
, NULL
, hInstance
, NULL
) );
2064 hMenus
[3] = CreatePopupMenu();
2065 AppendMenu(hMenus
[3], MF_STRING
, 0, "&Enabled");
2066 AppendMenu(hMenus
[3], MF_STRING
|MF_DISABLED
, 0, "&Disabled");
2068 hMenus
[2] = CreatePopupMenu();
2069 AppendMenu(hMenus
[2], MF_STRING
|MF_POPUP
, (UINT_PTR
) hMenus
[3], "&Popup");
2070 AppendMenu(hMenus
[2], MF_STRING
, 0, "&Enabled");
2071 AppendMenu(hMenus
[2], MF_STRING
|MF_DISABLED
, 0, "&Disabled");
2073 hMenus
[1] = CreateMenu();
2074 AppendMenu(hMenus
[1], MF_STRING
|MF_POPUP
, (UINT_PTR
) hMenus
[2], "&Menu");
2075 AppendMenu(hMenus
[1], MF_STRING
, 0, "&Enabled");
2076 AppendMenu(hMenus
[1], MF_STRING
|MF_DISABLED
, 0, "&Disabled");
2078 SetMenu(hWnd
, hMenus
[1]);
2079 ShowWindow(hWnd
, SW_SHOW
);
2082 hThread
= CreateThread(NULL
, 0, test_menu_input_thread
, hWnd
, 0, &tid
);
2085 if (WAIT_TIMEOUT
!= WaitForSingleObject(hThread
, 50))
2087 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
2089 DestroyWindow(hWnd
);
2092 static void test_menu_flags( void )
2094 HMENU hMenu
, hPopupMenu
;
2096 hMenu
= CreateMenu();
2097 hPopupMenu
= CreatePopupMenu();
2099 AppendMenu(hMenu
, MF_POPUP
| MF_STRING
, (UINT_PTR
)hPopupMenu
, "Popup");
2101 AppendMenu(hPopupMenu
, MF_STRING
| MF_HILITE
| MF_DEFAULT
, 101, "Item 1");
2102 InsertMenu(hPopupMenu
, 1, MF_BYPOSITION
| MF_STRING
| MF_HILITE
| MF_DEFAULT
, 102, "Item 2");
2103 AppendMenu(hPopupMenu
, MF_STRING
, 103, "Item 3");
2104 ModifyMenu(hPopupMenu
, 2, MF_BYPOSITION
| MF_STRING
| MF_HILITE
| MF_DEFAULT
, 103, "Item 3");
2106 ok(GetMenuState(hPopupMenu
, 0, MF_BYPOSITION
) & MF_HILITE
,
2107 "AppendMenu should accept MF_HILITE\n");
2108 ok(GetMenuState(hPopupMenu
, 1, MF_BYPOSITION
) & MF_HILITE
,
2109 "InsertMenu should accept MF_HILITE\n");
2110 ok(GetMenuState(hPopupMenu
, 2, MF_BYPOSITION
) & MF_HILITE
,
2111 "ModifyMenu should accept MF_HILITE\n");
2113 ok(!(GetMenuState(hPopupMenu
, 0, MF_BYPOSITION
) & MF_DEFAULT
),
2114 "AppendMenu must not accept MF_DEFAULT\n");
2115 ok(!(GetMenuState(hPopupMenu
, 1, MF_BYPOSITION
) & MF_DEFAULT
),
2116 "InsertMenu must not accept MF_DEFAULT\n");
2117 ok(!(GetMenuState(hPopupMenu
, 2, MF_BYPOSITION
) & MF_DEFAULT
),
2118 "ModifyMenu must not accept MF_DEFAULT\n");
2123 static void test_menu_hilitemenuitem( void )
2125 HMENU hMenu
, hPopupMenu
;
2129 wclass
.lpszClassName
= "HiliteMenuTestClass";
2130 wclass
.style
= CS_HREDRAW
| CS_VREDRAW
;
2131 wclass
.lpfnWndProc
= WndProc
;
2132 wclass
.hInstance
= GetModuleHandleA( NULL
);
2133 wclass
.hIcon
= LoadIconA( 0, IDI_APPLICATION
);
2134 wclass
.hCursor
= LoadCursorA( NULL
, IDC_ARROW
);
2135 wclass
.hbrBackground
= (HBRUSH
)( COLOR_WINDOW
+ 1 );
2136 wclass
.lpszMenuName
= 0;
2137 wclass
.cbClsExtra
= 0;
2138 wclass
.cbWndExtra
= 0;
2139 assert (RegisterClassA( &wclass
));
2140 assert (hWnd
= CreateWindowA( wclass
.lpszClassName
, "HiliteMenuTest",
2141 WS_OVERLAPPEDWINDOW
, CW_USEDEFAULT
, 0,
2142 400, 200, NULL
, NULL
, wclass
.hInstance
, NULL
) );
2144 hMenu
= CreateMenu();
2145 hPopupMenu
= CreatePopupMenu();
2147 AppendMenu(hMenu
, MF_POPUP
| MF_STRING
, (UINT_PTR
)hPopupMenu
, "Popup");
2149 AppendMenu(hPopupMenu
, MF_STRING
, 101, "Item 1");
2150 AppendMenu(hPopupMenu
, MF_STRING
, 102, "Item 2");
2151 AppendMenu(hPopupMenu
, MF_STRING
, 103, "Item 3");
2153 SetMenu(hWnd
, hMenu
);
2155 /* test invalid arguments */
2157 ok(!(GetMenuState(hPopupMenu
, 1, MF_BYPOSITION
) & MF_HILITE
),
2158 "HiliteMenuItem: Item 2 is hilited\n");
2160 SetLastError(0xdeadbeef);
2163 ok(!HiliteMenuItem(NULL
, hPopupMenu
, 1, MF_HILITE
| MF_BYPOSITION
),
2164 "HiliteMenuItem: call should have failed.\n");
2166 ok(GetLastError() == 0xdeadbeef || /* 9x */
2167 GetLastError() == ERROR_INVALID_WINDOW_HANDLE
/* NT */,
2168 "HiliteMenuItem: expected error ERROR_INVALID_WINDOW_HANDLE, got: %d\n", GetLastError());
2170 SetLastError(0xdeadbeef);
2171 ok(!HiliteMenuItem(hWnd
, NULL
, 1, MF_HILITE
| MF_BYPOSITION
),
2172 "HiliteMenuItem: call should have failed.\n");
2173 ok(GetLastError() == 0xdeadbeef || /* 9x */
2174 GetLastError() == ERROR_INVALID_MENU_HANDLE
/* NT */,
2175 "HiliteMenuItem: expected error ERROR_INVALID_MENU_HANDLE, got: %d\n", GetLastError());
2177 ok(!(GetMenuState(hPopupMenu
, 1, MF_BYPOSITION
) & MF_HILITE
),
2178 "HiliteMenuItem: Item 2 is hilited\n");
2180 /* either MF_HILITE or MF_UNHILITE *and* MF_BYCOMMAND or MF_BYPOSITION need to be set */
2182 SetLastError(0xdeadbeef);
2183 ok(HiliteMenuItem(hWnd
, hPopupMenu
, 1, MF_BYPOSITION
),
2184 "HiliteMenuItem: call should have succeeded.\n");
2185 ok(GetLastError() == 0xdeadbeef,
2186 "HiliteMenuItem: expected error 0xdeadbeef, got: %d\n", GetLastError());
2188 ok(!(GetMenuState(hPopupMenu
, 1, MF_BYPOSITION
) & MF_HILITE
),
2189 "HiliteMenuItem: Item 2 is hilited\n");
2191 SetLastError(0xdeadbeef);
2194 ok(HiliteMenuItem(hWnd
, hPopupMenu
, 1, MF_HILITE
),
2195 "HiliteMenuItem: call should have succeeded.\n");
2197 ok(GetLastError() == 0xdeadbeef,
2198 "HiliteMenuItem: expected error 0xdeadbeef, got: %d\n", GetLastError());
2200 ok(!(GetMenuState(hPopupMenu
, 1, MF_BYPOSITION
) & MF_HILITE
),
2201 "HiliteMenuItem: Item 2 is hilited\n");
2203 /* hilite a menu item (by position) */
2205 SetLastError(0xdeadbeef);
2206 ok(HiliteMenuItem(hWnd
, hPopupMenu
, 1, MF_HILITE
| MF_BYPOSITION
),
2207 "HiliteMenuItem: call should not have failed.\n");
2208 ok(GetLastError() == 0xdeadbeef,
2209 "HiliteMenuItem: expected error 0xdeadbeef, got: %d\n", GetLastError());
2213 ok(GetMenuState(hPopupMenu
, 1, MF_BYPOSITION
) & MF_HILITE
,
2214 "HiliteMenuItem: Item 2 is not hilited\n");
2217 /* unhilite a menu item (by position) */
2219 SetLastError(0xdeadbeef);
2220 ok(HiliteMenuItem(hWnd
, hPopupMenu
, 1, MF_UNHILITE
| MF_BYPOSITION
),
2221 "HiliteMenuItem: call should not have failed.\n");
2222 ok(GetLastError() == 0xdeadbeef,
2223 "HiliteMenuItem: expected error 0xdeadbeef, got: %d\n", GetLastError());
2225 ok(!(GetMenuState(hPopupMenu
, 1, MF_BYPOSITION
) & MF_HILITE
),
2226 "HiliteMenuItem: Item 2 is hilited\n");
2228 /* hilite a menu item (by command) */
2230 SetLastError(0xdeadbeef);
2231 ok(HiliteMenuItem(hWnd
, hPopupMenu
, 103, MF_HILITE
| MF_BYCOMMAND
),
2232 "HiliteMenuItem: call should not have failed.\n");
2233 ok(GetLastError() == 0xdeadbeef,
2234 "HiliteMenuItem: expected error 0xdeadbeef, got: %d\n", GetLastError());
2238 ok(GetMenuState(hPopupMenu
, 2, MF_BYPOSITION
) & MF_HILITE
,
2239 "HiliteMenuItem: Item 3 is not hilited\n");
2242 /* unhilite a menu item (by command) */
2244 SetLastError(0xdeadbeef);
2245 ok(HiliteMenuItem(hWnd
, hPopupMenu
, 103, MF_UNHILITE
| MF_BYCOMMAND
),
2246 "HiliteMenuItem: call should not have failed.\n");
2247 ok(GetLastError() == 0xdeadbeef,
2248 "HiliteMenuItem: expected error 0xdeadbeef, got: %d\n", GetLastError());
2250 ok(!(GetMenuState(hPopupMenu
, 2, MF_BYPOSITION
) & MF_HILITE
),
2251 "HiliteMenuItem: Item 3 is hilited\n");
2253 DestroyWindow(hWnd
);
2256 static void check_menu_items(HMENU hmenu
, UINT checked_cmd
, UINT checked_type
,
2261 count
= GetMenuItemCount(hmenu
);
2262 ok (count
!= -1, "GetMenuItemCount returned -1\n");
2264 for (i
= 0; i
< count
; i
++)
2269 memset(&mii
, 0, sizeof(mii
));
2270 mii
.cbSize
= sizeof(mii
);
2271 mii
.fMask
= MIIM_FTYPE
| MIIM_STATE
| MIIM_ID
| MIIM_SUBMENU
;
2272 ret
= GetMenuItemInfo(hmenu
, i
, TRUE
, &mii
);
2273 ok(ret
, "GetMenuItemInfo(%u) failed\n", i
);
2275 trace("item #%u: fType %04x, fState %04x, wID %u, hSubMenu %p\n",
2276 i
, mii
.fType
, mii
.fState
, mii
.wID
, mii
.hSubMenu
);
2280 ok(mii
.wID
== (UINT_PTR
)mii
.hSubMenu
, "id %u: wID should be equal to hSubMenu\n", checked_cmd
);
2281 check_menu_items(mii
.hSubMenu
, checked_cmd
, checked_type
, checked_state
);
2285 if (mii
.wID
== checked_cmd
)
2287 ok(mii
.fType
== checked_type
, "id %u: expected fType %04x, got %04x\n", checked_cmd
, checked_type
, mii
.fType
);
2288 ok(mii
.fState
== checked_state
, "id %u: expected fState %04x, got %04x\n", checked_cmd
, checked_state
, mii
.fState
);
2289 ok(mii
.wID
!= 0, "id %u: not expected wID 0\n", checked_cmd
);
2293 ok(mii
.fType
!= MFT_RADIOCHECK
, "id %u: not expected fType MFT_RADIOCHECK on cmd %u\n", checked_cmd
, mii
.wID
);
2295 if (mii
.fType
== MFT_SEPARATOR
)
2297 ok(mii
.fState
== MFS_GRAYED
, "id %u: expected fState MFS_GRAYED, got %04x\n", checked_cmd
, mii
.fState
);
2298 ok(mii
.wID
== 0, "id %u: expected wID 0, got %u\n", checked_cmd
, mii
.wID
);
2302 ok(mii
.fState
== 0, "id %u: expected fState 0, got %04x\n", checked_cmd
, mii
.fState
);
2303 ok(mii
.wID
!= 0, "id %u: not expected wID 0\n", checked_cmd
);
2310 static void clear_ftype_and_state(HMENU hmenu
, UINT id
, UINT flags
)
2315 memset(&mii
, 0, sizeof(mii
));
2316 mii
.cbSize
= sizeof(mii
);
2317 mii
.fMask
= MIIM_FTYPE
| MIIM_STATE
;
2318 ret
= SetMenuItemInfo(hmenu
, id
, (flags
& MF_BYPOSITION
) != 0, &mii
);
2319 ok(ret
, "SetMenuItemInfo(%u) failed\n", id
);
2322 static void test_CheckMenuRadioItem(void)
2327 hmenu
= LoadMenu(GetModuleHandle(0), MAKEINTRESOURCE(1));
2330 check_menu_items(hmenu
, -1, 0, 0);
2332 ret
= CheckMenuRadioItem(hmenu
, 100, 100, 100, MF_BYCOMMAND
);
2333 ok(ret
, "CheckMenuRadioItem failed\n");
2334 check_menu_items(hmenu
, 100, MFT_RADIOCHECK
, MFS_CHECKED
);
2336 /* MSDN is wrong, Windows does not remove MFT_RADIOCHECK */
2337 ret
= CheckMenuRadioItem(hmenu
, 100, 100, -1, MF_BYCOMMAND
);
2338 ok(!ret
, "CheckMenuRadioItem should return FALSE\n");
2339 check_menu_items(hmenu
, 100, MFT_RADIOCHECK
, 0);
2342 clear_ftype_and_state(hmenu
, 100, MF_BYCOMMAND
);
2343 check_menu_items(hmenu
, -1, 0, 0);
2345 /* first and checked items are on different menus */
2346 ret
= CheckMenuRadioItem(hmenu
, 0, 300, 202, MF_BYCOMMAND
);
2347 ok(!ret
, "CheckMenuRadioItem should return FALSE\n");
2348 check_menu_items(hmenu
, -1, 0, 0);
2350 ret
= CheckMenuRadioItem(hmenu
, 200, 300, 202, MF_BYCOMMAND
);
2351 ok(ret
, "CheckMenuRadioItem failed\n");
2352 check_menu_items(hmenu
, 202, MFT_RADIOCHECK
, MFS_CHECKED
);
2354 /* MSDN is wrong, Windows does not remove MFT_RADIOCHECK */
2355 ret
= CheckMenuRadioItem(hmenu
, 202, 202, -1, MF_BYCOMMAND
);
2356 ok(!ret
, "CheckMenuRadioItem should return FALSE\n");
2357 check_menu_items(hmenu
, 202, MFT_RADIOCHECK
, 0);
2360 clear_ftype_and_state(hmenu
, 202, MF_BYCOMMAND
);
2361 check_menu_items(hmenu
, -1, 0, 0);
2363 /* just for fun, try to check separator */
2364 ret
= CheckMenuRadioItem(hmenu
, 0, 300, 0, MF_BYCOMMAND
);
2365 ok(!ret
, "CheckMenuRadioItem should return FALSE\n");
2366 check_menu_items(hmenu
, -1, 0, 0);
2369 static void test_menu_resource_layout(void)
2373 MENUITEMTEMPLATEHEADER mith
;
2377 { 0, 0 }, /* versionNumber, offset */
2379 /* mtOption, mtID, mtString[] '\0' terminated */
2380 MF_STRING
, 1, 'F', 0,
2383 /* MF_SEPARATOR, 4, 'S', 0, FIXME: Wine ignores 'S' */
2384 MF_STRING
|MF_GRAYED
|MF_END
, 5, 'E', 0
2389 UINT type
, state
, id
;
2393 { MF_STRING
, MF_ENABLED
, 1, "F" },
2394 { MF_SEPARATOR
, MF_GRAYED
|MF_DISABLED
, 2, "" },
2395 { MF_SEPARATOR
, MF_GRAYED
|MF_DISABLED
, 3, "" },
2396 /*{ MF_SEPARATOR, MF_GRAYED|MF_DISABLED, 4, "S" }, FIXME: Wine ignores 'S'*/
2397 { MF_STRING
, MF_GRAYED
, 5, "E" },
2398 { MF_SEPARATOR
, MF_GRAYED
|MF_DISABLED
, 6, "" },
2399 { MF_STRING
, MF_ENABLED
, 7, "" },
2400 { MF_SEPARATOR
, MF_GRAYED
|MF_DISABLED
, 8, "" }
2406 hmenu
= LoadMenuIndirect(&menu_template
);
2407 ok(hmenu
!= 0, "LoadMenuIndirect error %u\n", GetLastError());
2409 ret
= AppendMenu(hmenu
, MF_STRING
, 6, NULL
);
2410 ok(ret
, "AppendMenu failed\n");
2411 ret
= AppendMenu(hmenu
, MF_STRING
, 7, "\0");
2412 ok(ret
, "AppendMenu failed\n");
2413 ret
= AppendMenu(hmenu
, MF_SEPARATOR
, 8, "separator");
2414 ok(ret
, "AppendMenu failed\n");
2416 count
= GetMenuItemCount(hmenu
);
2417 ok(count
== sizeof(menu_data
)/sizeof(menu_data
[0]),
2418 "expected %u menu items, got %u\n",
2419 (UINT
)(sizeof(menu_data
)/sizeof(menu_data
[0])), count
);
2421 for (i
= 0; i
< count
; i
++)
2426 memset(&mii
, 0, sizeof(mii
));
2427 mii
.cbSize
= sizeof(mii
);
2428 mii
.dwTypeData
= buf
;
2429 mii
.cch
= sizeof(buf
);
2430 mii
.fMask
= MIIM_FTYPE
| MIIM_STATE
| MIIM_ID
| MIIM_STRING
;
2431 ret
= GetMenuItemInfo(hmenu
, i
, TRUE
, &mii
);
2432 ok(ret
, "GetMenuItemInfo(%u) failed\n", i
);
2434 trace("item #%u: fType %04x, fState %04x, wID %u, dwTypeData %s\n",
2435 i
, mii
.fType
, mii
.fState
, mii
.wID
, (LPCSTR
)mii
.dwTypeData
);
2437 ok(mii
.fType
== menu_data
[i
].type
,
2438 "%u: expected fType %04x, got %04x\n", i
, menu_data
[i
].type
, mii
.fType
);
2439 ok(mii
.fState
== menu_data
[i
].state
,
2440 "%u: expected fState %04x, got %04x\n", i
, menu_data
[i
].state
, mii
.fState
);
2441 ok(mii
.wID
== menu_data
[i
].id
,
2442 "%u: expected wID %04x, got %04x\n", i
, menu_data
[i
].id
, mii
.wID
);
2443 ok(mii
.cch
== strlen(menu_data
[i
].str
),
2444 "%u: expected cch %u, got %u\n", i
, (UINT
)strlen(menu_data
[i
].str
), mii
.cch
);
2445 ok(!strcmp(mii
.dwTypeData
, menu_data
[i
].str
),
2446 "%u: expected dwTypeData %s, got %s\n", i
, menu_data
[i
].str
, (LPCSTR
)mii
.dwTypeData
);
2458 static HMENU
create_menu_from_data(const struct menu_data
*item
, INT item_count
)
2464 hmenu
= CreateMenu();
2467 for (i
= 0; i
< item_count
; i
++)
2469 SetLastError(0xdeadbeef);
2470 ret
= AppendMenu(hmenu
, item
[i
].type
, item
[i
].id
, item
[i
].str
);
2471 ok(ret
, "%d: AppendMenu(%04x, %04x, %p) error %u\n",
2472 i
, item
[i
].type
, item
[i
].id
, item
[i
].str
, GetLastError());
2477 /* use InsertMenuItem: does not set the MFT_BITMAP flag,
2478 * and does not accept non-magic bitmaps with invalid
2480 static HMENU
create_menuitem_from_data(const struct menu_data
*item
, INT item_count
)
2485 MENUITEMINFO mii
= { sizeof( MENUITEMINFO
)};
2487 hmenu
= CreateMenu();
2490 for (i
= 0; i
< item_count
; i
++)
2492 SetLastError(0xdeadbeef);
2494 mii
.fMask
= MIIM_FTYPE
| MIIM_ID
| MIIM_STATE
;
2496 if( item
[i
].type
& MFT_BITMAP
)
2498 mii
.fMask
|= MIIM_BITMAP
;
2499 mii
.hbmpItem
= (HBITMAP
)item
[i
].str
;
2501 else if( item
[i
].type
& MFT_SEPARATOR
)
2502 mii
.fType
= MFT_SEPARATOR
;
2505 mii
.fMask
|= MIIM_STRING
;
2506 mii
.dwTypeData
= (LPSTR
)item
[i
].str
;
2507 mii
.cch
= strlen( item
[i
].str
);
2510 if( item
[i
].type
& MF_HELP
) mii
.fType
|= MF_HELP
;
2511 mii
.wID
= item
[i
].id
;
2512 ret
= InsertMenuItem( hmenu
, -1, TRUE
, &mii
);
2513 ok(ret
, "%d: InsertMenuItem(%04x, %04x, %p) error %u\n",
2514 i
, item
[i
].type
, item
[i
].id
, item
[i
].str
, GetLastError());
2519 static void compare_menu_data(HMENU hmenu
, const struct menu_data
*item
, INT item_count
)
2524 count
= GetMenuItemCount(hmenu
);
2525 ok(count
== item_count
, "expected %d, got %d menu items\n", count
, item_count
);
2527 for (i
= 0; i
< count
; i
++)
2532 memset(&mii
, 0, sizeof(mii
));
2533 mii
.cbSize
= sizeof(mii
);
2534 mii
.dwTypeData
= buf
;
2535 mii
.cch
= sizeof(buf
);
2536 mii
.fMask
= MIIM_FTYPE
| MIIM_ID
| MIIM_STRING
| MIIM_BITMAP
;
2537 ret
= GetMenuItemInfo(hmenu
, i
, TRUE
, &mii
);
2538 ok(ret
, "GetMenuItemInfo(%u) failed\n", i
);
2540 trace("item #%u: fType %04x, fState %04x, wID %04x, hbmp %p\n",
2541 i
, mii
.fType
, mii
.fState
, mii
.wID
, mii
.hbmpItem
);
2543 ok(mii
.fType
== item
[i
].type
,
2544 "%u: expected fType %04x, got %04x\n", i
, item
[i
].type
, mii
.fType
);
2545 ok(mii
.wID
== item
[i
].id
,
2546 "%u: expected wID %04x, got %04x\n", i
, item
[i
].id
, mii
.wID
);
2547 if (mii
.hbmpItem
|| !item
[i
].str
)
2548 /* For some reason Windows sets high word to not 0 for
2551 ok(LOWORD(mii
.hbmpItem
) == LOWORD(item
[i
].str
),
2552 "%u: expected hbmpItem %p, got %p\n", i
, item
[i
].str
, mii
.hbmpItem
);
2555 ok(mii
.cch
== strlen(item
[i
].str
),
2556 "%u: expected cch %u, got %u\n", i
, (UINT
)strlen(item
[i
].str
), mii
.cch
);
2557 ok(!strcmp(mii
.dwTypeData
, item
[i
].str
),
2558 "%u: expected dwTypeData %s, got %s\n", i
, item
[i
].str
, (LPCSTR
)mii
.dwTypeData
);
2563 static void test_InsertMenu(void)
2565 HBITMAP hbm
= CreateBitmap(1,1,1,1,NULL
);
2566 /* Note: XP treats only bitmap handles 1 - 6 as "magic" ones
2567 * regardless of their id.
2569 static const struct menu_data in1
[] =
2571 { MF_STRING
, 1, "File" },
2572 { MF_BITMAP
|MF_HELP
, SC_CLOSE
, MAKEINTRESOURCE(1) },
2573 { MF_STRING
|MF_HELP
, 2, "Help" }
2575 static const struct menu_data out1
[] =
2577 { MF_STRING
, 1, "File" },
2578 { MF_STRING
|MF_HELP
, 2, "Help" },
2579 { MF_BITMAP
|MF_HELP
, SC_CLOSE
, MAKEINTRESOURCE(1) }
2581 static const struct menu_data out1a
[] =
2583 { MF_STRING
, 1, "File" },
2584 { MF_STRING
|MF_HELP
, 2, "Help" },
2585 { MF_HELP
, SC_CLOSE
, MAKEINTRESOURCE(1) }
2587 const struct menu_data in2
[] =
2589 { MF_STRING
, 1, "File" },
2590 { MF_BITMAP
|MF_HELP
, SC_CLOSE
, (char*)hbm
},
2591 { MF_STRING
|MF_HELP
, 2, "Help" }
2593 const struct menu_data out2
[] =
2595 { MF_STRING
, 1, "File" },
2596 { MF_BITMAP
|MF_HELP
, SC_CLOSE
, (char*)hbm
},
2597 { MF_STRING
|MF_HELP
, 2, "Help" }
2599 const struct menu_data out2a
[] =
2601 { MF_STRING
, 1, "File" },
2602 { MF_HELP
, SC_CLOSE
, (char*)hbm
},
2603 { MF_STRING
|MF_HELP
, 2, "Help" }
2605 static const struct menu_data in3
[] =
2607 { MF_STRING
, 1, "File" },
2608 { MF_SEPARATOR
|MF_HELP
, SC_CLOSE
, MAKEINTRESOURCE(1) },
2609 { MF_STRING
|MF_HELP
, 2, "Help" }
2611 static const struct menu_data out3
[] =
2613 { MF_STRING
, 1, "File" },
2614 { MF_SEPARATOR
|MF_HELP
, SC_CLOSE
, MAKEINTRESOURCE(0) },
2615 { MF_STRING
|MF_HELP
, 2, "Help" },
2617 static const struct menu_data in4
[] =
2619 { MF_STRING
, 1, "File" },
2620 { MF_BITMAP
|MF_HELP
, 1, MAKEINTRESOURCE(1) },
2621 { MF_STRING
|MF_HELP
, 2, "Help" }
2623 static const struct menu_data out4
[] =
2625 { MF_STRING
, 1, "File" },
2626 { MF_STRING
|MF_HELP
, 2, "Help" },
2627 { MF_BITMAP
|MF_HELP
, 1, MAKEINTRESOURCE(1) }
2629 static const struct menu_data out4a
[] =
2631 { MF_STRING
, 1, "File" },
2632 { MF_STRING
|MF_HELP
, 2, "Help" },
2633 { MF_HELP
, 1, MAKEINTRESOURCE(1) }
2637 #define create_menu(a) create_menu_from_data((a), sizeof(a)/sizeof((a)[0]))
2638 #define create_menuitem(a) create_menuitem_from_data((a), sizeof(a)/sizeof((a)[0]))
2639 #define compare_menu(h, a) compare_menu_data((h), (a), sizeof(a)/sizeof((a)[0]))
2641 hmenu
= create_menu(in1
);
2642 compare_menu(hmenu
, out1
);
2645 hmenu
= create_menu(in2
);
2646 compare_menu(hmenu
, out2
);
2649 hmenu
= create_menu(in3
);
2650 compare_menu(hmenu
, out3
);
2653 hmenu
= create_menu(in4
);
2654 compare_menu(hmenu
, out4
);
2657 /* now using InsertMenuItemInfo */
2658 hmenu
= create_menuitem(in1
);
2659 compare_menu(hmenu
, out1a
);
2662 hmenu
= create_menuitem(in2
);
2663 compare_menu(hmenu
, out2a
);
2666 hmenu
= create_menuitem(in3
);
2667 compare_menu(hmenu
, out3
);
2670 hmenu
= create_menuitem(in4
);
2671 compare_menu(hmenu
, out4a
);
2675 #undef create_menuitem
2679 static void test_menu_getmenuinfo(void)
2688 win_skip("GetMenuInfo is not available\n");
2693 hmenu
= CreateMenu();
2695 /* test some parameter errors */
2696 SetLastError(0xdeadbeef);
2697 ret
= pGetMenuInfo( hmenu
, NULL
);
2698 gle
= GetLastError();
2699 ok( !ret
, "GetMenuInfo() should have failed\n");
2700 ok( gle
== ERROR_INVALID_PARAMETER
||
2701 broken(gle
== 0xdeadbeef), /* Win98, WinME */
2702 "GetMenuInfo() error got %u expected %u\n", gle
, ERROR_INVALID_PARAMETER
);
2703 SetLastError(0xdeadbeef);
2705 ret
= pGetMenuInfo( hmenu
, &mi
);
2706 gle
= GetLastError();
2707 ok( !ret
, "GetMenuInfo() should have failed\n");
2708 ok( gle
== ERROR_INVALID_PARAMETER
||
2709 broken(gle
== 0xdeadbeef), /* Win98, WinME */
2710 "GetMenuInfo() error got %u expected %u\n", gle
, ERROR_INVALID_PARAMETER
);
2711 SetLastError(0xdeadbeef);
2712 mi
.cbSize
= sizeof( MENUINFO
);
2713 ret
= pGetMenuInfo( hmenu
, &mi
);
2714 gle
= GetLastError();
2715 ok( ret
, "GetMenuInfo() should have succeeded\n");
2716 ok( gle
== 0xdeadbeef, "GetMenuInfo() error got %u\n", gle
);
2717 SetLastError(0xdeadbeef);
2719 ret
= pGetMenuInfo( NULL
, &mi
);
2720 gle
= GetLastError();
2721 ok( !ret
, "GetMenuInfo() should have failed\n");
2722 ok( gle
== ERROR_INVALID_PARAMETER
||
2723 broken(gle
== 0xdeadbeef), /* Win98, WinME */
2724 "GetMenuInfo() error got %u expected %u\n", gle
, ERROR_INVALID_PARAMETER
);
2726 DestroyMenu( hmenu
);
2730 static void test_menu_setmenuinfo(void)
2732 HMENU hmenu
, hsubmenu
;
2734 MENUITEMINFOA mii
= {sizeof( MENUITEMINFOA
)};
2738 if (!pGetMenuInfo
|| !pSetMenuInfo
)
2740 win_skip("Get/SetMenuInfo are not available\n");
2744 /* create a menu with a submenu */
2745 hmenu
= CreateMenu();
2746 hsubmenu
= CreateMenu();
2747 assert( hmenu
&& hsubmenu
);
2748 mii
.fMask
= MIIM_SUBMENU
;
2749 mii
.hSubMenu
= hsubmenu
;
2750 ret
= InsertMenuItem( hmenu
, 0, FALSE
, &mii
);
2751 ok( ret
, "InsertMenuItem failed with error %d\n", GetLastError());
2752 /* test some parameter errors */
2753 SetLastError(0xdeadbeef);
2754 ret
= pSetMenuInfo( hmenu
, NULL
);
2755 gle
= GetLastError();
2756 ok( !ret
, "SetMenuInfo() should have failed\n");
2757 ok( gle
== ERROR_INVALID_PARAMETER
||
2758 broken(gle
== 0xdeadbeef), /* Win98, WinME */
2759 "SetMenuInfo() error got %u expected %u\n", gle
, ERROR_INVALID_PARAMETER
);
2760 SetLastError(0xdeadbeef);
2762 ret
= pSetMenuInfo( hmenu
, &mi
);
2763 gle
= GetLastError();
2764 ok( !ret
, "SetMenuInfo() should have failed\n");
2765 ok( gle
== ERROR_INVALID_PARAMETER
||
2766 broken(gle
== 0xdeadbeef), /* Win98, WinME */
2767 "SetMenuInfo() error got %u expected %u\n", gle
, ERROR_INVALID_PARAMETER
);
2768 SetLastError(0xdeadbeef);
2769 mi
.cbSize
= sizeof( MENUINFO
);
2770 ret
= pSetMenuInfo( hmenu
, &mi
);
2771 gle
= GetLastError();
2772 ok( ret
, "SetMenuInfo() should have succeeded\n");
2773 ok( gle
== 0xdeadbeef, "SetMenuInfo() error got %u\n", gle
);
2774 SetLastError(0xdeadbeef);
2776 ret
= pSetMenuInfo( NULL
, &mi
);
2777 gle
= GetLastError();
2778 ok( !ret
, "SetMenuInfo() should have failed\n");
2779 ok( gle
== ERROR_INVALID_PARAMETER
||
2780 broken(gle
== 0xdeadbeef), /* Win98, WinME */
2781 "SetMenuInfo() error got %u expected %u\n", gle
, ERROR_INVALID_PARAMETER
);
2782 /* functional tests */
2783 /* menu and submenu should have the CHECKORBMP style bit cleared */
2784 SetLastError(0xdeadbeef);
2785 mi
.cbSize
= sizeof( MENUINFO
);
2786 mi
.fMask
= MIM_STYLE
;
2787 ret
= pGetMenuInfo( hmenu
, &mi
);
2788 gle
= GetLastError();
2789 ok( ret
, "GetMenuInfo() should have succeeded\n");
2790 ok( gle
== 0xdeadbeef, "GetMenuInfo() error got %u\n", gle
);
2791 ok( !(mi
.dwStyle
& MNS_CHECKORBMP
), "menustyle was not expected to have the MNS_CHECKORBMP flag\n");
2792 SetLastError(0xdeadbeef);
2793 mi
.cbSize
= sizeof( MENUINFO
);
2794 mi
.fMask
= MIM_STYLE
;
2795 ret
= pGetMenuInfo( hsubmenu
, &mi
);
2796 gle
= GetLastError();
2797 ok( ret
, "GetMenuInfo() should have succeeded\n");
2798 ok( gle
== 0xdeadbeef, "GetMenuInfo() error got %u\n", gle
);
2799 ok( !(mi
.dwStyle
& MNS_CHECKORBMP
), "menustyle was not expected to have the MNS_CHECKORBMP flag\n");
2801 SetLastError(0xdeadbeef);
2802 mi
.cbSize
= sizeof( MENUINFO
);
2803 mi
.fMask
= MIM_STYLE
| MIM_APPLYTOSUBMENUS
;
2804 mi
.dwStyle
= MNS_CHECKORBMP
;
2805 ret
= pSetMenuInfo( hmenu
, &mi
);
2806 gle
= GetLastError();
2807 ok( ret
, "SetMenuInfo() should have succeeded\n");
2808 ok( gle
== 0xdeadbeef, "SetMenuInfo() error got %u\n", gle
);
2809 /* Now both menus should have the MNS_CHECKORBMP style bit set */
2810 SetLastError(0xdeadbeef);
2811 mi
.cbSize
= sizeof( MENUINFO
);
2812 mi
.fMask
= MIM_STYLE
;
2813 ret
= pGetMenuInfo( hmenu
, &mi
);
2814 gle
= GetLastError();
2815 ok( ret
, "GetMenuInfo() should have succeeded\n");
2816 ok( gle
== 0xdeadbeef, "GetMenuInfo() error got %u\n", gle
);
2817 ok( mi
.dwStyle
& MNS_CHECKORBMP
, "menustyle was expected to have the MNS_CHECKORBMP flag\n");
2818 SetLastError(0xdeadbeef);
2819 mi
.cbSize
= sizeof( MENUINFO
);
2820 mi
.fMask
= MIM_STYLE
;
2821 ret
= pGetMenuInfo( hsubmenu
, &mi
);
2822 gle
= GetLastError();
2823 ok( ret
, "GetMenuInfo() should have succeeded\n");
2824 ok( gle
== 0xdeadbeef, "GetMenuInfo() error got %u\n", gle
);
2825 ok( mi
.dwStyle
& MNS_CHECKORBMP
, "menustyle was expected to have the MNS_CHECKORBMP flag\n");
2826 /* now repeat that without the APPLYTOSUBMENUS flag and another style bit */
2827 SetLastError(0xdeadbeef);
2828 mi
.cbSize
= sizeof( MENUINFO
);
2829 mi
.fMask
= MIM_STYLE
;
2830 mi
.dwStyle
= MNS_NOCHECK
;
2831 ret
= pSetMenuInfo( hmenu
, &mi
);
2832 gle
= GetLastError();
2833 ok( ret
, "SetMenuInfo() should have succeeded\n");
2834 ok( gle
== 0xdeadbeef, "SetMenuInfo() error got %u\n", gle
);
2835 /* Now only the top menu should have the MNS_NOCHECK style bit set */
2836 SetLastError(0xdeadbeef);
2837 mi
.cbSize
= sizeof( MENUINFO
);
2838 mi
.fMask
= MIM_STYLE
;
2839 ret
= pGetMenuInfo( hmenu
, &mi
);
2840 gle
= GetLastError();
2841 ok( ret
, "GetMenuInfo() should have succeeded\n");
2842 ok( gle
== 0xdeadbeef, "GetMenuInfo() error got %u\n", gle
);
2843 ok( mi
.dwStyle
& MNS_NOCHECK
, "menustyle was expected to have the MNS_NOCHECK flag\n");
2844 SetLastError(0xdeadbeef);
2845 mi
.cbSize
= sizeof( MENUINFO
);
2846 mi
.fMask
= MIM_STYLE
;
2847 ret
= pGetMenuInfo( hsubmenu
, &mi
);
2848 gle
= GetLastError();
2849 ok( ret
, "GetMenuInfo() should have succeeded\n");
2850 ok( gle
== 0xdeadbeef, "GetMenuInfo() error got %u\n", gle
);
2851 ok( !(mi
.dwStyle
& MNS_NOCHECK
), "menustyle was not expected to have the MNS_NOCHECK flag\n");
2853 DestroyMenu( hsubmenu
);
2854 DestroyMenu( hmenu
);
2858 /* little func to easy switch either TrackPopupMenu() or TrackPopupMenuEx() */
2859 static DWORD
MyTrackPopupMenu( int ex
, HMENU hmenu
, UINT flags
, INT x
, INT y
, HWND hwnd
, LPTPMPARAMS ptpm
)
2862 ? TrackPopupMenuEx( hmenu
, flags
, x
, y
, hwnd
, ptpm
)
2863 : TrackPopupMenu( hmenu
, flags
, x
, y
, 0, hwnd
, NULL
);
2866 /* some TrackPopupMenu and TrackPopupMenuEx tests */
2867 /* the LastError values differ between NO_ERROR and invalid handle */
2868 /* between all windows versions tested. The first value is that valid on XP */
2869 /* Vista was the only that made returned different error values */
2870 /* between the TrackPopupMenu and TrackPopupMenuEx functions */
2871 static void test_menu_trackpopupmenu(void)
2877 HWND hwnd
= CreateWindowEx(0, MAKEINTATOM(atomMenuCheckClass
), NULL
,
2878 WS_VISIBLE
, CW_USEDEFAULT
, CW_USEDEFAULT
, 200, 200,
2879 NULL
, NULL
, NULL
, NULL
);
2880 ok(hwnd
!= NULL
, "CreateWindowEx failed with error %d\n", GetLastError());
2882 SetWindowLongPtr( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)menu_ownerdraw_wnd_proc
);
2883 for( Ex
= 0; Ex
< 2; Ex
++)
2885 hmenu
= CreatePopupMenu();
2886 ok(hmenu
!= NULL
, "CreateMenu failed with error %d\n", GetLastError());
2889 DestroyWindow(hwnd
);
2892 /* display the menu */
2893 /* start with an invalid menu handle */
2894 SetLastError(0xdeadbeef);
2896 gflag_initmenupopup
= gflag_entermenuloop
= gflag_initmenu
= 0;
2897 ret
= MyTrackPopupMenu( Ex
, NULL
, TPM_RETURNCMD
, 100,100, hwnd
, NULL
);
2898 gle
= GetLastError();
2899 ok( !ret
, "TrackPopupMenu%s should have failed\n", Ex
? "Ex" : "");
2900 ok( gle
== ERROR_INVALID_MENU_HANDLE
2901 || broken (gle
== 0xdeadbeef) /* win95 */
2902 || broken (gle
== NO_ERROR
) /* win98/ME */
2903 ,"TrackPopupMenu%s error got %u expected %u\n",
2904 Ex
? "Ex" : "", gle
, ERROR_INVALID_MENU_HANDLE
);
2905 ok( !(gflag_initmenupopup
|| gflag_entermenuloop
|| gflag_initmenu
),
2906 "got unexpected message(s)%s%s%s\n",
2907 gflag_initmenupopup
? " WM_INITMENUPOPUP ": " ",
2908 gflag_entermenuloop
? "WM_INITMENULOOP ": "",
2909 gflag_initmenu
? "WM_INITMENU": "");
2910 /* another one but not NULL */
2911 SetLastError(0xdeadbeef);
2912 gflag_initmenupopup
= gflag_entermenuloop
= gflag_initmenu
= 0;
2913 ret
= MyTrackPopupMenu( Ex
, (HMENU
)hwnd
, TPM_RETURNCMD
, 100,100, hwnd
, NULL
);
2914 gle
= GetLastError();
2915 ok( !ret
, "TrackPopupMenu%s should have failed\n", Ex
? "Ex" : "");
2916 ok( gle
== ERROR_INVALID_MENU_HANDLE
2917 || broken (gle
== 0xdeadbeef) /* win95 */
2918 || broken (gle
== NO_ERROR
) /* win98/ME */
2919 ,"TrackPopupMenu%s error got %u expected %u\n",
2920 Ex
? "Ex" : "", gle
, ERROR_INVALID_MENU_HANDLE
);
2921 ok( !(gflag_initmenupopup
|| gflag_entermenuloop
|| gflag_initmenu
),
2922 "got unexpected message(s)%s%s%s\n",
2923 gflag_initmenupopup
? " WM_INITMENUPOPUP ": " ",
2924 gflag_entermenuloop
? "WM_INITMENULOOP ": "",
2925 gflag_initmenu
? "WM_INITMENU": "");
2926 /* now a somewhat successful call */
2927 SetLastError(0xdeadbeef);
2928 gflag_initmenupopup
= gflag_entermenuloop
= gflag_initmenu
= 0;
2929 ret
= MyTrackPopupMenu( Ex
, hmenu
, TPM_RETURNCMD
, 100,100, hwnd
, NULL
);
2930 gle
= GetLastError();
2931 ok( ret
== 0, "TrackPopupMenu%s returned %d expected zero\n", Ex
? "Ex" : "", ret
);
2933 || gle
== ERROR_INVALID_MENU_HANDLE
/* NT4, win2k */
2934 || broken (gle
== 0xdeadbeef) /* win95 */
2935 ,"TrackPopupMenu%s error got %u expected %u or %u\n",
2936 Ex
? "Ex" : "", gle
, NO_ERROR
, ERROR_INVALID_MENU_HANDLE
);
2937 ok( gflag_initmenupopup
&& gflag_entermenuloop
&& gflag_initmenu
,
2938 "missed expected message(s)%s%s%s\n",
2939 !gflag_initmenupopup
? " WM_INITMENUPOPUP ": " ",
2940 !gflag_entermenuloop
? "WM_INITMENULOOP ": "",
2941 !gflag_initmenu
? "WM_INITMENU": "");
2943 ret
= AppendMenuA( hmenu
, MF_STRING
, 1, "winetest");
2944 ok( ret
, "AppendMenA has failed!\n");
2945 SetLastError(0xdeadbeef);
2946 gflag_initmenupopup
= gflag_entermenuloop
= gflag_initmenu
= 0;
2947 ret
= MyTrackPopupMenu( Ex
, hmenu
, TPM_RETURNCMD
, 100,100, hwnd
, NULL
);
2948 gle
= GetLastError();
2949 ok( ret
== 0, "TrackPopupMenu%s returned %d expected zero\n", Ex
? "Ex" : "", ret
);
2951 || gle
== ERROR_INVALID_MENU_HANDLE
/* NT4, win2k and Vista in the TrackPopupMenuEx case */
2952 || broken (gle
== 0xdeadbeef) /* win95 */
2953 ,"TrackPopupMenu%s error got %u expected %u or %u\n",
2954 Ex
? "Ex" : "", gle
, NO_ERROR
, ERROR_INVALID_MENU_HANDLE
);
2955 ok( gflag_initmenupopup
&& gflag_entermenuloop
&& gflag_initmenu
,
2956 "missed expected message(s)%s%s%s\n",
2957 !gflag_initmenupopup
? " WM_INITMENUPOPUP ": " ",
2958 !gflag_entermenuloop
? "WM_INITMENULOOP ": "",
2959 !gflag_initmenu
? "WM_INITMENU": "");
2963 DestroyWindow(hwnd
);
2966 static HMENU g_hmenu
;
2968 static LRESULT WINAPI
menu_track_again_wnd_proc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
2972 case WM_ENTERMENULOOP
:
2976 /* try a recursive call */
2977 SetLastError(0xdeadbeef);
2978 ret
= TrackPopupMenu(g_hmenu
, 0, 100, 100, 0, hwnd
, NULL
);
2979 ok(ret
== FALSE
, "got %d\n", ret
);
2980 ok(GetLastError() == ERROR_POPUP_ALREADY_ACTIVE
||
2981 broken(GetLastError() == 0xdeadbeef) /* W9x */, "got %d\n", GetLastError());
2983 /* exit menu modal loop
2984 * ( A SendMessage does not work on NT3.51 here ) */
2985 return PostMessage(hwnd
, WM_CANCELMODE
, 0, 0);
2988 return DefWindowProc(hwnd
, msg
, wparam
, lparam
);
2991 static void test_menu_trackagain(void)
2996 hwnd
= CreateWindowEx(0, MAKEINTATOM(atomMenuCheckClass
), NULL
,
2997 WS_VISIBLE
, CW_USEDEFAULT
, CW_USEDEFAULT
, 200, 200,
2998 NULL
, NULL
, NULL
, NULL
);
2999 ok(hwnd
!= NULL
, "CreateWindowEx failed with error %d\n", GetLastError());
3001 SetWindowLongPtr( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)menu_track_again_wnd_proc
);
3003 g_hmenu
= CreatePopupMenu();
3004 ok(g_hmenu
!= NULL
, "CreateMenu failed with error %d\n", GetLastError());
3006 ret
= TrackPopupMenu( g_hmenu
, 0, 100, 100, 0, hwnd
, NULL
);
3007 todo_wine
ok(ret
== FALSE
, "got %d\n", ret
);
3009 DestroyMenu(g_hmenu
);
3010 DestroyWindow(hwnd
);
3013 /* test handling of WM_CANCELMODE messages */
3014 static int g_got_enteridle
;
3015 static HWND g_hwndtosend
;
3016 static LRESULT WINAPI
menu_cancelmode_wnd_proc(HWND hwnd
, UINT msg
,
3017 WPARAM wparam
, LPARAM lparam
)
3021 case WM_ENTERMENULOOP
:
3022 g_got_enteridle
= 0;
3023 return SendMessage( g_hwndtosend
, WM_CANCELMODE
, 0, 0);
3026 if( g_got_enteridle
++ == 0) {
3027 /* little hack to get another WM_ENTERIDLE message */
3028 PostMessage( hwnd
, WM_MOUSEMOVE
, 0, 0);
3029 return SendMessage( g_hwndtosend
, WM_CANCELMODE
, 0, 0);
3035 return DefWindowProc( hwnd
, msg
, wparam
, lparam
);
3038 static void test_menu_cancelmode(void)
3041 HWND hwnd
, hwndchild
;
3043 if( !pEndMenu
) { /* win95 */
3044 win_skip( "EndMenu is not available\n");
3047 hwnd
= CreateWindowEx( 0, MAKEINTATOM(atomMenuCheckClass
), NULL
,
3048 WS_VISIBLE
, CW_USEDEFAULT
, CW_USEDEFAULT
, 200, 200,
3049 NULL
, NULL
, NULL
, NULL
);
3050 hwndchild
= CreateWindowEx( 0, MAKEINTATOM(atomMenuCheckClass
), NULL
,
3051 WS_VISIBLE
| WS_CHILD
, 10, 10, 20, 20,
3052 hwnd
, NULL
, NULL
, NULL
);
3053 ok( hwnd
!= NULL
&& hwndchild
!= NULL
,
3054 "CreateWindowEx failed with error %d\n", GetLastError());
3055 g_hwndtosend
= hwnd
;
3056 SetWindowLongPtr( hwnd
, GWLP_WNDPROC
, (LONG_PTR
)menu_cancelmode_wnd_proc
);
3057 SetWindowLongPtr( hwndchild
, GWLP_WNDPROC
, (LONG_PTR
)menu_cancelmode_wnd_proc
);
3058 menu
= CreatePopupMenu();
3059 ok( menu
!= NULL
, "CreatePopupMenu failed with error %d\n", GetLastError());
3060 ret
= AppendMenuA( menu
, MF_STRING
, 1, "winetest");
3061 ok( ret
, "Functie failed lasterror is %u\n", GetLastError());
3062 /* seems to be needed only on wine :( */
3063 {MSG msg
; while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);}
3064 /* test the effect of sending a WM_CANCELMODE message in the WM_INITMENULOOP
3065 * handler of the menu owner */
3066 /* test results is exctracted from variable g_got_enteridle. Possible values:
3067 * 0 : complete conformance. Sending WM_CANCELMODE cancels a menu initializing tracking
3068 * 1 : Sending WM_CANCELMODE cancels a menu that is in tracking state
3069 * 2 : Sending WM_CANCELMODE does not work
3071 /* menu owner is top level window */
3072 g_hwndtosend
= hwnd
;
3073 TrackPopupMenu( menu
, TPM_RETURNCMD
, 100,100, 0, hwnd
, NULL
);
3075 ok( g_got_enteridle
== 0, "received %d WM_ENTERIDLE messages, none expected\n", g_got_enteridle
);
3077 ok( g_got_enteridle
< 2, "received %d WM_ENTERIDLE messages, should be less than 2\n", g_got_enteridle
);
3078 /* menu owner is child window */
3079 g_hwndtosend
= hwndchild
;
3080 TrackPopupMenu( menu
, TPM_RETURNCMD
, 100,100, 0, hwndchild
, NULL
);
3082 ok(g_got_enteridle
== 0, "received %d WM_ENTERIDLE messages, none expected\n", g_got_enteridle
);
3084 ok(g_got_enteridle
< 2, "received %d WM_ENTERIDLE messages, should be less than 2\n", g_got_enteridle
);
3085 /* now send the WM_CANCELMODE messages to the WRONG window */
3086 /* those should fail ( to have any effect) */
3087 g_hwndtosend
= hwnd
;
3088 TrackPopupMenu( menu
, TPM_RETURNCMD
, 100,100, 0, hwndchild
, NULL
);
3089 ok( g_got_enteridle
== 2, "received %d WM_ENTERIDLE messages, should be 2\n", g_got_enteridle
);
3092 DestroyWindow( hwndchild
);
3093 DestroyWindow( hwnd
);
3096 /* show menu trees have a maximum depth */
3097 static void test_menu_maxdepth(void)
3099 #define NR_MENUS 100
3100 HMENU hmenus
[ NR_MENUS
];
3104 SetLastError(12345678);
3105 for( i
= 0; i
< NR_MENUS
; i
++) {
3106 hmenus
[i
] = CreatePopupMenu();
3107 if( !hmenus
[i
]) break;
3109 ok( i
== NR_MENUS
, "could not create more than %d menu's\n", i
);
3110 for( i
= 1; i
< NR_MENUS
; i
++) {
3111 ret
= AppendMenuA( hmenus
[i
], MF_POPUP
, (UINT_PTR
)hmenus
[i
-1],"test");
3114 trace("Maximum depth is %d\n", i
);
3115 ok( GetLastError() == 12345678, "unexpected error %d\n", GetLastError());
3117 broken( i
== NR_MENUS
), /* win98, NT */
3118 "no ( or very large) limit on menu depth!\n");
3120 for( i
= 0; i
< NR_MENUS
; i
++)
3121 DestroyMenu( hmenus
[i
]);
3125 static void test_menu_circref(void)
3130 menu1
= CreatePopupMenu();
3131 menu2
= CreatePopupMenu();
3132 ok( menu1
&& menu2
, "error creating menus.\n");
3133 ret
= AppendMenuA( menu1
, MF_POPUP
, (UINT_PTR
)menu2
, "winetest");
3134 ok( ret
, "AppendMenu failed, error is %d\n", GetLastError());
3135 ret
= AppendMenuA( menu1
, MF_STRING
| MF_HILITE
, 123, "winetest");
3136 ok( ret
, "AppendMenu failed, error is %d\n", GetLastError());
3137 /* app chooses an id that happens to clash with its own hmenu */
3138 ret
= AppendMenuA( menu2
, MF_STRING
, (UINT_PTR
)menu2
, "winetest");
3139 ok( ret
, "AppendMenu failed, error is %d\n", GetLastError());
3140 /* now attempt to change the string of the first item of menu1 */
3141 ret
= ModifyMenuA( menu1
, (UINT_PTR
)menu2
, MF_POPUP
, (UINT_PTR
)menu2
, "menu 2");
3143 broken( ret
), /* win98, NT */
3144 "ModifyMenu should have failed.\n");
3145 if( !ret
) { /* will probably stack fault if the ModifyMenu succeeded */
3146 ret
= GetMenuState( menu1
, 123, 0);
3147 ok( ret
== MF_HILITE
, "GetMenuState returned %x\n",ret
);
3149 DestroyMenu( menu2
);
3150 DestroyMenu( menu1
);
3153 /* test how the menu texts are aligned when the menu items have
3154 * different combinations of text and bitmaps (bug #13350) */
3155 static void test_menualign(void)
3159 HBITMAP hbm1
, hbm2
, hbm3
;
3160 MENUITEMINFO mii
= { sizeof(MENUITEMINFO
)};
3163 MENUINFO mi
= { sizeof( MENUINFO
)};
3165 if( !winetest_interactive
) {
3166 skip( "interactive alignment tests.\n");
3169 hwnd
= CreateWindowEx(0,
3171 "Menu text alignment Test\nPlease make a selection.",
3172 WS_OVERLAPPEDWINDOW
,
3175 NULL
, NULL
, 0, NULL
);
3176 ShowWindow( hwnd
, SW_SHOW
);
3177 /* create bitmaps */
3178 memset( bmfill
, 0xcc, sizeof( bmfill
));
3179 hbm1
= CreateBitmap( 10,10,1,1,bmfill
);
3180 hbm2
= CreateBitmap( 20,20,1,1,bmfill
);
3181 hbm3
= CreateBitmap( 50,6,1,1,bmfill
);
3182 ok( hbm1
&& hbm2
&& hbm3
, "Creating bitmaps failed\n");
3183 menu
= CreatePopupMenu();
3184 ok( menu
!= NULL
, "CreatePopupMenu() failed\n");
3186 mi
.fMask
= MIM_STYLE
;
3187 ret
= pGetMenuInfo( menu
, &mi
);
3188 ok( ret
, "GetMenuInfo failed: %d\n", GetLastError());
3189 ok( menu
!= NULL
, "GetMenuInfo() failed\n");
3190 ok( 0 == mi
.dwStyle
, "menuinfo style is %x\n", mi
.dwStyle
);
3193 mii
.fMask
= MIIM_BITMAP
| MIIM_STRING
| MIIM_ID
;
3195 mii
.hbmpItem
= hbm1
;
3196 mii
.dwTypeData
= (LPSTR
) " OK: menu texts are correctly left-aligned.";
3197 ret
= InsertMenuItem( menu
, -1, TRUE
, &mii
);
3198 ok( ret
, "InsertMenuItem() failed\n");
3199 mii
.fMask
= MIIM_BITMAP
| MIIM_STRING
| MIIM_ID
;
3201 mii
.hbmpItem
= hbm2
;
3202 mii
.dwTypeData
= (LPSTR
) " FAIL: menu texts are NOT left-aligned.";
3203 ret
= InsertMenuItem( menu
, -1, TRUE
, &mii
);
3204 ok( ret
, "InsertMenuItem() failed\n");
3205 ret
= TrackPopupMenu( menu
, TPM_RETURNCMD
, 110, 200, 0, hwnd
, NULL
);
3206 ok( ret
!= 2, "User indicated that menu text alignment test 1 failed %d\n", ret
);
3208 mii
.fMask
= MIIM_BITMAP
| MIIM_STRING
| MIIM_ID
;
3210 mii
.hbmpItem
= hbm3
;
3211 mii
.dwTypeData
= NULL
;
3212 ret
= InsertMenuItem( menu
, 0, TRUE
, &mii
);
3213 ok( ret
, "InsertMenuItem() failed\n");
3214 mii
.fMask
= MIIM_BITMAP
| MIIM_STRING
| MIIM_ID
;
3216 mii
.hbmpItem
= hbm1
;
3217 /* make the text a bit longer, to keep it readable */
3218 /* this bug is on winXP and reproduced on wine */
3219 mii
.dwTypeData
= (LPSTR
) " OK: menu texts are to the right of the bitmaps........";
3220 ret
= SetMenuItemInfo( menu
, 1, TRUE
, &mii
);
3221 ok( ret
, "SetMenuItemInfo() failed\n");
3223 mii
.hbmpItem
= hbm2
;
3224 mii
.dwTypeData
= (LPSTR
) " FAIL: menu texts are below the first bitmap. ";
3225 ret
= SetMenuItemInfo( menu
, 2, TRUE
, &mii
);
3226 ok( ret
, "SetMenuItemInfo() failed\n");
3227 ret
= TrackPopupMenu( menu
, TPM_RETURNCMD
, 110, 200, 0, hwnd
, NULL
);
3228 ok( ret
!= 2, "User indicated that menu text alignment test 2 failed %d\n", ret
);
3230 mii
.fMask
= MIIM_TYPE
| MIIM_ID
;
3232 mii
.fType
= MFT_BITMAP
;
3233 mii
.dwTypeData
= (LPSTR
) hbm3
;
3234 ret
= SetMenuItemInfo( menu
, 0, TRUE
, &mii
);
3235 ok( ret
, "SetMenuItemInfo() failed\n");
3236 mii
.fMask
= MIIM_BITMAP
| MIIM_STRING
| MIIM_ID
;
3238 mii
.hbmpItem
= NULL
;
3239 mii
.dwTypeData
= (LPSTR
) " OK: menu texts are below the bitmap.";
3240 ret
= SetMenuItemInfo( menu
, 1, TRUE
, &mii
);
3241 ok( ret
, "SetMenuItemInfo() failed\n");
3243 mii
.hbmpItem
= NULL
;
3244 mii
.dwTypeData
= (LPSTR
) " FAIL: menu texts are NOT below the bitmap.";
3245 ret
= SetMenuItemInfo( menu
, 2, TRUE
, &mii
);
3246 ok( ret
, "SetMenuItemInfo() failed\n");
3247 ret
= TrackPopupMenu( menu
, TPM_RETURNCMD
, 110, 200, 0, hwnd
, NULL
);
3248 ok( ret
!= 2, "User indicated that menu text alignment test 3 failed %d\n", ret
);
3250 DeleteObject( hbm1
);
3251 DeleteObject( hbm2
);
3252 DeleteObject( hbm3
);
3254 DestroyWindow( hwnd
);
3259 init_function_pointers();
3261 /* Wine defines MENUITEMINFO for W2K and above. NT4 and below can't
3264 if (correct_behavior())
3266 test_menu_add_string();
3267 test_menu_iteminfo();
3268 test_menu_search_bycommand();
3269 test_CheckMenuRadioItem();
3270 test_menu_resource_layout();
3275 register_menu_check_class();
3277 test_menu_locked_by_window();
3278 test_subpopup_locked_by_menu();
3279 test_menu_ownerdraw();
3280 test_menu_bmp_and_string();
3281 test_menu_getmenuinfo();
3282 test_menu_setmenuinfo();
3286 test_menu_hilitemenuitem();
3287 test_menu_trackpopupmenu();
3288 test_menu_trackagain();
3289 test_menu_cancelmode();
3290 test_menu_maxdepth();
3291 test_menu_circref();