ReactOS 0.4.16-dev-122-g325d74c
menu.c File Reference
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "wine/test.h"
Include dependency graph for menu.c:

Go to the source code of this file.

Classes

struct  TEST_INPUT
 
struct  menu_item_pair_s
 
struct  menu_mouse_tests_s
 
struct  menu_data
 

Macros

#define OEMRESOURCE   /* For OBM_MNARROW */
 
#define MOD_SIZE   10
 
#define MOD_NRMENUS   8
 
#define TMII_INSMI(c1, d1, e1, f1, g1, h1, i1, j1, k1, l1, m1, eret1)
 
#define TMII_GMII(c2, l2, d3, e3, f3, g3, h3, i3, j3, k3, l3, m3, expname, eret2, eret3)
 
#define TMII_DONE
 
#define TMII_MODM(flags, id, data)    modify_menu( __LINE__, hmenu, ansi, flags, id, data )
 
#define TMII_SMII(c1, d1, e1, f1, g1, h1, i1, j1, k1, l1, m1)    set_menu_item_info( __LINE__, hmenu, ansi, c1, d1, e1, f1, g1, h1, i1, j1, k1, l1, m1 )
 
#define OK   1
 
#define ER   0
 
#define create_menu(a)   create_menu_from_data((a), ARRAY_SIZE(a))
 
#define create_menuitem(a)   create_menuitem_from_data((a), ARRAY_SIZE(a))
 
#define compare_menu(h, a)   compare_menu_data((h), (a), ARRAY_SIZE(a))
 
#define NR_MENUS   100
 

Functions

static LRESULT WINAPI menu_check_wnd_proc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
 
static LRESULT WINAPI menu_ownerdraw_wnd_proc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
 
static void register_menu_check_class (void)
 
static void test_getmenubarinfo (void)
 
static void test_GetMenuItemRect (void)
 
static void test_system_menu (void)
 
static void test_menu_locked_by_window (void)
 
static LRESULT WINAPI subpopuplocked_wnd_proc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
 
static void test_subpopup_locked_by_menu (void)
 
static void test_menu_ownerdraw (void)
 
static void test_mbs_help (int ispop, int hassub, int mnuopt, HWND hwnd, int arrowwidth, int count, HBITMAP hbmp, SIZE bmpsize, LPCSTR text, SIZE size, SIZE sc_size)
 
static void test_menu_bmp_and_string (void)
 
static void test_menu_add_string (void)
 
static int strncmpW (const WCHAR *str1, const WCHAR *str2, int n)
 
static WCHARstrcpyW (WCHAR *dst, const WCHAR *src)
 
static void insert_menu_item (int line, HMENU hmenu, BOOL ansi, UINT mask, UINT type, UINT state, UINT id, HMENU submenu, HBITMAP checked, HBITMAP unchecked, ULONG_PTR data, void *type_data, UINT len, HBITMAP item, BOOL expect)
 
static void check_menu_item_info (int line, HMENU hmenu, BOOL ansi, UINT mask, UINT type, UINT state, UINT id, HMENU submenu, HBITMAP checked, HBITMAP unchecked, ULONG_PTR data, void *type_data, UINT in_len, UINT out_len, HBITMAP item, LPCSTR expname, BOOL expect, BOOL expstring)
 
static void modify_menu (int line, HMENU hmenu, BOOL ansi, UINT flags, UINT_PTR id, void *data)
 
static void set_menu_item_info (int line, HMENU hmenu, BOOL ansi, UINT mask, UINT type, UINT state, UINT id, HMENU submenu, HBITMAP checked, HBITMAP unchecked, ULONG_PTR data, void *type_data, UINT len, HBITMAP item)
 
static void test_menu_iteminfo (void)
 
static void test_menu_search_bycommand (void)
 
static void send_key (WORD wVk)
 
static BOOL click_menu (HANDLE hWnd, struct menu_item_pair_s *mi)
 
static DWORD WINAPI test_menu_input_thread (LPVOID lpParameter)
 
static LRESULT CALLBACK WndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
static void test_menu_input (void)
 
static void test_menu_flags (void)
 
static void test_menu_hilitemenuitem (void)
 
static void check_menu_items (HMENU hmenu, UINT checked_cmd, UINT checked_type, UINT checked_state)
 
static void clear_ftype_and_state (HMENU hmenu, UINT id, UINT flags)
 
static void test_CheckMenuRadioItem (void)
 
static void test_menu_resource_layout (void)
 
static HMENU create_menu_from_data (const struct menu_data *item, INT item_count)
 
static HMENU create_menuitem_from_data (const struct menu_data *item, INT item_count)
 
static void compare_menu_data (HMENU hmenu, const struct menu_data *item, INT item_count)
 
static void test_InsertMenu (void)
 
static void test_menu_getmenuinfo (void)
 
static void test_menu_setmenuinfo (void)
 
static DWORD MyTrackPopupMenu (int ex, HMENU hmenu, UINT flags, INT x, INT y, HWND hwnd, LPTPMPARAMS ptpm)
 
static void test_menu_trackpopupmenu (void)
 
static LRESULT WINAPI menu_track_again_wnd_proc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
 
static void test_menu_trackagain (void)
 
static LRESULT WINAPI menu_cancelmode_wnd_proc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
 
static void test_menu_cancelmode (void)
 
static void test_menu_maxdepth (void)
 
static void test_menu_circref (void)
 
static void test_menualign (void)
 
static LRESULT WINAPI menu_fill_in_init (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
 
static void test_emptypopup (void)
 
static HMENU get_bad_hmenu (UINT_PTR id)
 
static void test_AppendMenu (void)
 
 START_TEST (menu)
 

Variables

static ATOM atomMenuCheckClass
 
static BOOL bMenuVisible
 
static INT popmenu
 
static BOOL got_input
 
static HMENU hMenus [4]
 
struct {
   LPCSTR   text
 
   SIZE   size
 
   SIZE   sc_size
 
MOD_txtsizes []
 
static unsigned int MOD_maxid
 
static RECT MOD_rc [MOD_NRMENUS]
 
static int MOD_avec
 
static int MOD_hic
 
static int MOD_odheight
 
static SIZE MODsizes [MOD_NRMENUS]
 
static BOOL MOD_GotDrawItemMsg = FALSE
 
static int gflag_initmenupopup
 
static int gflag_entermenuloop
 
static int gflag_initmenu
 
static int gflag_enteridle
 
static WPARAM selectitem_wp
 
static LPARAM selectitem_lp
 
static struct menu_mouse_tests_s menu_tests []
 
static HMENU g_hmenu
 
static int g_got_enteridle
 
static HWND g_hwndtosend
 

Macro Definition Documentation

◆ compare_menu

#define compare_menu (   h,
  a 
)    compare_menu_data((h), (a), ARRAY_SIZE(a))

◆ create_menu

#define create_menu (   a)    create_menu_from_data((a), ARRAY_SIZE(a))

◆ create_menuitem

#define create_menuitem (   a)    create_menuitem_from_data((a), ARRAY_SIZE(a))

◆ ER

#define ER   0

Definition at line 1390 of file menu.c.

◆ MOD_NRMENUS

#define MOD_NRMENUS   8

Definition at line 73 of file menu.c.

◆ MOD_SIZE

#define MOD_SIZE   10

Definition at line 72 of file menu.c.

◆ NR_MENUS

#define NR_MENUS   100

◆ OEMRESOURCE

#define OEMRESOURCE   /* For OBM_MNARROW */

Definition at line 27 of file menu.c.

◆ OK

#define OK   1

Definition at line 1389 of file menu.c.

◆ TMII_DONE

#define TMII_DONE
Value:
DestroyMenu( hmenu );\
DestroyMenu( submenu );
#define TRUE
Definition: types.h:120
static HMENU hmenu
Definition: win.c:66
BOOL WINAPI RemoveMenu(_In_ HMENU, _In_ UINT, _In_ UINT)

Definition at line 1375 of file menu.c.

◆ TMII_GMII

#define TMII_GMII (   c2,
  l2,
  d3,
  e3,
  f3,
  g3,
  h3,
  i3,
  j3,
  k3,
  l3,
  m3,
  expname,
  eret2,
  eret3 
)
Value:
check_menu_item_info( __LINE__, hmenu, ansi, c2, d3, e3, f3, g3, h3, i3, j3, k3, l2, l3, m3, \
expname, eret2, eret3 )
static void check_menu_item_info(int line, HMENU hmenu, BOOL ansi, UINT mask, UINT type, UINT state, UINT id, HMENU submenu, HBITMAP checked, HBITMAP unchecked, ULONG_PTR data, void *type_data, UINT in_len, UINT out_len, HBITMAP item, LPCSTR expname, BOOL expect, BOOL expstring)
Definition: menu.c:1248
#define f3(x, y, z)
Definition: sha1.c:32

Definition at line 1369 of file menu.c.

◆ TMII_INSMI

#define TMII_INSMI (   c1,
  d1,
  e1,
  f1,
  g1,
  h1,
  i1,
  j1,
  k1,
  l1,
  m1,
  eret1 
)
Value:
submenu = CreateMenu();\
if(ansi)strcpy( string, init );\
else strcpyW( string, init );\
insert_menu_item( __LINE__, hmenu, ansi, c1, d1, e1, f1, g1, h1, i1, j1, k1, l1, m1, eret1 )
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define strcpyW(d, s)
Definition: unicode.h:35
#define f1(x, y, z)
Definition: sha1.c:30
static int init
Definition: wintirpc.c:33
HMENU WINAPI CreateMenu(void)
Definition: menu.c:829

Definition at line 1361 of file menu.c.

◆ TMII_MODM

#define TMII_MODM (   flags,
  id,
  data 
)     modify_menu( __LINE__, hmenu, ansi, flags, id, data )

Definition at line 1381 of file menu.c.

◆ TMII_SMII

#define TMII_SMII (   c1,
  d1,
  e1,
  f1,
  g1,
  h1,
  i1,
  j1,
  k1,
  l1,
  m1 
)     set_menu_item_info( __LINE__, hmenu, ansi, c1, d1, e1, f1, g1, h1, i1, j1, k1, l1, m1 )

Definition at line 1385 of file menu.c.

Function Documentation

◆ check_menu_item_info()

static void check_menu_item_info ( int  line,
HMENU  hmenu,
BOOL  ansi,
UINT  mask,
UINT  type,
UINT  state,
UINT  id,
HMENU  submenu,
HBITMAP  checked,
HBITMAP  unchecked,
ULONG_PTR  data,
void type_data,
UINT  in_len,
UINT  out_len,
HBITMAP  item,
LPCSTR  expname,
BOOL  expect,
BOOL  expstring 
)
static

Definition at line 1248 of file menu.c.

1252{
1254 BOOL ret;
1255 WCHAR buffer[80];
1256
1257 SetLastError( 0xdeadbeef );
1258 memset( &info, 0xcc, sizeof(info) );
1259 info.cbSize = sizeof(info);
1260 info.fMask = mask;
1261 info.dwTypeData = type_data;
1262 info.cch = in_len;
1263
1264 ret = ansi ? GetMenuItemInfoA( hmenu, 0, TRUE, &info ) :
1266 if (!expect)
1267 {
1268 ok_(__FILE__, line)( !ret, "GetMenuItemInfo should have failed.\n" );
1269 return;
1270 }
1271 ok_(__FILE__, line)( ret, "GetMenuItemInfo failed, err %u\n", GetLastError());
1272 if (mask & MIIM_TYPE)
1273 ok_(__FILE__, line)( info.fType == type || info.fType == LOWORD(type),
1274 "wrong type %x/%x\n", info.fType, type );
1275 if (mask & MIIM_STATE)
1276 ok_(__FILE__, line)( info.fState == state || info.fState == LOWORD(state),
1277 "wrong state %x/%x\n", info.fState, state );
1278 if (mask & MIIM_ID)
1279 ok_(__FILE__, line)( info.wID == id || info.wID == LOWORD(id),
1280 "wrong id %x/%x\n", info.wID, id );
1281 if (mask & MIIM_SUBMENU)
1282 ok_(__FILE__, line)( info.hSubMenu == submenu || (ULONG_PTR)info.hSubMenu == LOWORD(submenu),
1283 "wrong submenu %p/%p\n", info.hSubMenu, submenu );
1284 if (mask & MIIM_CHECKMARKS)
1285 {
1286 ok_(__FILE__, line)( info.hbmpChecked == checked || (ULONG_PTR)info.hbmpChecked == LOWORD(checked),
1287 "wrong bmpchecked %p/%p\n", info.hbmpChecked, checked );
1288 ok_(__FILE__, line)( info.hbmpUnchecked == unchecked || (ULONG_PTR)info.hbmpUnchecked == LOWORD(unchecked),
1289 "wrong bmpunchecked %p/%p\n", info.hbmpUnchecked, unchecked );
1290 }
1291 if (mask & MIIM_DATA)
1292 ok_(__FILE__, line)( info.dwItemData == data || info.dwItemData == LOWORD(data),
1293 "wrong item data %lx/%lx\n", info.dwItemData, data );
1294 if (mask & MIIM_BITMAP)
1295 ok_(__FILE__, line)( info.hbmpItem == item || (ULONG_PTR)info.hbmpItem == LOWORD(item),
1296 "wrong bmpitem %p/%p\n", info.hbmpItem, item );
1297 ok_(__FILE__, line)( info.dwTypeData == type_data || (ULONG_PTR)info.dwTypeData == LOWORD(type_data),
1298 "wrong type data %p/%p\n", info.dwTypeData, type_data );
1299 ok_(__FILE__, line)( info.cch == out_len ||
1300 broken(! ansi && info.cch == 2 * out_len) /* East-Asian */,
1301 "wrong len %x/%x\n", info.cch, out_len );
1302 if (expname)
1303 {
1304 if(ansi)
1305 ok_(__FILE__, line)( !strncmp( expname, info.dwTypeData, out_len ),
1306 "menu item name differed from '%s' '%s'\n", expname, info.dwTypeData );
1307 else
1308 ok_(__FILE__, line)( !strncmpW( (WCHAR *)expname, (WCHAR *)info.dwTypeData, out_len ),
1309 "menu item name wrong\n" );
1310
1311 SetLastError( 0xdeadbeef );
1312 ret = ansi ? GetMenuStringA( hmenu, 0, (char *)buffer, 80, MF_BYPOSITION ) :
1314 if (expstring)
1315 ok_(__FILE__, line)( ret, "GetMenuString failed, err %u\n", GetLastError());
1316 else
1317 ok_(__FILE__, line)( !ret, "GetMenuString should have failed\n" );
1318 }
1319}
#define expect(EXPECTED, GOT)
Definition: SystemMenu.c:483
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
static int state
Definition: maze.c:121
#define broken(x)
Definition: atltest.h:178
#define ok_(x1, x2)
Definition: atltest.h:61
#define SetLastError(x)
Definition: compat.h:752
#define ULONG_PTR
Definition: config.h:101
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLuint buffer
Definition: glext.h:5915
GLenum GLint GLuint mask
Definition: glext.h:6028
GLuint id
Definition: glext.h:5910
static ATOM item
Definition: dde.c:856
#define LOWORD(l)
Definition: pedump.c:82
#define strncmpW(s1, s2, n)
Definition: unicode.h:42
#define memset(x, y, z)
Definition: compat.h:39
Definition: parser.c:49
int ret
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define MIIM_ID
Definition: winuser.h:725
int WINAPI GetMenuStringW(_In_ HMENU hMenu, _In_ UINT uIDItem, _Out_writes_opt_(cchMax) LPWSTR lpString, _In_ int cchMax, _In_ UINT flags)
#define MIIM_CHECKMARKS
Definition: winuser.h:727
int WINAPI GetMenuStringA(_In_ HMENU hMenu, _In_ UINT uIDItem, _Out_writes_opt_(cchMax) LPSTR lpString, _In_ int cchMax, _In_ UINT flags)
#define MIIM_STATE
Definition: winuser.h:724
#define MIIM_SUBMENU
Definition: winuser.h:726
#define MIIM_BITMAP
Definition: winuser.h:731
#define MF_BYPOSITION
Definition: winuser.h:203
BOOL WINAPI GetMenuItemInfoW(_In_ HMENU, _In_ UINT, _In_ BOOL, _Inout_ LPMENUITEMINFOW)
BOOL WINAPI GetMenuItemInfoA(_In_ HMENU, _In_ UINT, _In_ BOOL, _Inout_ LPMENUITEMINFOA)
#define MIIM_DATA
Definition: winuser.h:729
#define MIIM_TYPE
Definition: winuser.h:728
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ check_menu_items()

static void check_menu_items ( HMENU  hmenu,
UINT  checked_cmd,
UINT  checked_type,
UINT  checked_state 
)
static

Definition at line 2657 of file menu.c.

2659{
2660 INT i, count;
2661
2663 ok (count != -1, "GetMenuItemCount returned -1\n");
2664
2665 for (i = 0; i < count; i++)
2666 {
2667 BOOL ret;
2668 MENUITEMINFOA mii;
2669
2670 memset(&mii, 0, sizeof(mii));
2671 mii.cbSize = sizeof(mii);
2673 ret = GetMenuItemInfoA(hmenu, i, TRUE, &mii);
2674 ok(ret, "GetMenuItemInfo(%u) failed\n", i);
2675
2676 if (winetest_debug > 1)
2677 trace("item #%u: fType %04x, fState %04x, wID %u, hSubMenu %p\n",
2678 i, mii.fType, mii.fState, mii.wID, mii.hSubMenu);
2679
2680 if (mii.hSubMenu)
2681 {
2682 ok(mii.wID == (UINT_PTR)mii.hSubMenu, "id %u: wID %x should be equal to hSubMenu %p\n",
2683 checked_cmd, mii.wID, mii.hSubMenu);
2684 if (!GetMenuItemCount(mii.hSubMenu))
2685 {
2686 ok(mii.fType == checked_type, "id %u: expected fType %04x, got %04x\n", checked_cmd, checked_type, mii.fType);
2687 ok(mii.fState == checked_state, "id %u: expected fState %04x, got %04x\n", checked_cmd, checked_state, mii.fState);
2688 }
2689 check_menu_items(mii.hSubMenu, checked_cmd, checked_type, checked_state);
2690 }
2691 else
2692 {
2693 if (mii.wID == checked_cmd)
2694 {
2695 ok(mii.fType == checked_type, "id %u: expected fType %04x, got %04x\n", checked_cmd, checked_type, mii.fType);
2696 ok(mii.fState == checked_state, "id %u: expected fState %04x, got %04x\n", checked_cmd, checked_state, mii.fState);
2697 ok(mii.wID != 0, "id %u: not expected wID 0\n", checked_cmd);
2698 }
2699 else
2700 {
2701 ok(mii.fType != MFT_RADIOCHECK, "id %u: not expected fType MFT_RADIOCHECK on cmd %u\n", checked_cmd, mii.wID);
2702
2703 if (mii.fType == MFT_SEPARATOR)
2704 {
2705 ok(mii.fState == MFS_GRAYED, "id %u: expected fState MFS_GRAYED, got %04x\n", checked_cmd, mii.fState);
2706 ok(mii.wID == 0, "id %u: expected wID 0, got %u\n", checked_cmd, mii.wID);
2707 }
2708 else
2709 {
2710 ok(mii.fState == 0, "id %u: expected fState 0, got %04x\n", checked_cmd, mii.fState);
2711 ok(mii.wID != 0, "id %u: not expected wID 0\n", checked_cmd);
2712 }
2713 }
2714 }
2715 }
2716}
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static void check_menu_items(HMENU hmenu, UINT checked_cmd, UINT checked_type, UINT checked_state)
Definition: menu.c:2657
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
int winetest_debug
int32_t INT
Definition: typedefs.h:58
int WINAPI GetMenuItemCount(_In_opt_ HMENU)
#define MIIM_FTYPE
Definition: winuser.h:732
#define MFT_SEPARATOR
Definition: winuser.h:747
#define MFS_GRAYED
Definition: winuser.h:754
#define MFT_RADIOCHECK
Definition: winuser.h:745

Referenced by check_menu_items(), test_AppendMenu(), and test_CheckMenuRadioItem().

◆ clear_ftype_and_state()

static void clear_ftype_and_state ( HMENU  hmenu,
UINT  id,
UINT  flags 
)
static

Definition at line 2718 of file menu.c.

2719{
2720 BOOL ret;
2721 MENUITEMINFOA mii;
2722
2723 memset(&mii, 0, sizeof(mii));
2724 mii.cbSize = sizeof(mii);
2725 mii.fMask = MIIM_FTYPE | MIIM_STATE;
2726 ret = SetMenuItemInfoA(hmenu, id, (flags & MF_BYPOSITION) != 0, &mii);
2727 ok(ret, "SetMenuItemInfo(%u) failed\n", id);
2728}
GLbitfield flags
Definition: glext.h:7161
BOOL WINAPI SetMenuItemInfoA(_In_ HMENU, _In_ UINT, _In_ BOOL, _In_ LPCMENUITEMINFOA)

Referenced by test_CheckMenuRadioItem().

◆ click_menu()

static BOOL click_menu ( HANDLE  hWnd,
struct menu_item_pair_s mi 
)
static

Definition at line 2269 of file menu.c.

2270{
2271 HMENU hMenu = hMenus[mi->uMenu];
2272 TEST_INPUT i[3];
2273 MSG msg;
2274 RECT r;
2275 int screen_w = GetSystemMetrics(SM_CXSCREEN);
2276 int screen_h = GetSystemMetrics(SM_CYSCREEN);
2277 BOOL ret = GetMenuItemRect(mi->uMenu > 2 ? NULL : hWnd, hMenu, mi->uItem, &r);
2278 if(!ret) return FALSE;
2279
2280 memset(i, 0, sizeof(i));
2281 i[0].type = i[1].type = i[2].type = INPUT_MOUSE;
2282 i[0].u.mi.dx = i[1].u.mi.dx = i[2].u.mi.dx
2283 = ((r.left + 5) * 65535) / screen_w;
2284 i[0].u.mi.dy = i[1].u.mi.dy = i[2].u.mi.dy
2285 = ((r.top + 5) * 65535) / screen_h;
2286 i[0].u.mi.dwFlags = i[1].u.mi.dwFlags = i[2].u.mi.dwFlags
2288 i[0].u.mi.dwFlags |= MOUSEEVENTF_MOVE;
2289 i[1].u.mi.dwFlags |= MOUSEEVENTF_LEFTDOWN;
2290 i[2].u.mi.dwFlags |= MOUSEEVENTF_LEFTUP;
2291 ret = SendInput(3, (INPUT *) i, sizeof(INPUT));
2292
2293 /* hack to prevent mouse message buildup in Wine */
2294 while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg );
2295 return ret;
2296}
#define msg(x)
Definition: auth_time.c:54
HWND hWnd
Definition: settings.c:17
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:63
static HMENU hMenus[4]
Definition: menu.c:70
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
static MONITORINFO mi
Definition: win.c:7338
UINT WINAPI SendInput(UINT, LPINPUT, int)
Definition: ntwrapper.h:344
#define INPUT_MOUSE
Definition: winable.h:9
LRESULT WINAPI DispatchMessageA(_In_ const MSG *)
#define MOUSEEVENTF_ABSOLUTE
Definition: winuser.h:1197
#define SM_CYSCREEN
Definition: winuser.h:963
#define MOUSEEVENTF_LEFTUP
Definition: winuser.h:1188
#define MOUSEEVENTF_MOVE
Definition: winuser.h:1186
#define MOUSEEVENTF_LEFTDOWN
Definition: winuser.h:1187
#define PM_REMOVE
Definition: winuser.h:1199
BOOL WINAPI GetMenuItemRect(_In_opt_ HWND, _In_ HMENU, _In_ UINT, _Out_ LPRECT)
BOOL WINAPI PeekMessageA(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
#define SM_CXSCREEN
Definition: winuser.h:962
int WINAPI GetSystemMetrics(_In_ int)

Referenced by test_menu_input_thread().

◆ compare_menu_data()

static void compare_menu_data ( HMENU  hmenu,
const struct menu_data item,
INT  item_count 
)
static

Definition at line 2926 of file menu.c.

2927{
2928 INT count, i;
2929 BOOL ret;
2930
2932 ok(count == item_count, "expected %d, got %d menu items\n", count, item_count);
2933
2934 for (i = 0; i < count; i++)
2935 {
2936 char buf[20];
2937 MENUITEMINFOA mii;
2938
2939 memset(&mii, 0, sizeof(mii));
2940 mii.cbSize = sizeof(mii);
2941 mii.dwTypeData = buf;
2942 mii.cch = sizeof(buf);
2944 ret = GetMenuItemInfoA(hmenu, i, TRUE, &mii);
2945 ok(ret, "GetMenuItemInfo(%u) failed\n", i);
2946
2947 if (winetest_debug > 1)
2948 trace("item #%u: fType %04x, fState %04x, wID %04x, hbmp %p\n",
2949 i, mii.fType, mii.fState, mii.wID, mii.hbmpItem);
2950
2951 ok(mii.fType == item[i].type,
2952 "%u: expected fType %04x, got %04x\n", i, item[i].type, mii.fType);
2953 ok(mii.wID == item[i].id,
2954 "%u: expected wID %04x, got %04x\n", i, item[i].id, mii.wID);
2955 if (mii.hbmpItem || !item[i].str)
2956 /* For some reason Windows sets high word to not 0 for
2957 * not "magic" ids.
2958 */
2959 ok(LOWORD(mii.hbmpItem) == LOWORD(item[i].str),
2960 "%u: expected hbmpItem %p, got %p\n", i, item[i].str, mii.hbmpItem);
2961 else
2962 {
2963 ok(mii.cch == strlen(item[i].str),
2964 "%u: expected cch %u, got %u\n", i, (UINT)strlen(item[i].str), mii.cch);
2965 ok(!strcmp(mii.dwTypeData, item[i].str),
2966 "%u: expected dwTypeData %s, got %s\n", i, item[i].str, (LPCSTR)mii.dwTypeData);
2967 }
2968 }
2969}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
unsigned int UINT
Definition: ndis.h:50
const WCHAR * str
LPSTR dwTypeData
Definition: winuser.h:3254
#define MIIM_STRING
Definition: winuser.h:730
const char * LPCSTR
Definition: xmlstorage.h:183

◆ create_menu_from_data()

static HMENU create_menu_from_data ( const struct menu_data item,
INT  item_count 
)
static

Definition at line 2865 of file menu.c.

2866{
2867 HMENU hmenu;
2868 INT i;
2869 BOOL ret;
2870
2871 hmenu = CreateMenu();
2872 assert(hmenu != 0);
2873
2874 for (i = 0; i < item_count; i++)
2875 {
2876 SetLastError(0xdeadbeef);
2877 ret = AppendMenuA(hmenu, item[i].type, item[i].id, item[i].str);
2878 ok(ret, "%d: AppendMenu(%04x, %04x, %p) error %u\n",
2879 i, item[i].type, item[i].id, item[i].str, GetLastError());
2880 }
2881 return hmenu;
2882}
#define assert(x)
Definition: debug.h:53
BOOL WINAPI AppendMenuA(_In_ HMENU, _In_ UINT, _In_ UINT_PTR, _In_opt_ LPCSTR)

◆ create_menuitem_from_data()

static HMENU create_menuitem_from_data ( const struct menu_data item,
INT  item_count 
)
static

Definition at line 2887 of file menu.c.

2888{
2889 HMENU hmenu;
2890 INT i;
2891 BOOL ret;
2892 MENUITEMINFOA mii = { sizeof( MENUITEMINFOA) };
2893
2894 hmenu = CreateMenu();
2895 assert(hmenu != 0);
2896
2897 for (i = 0; i < item_count; i++)
2898 {
2899 SetLastError(0xdeadbeef);
2900
2902 mii.fType = 0;
2903 if( item[i].type & MFT_BITMAP)
2904 {
2905 mii.fMask |= MIIM_BITMAP;
2906 mii.hbmpItem = (HBITMAP)item[i].str;
2907 }
2908 else if( item[i].type & MFT_SEPARATOR)
2909 mii.fType = MFT_SEPARATOR;
2910 else
2911 {
2912 mii.fMask |= MIIM_STRING;
2913 mii.dwTypeData = (LPSTR)item[i].str;
2914 mii.cch = strlen( item[i].str);
2915 }
2916 mii.fState = 0;
2917 if( item[i].type & MF_HELP) mii.fType |= MF_HELP;
2918 mii.wID = item[i].id;
2919 ret = InsertMenuItemA( hmenu, -1, TRUE, &mii);
2920 ok(ret, "%d: InsertMenuItem(%04x, %04x, %p) error %u\n",
2921 i, item[i].type, item[i].id, item[i].str, GetLastError());
2922 }
2923 return hmenu;
2924}
static HBITMAP
Definition: button.c:44
struct tagMENUITEMINFOA MENUITEMINFOA
BOOL WINAPI InsertMenuItemA(_In_ HMENU, _In_ UINT, _In_ BOOL, _In_ LPCMENUITEMINFOA)
#define MFT_BITMAP
Definition: winuser.h:741
#define MF_HELP
Definition: winuser.h:142
char * LPSTR
Definition: xmlstorage.h:182

◆ get_bad_hmenu()

static HMENU get_bad_hmenu ( UINT_PTR  id)
static

Definition at line 3808 of file menu.c.

3809{
3810 while (IsMenu( (HMENU)id )) id++;
3811 return (HMENU)id;
3812}
BOOL WINAPI IsMenu(_In_ HMENU)

Referenced by test_AppendMenu().

◆ insert_menu_item()

static void insert_menu_item ( int  line,
HMENU  hmenu,
BOOL  ansi,
UINT  mask,
UINT  type,
UINT  state,
UINT  id,
HMENU  submenu,
HBITMAP  checked,
HBITMAP  unchecked,
ULONG_PTR  data,
void type_data,
UINT  len,
HBITMAP  item,
BOOL  expect 
)
static

Definition at line 1218 of file menu.c.

1221{
1223 BOOL ret;
1224
1225 /* magic bitmap handle to test smaller cbSize */
1226 if (item == (HBITMAP)(ULONG_PTR)0xdeadbeef)
1227 info.cbSize = FIELD_OFFSET(MENUITEMINFOA,hbmpItem);
1228 else
1229 info.cbSize = sizeof(info);
1230 info.fMask = mask;
1231 info.fType = type;
1232 info.fState = state;
1233 info.wID = id;
1234 info.hSubMenu = submenu;
1235 info.hbmpChecked = checked;
1236 info.hbmpUnchecked = unchecked;
1237 info.dwItemData = data;
1238 info.dwTypeData = type_data;
1239 info.cch = len;
1240 info.hbmpItem = item;
1241 SetLastError( 0xdeadbeef );
1242 if (ansi) ret = InsertMenuItemA( hmenu, 0, TRUE, &info );
1243 else ret = InsertMenuItemW( hmenu, 0, TRUE, (MENUITEMINFOW*)&info );
1244 if (!expect) ok_(__FILE__, line)( !ret, "InsertMenuItem should have failed.\n" );
1245 else ok_(__FILE__, line)( ret, "InsertMenuItem failed, err %u\n", GetLastError());
1246}
GLenum GLsizei len
Definition: glext.h:6722
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
uint32_t ULONG_PTR
Definition: typedefs.h:65
BOOL WINAPI InsertMenuItemW(_In_ HMENU, _In_ UINT, _In_ BOOL, _In_ LPCMENUITEMINFOW)

◆ menu_cancelmode_wnd_proc()

static LRESULT WINAPI menu_cancelmode_wnd_proc ( HWND  hwnd,
UINT  msg,
WPARAM  wparam,
LPARAM  lparam 
)
static

Definition at line 3457 of file menu.c.

3459{
3460 switch (msg)
3461 {
3462 case WM_ENTERMENULOOP:
3463 g_got_enteridle = 0;
3464 return SendMessageA( g_hwndtosend, WM_CANCELMODE, 0, 0);
3465 case WM_ENTERIDLE:
3466 {
3467 if( g_got_enteridle++ == 0) {
3468 /* little hack to get another WM_ENTERIDLE message */
3470 return SendMessageA( g_hwndtosend, WM_CANCELMODE, 0, 0);
3471 }
3472 EndMenu();
3473 return TRUE;
3474 }
3475 }
3476 return DefWindowProcA( hwnd, msg, wparam, lparam);
3477}
@ lparam
Definition: SystemMenu.c:31
@ wparam
Definition: SystemMenu.c:30
static HWND g_hwndtosend
Definition: menu.c:3456
static int g_got_enteridle
Definition: menu.c:3455
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
BOOL WINAPI EndMenu(void)
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_CANCELMODE
Definition: winuser.h:1638
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_MOUSEMOVE
Definition: winuser.h:1778
#define WM_ENTERMENULOOP
Definition: winuser.h:1807
#define WM_ENTERIDLE
Definition: winuser.h:1752
BOOL WINAPI PostMessageA(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by test_menu_cancelmode().

◆ menu_check_wnd_proc()

static LRESULT WINAPI menu_check_wnd_proc ( HWND  hwnd,
UINT  msg,
WPARAM  wparam,
LPARAM  lparam 
)
static

Definition at line 38 of file menu.c.

39{
40 switch (msg)
41 {
43 /* mark window as having entered menu loop */
45 /* exit menu modal loop
46 * ( A SendMessage does not work on NT3.51 here ) */
47 return PostMessageA(hwnd, WM_CANCELMODE, 0, 0);
48 }
50}
#define GWLP_USERDATA
Definition: treelist.c:63
#define SetWindowLongPtrA
Definition: winuser.h:5357

Referenced by register_menu_check_class().

◆ menu_fill_in_init()

static LRESULT WINAPI menu_fill_in_init ( HWND  hwnd,
UINT  msg,
WPARAM  wparam,
LPARAM  lparam 
)
static

Definition at line 3708 of file menu.c.

3710{
3711 HMENU hmenupopup;
3712 BOOL ret;
3713 switch (msg)
3714 {
3715 case WM_INITMENUPOPUP:
3717 hmenupopup = (HMENU) wparam;
3718 ret = AppendMenuA(hmenupopup, MF_STRING , 100, "item 1");
3719 ok(ret, "AppendMenu failed.\n");
3720 ret = AppendMenuA(hmenupopup, MF_STRING , 101, "item 2");
3721 ok(ret, "AppendMenu failed.\n");
3722 break;
3723 case WM_ENTERMENULOOP:
3725 break;
3726 case WM_INITMENU:
3728 break;
3729 case WM_ENTERIDLE:
3732 return TRUE;
3733 case WM_MENUSELECT:
3736 break;
3737 }
3738 return DefWindowProcA(hwnd, msg, wparam, lparam);
3739}
static WPARAM selectitem_wp
Definition: menu.c:99
static int gflag_entermenuloop
Definition: menu.c:96
static int gflag_initmenupopup
Definition: menu.c:95
static int gflag_enteridle
Definition: menu.c:98
static LPARAM selectitem_lp
Definition: menu.c:100
static int gflag_initmenu
Definition: menu.c:97
#define MF_STRING
Definition: winuser.h:138
#define WM_INITMENU
Definition: winuser.h:1748
#define WM_INITMENUPOPUP
Definition: winuser.h:1749
#define WM_MENUSELECT
Definition: winuser.h:1750

Referenced by test_emptypopup().

◆ menu_ownerdraw_wnd_proc()

static LRESULT WINAPI menu_ownerdraw_wnd_proc ( HWND  hwnd,
UINT  msg,
WPARAM  wparam,
LPARAM  lparam 
)
static

Definition at line 103 of file menu.c.

105{
106 static HMENU hmenupopup;
107 switch (msg)
108 {
109 case WM_INITMENUPOPUP:
111 hmenupopup = (HMENU) wparam;
112 break;
113 case WM_ENTERMENULOOP:
115 break;
116 case WM_INITMENU:
118 break;
119 case WM_MEASUREITEM:
120 {
122 if (winetest_debug > 1)
123 trace("WM_MEASUREITEM received data %lx size %dx%d\n",
124 pmis->itemData, pmis->itemWidth, pmis->itemHeight);
125 ok( !wparam, "wrong wparam %lx\n", wparam );
126 ok( pmis->CtlType == ODT_MENU, "wrong type %x\n", pmis->CtlType );
127 MOD_odheight = pmis->itemHeight;
128 pmis->itemWidth = MODsizes[pmis->itemData].cx;
129 pmis->itemHeight = MODsizes[pmis->itemData].cy;
130 return TRUE;
131 }
132 case WM_DRAWITEM:
133 {
134 DRAWITEMSTRUCT * pdis;
136 HPEN oldpen;
137 char chrs[]="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
138 SIZE sz;
139 int i;
140 pdis = (DRAWITEMSTRUCT *) lparam;
141 if (winetest_debug > 1) {
142 RECT rc;
143 GetMenuItemRect( hwnd, (HMENU)pdis->hwndItem, pdis->itemData ,&rc);
144 trace("WM_DRAWITEM received hwnd %p hmenu %p itemdata %ld item %d rc %s itemrc: %s\n",
145 hwnd, pdis->hwndItem, pdis->itemData, pdis->itemID,
147 oldpen=SelectObject( pdis->hDC, GetStockObject(
149 Rectangle( pdis->hDC, pdis->rcItem.left,pdis->rcItem.top,
150 pdis->rcItem.right,pdis->rcItem.bottom );
151 SelectObject( pdis->hDC, oldpen);
152 }
153 ok( !wparam, "wrong wparam %lx\n", wparam );
154 ok( pdis->CtlType == ODT_MENU, "wrong type %x\n", pdis->CtlType );
155 /* calculate widths of some menu texts */
156 if( ! MOD_txtsizes[0].size.cx)
157 for(i = 0; MOD_txtsizes[i].text; i++) {
158 char buf[100], *p;
159 RECT rc={0,0,0,0};
161 if( ( p = strchr( buf, '\t'))) {
162 *p = '\0';
163 DrawTextA( pdis->hDC, p + 1, -1, &rc,
165 MOD_txtsizes[i].sc_size.cx= rc.right - rc.left;
166 MOD_txtsizes[i].sc_size.cy= rc.bottom - rc.top;
167 }
168 DrawTextA( pdis->hDC, buf, -1, &rc,
170 MOD_txtsizes[i].size.cx= rc.right - rc.left;
171 MOD_txtsizes[i].size.cy= rc.bottom - rc.top;
172 }
173
174 if( pdis->itemData > MOD_maxid) return TRUE;
175 /* store the rectangle */
176 MOD_rc[pdis->itemData] = pdis->rcItem;
177 /* calculate average character width */
178 GetTextExtentPointA( pdis->hDC, chrs, 52, &sz );
179 MOD_avec = (sz.cx + 26)/52;
180 GetTextMetricsA( pdis->hDC, &tm);
181 MOD_hic = tm.tmHeight;
183 return TRUE;
184 }
185 case WM_ENTERIDLE:
186 {
188 ok( lparam || broken(!lparam), /* win9x, nt4 */
189 "Menu window handle is NULL!\n");
190 if( lparam) {
192 ok( hmenupopup == hmenu, "MN_GETHMENU returns %p expected %p\n",
193 hmenu, hmenupopup);
194 }
196 return TRUE;
197 }
198 case WM_MENUSELECT:
201 break;
202 }
204}
char * strchr(const char *String, int ch)
Definition: utclib.c:501
static const char * wine_dbgstr_rect(const RECT *prc)
Definition: atltest.h:160
GLsizeiptr size
Definition: glext.h:5919
GLfloat GLfloat p
Definition: glext.h:8902
static int MOD_odheight
Definition: menu.c:91
static RECT MOD_rc[MOD_NRMENUS]
Definition: menu.c:89
static struct @1729 MOD_txtsizes[]
static BOOL MOD_GotDrawItemMsg
Definition: menu.c:94
static int MOD_hic
Definition: menu.c:90
LPCSTR text
Definition: menu.c:77
static int MOD_avec
Definition: menu.c:90
static SIZE MODsizes[MOD_NRMENUS]
Definition: menu.c:92
static unsigned int MOD_maxid
Definition: menu.c:88
LONG cx
Definition: kdterminal.h:27
LONG cy
Definition: kdterminal.h:28
ULONG_PTR itemData
Definition: winuser.h:3096
ULONG_PTR itemData
Definition: winuser.h:3649
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
Definition: time.h:68
INT WINAPI DrawTextA(HDC hdc, LPCSTR str, INT count, LPRECT rect, UINT flags)
Definition: font.c:373
HGDIOBJ WINAPI GetStockObject(_In_ int)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
#define WHITE_PEN
Definition: wingdi.h:905
#define BLACK_PEN
Definition: wingdi.h:903
BOOL WINAPI GetTextMetricsA(_In_ HDC, _Out_ LPTEXTMETRICA)
Definition: text.c:200
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
BOOL WINAPI GetTextExtentPointA(_In_ HDC hdc, _In_reads_(c) LPCSTR lpString, _In_ int c, _Out_ LPSIZE lpsz)
#define ODS_SELECTED
Definition: winuser.h:2548
#define DT_SINGLELINE
Definition: winuser.h:540
#define MN_GETHMENU
Definition: winuser.h:1776
#define WM_DRAWITEM
Definition: winuser.h:1648
#define WM_MEASUREITEM
Definition: winuser.h:1649
#define DT_CALCRECT
Definition: winuser.h:526
#define ODT_MENU
Definition: winuser.h:2540

Referenced by test_emptypopup(), test_menu_bmp_and_string(), test_menu_ownerdraw(), and test_menu_trackpopupmenu().

◆ menu_track_again_wnd_proc()

static LRESULT WINAPI menu_track_again_wnd_proc ( HWND  hwnd,
UINT  msg,
WPARAM  wparam,
LPARAM  lparam 
)
static

Definition at line 3404 of file menu.c.

3405{
3406 switch (msg)
3407 {
3408 case WM_ENTERMENULOOP:
3409 {
3410 BOOL ret;
3411
3412 /* try a recursive call */
3413 SetLastError(0xdeadbeef);
3414 ret = TrackPopupMenu(g_hmenu, 0, 100, 100, 0, hwnd, NULL);
3415 ok(ret == FALSE, "got %d\n", ret);
3417 broken(GetLastError() == 0xdeadbeef) /* W9x */, "got %d\n", GetLastError());
3418
3419 /* exit menu modal loop
3420 * ( A SendMessage does not work on NT3.51 here ) */
3421 return PostMessageA(hwnd, WM_CANCELMODE, 0, 0);
3422 }
3423 }
3424 return DefWindowProcA(hwnd, msg, wparam, lparam);
3425}
static HMENU g_hmenu
Definition: menu.c:3402
#define ERROR_POPUP_ALREADY_ACTIVE
Definition: winerror.h:927
BOOL WINAPI TrackPopupMenu(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _Reserved_ int, _In_ HWND, _Reserved_ LPCRECT)

Referenced by test_menu_trackagain().

◆ modify_menu()

static void modify_menu ( int  line,
HMENU  hmenu,
BOOL  ansi,
UINT  flags,
UINT_PTR  id,
void data 
)
static

Definition at line 1321 of file menu.c.

1322{
1323 BOOL ret;
1324
1325 SetLastError( 0xdeadbeef );
1326 if (ansi) ret = ModifyMenuA( hmenu, 0, flags, id, data );
1327 else ret = ModifyMenuW( hmenu, 0, flags, id, data );
1328 ok_(__FILE__,line)( ret, "ModifyMenuA failed, err %u\n", GetLastError());
1329}
BOOL WINAPI ModifyMenuA(_In_ HMENU, _In_ UINT, _In_ UINT, _In_ UINT_PTR, _In_opt_ LPCSTR)
BOOL WINAPI ModifyMenuW(_In_ HMENU, _In_ UINT, _In_ UINT, _In_ UINT_PTR, _In_opt_ LPCWSTR)

◆ MyTrackPopupMenu()

static DWORD MyTrackPopupMenu ( int  ex,
HMENU  hmenu,
UINT  flags,
INT  x,
INT  y,
HWND  hwnd,
LPTPMPARAMS  ptpm 
)
static

Definition at line 3281 of file menu.c.

3282{
3283 return ex
3284 ? TrackPopupMenuEx( hmenu, flags, x, y, hwnd, ptpm)
3285 : TrackPopupMenu( hmenu, flags, x, y, 0, hwnd, NULL);
3286}
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
Definition: comerr.c:44
BOOL WINAPI TrackPopupMenuEx(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _In_ HWND, _In_opt_ LPTPMPARAMS)

Referenced by test_menu_trackpopupmenu().

◆ register_menu_check_class()

static void register_menu_check_class ( void  )
static

Definition at line 206 of file menu.c.

207{
208 WNDCLASSA wc =
209 {
210 0,
212 0,
213 0,
215 NULL,
217 (HBRUSH)(COLOR_BTNFACE+1),
218 NULL,
219 "WineMenuCheck",
220 };
221
223}
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
static LRESULT WINAPI menu_check_wnd_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: menu.c:38
static ATOM atomMenuCheckClass
Definition: menu.c:36
#define IDC_ARROW
Definition: winuser.h:687
ATOM WINAPI RegisterClassA(_In_ CONST WNDCLASSA *)
HCURSOR WINAPI LoadCursorA(_In_opt_ HINSTANCE, _In_ LPCSTR)
Definition: cursoricon.c:2142
#define COLOR_BTNFACE
Definition: winuser.h:931

Referenced by START_TEST().

◆ send_key()

static void send_key ( WORD  wVk)
static

Definition at line 2259 of file menu.c.

2260{
2261 TEST_INPUT i[2];
2262 memset(i, 0, sizeof(i));
2263 i[0].type = i[1].type = INPUT_KEYBOARD;
2264 i[0].u.ki.wVk = i[1].u.ki.wVk = wVk;
2265 i[1].u.ki.dwFlags = KEYEVENTF_KEYUP;
2266 SendInput(2, (INPUT *) i, sizeof(INPUT));
2267}
#define INPUT_KEYBOARD
Definition: winable.h:10
#define KEYEVENTF_KEYUP
Definition: winuser.h:1105

Referenced by test_menu_input_thread().

◆ set_menu_item_info()

static void set_menu_item_info ( int  line,
HMENU  hmenu,
BOOL  ansi,
UINT  mask,
UINT  type,
UINT  state,
UINT  id,
HMENU  submenu,
HBITMAP  checked,
HBITMAP  unchecked,
ULONG_PTR  data,
void type_data,
UINT  len,
HBITMAP  item 
)
static

Definition at line 1331 of file menu.c.

1335{
1337 BOOL ret;
1338
1339 /* magic bitmap handle to test smaller cbSize */
1340 if (item == (HBITMAP)(ULONG_PTR)0xdeadbeef)
1341 info.cbSize = FIELD_OFFSET(MENUITEMINFOA,hbmpItem);
1342 else
1343 info.cbSize = sizeof(info);
1344 info.fMask = mask;
1345 info.fType = type;
1346 info.fState = state;
1347 info.wID = id;
1348 info.hSubMenu = submenu;
1349 info.hbmpChecked = checked;
1350 info.hbmpUnchecked = unchecked;
1351 info.dwItemData = data;
1352 info.dwTypeData = type_data;
1353 info.cch = len;
1354 info.hbmpItem = item;
1355 SetLastError( 0xdeadbeef );
1356 if (ansi) ret = SetMenuItemInfoA( hmenu, 0, TRUE, &info );
1357 else ret = SetMenuItemInfoW( hmenu, 0, TRUE, (MENUITEMINFOW*)&info );
1358 ok_(__FILE__, line)( ret, "SetMenuItemInfo failed, err %u\n", GetLastError());
1359}
BOOL WINAPI SetMenuItemInfoW(_In_ HMENU, _In_ UINT, _In_ BOOL, _In_ LPCMENUITEMINFOW)

◆ START_TEST()

START_TEST ( menu  )

Definition at line 4250 of file menu.c.

4251{
4253
4262
4273
4282}
static void test_menu_cancelmode(void)
Definition: menu.c:3479
static void test_AppendMenu(void)
Definition: menu.c:3814
static void test_getmenubarinfo(void)
Definition: menu.c:225
static void test_menu_hilitemenuitem(void)
Definition: menu.c:2519
static void test_menu_maxdepth(void)
Definition: menu.c:3548
static void test_InsertMenu(void)
Definition: menu.c:2971
static void test_menu_trackagain(void)
Definition: menu.c:3427
static void register_menu_check_class(void)
Definition: menu.c:206
static void test_menu_getmenuinfo(void)
Definition: menu.c:3087
static void test_menualign(void)
Definition: menu.c:3606
static void test_system_menu(void)
Definition: menu.c:398
static void test_menu_bmp_and_string(void)
Definition: menu.c:963
static void test_CheckMenuRadioItem(void)
Definition: menu.c:2730
static void test_menu_locked_by_window(void)
Definition: menu.c:585
static void test_menu_resource_layout(void)
Definition: menu.c:2777
static void test_menu_circref(void)
Definition: menu.c:3576
static void test_emptypopup(void)
Definition: menu.c:3741
static void test_menu_search_bycommand(void)
Definition: menu.c:1887
static void test_GetMenuItemRect(void)
Definition: menu.c:342
static void test_menu_iteminfo(void)
Definition: menu.c:1393
static void test_subpopup_locked_by_menu(void)
Definition: menu.c:635
static void test_menu_ownerdraw(void)
Definition: menu.c:700
static void test_menu_flags(void)
Definition: menu.c:2488
static void test_menu_setmenuinfo(void)
Definition: menu.c:3132
static void test_menu_trackpopupmenu(void)
Definition: menu.c:3293
static void test_menu_add_string(void)
Definition: menu.c:1076
static void test_menu_input(void)
Definition: menu.c:2429

◆ strcpyW()

static WCHAR * strcpyW ( WCHAR dst,
const WCHAR src 
)
static

Definition at line 1211 of file menu.c.

1212{
1213 WCHAR *p = dst;
1214 while ((*p++ = *src++));
1215 return dst;
1216}
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

◆ strncmpW()

static int strncmpW ( const WCHAR str1,
const WCHAR str2,
int  n 
)
static

Definition at line 1204 of file menu.c.

1205{
1206 if (n <= 0) return 0;
1207 while ((--n > 0) && *str1 && (*str1 == *str2)) { str1++; str2++; }
1208 return *str1 - *str2;
1209}
GLdouble n
Definition: glext.h:7729

◆ subpopuplocked_wnd_proc()

static LRESULT WINAPI subpopuplocked_wnd_proc ( HWND  hwnd,
UINT  msg,
WPARAM  wparam,
LPARAM  lparam 
)
static

Definition at line 619 of file menu.c.

620{
621 HWND hwndmenu;
622 switch (msg)
623 {
624 case WM_ENTERIDLE:
625 hwndmenu = GetCapture();
626 if( hwndmenu) {
627 PostMessageA( hwndmenu, WM_KEYDOWN, VK_DOWN, 0);
628 PostMessageA( hwndmenu, WM_KEYDOWN, VK_RIGHT, 0);
629 PostMessageA( hwndmenu, WM_KEYDOWN, VK_RETURN, 0);
630 }
631 }
633}
HWND WINAPI GetCapture(void)
Definition: message.c:2881
#define VK_RETURN
Definition: winuser.h:2204
#define VK_RIGHT
Definition: winuser.h:2229
#define VK_DOWN
Definition: winuser.h:2230
#define WM_KEYDOWN
Definition: winuser.h:1718

Referenced by test_subpopup_locked_by_menu().

◆ test_AppendMenu()

static void test_AppendMenu ( void  )
static

Definition at line 3814 of file menu.c.

3815{
3816 static char string[] = "string";
3817 MENUITEMINFOA mii;
3818 HMENU hmenu, hsubmenu;
3819 HBITMAP hbmp;
3820 char buf[16];
3821 BOOL ret;
3822
3823 hmenu = CreateMenu();
3824 ok(hmenu != 0, "CreateMenu failed\n");
3825 ret = AppendMenuA(hmenu, MF_OWNERDRAW, 201, "item 1");
3826 ok(ret, "AppendMenu failed\n");
3829
3830 hmenu = CreateMenu();
3831 ok(hmenu != 0, "CreateMenu failed\n");
3832 hsubmenu = get_bad_hmenu( 202 );
3833 ret = AppendMenuA(hmenu, MF_POPUP, (UINT_PTR)hsubmenu, "item 1");
3834 ok(ret, "AppendMenu failed\n");
3835 check_menu_items(hmenu, (UINT_PTR)hsubmenu, MF_STRING, 0);
3837
3838 hmenu = CreateMenu();
3839 ok(hmenu != 0, "CreateMenu failed\n");
3840 hsubmenu = get_bad_hmenu( 203 );
3841 ret = AppendMenuA(hmenu, MF_OWNERDRAW | MF_POPUP, (UINT_PTR)hsubmenu, "item 1");
3842 ok(ret, "AppendMenu failed\n");
3845
3846 hmenu = CreateMenu();
3847 ok(hmenu != 0, "CreateMenu failed\n");
3848 hsubmenu = CreateMenu();
3849 ok(hsubmenu != 0, "CreateMenu failed\n");
3850 ret = AppendMenuA(hmenu, MF_OWNERDRAW, (UINT_PTR)hsubmenu, "item 1");
3851 ok(ret, "AppendMenu failed\n");
3854 DestroyMenu(hsubmenu);
3855
3856 hmenu = CreateMenu();
3857 ok(hmenu != 0, "CreateMenu failed\n");
3858 hsubmenu = CreateMenu();
3859 ok(hsubmenu != 0, "CreateMenu failed\n");
3860 ret = AppendMenuA(hmenu, MF_POPUP, (UINT_PTR)hsubmenu, "item 1");
3861 ok(ret, "AppendMenu failed\n");
3862 check_menu_items(hmenu, (UINT_PTR)hsubmenu, MF_STRING, 0);
3864 DestroyMenu(hsubmenu);
3865
3866 hmenu = CreateMenu();
3867 ok(hmenu != 0, "CreateMenu failed\n");
3868 hsubmenu = CreateMenu();
3869 ok(hsubmenu != 0, "CreateMenu failed\n");
3870 ret = AppendMenuA(hmenu, MF_OWNERDRAW | MF_POPUP, (UINT_PTR)hsubmenu, "item 1");
3871 ok(ret, "AppendMenu failed\n");
3874 DestroyMenu(hsubmenu);
3875
3876 hmenu = CreateMenu();
3877 ok(hmenu != 0, "CreateMenu failed\n");
3878 hsubmenu = CreatePopupMenu();
3879 ok(hsubmenu != 0, "CreatePopupMenu failed\n");
3880 ret = AppendMenuA(hmenu, MF_OWNERDRAW, (UINT_PTR)hsubmenu, "item 1");
3881 ok(ret, "AppendMenu failed\n");
3884 DestroyMenu(hsubmenu);
3885
3886 hmenu = CreateMenu();
3887 ok(hmenu != 0, "CreateMenu failed\n");
3888 hsubmenu = CreatePopupMenu();
3889 ok(hsubmenu != 0, "CreatePopupMenu failed\n");
3890 ret = AppendMenuA(hmenu, MF_POPUP, (UINT_PTR)hsubmenu, "item 1");
3891 ok(ret, "AppendMenu failed\n");
3892 check_menu_items(hmenu, (UINT_PTR)hsubmenu, MF_STRING, 0);
3894 DestroyMenu(hsubmenu);
3895
3896 hmenu = CreateMenu();
3897 ok(hmenu != 0, "CreateMenu failed\n");
3898 hsubmenu = CreatePopupMenu();
3899 ok(hsubmenu != 0, "CreatePopupMenu failed\n");
3900 ret = AppendMenuA(hmenu, MF_OWNERDRAW | MF_POPUP, (UINT_PTR)hsubmenu, "item 1");
3901 ok(ret, "AppendMenu failed\n");
3904 DestroyMenu(hsubmenu);
3905
3906 hmenu = CreateMenu();
3907 ok(hmenu != 0, "CreateMenu failed\n");
3908 ret = AppendMenuA(hmenu, MF_STRING, 204, "item 1");
3909 ok(ret, "AppendMenu failed\n");
3911 hsubmenu = get_bad_hmenu( 205 );
3912 ret = ModifyMenuA(hmenu, 0, MF_POPUP | MF_BYPOSITION, (UINT_PTR)hsubmenu, "item 2");
3913 ok(ret, "ModifyMenu failed\n");
3914 check_menu_items(hmenu, (UINT_PTR)hsubmenu, MF_STRING, 0);
3915 memset(&mii, 0, sizeof(mii));
3916 mii.cbSize = sizeof(mii);
3917 mii.fMask = MIIM_SUBMENU;
3918 mii.hSubMenu = get_bad_hmenu( 204 );
3919 ret = InsertMenuItemA(hmenu, 0, TRUE, &mii);
3920 ok(!ret, "InsertMenuItem should fail\n");
3921 ret = SetMenuItemInfoA(hmenu, 0, TRUE, &mii);
3922 ok(!ret, "SetMenuItemInfo should fail\n");
3923 mii.fMask = MIIM_ID;
3924 mii.wID = 206;
3925 ret = InsertMenuItemA(hmenu, 0, TRUE, &mii);
3926 ok(ret, "InsertMenuItem failed\n");
3927if (0) /* FIXME: uncomment once Wine is fixed */ {
3929}
3930 mii.wID = 207;
3931 ret = SetMenuItemInfoA(hmenu, 0, TRUE, &mii);
3932 ok(ret, "SetMenuItemInfo failed\n");
3933if (0) /* FIXME: uncomment once Wine is fixed */ {
3935}
3937
3938 hbmp = CreateBitmap(1, 1, 1, 1, NULL);
3939 hmenu = CreateMenu();
3940 ok(hmenu != 0, "CreateMenu failed\n");
3941
3942 /* menu item with a string and a bitmap */
3943 memset(&mii, 0, sizeof(mii));
3944 mii.cbSize = sizeof(mii);
3946 mii.dwTypeData = string;
3947 mii.cch = strlen(string);
3948 mii.hbmpItem = hbmp;
3949 ret = InsertMenuItemA(hmenu, 0, TRUE, &mii);
3950 ok(ret, "InsertMenuItem failed\n");
3951 memset(&mii, 0x81, sizeof(mii));
3952 memset(buf, 0x81, sizeof(buf));
3953 mii.cbSize = sizeof(mii);
3955 mii.dwTypeData = buf;
3956 mii.cch = sizeof(buf);
3957 mii.dwItemData = 0x81818181;
3958 ret = GetMenuItemInfoA(hmenu, 0, TRUE, &mii);
3959 ok(ret, "GetMenuItemInfo failed\n");
3960 ok(mii.fType == MF_STRING, "expected MF_STRING, got %#x\n", mii.fType);
3961 ok(mii.fState == MF_ENABLED, "expected MF_ENABLED, got %#x\n", mii.fState);
3962 ok(mii.wID == 0, "expected 0, got %#x\n", mii.wID);
3963 ok(mii.hSubMenu == 0, "expected 0, got %p\n", mii.hSubMenu);
3964 ok(mii.dwItemData == 0x81818181, "expected 0x81818181, got %#lx\n", mii.dwItemData);
3965 ok(mii.dwTypeData == buf, "expected %p, got %p\n", buf, mii.dwTypeData);
3966 ok(mii.cch == 6, "expected 6, got %u\n", mii.cch);
3967 ok(!strcmp(buf, string), "expected %s, got %s\n", string, buf);
3968 ok(mii.hbmpItem == hbmp, "expected %p, got %p\n", hbmp, mii.hbmpItem);
3969
3970 memset(&mii, 0x81, sizeof(mii));
3971 mii.cbSize = sizeof(mii);
3972 mii.fMask = MIIM_TYPE;
3973 mii.dwItemData = 0x81818181;
3974 ret = GetMenuItemInfoA(hmenu, 0, TRUE, &mii);
3975 ok(ret, "GetMenuItemInfo failed\n");
3976 ok(mii.fType == MF_BITMAP, "expected MF_BITMAP, got %#x\n", mii.fType);
3977 ok(mii.fState == 0x81818181, "expected 0x81818181, got %#x\n", mii.fState);
3978 ok(mii.wID == 0x81818181, "expected 0x81818181, got %#x\n", mii.wID);
3979 ok(mii.hSubMenu == 0, "expected 0, got %p\n", mii.hSubMenu);
3980 ok(mii.dwItemData == 0x81818181, "expected 0x81818181, got %#lx\n", mii.dwItemData);
3981 ok(mii.dwTypeData == (LPSTR)hbmp, "expected %p, got %p\n", hbmp, mii.dwTypeData);
3982 ok(mii.cch == 6, "expected 6, got %u\n", mii.cch);
3983 ok(mii.hbmpItem == hbmp, "expected %p, got %p\n", hbmp, mii.hbmpItem);
3984
3985 memset(&mii, 0x81, sizeof(mii));
3986 memset(buf, 0x81, sizeof(buf));
3987 mii.cbSize = sizeof(mii);
3989 mii.dwTypeData = buf;
3990 mii.cch = sizeof(buf);
3991 mii.dwItemData = 0x81818181;
3992 ret = GetMenuItemInfoA(hmenu, 0, TRUE, &mii);
3993 ok(ret, "GetMenuItemInfo failed\n");
3994 ok(mii.fType == MF_BITMAP, "expected MF_BITMAP, got %#x\n", mii.fType);
3995 ok(mii.fState == MF_ENABLED, "expected MF_ENABLED, got %#x\n", mii.fState);
3996 ok(mii.wID == 0, "expected 0, got %#x\n", mii.wID);
3997 ok(mii.hSubMenu == 0, "expected 0, got %p\n", mii.hSubMenu);
3998 ok(mii.dwItemData == 0, "expected 0, got %#lx\n", mii.dwItemData);
3999 ok(mii.dwTypeData == (LPSTR)hbmp, "expected %p, got %p\n", hbmp, mii.dwTypeData);
4000 ok(mii.cch == 6, "expected 6, got %u\n", mii.cch);
4001 ok(mii.hbmpItem == hbmp, "expected %p, got %p\n", hbmp, mii.hbmpItem);
4002
4005
4006 hmenu = CreateMenu();
4007 ok(hmenu != 0, "CreateMenu failed\n");
4008
4009 /* menu item with a string and a "magic" bitmap */
4010 memset(&mii, 0, sizeof(mii));
4011 mii.cbSize = sizeof(mii);
4013 mii.dwTypeData = string;
4014 mii.cch = strlen(string);
4015 mii.hbmpItem = HBMMENU_POPUP_RESTORE;
4016 ret = InsertMenuItemA(hmenu, 0, TRUE, &mii);
4017 ok(ret, "InsertMenuItem failed\n");
4018 memset(&mii, 0x81, sizeof(mii));
4019 memset(buf, 0x81, sizeof(buf));
4020 mii.cbSize = sizeof(mii);
4022 mii.dwTypeData = buf;
4023 mii.cch = sizeof(buf);
4024 mii.dwItemData = 0x81818181;
4025 ret = GetMenuItemInfoA(hmenu, 0, TRUE, &mii);
4026 ok(ret, "GetMenuItemInfo failed\n");
4027 ok(mii.fType == MF_STRING, "expected MF_STRING, got %#x\n", mii.fType);
4028 ok(mii.fState == MF_ENABLED, "expected MF_ENABLED, got %#x\n", mii.fState);
4029 ok(mii.wID == 0, "expected 0, got %#x\n", mii.wID);
4030 ok(mii.hSubMenu == 0, "expected 0, got %p\n", mii.hSubMenu);
4031 ok(mii.dwItemData == 0x81818181, "expected 0x81818181, got %#lx\n", mii.dwItemData);
4032 ok(mii.dwTypeData == buf, "expected %p, got %p\n", buf, mii.dwTypeData);
4033 ok(mii.cch == 6, "expected 6, got %u\n", mii.cch);
4034 ok(!strcmp(buf, string), "expected %s, got %s\n", string, buf);
4035 ok(mii.hbmpItem == HBMMENU_POPUP_RESTORE, "expected HBMMENU_POPUP_RESTORE, got %p\n", mii.hbmpItem);
4036
4037 memset(&mii, 0x81, sizeof(mii));
4038 mii.cbSize = sizeof(mii);
4039 mii.fMask = MIIM_TYPE;
4040 mii.dwTypeData = buf;
4041 mii.cch = sizeof(buf);
4042 mii.dwItemData = 0x81818181;
4043 ret = GetMenuItemInfoA(hmenu, 0, TRUE, &mii);
4044 ok(ret, "GetMenuItemInfo failed\n");
4045 ok(mii.fType == MF_STRING, "expected MF_STRING, got %#x\n", mii.fType);
4046 ok(mii.fState == 0x81818181, "expected 0x81818181, got %#x\n", mii.fState);
4047 ok(mii.wID == 0x81818181, "expected 0x81818181, got %#x\n", mii.wID);
4048 ok(mii.hSubMenu == 0, "expected 0, got %p\n", mii.hSubMenu);
4049 ok(mii.dwItemData == 0x81818181, "expected 0x81818181, got %#lx\n", mii.dwItemData);
4050 ok(mii.dwTypeData == buf, "expected %p, got %p\n", buf, mii.dwTypeData);
4051 ok(mii.cch == 6, "expected 6, got %u\n", mii.cch);
4052 ok(!strcmp(buf, string), "expected %s, got %s\n", string, buf);
4053 ok(mii.hbmpItem == HBMMENU_POPUP_RESTORE, "expected HBMMENU_POPUP_RESTORE, got %p\n", mii.hbmpItem);
4054
4055 memset(&mii, 0x81, sizeof(mii));
4056 memset(buf, 0x81, sizeof(buf));
4057 mii.cbSize = sizeof(mii);
4059 mii.dwTypeData = buf;
4060 mii.cch = sizeof(buf);
4061 mii.dwItemData = 0x81818181;
4062 ret = GetMenuItemInfoA(hmenu, 0, TRUE, &mii);
4063 ok(ret, "GetMenuItemInfo failed\n");
4064 ok(mii.fType == MF_STRING, "expected MF_STRING, got %#x\n", mii.fType);
4065 ok(mii.fState == MF_ENABLED, "expected MF_ENABLED, got %#x\n", mii.fState);
4066 ok(mii.wID == 0, "expected 0, got %#x\n", mii.wID);
4067 ok(mii.hSubMenu == 0, "expected 0, got %p\n", mii.hSubMenu);
4068 ok(mii.dwItemData == 0, "expected 0, got %#lx\n", mii.dwItemData);
4069 ok(mii.dwTypeData == buf, "expected %p, got %p\n", buf, mii.dwTypeData);
4070 ok(mii.cch == 6, "expected 6, got %u\n", mii.cch);
4071 ok(!strcmp(buf, string), "expected %s, got %s\n", string, buf);
4072 ok(mii.hbmpItem == HBMMENU_POPUP_RESTORE, "expected HBMMENU_POPUP_RESTORE, got %p\n", mii.hbmpItem);
4073
4075
4076 hbmp = CreateBitmap(1, 1, 1, 1, NULL);
4077 hmenu = CreateMenu();
4078 ok(hmenu != 0, "CreateMenu failed\n");
4079
4080 /* menu item with a string */
4081 memset(&mii, 0, sizeof(mii));
4082 mii.cbSize = sizeof(mii);
4084 mii.dwItemData = (ULONG_PTR)hbmp;
4085 mii.dwTypeData = string;
4086 mii.cch = strlen(string);
4087 mii.hbmpItem = hbmp;
4088 ret = InsertMenuItemA(hmenu, 0, TRUE, &mii);
4089 ok(ret, "InsertMenuItem failed\n");
4090 memset(&mii, 0x81, sizeof(mii));
4091 memset(buf, 0x81, sizeof(buf));
4092 mii.cbSize = sizeof(mii);
4094 mii.dwTypeData = buf;
4095 mii.cch = sizeof(buf);
4096 mii.dwItemData = 0x81818181;
4097 ret = GetMenuItemInfoA(hmenu, 0, TRUE, &mii);
4098 ok(ret, "GetMenuItemInfo failed\n");
4099 ok(mii.fType == MF_STRING, "expected MF_STRING, got %#x\n", mii.fType);
4100 ok(mii.fState == MF_ENABLED, "expected MF_ENABLED, got %#x\n", mii.fState);
4101 ok(mii.wID == 0, "expected 0, got %#x\n", mii.wID);
4102 ok(mii.hSubMenu == 0, "expected 0, got %p\n", mii.hSubMenu);
4103 ok(mii.dwItemData == (ULONG_PTR)hbmp, "expected %p, got %#lx\n", hbmp, mii.dwItemData);
4104 ok(mii.dwTypeData == buf, "expected %p, got %p\n", buf, mii.dwTypeData);
4105 ok(mii.cch == 6, "expected 6, got %u\n", mii.cch);
4106 ok(!strcmp(buf, string), "expected %s, got %s\n", string, buf);
4107 ok(mii.hbmpItem == 0, "expected 0, got %p\n", mii.hbmpItem);
4108
4109 memset(&mii, 0x81, sizeof(mii));
4110 memset(buf, 0x81, sizeof(buf));
4111 mii.cbSize = sizeof(mii);
4112 mii.fMask = MIIM_TYPE;
4113 mii.dwTypeData = buf;
4114 mii.cch = sizeof(buf);
4115 mii.dwItemData = 0x81818181;
4116 ret = GetMenuItemInfoA(hmenu, 0, TRUE, &mii);
4117 ok(ret, "GetMenuItemInfo failed\n");
4118 ok(mii.fType == MF_STRING, "expected MF_STRING, got %#x\n", mii.fType);
4119 ok(mii.fState == 0x81818181, "expected 0x81818181, got %#x\n", mii.fState);
4120 ok(mii.wID == 0x81818181, "expected 0x81818181, got %#x\n", mii.wID);
4121 ok(mii.hSubMenu == 0, "expected 0, got %p\n", mii.hSubMenu);
4122 ok(mii.dwItemData == 0x81818181, "expected 0x81818181, got %#lx\n", mii.dwItemData);
4123 ok(mii.dwTypeData == buf, "expected %p, got %p\n", buf, mii.dwTypeData);
4124 ok(mii.cch == 6, "expected 6, got %u\n", mii.cch);
4125 ok(!strcmp(buf, string), "expected %s, got %s\n", string, buf);
4126 ok(mii.hbmpItem == 0, "expected 0, got %p\n", mii.hbmpItem);
4127
4130
4131 /* menu item with a string */
4132 hbmp = CreateBitmap(1, 1, 1, 1, NULL);
4133 hmenu = CreateMenu();
4134 ok(hmenu != 0, "CreateMenu failed\n");
4135 memset(&mii, 0, sizeof(mii));
4136 mii.cbSize = sizeof(mii);
4137 mii.fMask = MIIM_STRING;
4138 mii.dwTypeData = string;
4139 mii.cch = strlen(string);
4140 ret = InsertMenuItemA(hmenu, 0, TRUE, &mii);
4141 ok(ret, "InsertMenuItem failed\n");
4142 memset(&mii, 0x81, sizeof(mii));
4143 memset(buf, 0x81, sizeof(buf));
4144 mii.cbSize = sizeof(mii);
4146 mii.dwTypeData = buf;
4147 mii.cch = sizeof(buf);
4148 mii.dwItemData = 0x81818181;
4149 ret = GetMenuItemInfoA(hmenu, 0, TRUE, &mii);
4150 ok(ret, "GetMenuItemInfo failed\n");
4151 ok(mii.fType == MF_STRING, "expected MF_STRING, got %#x\n", mii.fType);
4152 ok(mii.fState == MF_ENABLED, "expected MF_ENABLED, got %#x\n", mii.fState);
4153 ok(mii.wID == 0, "expected 0, got %#x\n", mii.wID);
4154 ok(mii.hSubMenu == 0, "expected 0, got %p\n", mii.hSubMenu);
4155 ok(mii.dwItemData == 0x81818181, "expected 0x81818181, got %#lx\n", mii.dwItemData);
4156 ok(mii.dwTypeData == buf, "expected %p, got %p\n", buf, mii.dwTypeData);
4157 ok(mii.cch == 6, "expected 6, got %u\n", mii.cch);
4158 ok(!strcmp(buf, string), "expected %s, got %s\n", string, buf);
4159 ok(mii.hbmpItem == 0, "expected 0, got %p\n", mii.hbmpItem);
4160
4161 /* add "magic" bitmap to a menu item */
4162 mii.fMask = MIIM_BITMAP;
4163 mii.hbmpItem = HBMMENU_POPUP_RESTORE;
4164 ret = SetMenuItemInfoA(hmenu, 0, TRUE, &mii);
4165 ok(ret, "SetMenuItemInfo failed\n");
4166 memset(&mii, 0x81, sizeof(mii));
4167 memset(buf, 0x81, sizeof(buf));
4168 mii.cbSize = sizeof(mii);
4170 mii.dwTypeData = buf;
4171 mii.cch = sizeof(buf);
4172 mii.dwItemData = 0x81818181;
4173 ret = GetMenuItemInfoA(hmenu, 0, TRUE, &mii);
4174 ok(ret, "GetMenuItemInfo failed\n");
4175 ok(mii.fType == MF_STRING, "expected MF_STRING, got %#x\n", mii.fType);
4176 ok(mii.fState == MF_ENABLED, "expected MF_ENABLED, got %#x\n", mii.fState);
4177 ok(mii.wID == 0, "expected 0, got %#x\n", mii.wID);
4178 ok(mii.hSubMenu == 0, "expected 0, got %p\n", mii.hSubMenu);
4179 ok(mii.dwItemData == 0x81818181, "expected 0x81818181, got %#lx\n", mii.dwItemData);
4180 ok(mii.dwTypeData == buf, "expected %p, got %p\n", buf, mii.dwTypeData);
4181 ok(mii.cch == 6, "expected 6, got %u\n", mii.cch);
4182 ok(!strcmp(buf, string), "expected %s, got %s\n", string, buf);
4183 ok(mii.hbmpItem == HBMMENU_POPUP_RESTORE, "expected HBMMENU_POPUP_RESTORE, got %p\n", mii.hbmpItem);
4184
4185 memset(&mii, 0x81, sizeof(mii));
4186 memset(buf, 0x81, sizeof(buf));
4187 mii.cbSize = sizeof(mii);
4188 mii.fMask = MIIM_TYPE;
4189 mii.dwTypeData = buf;
4190 mii.cch = sizeof(buf);
4191 mii.dwItemData = 0x81818181;
4192 ret = GetMenuItemInfoA(hmenu, 0, TRUE, &mii);
4193 ok(ret, "GetMenuItemInfo failed\n");
4194 ok(mii.fType == MF_STRING, "expected MF_STRING, got %#x\n", mii.fType);
4195 ok(mii.fState == 0x81818181, "expected 0x81818181, got %#x\n", mii.fState);
4196 ok(mii.wID == 0x81818181, "expected 0x81818181, got %#x\n", mii.wID);
4197 ok(mii.hSubMenu == 0, "expected 0, got %p\n", mii.hSubMenu);
4198 ok(mii.dwItemData == 0x81818181, "expected 0x81818181, got %#lx\n", mii.dwItemData);
4199 ok(mii.dwTypeData == buf, "expected %p, got %p\n", buf, mii.dwTypeData);
4200 ok(mii.cch == 6, "expected 6, got %u\n", mii.cch);
4201 ok(!strcmp(buf, string), "expected %s, got %s\n", string, buf);
4202 ok(mii.hbmpItem == HBMMENU_POPUP_RESTORE, "expected HBMMENU_POPUP_RESTORE, got %p\n", mii.hbmpItem);
4203
4204 /* replace "magic" bitmap by a normal one */
4205 mii.fMask = MIIM_BITMAP;
4206 mii.hbmpItem = hbmp;
4207 ret = SetMenuItemInfoA(hmenu, 0, TRUE, &mii);
4208 ok(ret, "SetMenuItemInfo failed\n");
4209 memset(&mii, 0x81, sizeof(mii));
4210 memset(buf, 0x81, sizeof(buf));
4211 mii.cbSize = sizeof(mii);
4213 mii.dwTypeData = buf;
4214 mii.cch = sizeof(buf);
4215 mii.dwItemData = 0x81818181;
4216 ret = GetMenuItemInfoA(hmenu, 0, TRUE, &mii);
4217 ok(ret, "GetMenuItemInfo failed\n");
4218 ok(mii.fType == MF_STRING, "expected MF_STRING, got %#x\n", mii.fType);
4219 ok(mii.fState == MF_ENABLED, "expected MF_ENABLED, got %#x\n", mii.fState);
4220 ok(mii.wID == 0, "expected 0, got %#x\n", mii.wID);
4221 ok(mii.hSubMenu == 0, "expected 0, got %p\n", mii.hSubMenu);
4222 ok(mii.dwItemData == 0x81818181, "expected 0x81818181, got %#lx\n", mii.dwItemData);
4223 ok(mii.dwTypeData == buf, "expected %p, got %p\n", buf, mii.dwTypeData);
4224 ok(mii.cch == 6, "expected 6, got %u\n", mii.cch);
4225 ok(!strcmp(buf, string), "expected %s, got %s\n", string, buf);
4226 ok(mii.hbmpItem == hbmp, "expected %p, got %p\n", hbmp, mii.hbmpItem);
4227
4228 memset(&mii, 0x81, sizeof(mii));
4229 memset(buf, 0x81, sizeof(buf));
4230 mii.cbSize = sizeof(mii);
4231 mii.fMask = MIIM_TYPE;
4232 mii.dwTypeData = buf;
4233 mii.cch = sizeof(buf);
4234 mii.dwItemData = 0x81818181;
4235 ret = GetMenuItemInfoA(hmenu, 0, TRUE, &mii);
4236 ok(ret, "GetMenuItemInfo failed\n");
4237 ok(mii.fType == MF_BITMAP, "expected MF_BITMAP, got %#x\n", mii.fType);
4238 ok(mii.fState == 0x81818181, "expected 0x81818181, got %#x\n", mii.fState);
4239 ok(mii.wID == 0x81818181, "expected 0x81818181, got %#x\n", mii.wID);
4240 ok(mii.hSubMenu == 0, "expected 0, got %p\n", mii.hSubMenu);
4241 ok(mii.dwItemData == 0x81818181, "expected 0x81818181, got %#lx\n", mii.dwItemData);
4242 ok(mii.dwTypeData == (LPSTR)hbmp, "expected %p, got %p\n", hbmp, mii.dwTypeData);
4243 ok(mii.cch == 6, "expected 6, got %u\n", mii.cch);
4244 ok(mii.hbmpItem == hbmp, "expected %p, got %p\n", hbmp, mii.hbmpItem);
4245
4248}
HBITMAP hbmp
pKey DeleteObject()
char string[160]
Definition: util.h:11
static HMENU get_bad_hmenu(UINT_PTR id)
Definition: menu.c:3808
ULONG_PTR dwItemData
Definition: winuser.h:3253
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)
HMENU WINAPI CreatePopupMenu(void)
Definition: menu.c:838
#define HBMMENU_POPUP_RESTORE
Definition: winuser.h:2641
#define MF_POPUP
Definition: winuser.h:136
#define MF_ENABLED
Definition: winuser.h:128
#define MF_SEPARATOR
Definition: winuser.h:137
#define MF_BITMAP
Definition: winuser.h:131
BOOL WINAPI DestroyMenu(_In_ HMENU)
#define MF_OWNERDRAW
Definition: winuser.h:135

Referenced by START_TEST().

◆ test_CheckMenuRadioItem()

static void test_CheckMenuRadioItem ( void  )
static

Definition at line 2730 of file menu.c.

2731{
2732 BOOL ret;
2733 HMENU hmenu;
2734
2736 assert(hmenu != 0);
2737
2738 check_menu_items(hmenu, -1, 0, 0);
2739
2740 ret = CheckMenuRadioItem(hmenu, 100, 100, 100, MF_BYCOMMAND);
2741 ok(ret, "CheckMenuRadioItem failed\n");
2743
2744 /* MSDN is wrong, Windows does not remove MFT_RADIOCHECK */
2745 ret = CheckMenuRadioItem(hmenu, 100, 100, -1, MF_BYCOMMAND);
2746 ok(!ret, "CheckMenuRadioItem should return FALSE\n");
2748
2749 /* clear check */
2751 check_menu_items(hmenu, -1, 0, 0);
2752
2753 /* first and checked items are on different menus */
2754 ret = CheckMenuRadioItem(hmenu, 0, 300, 202, MF_BYCOMMAND);
2755 ok(!ret, "CheckMenuRadioItem should return FALSE\n");
2756 check_menu_items(hmenu, -1, 0, 0);
2757
2758 ret = CheckMenuRadioItem(hmenu, 200, 300, 202, MF_BYCOMMAND);
2759 ok(ret, "CheckMenuRadioItem failed\n");
2761
2762 /* MSDN is wrong, Windows does not remove MFT_RADIOCHECK */
2763 ret = CheckMenuRadioItem(hmenu, 202, 202, -1, MF_BYCOMMAND);
2764 ok(!ret, "CheckMenuRadioItem should return FALSE\n");
2766
2767 /* clear check */
2769 check_menu_items(hmenu, -1, 0, 0);
2770
2771 /* just for fun, try to check separator */
2773 ok(!ret, "CheckMenuRadioItem should return FALSE\n");
2774 check_menu_items(hmenu, -1, 0, 0);
2775}
static void clear_ftype_and_state(HMENU hmenu, UINT id, UINT flags)
Definition: menu.c:2718
#define MF_BYCOMMAND
Definition: winuser.h:202
#define MFS_CHECKED
Definition: winuser.h:750
BOOL WINAPI CheckMenuRadioItem(_In_ HMENU, _In_ UINT, _In_ UINT, _In_ UINT, _In_ UINT)
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581
HMENU WINAPI LoadMenuA(_In_opt_ HINSTANCE, _In_ LPCSTR)

Referenced by START_TEST().

◆ test_emptypopup()

static void test_emptypopup ( void  )
static

Definition at line 3741 of file menu.c.

3742{
3743 BOOL ret;
3744 HMENU hmenu;
3745
3748 NULL, NULL, NULL, NULL);
3749 ok(hwnd != NULL, "CreateWindowEx failed with error %d\n", GetLastError());
3751
3753 ok(hmenu != NULL, "CreateMenu failed with error %d\n", GetLastError());
3754
3756 selectitem_wp = 0xdeadbeef;
3757 selectitem_lp = 0xdeadbeef;
3758
3759 ret = TrackPopupMenu( hmenu, TPM_RETURNCMD, 100,100, 0, hwnd, NULL);
3760 ok(ret == 0, "got %i\n", ret);
3761
3762 ok(gflag_initmenupopup == 1, "got %i\n", gflag_initmenupopup);
3763 ok(gflag_entermenuloop == 1, "got %i\n", gflag_entermenuloop);
3764 ok(gflag_initmenu == 1, "got %i\n", gflag_initmenu);
3765 ok(gflag_enteridle == 0, "got %i\n", gflag_initmenu);
3766
3767 ok(selectitem_wp == 0xdeadbeef, "got %lx\n", selectitem_wp);
3768 ok(selectitem_lp == 0xdeadbeef, "got %lx\n", selectitem_lp);
3769
3771 selectitem_wp = 0xdeadbeef;
3772 selectitem_lp = 0xdeadbeef;
3773
3774 ret = TrackPopupMenu( hmenu, 0, 100,100, 0, hwnd, NULL);
3775 ok(ret == 0, "got %i\n", ret);
3776
3777 ok(gflag_initmenupopup == 1, "got %i\n", gflag_initmenupopup);
3778 ok(gflag_entermenuloop == 1, "got %i\n", gflag_entermenuloop);
3779 ok(gflag_initmenu == 1, "got %i\n", gflag_initmenu);
3780 ok(gflag_enteridle == 0, "got %i\n", gflag_initmenu);
3781
3782 ok(selectitem_wp == 0xdeadbeef, "got %lx\n", selectitem_wp);
3783 ok(selectitem_lp == 0xdeadbeef, "got %lx\n", selectitem_lp);
3784
3786
3788 selectitem_wp = 0xdeadbeef;
3789 selectitem_lp = 0xdeadbeef;
3790
3791 ret = TrackPopupMenu( hmenu, 0, 100,100, 0, hwnd, NULL);
3792 ok(ret == 1, "got %i\n", ret);
3793
3794 ok(gflag_initmenupopup == 1, "got %i\n", gflag_initmenupopup);
3795 ok(gflag_entermenuloop == 1, "got %i\n", gflag_entermenuloop);
3796 ok(gflag_initmenu == 1, "got %i\n", gflag_initmenu);
3797 ok(gflag_enteridle == 1, "got %i\n", gflag_initmenu);
3798
3799 ok(selectitem_wp == 0xffff0000, "got %lx\n", selectitem_wp);
3800 ok(selectitem_lp == 0, "got %lx\n", selectitem_lp);
3801
3803
3805 ok(ret, "DestroyMenu failed with error %d\n", GetLastError());
3806}
static LRESULT WINAPI menu_ownerdraw_wnd_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: menu.c:103
static LRESULT WINAPI menu_fill_in_init(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: menu.c:3708
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define WS_VISIBLE
Definition: pedump.c:620
#define GWLP_WNDPROC
Definition: treelist.c:66
#define MAKEINTATOM(i)
Definition: winbase.h:1463
HWND WINAPI CreateWindowExA(_In_ DWORD dwExStyle, _In_opt_ LPCSTR lpClassName, _In_opt_ LPCSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define CW_USEDEFAULT
Definition: winuser.h:225
#define TPM_RETURNCMD
Definition: winuser.h:2390
BOOL WINAPI DestroyWindow(_In_ HWND)

Referenced by START_TEST().

◆ test_getmenubarinfo()

static void test_getmenubarinfo ( void  )
static

Definition at line 225 of file menu.c.

226{
227 BOOL ret;
228 HMENU hmenu;
229 MENUBARINFO mbi;
230 RECT rcw, rci;
231 HWND hwnd;
232 INT err;
233
234 mbi.cbSize = sizeof(MENUBARINFO);
235
238 NULL, NULL, NULL, NULL);
239 ok(hwnd != NULL, "CreateWindowEx failed with error %d\n", GetLastError());
240
241 /* no menu: getmenubarinfo should fail */
242 SetLastError(0xdeadbeef);
243 ret = GetMenuBarInfo(hwnd, OBJID_MENU, 0, &mbi);
244 err = GetLastError();
245 ok(ret == FALSE, "GetMenuBarInfo should not have been successful\n");
246 ok(err == 0xdeadbeef, "err = %d\n", err);
247
248 /* create menubar, no items yet */
249 hmenu = CreateMenu();
250 ok(hmenu != NULL, "CreateMenu failed with error %d\n", GetLastError());
251
252 ret = SetMenu(hwnd, hmenu);
253 ok(ret, "SetMenu failed with error %d\n", GetLastError());
254
255 SetLastError(0xdeadbeef);
256 ret = GetMenuBarInfo(NULL, OBJID_CLIENT, 0, &mbi);
257 err = GetLastError();
258 ok(!ret, "GetMenuBarInfo succeeded\n");
259 ok(err == ERROR_INVALID_WINDOW_HANDLE, "err = %d\n", err);
260
261 SetLastError(0xdeadbeef);
262 ret = GetMenuBarInfo(hwnd, OBJID_CLIENT, 0, &mbi);
263 err = GetLastError();
264 ok(!ret, "GetMenuBarInfo succeeded\n");
265 ok(err==ERROR_INVALID_MENU_HANDLE || broken(err==0xdeadbeef) /* NT, W2K, XP */, "err = %d\n", err);
266
267 SetLastError(0xdeadbeef);
268 ret = GetMenuBarInfo(hwnd, OBJID_MENU, -1, &mbi);
269 err = GetLastError();
270 ok(ret == FALSE, "GetMenuBarInfo should have failed\n");
271 ok(err == 0xdeadbeef, "err = %d\n", err);
272
273 mbi.cbSize = 1000;
274 SetLastError(0xdeadbeef);
275 ret = GetMenuBarInfo(hwnd, OBJID_MENU, 0, &mbi);
276 err = GetLastError();
277 ok(ret == FALSE, "GetMenuBarInfo should have failed\n");
278 ok(err == ERROR_INVALID_PARAMETER, "err = %d\n", err);
279 mbi.cbSize = sizeof(MENUBARINFO);
280
281 SetLastError(0xdeadbeef);
282 ret = GetMenuBarInfo(hwnd, 123, 0, &mbi);
283 err = GetLastError();
284 ok(ret == FALSE, "GetMenuBarInfo should have failed\n");
285 ok(err == 0xdeadbeef, "err = %d\n", err);
286
287 ret = GetMenuBarInfo(hwnd, OBJID_MENU, 0, &mbi);
288 ok(ret, "GetMenuBarInfo failed with error %d\n", GetLastError());
289
290 ok(mbi.rcBar.left == 0 && mbi.rcBar.top == 0 && mbi.rcBar.bottom == 0 && mbi.rcBar.right == 0,
291 "rcBar: Expected (0,0)-(0,0), got: %s\n", wine_dbgstr_rect(&mbi.rcBar));
292 ok(mbi.hMenu == hmenu, "hMenu: Got %p instead of %p\n",
293 mbi.hMenu, hmenu);
294 ok(mbi.fBarFocused == 0, "fBarFocused: Got %d instead of 0.\n", mbi.fBarFocused);
295 ok(mbi.fFocused == 0, "fFocused: Got %d instead of 0.\n", mbi.fFocused);
296
297 /* add some items */
298 ret = AppendMenuA(hmenu, MF_STRING , 100, "item 1");
299 ok(ret, "AppendMenu failed.\n");
300 ret = AppendMenuA(hmenu, MF_STRING , 101, "item 2");
301 ok(ret, "AppendMenu failed.\n");
302 ret = SetMenu(hwnd, hmenu);
303 ok(ret, "SetMenu failed with error %d\n", GetLastError());
304
305 SetLastError(0xdeadbeef);
306 ret = GetMenuBarInfo(hwnd, OBJID_MENU, 200, &mbi);
307 err = GetLastError();
308 ok(ret == FALSE, "GetMenuBarInfo should have failed\n");
309 ok(err == 0xdeadbeef, "err = %d\n", err);
310
311 /* get info for the whole menu */
312 ret = GetMenuBarInfo(hwnd, OBJID_MENU, 0, &mbi);
313 ok(ret, "GetMenuBarInfo failed with error %d\n", GetLastError());
314
315 /* calculate menu rectangle, from window rectangle and the position of the first item */
316 ret = GetWindowRect(hwnd, &rcw);
317 ok(ret, "GetWindowRect failed.\n");
318 ret = GetMenuItemRect(hwnd, hmenu, 0, &rci);
319 ok(ret, "GetMenuItemRect failed.\n");
320 todo_wine ok(mbi.rcBar.left == rci.left && mbi.rcBar.top == rci.top &&
321 mbi.rcBar.bottom == rci.bottom && mbi.rcBar.right == rcw.right - rci.left + rcw.left,
322 "rcBar: Got %s instead of (%d,%d)-(%d,%d)\n", wine_dbgstr_rect(&mbi.rcBar),
323 rci.left, rci.top, rcw.right - rci.left + rcw.left, rci.bottom);
324 ok(mbi.hMenu == hmenu, "hMenu: Got %p instead of %p\n", mbi.hMenu, hmenu);
325 ok(mbi.fBarFocused == 0, "fBarFocused: got %d instead of 0\n", mbi.fBarFocused);
326 ok(mbi.fFocused == 0, "fFocused: got %d instead of 0\n", mbi.fFocused);
327
328 /* get info for item nr.2 */
329 ret = GetMenuBarInfo(hwnd, OBJID_MENU, 2, &mbi);
330 ok(ret, "GetMenuBarInfo failed with error %d\n", GetLastError());
331 ret = GetMenuItemRect(hwnd, hmenu, 1, &rci);
332 ok(ret, "GetMenuItemRect failed.\n");
333 ok(EqualRect(&mbi.rcBar, &rci), "rcBar: Got %s instead of %s\n", wine_dbgstr_rect(&mbi.rcBar),
334 wine_dbgstr_rect(&rci));
335 ok(mbi.hMenu == hmenu, "hMenu: Got %p instead of %p\n", mbi.hMenu, hmenu);
336 ok(mbi.fBarFocused == 0, "fBarFocused: got %d instead of 0\n", mbi.fBarFocused);
337 ok(mbi.fFocused == 0, "fFocused: got %d instead of 0\n", mbi.fFocused);
338
340}
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define todo_wine
Definition: custom.c:89
#define WS_SYSMENU
Definition: pedump.c:629
#define err(...)
BOOL fBarFocused
Definition: winuser.h:3733
DWORD cbSize
Definition: winuser.h:3729
#define OBJID_MENU
Definition: winable.h:18
#define OBJID_CLIENT
Definition: winable.h:19
#define ERROR_INVALID_MENU_HANDLE
Definition: winerror.h:882
#define ERROR_INVALID_WINDOW_HANDLE
Definition: winerror.h:881
BOOL WINAPI SetMenu(_In_ HWND, _In_opt_ HMENU)
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
struct tagMENUBARINFO MENUBARINFO
BOOL WINAPI GetMenuBarInfo(_In_ HWND, _In_ LONG, _In_ LONG, _Inout_ PMENUBARINFO)
BOOL WINAPI EqualRect(_In_ LPCRECT, _In_ LPCRECT)

Referenced by START_TEST().

◆ test_GetMenuItemRect()

static void test_GetMenuItemRect ( void  )
static

Definition at line 342 of file menu.c.

343{
344 HWND hwnd;
345 HMENU hmenu;
346 HMENU popup_hmenu;
347 RECT window_rect;
348 RECT item_rect;
349 POINT client_top_left;
350 INT caption_height;
351 BOOL ret;
352
354 NULL, NULL, NULL);
355 ok(hwnd != NULL, "CreateWindow failed with error %d\n", GetLastError());
356 hmenu = CreateMenu();
357 ok(hmenu != NULL, "CreateMenu failed with error %d\n", GetLastError());
358 popup_hmenu = CreatePopupMenu();
359 ok(popup_hmenu != NULL, "CreatePopupMenu failed with error %d\n", GetLastError());
360 ret = AppendMenuA(popup_hmenu, MF_STRING, 0, "Popup");
361 ok(ret, "AppendMenu failed with error %d\n", GetLastError());
362 ret = AppendMenuA(hmenu, MF_STRING | MF_POPUP, (UINT_PTR)popup_hmenu, "Menu");
363 ok(ret, "AppendMenu failed with error %d\n", GetLastError());
364 ret = SetMenu(hwnd, hmenu);
365 ok(ret, "SetMenu failed with error %d\n", GetLastError());
366
367 /* Get the menu item rectangle of the displayed sysmenu item */
368 ret = GetMenuItemRect(hwnd, hmenu, 0, &item_rect);
369 ok(ret, "GetMenuItemRect failed with error %d\n", GetLastError());
370 GetWindowRect(hwnd, &window_rect);
371 /* Get the screen coordinate of the left top corner of the client rectangle */
372 client_top_left.x = 0;
373 client_top_left.y = 0;
374 MapWindowPoints(hwnd, 0, &client_top_left, 1);
376
377 ok(item_rect.left == client_top_left.x, "Expect item_rect.left %d == %d\n", item_rect.left, client_top_left.x);
378 ok(item_rect.right <= window_rect.right, "Expect item_rect.right %d <= %d\n", item_rect.right, window_rect.right);
379 /* A gap of 1 pixel is added deliberately in commit 75f9e64, so using equal operator would fail on Wine.
380 * Check that top and bottom are correct with 1 pixel margin tolerance */
381 ok(item_rect.top - (window_rect.top + caption_height) <= 1, "Expect item_rect.top %d - %d <= 1\n", item_rect.top,
382 window_rect.top + caption_height);
383 ok(item_rect.bottom - (client_top_left.y - 1) <= 1, "Expect item_rect.bottom %d - %d <= 1\n", item_rect.bottom,
384 client_top_left.y - 1);
385
386 /* Get the item rectangle of the not yet displayed popup menu item. */
387 ret = GetMenuItemRect(hwnd, popup_hmenu, 0, &item_rect);
388 ok(ret, "GetMenuItemRect failed with error %d\n", GetLastError());
389 ok(item_rect.left == client_top_left.x, "Expect item_rect.left %d == %d\n", item_rect.left, client_top_left.x);
390 ok(item_rect.right == client_top_left.x, "Expect item_rect.right %d == %d\n", item_rect.right, client_top_left.x);
391 ok(item_rect.top == client_top_left.y, "Expect item_rect.top %d == %d\n", item_rect.top, client_top_left.y);
392 ok(item_rect.bottom == client_top_left.y, "Expect item_rect.bottom %d == %d\n", item_rect.bottom,
393 client_top_left.y);
394
396}
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
#define SM_CYFRAME
Definition: winuser.h:999
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4319
#define SM_CYCAPTION
Definition: winuser.h:966
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by START_TEST().

◆ test_InsertMenu()

static void test_InsertMenu ( void  )
static

Definition at line 2971 of file menu.c.

2972{
2973 HBITMAP hbm = CreateBitmap(1,1,1,1,NULL);
2974 /* Note: XP treats only bitmap handles 1 - 6 as "magic" ones
2975 * regardless of their id.
2976 */
2977 static const struct menu_data in1[] =
2978 {
2979 { MF_STRING, 1, "File" },
2981 { MF_STRING|MF_HELP, 2, "Help" }
2982 };
2983 static const struct menu_data out1[] =
2984 {
2985 { MF_STRING, 1, "File" },
2986 { MF_STRING|MF_HELP, 2, "Help" },
2988 };
2989 static const struct menu_data out1a[] =
2990 {
2991 { MF_STRING, 1, "File" },
2992 { MF_STRING|MF_HELP, 2, "Help" },
2994 };
2995 const struct menu_data in2[] =
2996 {
2997 { MF_STRING, 1, "File" },
2998 { MF_BITMAP|MF_HELP, SC_CLOSE, (char*)hbm },
2999 { MF_STRING|MF_HELP, 2, "Help" }
3000 };
3001 const struct menu_data out2[] =
3002 {
3003 { MF_STRING, 1, "File" },
3004 { MF_BITMAP|MF_HELP, SC_CLOSE, (char*)hbm },
3005 { MF_STRING|MF_HELP, 2, "Help" }
3006 };
3007 const struct menu_data out2a[] =
3008 {
3009 { MF_STRING, 1, "File" },
3010 { MF_HELP, SC_CLOSE, (char*)hbm },
3011 { MF_STRING|MF_HELP, 2, "Help" }
3012 };
3013 static const struct menu_data in3[] =
3014 {
3015 { MF_STRING, 1, "File" },
3017 { MF_STRING|MF_HELP, 2, "Help" }
3018 };
3019 static const struct menu_data out3[] =
3020 {
3021 { MF_STRING, 1, "File" },
3023 { MF_STRING|MF_HELP, 2, "Help" },
3024 };
3025 static const struct menu_data in4[] =
3026 {
3027 { MF_STRING, 1, "File" },
3029 { MF_STRING|MF_HELP, 2, "Help" }
3030 };
3031 static const struct menu_data out4[] =
3032 {
3033 { MF_STRING, 1, "File" },
3034 { MF_STRING|MF_HELP, 2, "Help" },
3036 };
3037 static const struct menu_data out4a[] =
3038 {
3039 { MF_STRING, 1, "File" },
3040 { MF_STRING|MF_HELP, 2, "Help" },
3041 { MF_HELP, 1, MAKEINTRESOURCEA(1) }
3042 };
3043 HMENU hmenu;
3044
3045#define create_menu(a) create_menu_from_data((a), ARRAY_SIZE(a))
3046#define create_menuitem(a) create_menuitem_from_data((a), ARRAY_SIZE(a))
3047#define compare_menu(h, a) compare_menu_data((h), (a), ARRAY_SIZE(a))
3048
3049 hmenu = create_menu(in1);
3050 compare_menu(hmenu, out1);
3052
3053 hmenu = create_menu(in2);
3054 compare_menu(hmenu, out2);
3056
3057 hmenu = create_menu(in3);
3058 compare_menu(hmenu, out3);
3060
3061 hmenu = create_menu(in4);
3062 compare_menu(hmenu, out4);
3064
3065 /* now using InsertMenuItemInfo */
3066 hmenu = create_menuitem(in1);
3067 compare_menu(hmenu, out1a);
3069
3070 hmenu = create_menuitem(in2);
3071 compare_menu(hmenu, out2a);
3073
3074 hmenu = create_menuitem(in3);
3075 compare_menu(hmenu, out3);
3077
3078 hmenu = create_menuitem(in4);
3079 compare_menu(hmenu, out4a);
3081
3082#undef create_menu
3083#undef create_menuitem
3084#undef compare_menu
3085}
#define compare_menu(h, a)
#define create_menuitem(a)
#define create_menu(a)
_In_ HBITMAP hbm
Definition: ntgdi.h:2776
#define SC_CLOSE
Definition: winuser.h:2595

Referenced by START_TEST().

◆ test_mbs_help()

static void test_mbs_help ( int  ispop,
int  hassub,
int  mnuopt,
HWND  hwnd,
int  arrowwidth,
int  count,
HBITMAP  hbmp,
SIZE  bmpsize,
LPCSTR  text,
SIZE  size,
SIZE  sc_size 
)
static

Definition at line 807 of file menu.c.

810{
811 BOOL ret;
812 HMENU hmenu, submenu;
813 MENUITEMINFOA mii={ sizeof( MENUITEMINFOA )};
814 MENUINFO mi;
815 RECT rc;
816 CHAR text_copy[16];
817 int hastab, expect;
818 BOOL failed = FALSE;
819
822 mii.fType = 0;
823 /* check the menu item unless MNS_CHECKORBMP is set */
824 mii.fState = (mnuopt != 2 ? MFS_CHECKED : MFS_UNCHECKED);
825 mii.dwItemData =0;
826 MODsizes[0] = bmpsize;
827 hastab = 0;
828 if( text ) {
829 char *p;
830 mii.fMask |= MIIM_STRING;
831 strcpy(text_copy, text);
832 mii.dwTypeData = text_copy; /* structure member declared non-const */
833 if( ( p = strchr( text, '\t'))) {
834 hastab = *(p + 1) ? 2 : 1;
835 }
836 }
837 /* tabs don't make sense in menubars */
838 if(hastab && !ispop) return;
839 if( hbmp) {
840 mii.fMask |= MIIM_BITMAP;
841 mii.hbmpItem = hbmp;
842 }
843 submenu = CreateMenu();
844 ok( submenu != 0, "CreateMenu failed with error %d\n", GetLastError());
845 if( ispop)
847 else
848 hmenu = CreateMenu();
849 ok( hmenu != 0, "Create{Popup}Menu failed with error %d\n", GetLastError());
850 if( hassub) {
851 mii.fMask |= MIIM_SUBMENU;
852 mii.hSubMenu = submenu;
853 }
854 if( mnuopt) {
855 mi.cbSize = sizeof(mi);
856 mi.fMask = MIM_STYLE;
857 GetMenuInfo( hmenu, &mi);
858 if( mnuopt) mi.dwStyle |= mnuopt == 1 ? MNS_NOCHECK : MNS_CHECKORBMP;
859 ret = SetMenuInfo( hmenu, &mi);
860 ok( ret, "SetMenuInfo failed with error %d\n", GetLastError());
861 }
862 ret = InsertMenuItemA( hmenu, 0, FALSE, &mii);
863 ok( ret, "InsertMenuItem failed with error %d\n", GetLastError());
864 failed = !ret;
865 if( winetest_debug) {
866 HDC hdc=GetDC(hwnd);
867 RECT rc = {100, 50, 400, 70};
868 char buf[100];
869
870 sprintf( buf,"%d text \"%s\" mnuopt %d", count, text ? text: "(nil)", mnuopt);
871 FillRect( hdc, &rc, (HBRUSH) COLOR_WINDOW);
872 TextOutA( hdc, 10, 50, buf, strlen( buf));
873 ReleaseDC( hwnd, hdc);
874 }
875 if(ispop)
876 TrackPopupMenu( hmenu, TPM_RETURNCMD, 100,100, 0, hwnd, NULL);
877 else {
878 ret = SetMenu( hwnd, hmenu);
879 ok(ret, "SetMenu failed with error %d\n", GetLastError());
881 }
882 ret = GetMenuItemRect( hwnd, hmenu, 0, &rc);
883 ok(ret, "GetMenuItemRect failed with error %d\n", GetLastError());
884
885 if (0) /* comment out menu size checks, behavior is different in almost every Windows version */
886 /* the tests should however succeed on win2000, XP and Wine (at least up to 1.1.15) */
887 /* with a variety of dpis and desktop font sizes */
888 {
889 /* check menu width */
890 if( ispop)
891 expect = ( text || hbmp ?
892 4 + (mnuopt != 1 ? GetSystemMetrics(SM_CXMENUCHECK) : 0)
893 : 0) +
894 arrowwidth + MOD_avec + (hbmp ?
895 ((INT_PTR)hbmp<0||(INT_PTR)hbmp>12 ? bmpsize.cx + 2 : GetSystemMetrics( SM_CXMENUSIZE) + 2)
896 : 0) +
897 (text && hastab ? /* TAB space */
898 MOD_avec + ( hastab==2 ? sc_size.cx : 0) : 0) +
899 (text ? 2 + (text[0] ? size.cx :0): 0) ;
900 else
901 expect = !(text || hbmp) ? 0 :
902 ( hbmp ? (text ? 2:0) + bmpsize.cx : 0 ) +
903 (text ? 2 * MOD_avec + (text[0] ? size.cx :0): 0) ;
904 ok( rc.right - rc.left == expect,
905 "menu width wrong, got %d expected %d\n", rc.right - rc.left, expect);
906 failed = failed || !(rc.right - rc.left == expect);
907 /* check menu height */
908 if( ispop)
909 expect = max( ( !(text || hbmp) ? GetSystemMetrics( SM_CYMENUSIZE)/2 : 0),
910 max( (text ? max( 2 + size.cy, MOD_hic + 4) : 0),
911 (hbmp ?
912 ((INT_PTR)hbmp<0||(INT_PTR)hbmp>12 ?
913 bmpsize.cy + 2
915 : 0)));
916 else
918 max( GetSystemMetrics( SM_CYMENU) - 1, (hbmp ? bmpsize.cy : 0)));
919 ok( rc.bottom - rc.top == expect,
920 "menu height wrong, got %d expected %d (%d)\n",
922 failed = failed || !(rc.bottom - rc.top == expect);
924 /* check the position of the bitmap */
925 /* horizontal */
926 if (!ispop)
927 expect = 3;
928 else if (mnuopt == 0)
930 else if (mnuopt == 1)
931 expect = 4;
932 else /* mnuopt == 2 */
933 expect = 2;
934 ok( expect == MOD_rc[0].left,
935 "bitmap left is %d expected %d\n", MOD_rc[0].left, expect);
936 failed = failed || !(expect == MOD_rc[0].left);
937 /* vertical */
938 expect = (rc.bottom - rc.top - MOD_rc[0].bottom + MOD_rc[0].top) / 2;
939 ok( expect == MOD_rc[0].top,
940 "bitmap top is %d expected %d\n", MOD_rc[0].top, expect);
941 failed = failed || !(expect == MOD_rc[0].top);
942 }
943 }
944 /* if there was a failure, report details */
945 if( failed) {
946 trace("*** count %d %s text \"%s\" bitmap %p bmsize %d,%d textsize %d+%d,%d mnuopt %d hastab %d\n",
947 count, (ispop? "POPUP": "MENUBAR"),text ? text: "(nil)", hbmp, bmpsize.cx, bmpsize.cy,
948 size.cx, size.cy, sc_size.cx, mnuopt, hastab);
949 trace(" check %d,%d arrow %d avechar %d\n",
952 if( hbmp == HBMMENU_CALLBACK)
953 trace( " rc %s bmp.rc %s\n", wine_dbgstr_rect(&rc), wine_dbgstr_rect(&MOD_rc[0]));
954 }
955 /* clean up */
956 ret = DestroyMenu(submenu);
957 ok(ret, "DestroyMenu failed with error %d\n", GetLastError());
959 ok(ret, "DestroyMenu failed with error %d\n", GetLastError());
960}
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
GLint left
Definition: glext.h:7726
#define sprintf(buf, format,...)
Definition: sprintf.c:55
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:88
SIZE sc_size
Definition: menu.c:79
_Out_opt_ int * cx
Definition: commctrl.h:585
DWORD cbSize
Definition: winuser.h:3787
#define max(a, b)
Definition: svc.c:63
int32_t INT_PTR
Definition: typedefs.h:64
BOOL WINAPI TextOutA(_In_ HDC hdc, _In_ int x, _In_ int y, _In_reads_(c) LPCSTR lpString, _In_ int c)
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define COLOR_WINDOW
Definition: winuser.h:921
#define SM_CXMENUCHECK
Definition: winuser.h:1034
#define SM_CYMENU
Definition: winuser.h:979
#define MNS_CHECKORBMP
Definition: winuser.h:763
#define SM_CYMENUCHECK
Definition: winuser.h:1035
BOOL WINAPI DrawMenuBar(_In_ HWND)
BOOL WINAPI SetMenuInfo(_In_ HMENU, _In_ LPCMENUINFO)
HDC WINAPI GetDC(_In_opt_ HWND)
BOOL WINAPI GetMenuInfo(_In_ HMENU, _Inout_ LPMENUINFO)
#define MNS_NOCHECK
Definition: winuser.h:758
#define SM_CXMENUSIZE
Definition: winuser.h:1020
#define MFS_UNCHECKED
Definition: winuser.h:756
#define SM_CYMENUSIZE
Definition: winuser.h:1021
#define HBMMENU_CALLBACK
Definition: winuser.h:2633
char CHAR
Definition: xmlstorage.h:175

Referenced by test_menu_bmp_and_string().

◆ test_menu_add_string()

static void test_menu_add_string ( void  )
static

Definition at line 1076 of file menu.c.

1077{
1078 HMENU hmenu;
1080 BOOL rc;
1081 int ret;
1082
1083 char string[0x80];
1084 char string2[0x80];
1085
1086 char strback[0x80];
1087 WCHAR strbackW[0x80];
1088 static CHAR blah[] = "blah";
1089 static const WCHAR expectedString[] = {'D','u','m','m','y',' ','s','t','r','i','n','g', 0};
1090
1091 hmenu = CreateMenu();
1092
1093 memset( &info, 0, sizeof info );
1094 info.cbSize = sizeof info;
1096 info.dwTypeData = blah;
1097 info.cch = 6;
1098 info.dwItemData = 0;
1099 info.wID = 1;
1100 info.fState = 0;
1102
1103 memset( &info, 0, sizeof info );
1104 info.cbSize = sizeof info;
1106 info.dwTypeData = string;
1107 info.cch = sizeof string;
1108 string[0] = 0;
1110
1111 ok( !strcmp( string, "blah" ), "menu item name differed\n");
1112
1113 /* Test combination of ownerdraw and strings with GetMenuItemString(A/W) */
1114 strcpy(string, "Dummy string");
1115 memset(&info, 0x00, sizeof(info));
1116 info.cbSize= sizeof(MENUITEMINFOA);
1117 info.fMask= MIIM_FTYPE | MIIM_STRING; /* Set OwnerDraw + typeData */
1118 info.fType= MFT_OWNERDRAW;
1119 info.dwTypeData= string;
1120 rc = InsertMenuItemA( hmenu, 0, TRUE, &info );
1121 ok (rc, "InsertMenuItem failed\n");
1122
1123 strcpy(string,"Garbage");
1124 ok (GetMenuStringA( hmenu, 0, strback, 99, MF_BYPOSITION), "GetMenuString on ownerdraw entry failed\n");
1125 ok (!strcmp( strback, "Dummy string" ), "Menu text from Ansi version incorrect\n");
1126
1127 ret = GetMenuStringW( hmenu, 0, strbackW, 99, MF_BYPOSITION );
1128 ok (ret, "GetMenuStringW on ownerdraw entry failed\n");
1129 ok (!lstrcmpW( strbackW, expectedString ), "Menu text from Unicode version incorrect\n");
1130
1131 /* Just try some invalid parameter tests */
1132 SetLastError(0xdeadbeef);
1133 rc = SetMenuItemInfoA( hmenu, 0, TRUE, NULL );
1134 ret = GetLastError();
1135 ok (!rc, "SetMenuItemInfoA succeeded unexpectedly\n");
1136 ok (ret == ERROR_INVALID_PARAMETER, "Expected 87, got %d\n", ret);
1137
1138 SetLastError(0xdeadbeef);
1139 rc = SetMenuItemInfoA( hmenu, 0, FALSE, NULL );
1140 ret = GetLastError();
1141 ok (!rc, "SetMenuItemInfoA succeeded unexpectedly\n");
1142 ok (ret == ERROR_INVALID_PARAMETER, "Expected 87, got %d\n", ret);
1143
1144 /* Just change ftype to string and see what text is stored */
1145 memset(&info, 0x00, sizeof(info));
1146 info.cbSize= sizeof(MENUITEMINFOA);
1147 info.fMask= MIIM_FTYPE; /* Set string type */
1148 info.fType= MFT_STRING;
1149 info.dwTypeData= (char *)0xdeadbeef;
1150 rc = SetMenuItemInfoA( hmenu, 0, TRUE, &info );
1151 ok (rc, "SetMenuItemInfo failed\n");
1152
1153 /* Did we keep the old dwTypeData? */
1154 ok (GetMenuStringA( hmenu, 0, strback, 99, MF_BYPOSITION), "GetMenuString on ownerdraw entry failed\n");
1155 ok (!strcmp( strback, "Dummy string" ), "Menu text from Ansi version incorrect\n");
1156
1157 /* Ensure change to bitmap type fails */
1158 memset(&info, 0x00, sizeof(info));
1159 info.cbSize= sizeof(MENUITEMINFOA);
1160 info.fMask= MIIM_FTYPE; /* Set as bitmap type */
1161 info.fType= MFT_BITMAP;
1162 info.dwTypeData= (char *)0xdeadbee2;
1163 rc = SetMenuItemInfoA( hmenu, 0, TRUE, &info );
1164 ok (!rc, "SetMenuItemInfo unexpectedly worked\n");
1165
1166 /* Just change ftype back and ensure data hasn't been freed */
1167 info.fType= MFT_OWNERDRAW; /* Set as ownerdraw type */
1168 info.dwTypeData= (char *)0xdeadbee3;
1169 rc = SetMenuItemInfoA( hmenu, 0, TRUE, &info );
1170 ok (rc, "SetMenuItemInfo failed\n");
1171
1172 /* Did we keep the old dwTypeData? */
1173 ok (GetMenuStringA( hmenu, 0, strback, 99, MF_BYPOSITION), "GetMenuString on ownerdraw entry failed\n");
1174 ok (!strcmp( strback, "Dummy string" ), "Menu text from Ansi version incorrect\n");
1175
1176 /* Just change string value (not type) */
1177 memset(&info, 0x00, sizeof(info));
1178 info.cbSize= sizeof(MENUITEMINFOA);
1179 info.fMask= MIIM_STRING; /* Set typeData */
1180 strcpy(string2, "string2");
1181 info.dwTypeData= string2;
1182 rc = SetMenuItemInfoA( hmenu, 0, TRUE, &info );
1183 ok (rc, "SetMenuItemInfo failed\n");
1184
1185 ok (GetMenuStringA( hmenu, 0, strback, 99, MF_BYPOSITION), "GetMenuString on ownerdraw entry failed\n");
1186 ok (!strcmp( strback, "string2" ), "Menu text from Ansi version incorrect\n");
1187
1188 /* crashes with wine 0.9.5 */
1189 memset(&info, 0x00, sizeof(info));
1190 info.cbSize= sizeof(MENUITEMINFOA);
1191 info.fMask= MIIM_FTYPE | MIIM_STRING; /* Set OwnerDraw + typeData */
1192 info.fType= MFT_OWNERDRAW;
1193 rc = InsertMenuItemA( hmenu, 0, TRUE, &info );
1194 ok (rc, "InsertMenuItem failed\n");
1196 "GetMenuString on ownerdraw entry succeeded.\n");
1198 ok (!ret, "GetMenuStringW on ownerdraw entry succeeded.\n");
1199
1200 DestroyMenu( hmenu );
1201}
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4242
static CHAR string2[MAX_PATH]
Definition: automation.c:345
#define MFT_OWNERDRAW
Definition: winuser.h:744
#define MFT_STRING
Definition: winuser.h:749

Referenced by START_TEST().

◆ test_menu_bmp_and_string()

static void test_menu_bmp_and_string ( void  )
static

Definition at line 963 of file menu.c.

964{
965 BYTE bmfill[300];
966 HBITMAP hbm_arrow;
967 BITMAP bm;
968 INT arrowwidth;
969 HWND hwnd;
970 HMENU hsysmenu;
971 MENUINFO mi= {sizeof(MENUINFO)};
972 MENUITEMINFOA mii= {sizeof(MENUITEMINFOA)};
973 int count, szidx, txtidx, bmpidx, hassub, mnuopt, ispop;
974 BOOL got;
975
976 memset( bmfill, 0xcc, sizeof( bmfill));
979 NULL, NULL, NULL, NULL);
980 hbm_arrow = LoadBitmapA( 0, (LPCSTR)OBM_MNARROW);
981 GetObjectA( hbm_arrow, sizeof(bm), &bm);
982 arrowwidth = bm.bmWidth;
983 ok(hwnd != NULL, "CreateWindowEx failed with error %d\n", GetLastError());
984 if( !hwnd) return;
985 /* test system menu */
986 hsysmenu = GetSystemMenu( hwnd, FALSE);
987 ok( hsysmenu != NULL, "GetSystemMenu failed with error %d\n", GetLastError());
988 mi.fMask = MIM_STYLE;
989 mi.dwStyle = 0;
990 got = GetMenuInfo( hsysmenu, &mi);
991 ok( got, "GetMenuInfo failed gle=%d\n", GetLastError());
992 ok( MNS_CHECKORBMP == mi.dwStyle, "System Menu Style is %08x, without the bit %08x\n",
993 mi.dwStyle, MNS_CHECKORBMP);
994 mii.fMask = MIIM_BITMAP;
995 mii.hbmpItem = NULL;
996 got = GetMenuItemInfoA( hsysmenu, SC_CLOSE, FALSE, &mii);
997 ok( got, "GetMenuItemInfoA failed gle=%d\n", GetLastError());
998 ok( HBMMENU_POPUP_CLOSE == mii.hbmpItem, "Item info did not get the right hbitmap: got %p expected %p\n",
999 mii.hbmpItem, HBMMENU_POPUP_CLOSE);
1000
1001 memset(&mii, 0x81, sizeof(mii));
1002 mii.cbSize = sizeof(mii);
1004 mii.dwTypeData = (LPSTR)bmfill;
1005 mii.cch = sizeof(bmfill);
1006 mii.dwItemData = 0x81818181;
1007 got = GetMenuItemInfoA(hsysmenu, SC_RESTORE, FALSE, &mii);
1008 ok(got, "GetMenuItemInfo failed\n");
1009 ok((mii.fType & ~(MFT_RIGHTJUSTIFY|MFT_RIGHTORDER)) == MFT_STRING, "expected MFT_STRING, got %#x\n", mii.fType);
1010 ok(mii.fState == MF_ENABLED, "expected MF_ENABLED, got %#x\n", mii.fState);
1011 ok(mii.wID == SC_RESTORE, "expected SC_RESTORE, got %#x\n", mii.wID);
1012 ok(mii.hSubMenu == 0, "expected 0, got %p\n", mii.hSubMenu);
1013 ok(mii.dwItemData == 0, "expected 0, got %#lx\n", mii.dwItemData);
1014 ok(mii.dwTypeData == (LPSTR)bmfill, "expected %p, got %p\n", bmfill, mii.dwTypeData);
1015 ok(mii.cch != 0, "cch should not be 0\n");
1016 ok(mii.hbmpItem == HBMMENU_POPUP_RESTORE, "expected HBMMENU_POPUP_RESTORE, got %p\n", mii.hbmpItem);
1017
1018 mii.cbSize = sizeof(mii);
1019 mii.fMask = MIIM_TYPE;
1020 mii.hbmpItem = (HBITMAP)0x81818181;
1021 got = GetMenuItemInfoA(hsysmenu, SC_CLOSE, FALSE, &mii);
1022 ok(got, "GetMenuItemInfo failed\n");
1023 ok((mii.fType & ~(MFT_RIGHTJUSTIFY|MFT_RIGHTORDER)) == MFT_STRING, "expected MFT_STRING, got %#x\n", mii.fType);
1024 ok(mii.fState == MF_ENABLED, "expected MF_ENABLED, got %#x\n", mii.fState);
1025 ok(mii.wID == SC_RESTORE, "expected SC_RESTORE, got %#x\n", mii.wID);
1026 ok(mii.hSubMenu == 0, "expected 0, got %p\n", mii.hSubMenu);
1027 ok(mii.dwItemData == 0, "expected 0, got %#lx\n", mii.dwItemData);
1028 ok(mii.dwTypeData == (LPSTR)bmfill, "expected %p, got %p\n", bmfill, mii.dwTypeData);
1029 ok(mii.cch != 0, "cch should not be 0\n");
1030 ok(mii.hbmpItem == HBMMENU_POPUP_CLOSE, "expected HBMMENU_POPUP_CLOSE, got %p\n", mii.hbmpItem);
1031
1033
1034 if( winetest_debug)
1035 trace(" check %d,%d arrow %d avechar %d\n",
1038 count = 0;
1039 MOD_maxid = 0;
1040 for( ispop=1; ispop >= 0; ispop--){
1041 static SIZE bmsizes[]= {
1042 {10,10},{38,38},{1,30},{55,5}};
1043 for( szidx=0; szidx < ARRAY_SIZE(bmsizes); szidx++) {
1044 HBITMAP hbm = CreateBitmap( bmsizes[szidx].cx, bmsizes[szidx].cy,1,1,bmfill);
1046 ok( hbm != 0, "CreateBitmap failed err %d\n", GetLastError());
1047 for( txtidx = 0; txtidx < ARRAY_SIZE(MOD_txtsizes); txtidx++) {
1048 for( hassub = 0; hassub < 2 ; hassub++) { /* add submenu item */
1049 for( mnuopt = 0; mnuopt < 3 ; mnuopt++){ /* test MNS_NOCHECK/MNS_CHECKORBMP */
1050 for( bmpidx = 0; bmpidx <ARRAY_SIZE(bitmaps); bmpidx++) {
1051 /* no need to test NULL bitmaps of several sizes */
1052 if( !bitmaps[bmpidx] && szidx > 0) continue;
1053 /* the HBMMENU_POPUP not to test for menu bars */
1054 if( !ispop &&
1055 bitmaps[bmpidx] >= HBMMENU_POPUP_CLOSE &&
1056 bitmaps[bmpidx] <= HBMMENU_POPUP_MINIMIZE) continue;
1057 if( !ispop && hassub) continue;
1058 test_mbs_help( ispop, hassub, mnuopt,
1059 hwnd, arrowwidth, ++count,
1060 bitmaps[bmpidx],
1061 bmsizes[szidx],
1062 MOD_txtsizes[txtidx].text,
1063 MOD_txtsizes[txtidx].size,
1064 MOD_txtsizes[txtidx].sc_size);
1065 }
1066 }
1067 }
1068 }
1069 DeleteObject( hbm);
1070 }
1071 }
1072 /* clean up */
1074}
#define ARRAY_SIZE(A)
Definition: main.h:20
static void test_mbs_help(int ispop, int hassub, int mnuopt, HWND hwnd, int arrowwidth, int count, HBITMAP hbmp, SIZE bmpsize, LPCSTR text, SIZE size, SIZE sc_size)
Definition: menu.c:807
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
Definition: bl.h:1331
int WINAPI GetObjectA(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
#define HBMMENU_POPUP_MINIMIZE
Definition: winuser.h:2643
#define MFT_RIGHTORDER
Definition: winuser.h:748
HBITMAP WINAPI LoadBitmapA(_In_opt_ HINSTANCE, _In_ LPCSTR)
Definition: cursoricon.c:2200
HMENU WINAPI GetSystemMenu(_In_ HWND, _In_ BOOL)
#define HBMMENU_POPUP_CLOSE
Definition: winuser.h:2640
#define MFT_RIGHTJUSTIFY
Definition: winuser.h:746
struct tagMENUINFO MENUINFO
#define SC_RESTORE
Definition: winuser.h:2601
unsigned char BYTE
Definition: xxhash.c:193

Referenced by START_TEST().

◆ test_menu_cancelmode()

static void test_menu_cancelmode ( void  )
static

Definition at line 3479 of file menu.c.

3480{
3481 DWORD ret;
3482 HWND hwnd, hwndchild;
3483 HMENU menu, menubar;
3484 MSG msg;
3485
3488 NULL, NULL, NULL, NULL);
3490 WS_VISIBLE | WS_CHILD, 10, 10, 20, 20,
3491 hwnd, NULL, NULL, NULL);
3492 ok( hwnd != NULL && hwndchild != NULL,
3493 "CreateWindowEx failed with error %d\n", GetLastError());
3497 menu = CreatePopupMenu();
3498 ok( menu != NULL, "CreatePopupMenu failed with error %d\n", GetLastError());
3499 ret = AppendMenuA( menu, MF_STRING, 1, "winetest");
3500 ok( ret, "Functie failed lasterror is %u\n", GetLastError());
3501 /* seems to be needed only on wine :( */
3502 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
3504 /* test the effect of sending a WM_CANCELMODE message in the WM_INITMENULOOP
3505 * handler of the menu owner */
3506 /* test results is extracted from variable g_got_enteridle. Possible values:
3507 * 0 : complete conformance. Sending WM_CANCELMODE cancels a menu initializing tracking
3508 * 1 : Sending WM_CANCELMODE cancels a menu that is in tracking state
3509 * 2 : Sending WM_CANCELMODE does not work
3510 */
3511 /* menu owner is top level window */
3513 TrackPopupMenu( menu, TPM_RETURNCMD, 100,100, 0, hwnd, NULL);
3514 ok( g_got_enteridle == 0, "received %d WM_ENTERIDLE messages, none expected\n", g_got_enteridle);
3515 /* menu owner is child window */
3516 g_hwndtosend = hwndchild;
3517 TrackPopupMenu( menu, TPM_RETURNCMD, 100,100, 0, hwndchild, NULL);
3518 ok(g_got_enteridle == 0, "received %d WM_ENTERIDLE messages, none expected\n", g_got_enteridle);
3519 /* now send the WM_CANCELMODE messages to the WRONG window */
3520 /* those should fail ( to have any effect) */
3522 TrackPopupMenu( menu, TPM_RETURNCMD, 100,100, 0, hwndchild, NULL);
3523 ok( g_got_enteridle == 2, "received %d WM_ENTERIDLE messages, should be 2\n", g_got_enteridle);
3524
3525 /* test canceling tracking in a window's menu bar */
3526 menubar = CreateMenu();
3527 ok( menubar != NULL, "CreateMenu failed with error %d\n", GetLastError());
3528 ret = AppendMenuA( menubar, MF_POPUP|MF_STRING, (UINT_PTR)menu, "winetest");
3529 ok( ret, "AppendMenuA failed lasterror is %u\n", GetLastError());
3530 ret = SetMenu( hwnd, menubar );
3531 ok( ret, "SetMenu failed lasterror is %u\n", GetLastError());
3532 /* initiate tracking */
3535 ok( ret == 0, "Sending WM_SYSCOMMAND/SC_KEYMENU failed lasterror is %u\n", GetLastError());
3536 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
3538 ok(g_got_enteridle == 0, "received %d WM_ENTERIDLE messages, none expected\n", g_got_enteridle);
3539
3540 /* cleanup */
3541 DestroyMenu( menubar );
3542 DestroyMenu( menu);
3543 DestroyWindow( hwndchild);
3545}
unsigned long DWORD
Definition: ntddk_ex.h:95
static LRESULT WINAPI menu_cancelmode_wnd_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: menu.c:3457
#define WS_CHILD
Definition: pedump.c:617
#define WM_SYSCOMMAND
Definition: winuser.h:1744
#define SC_KEYMENU
Definition: winuser.h:2599

Referenced by START_TEST().

◆ test_menu_circref()

static void test_menu_circref ( void  )
static

Definition at line 3576 of file menu.c.

3577{
3578 HMENU menu1, menu2;
3579 DWORD ret;
3580
3581 menu1 = CreatePopupMenu();
3582 menu2 = CreatePopupMenu();
3583 ok( menu1 && menu2, "error creating menus.\n");
3584 ret = AppendMenuA( menu1, MF_POPUP, (UINT_PTR)menu2, "winetest");
3585 ok( ret, "AppendMenu failed, error is %d\n", GetLastError());
3586 ret = AppendMenuA( menu1, MF_STRING | MF_HILITE, 123, "winetest");
3587 ok( ret, "AppendMenu failed, error is %d\n", GetLastError());
3588 /* app chooses an id that happens to clash with its own hmenu */
3589 ret = AppendMenuA( menu2, MF_STRING, (UINT_PTR)menu2, "winetest");
3590 ok( ret, "AppendMenu failed, error is %d\n", GetLastError());
3591 /* now attempt to change the string of the first item of menu1 */
3592 ret = ModifyMenuA( menu1, (UINT_PTR)menu2, MF_POPUP, (UINT_PTR)menu2, "menu 2");
3593 ok( !ret ||
3594 broken( ret), /* win98, NT */
3595 "ModifyMenu should have failed.\n");
3596 if( !ret) { /* will probably stack fault if the ModifyMenu succeeded */
3597 ret = GetMenuState( menu1, 123, 0);
3598 ok( ret == MF_HILITE, "GetMenuState returned %x\n",ret);
3599 }
3600 DestroyMenu( menu2);
3601 DestroyMenu( menu1);
3602}
UINT WINAPI GetMenuState(_In_ HMENU, _In_ UINT, _In_ UINT)
#define MF_HILITE
Definition: winuser.h:205

Referenced by START_TEST().

◆ test_menu_flags()

static void test_menu_flags ( void  )
static

Definition at line 2488 of file menu.c.

2489{
2490 HMENU hMenu, hPopupMenu;
2491
2492 hMenu = CreateMenu();
2493 hPopupMenu = CreatePopupMenu();
2494
2495 AppendMenuA(hMenu, MF_POPUP | MF_STRING, (UINT_PTR)hPopupMenu, "Popup");
2496
2497 AppendMenuA(hPopupMenu, MF_STRING | MF_HILITE | MF_DEFAULT, 101, "Item 1");
2498 InsertMenuA(hPopupMenu, 1, MF_BYPOSITION | MF_STRING | MF_HILITE | MF_DEFAULT, 102, "Item 2");
2499 AppendMenuA(hPopupMenu, MF_STRING, 103, "Item 3");
2500 ModifyMenuA(hPopupMenu, 2, MF_BYPOSITION | MF_STRING | MF_HILITE | MF_DEFAULT, 103, "Item 3");
2501
2502 ok(GetMenuState(hPopupMenu, 0, MF_BYPOSITION) & MF_HILITE,
2503 "AppendMenu should accept MF_HILITE\n");
2504 ok(GetMenuState(hPopupMenu, 1, MF_BYPOSITION) & MF_HILITE,
2505 "InsertMenu should accept MF_HILITE\n");
2506 ok(GetMenuState(hPopupMenu, 2, MF_BYPOSITION) & MF_HILITE,
2507 "ModifyMenu should accept MF_HILITE\n");
2508
2509 ok(!(GetMenuState(hPopupMenu, 0, MF_BYPOSITION) & MF_DEFAULT),
2510 "AppendMenu must not accept MF_DEFAULT\n");
2511 ok(!(GetMenuState(hPopupMenu, 1, MF_BYPOSITION) & MF_DEFAULT),
2512 "InsertMenu must not accept MF_DEFAULT\n");
2513 ok(!(GetMenuState(hPopupMenu, 2, MF_BYPOSITION) & MF_DEFAULT),
2514 "ModifyMenu must not accept MF_DEFAULT\n");
2515
2516 DestroyMenu(hMenu);
2517}
BOOL WINAPI InsertMenuA(_In_ HMENU, _In_ UINT, _In_ UINT, _In_ UINT_PTR, _In_opt_ LPCSTR)
#define MF_DEFAULT
Definition: winuser.h:140

Referenced by START_TEST().

◆ test_menu_getmenuinfo()

static void test_menu_getmenuinfo ( void  )
static

Definition at line 3087 of file menu.c.

3088{
3089 HMENU hmenu;
3090 MENUINFO mi = {0};
3091 BOOL ret;
3092 DWORD gle;
3093
3094 /* create a menu */
3095 hmenu = CreateMenu();
3096 assert( hmenu);
3097 /* test some parameter errors */
3098 SetLastError(0xdeadbeef);
3100 gle= GetLastError();
3101 ok( !ret, "GetMenuInfo() should have failed\n");
3102 ok( gle == ERROR_INVALID_PARAMETER ||
3103 broken(gle == 0xdeadbeef), /* Win98, WinME */
3104 "GetMenuInfo() error got %u expected %u\n", gle, ERROR_INVALID_PARAMETER);
3105 SetLastError(0xdeadbeef);
3106 mi.cbSize = 0;
3107 ret = GetMenuInfo( hmenu, &mi);
3108 gle= GetLastError();
3109 ok( !ret, "GetMenuInfo() should have failed\n");
3110 ok( gle == ERROR_INVALID_PARAMETER ||
3111 broken(gle == 0xdeadbeef), /* Win98, WinME */
3112 "GetMenuInfo() error got %u expected %u\n", gle, ERROR_INVALID_PARAMETER);
3113 SetLastError(0xdeadbeef);
3114 mi.cbSize = sizeof( MENUINFO);
3115 ret = GetMenuInfo( hmenu, &mi);
3116 gle= GetLastError();
3117 ok( ret, "GetMenuInfo() should have succeeded\n");
3118 ok( gle == 0xdeadbeef, "GetMenuInfo() error got %u\n", gle);
3119 SetLastError(0xdeadbeef);
3120 mi.cbSize = 0;
3121 ret = GetMenuInfo( NULL, &mi);
3122 gle= GetLastError();
3123 ok( !ret, "GetMenuInfo() should have failed\n");
3124 ok( gle == ERROR_INVALID_PARAMETER ||
3125 broken(gle == 0xdeadbeef), /* Win98, WinME */
3126 "GetMenuInfo() error got %u expected %u\n", gle, ERROR_INVALID_PARAMETER);
3127 /* clean up */
3129 return;
3130}

Referenced by START_TEST().

◆ test_menu_hilitemenuitem()

static void test_menu_hilitemenuitem ( void  )
static

Definition at line 2519 of file menu.c.

2520{
2521 HMENU hMenu, hPopupMenu;
2522 WNDCLASSA wclass;
2523 HWND hWnd;
2524 ATOM aclass;
2525
2526 wclass.lpszClassName = "HiliteMenuTestClass";
2527 wclass.style = CS_HREDRAW | CS_VREDRAW;
2528 wclass.lpfnWndProc = WndProc;
2529 wclass.hInstance = GetModuleHandleA( NULL );
2530 wclass.hIcon = LoadIconA( 0, (LPCSTR)IDI_APPLICATION );
2531 wclass.hCursor = LoadCursorA( 0, (LPCSTR)IDC_ARROW );
2532 wclass.hbrBackground = (HBRUSH)( COLOR_WINDOW + 1 );
2533 wclass.lpszMenuName = 0;
2534 wclass.cbClsExtra = 0;
2535 wclass.cbWndExtra = 0;
2536 aclass = RegisterClassA( &wclass );
2537 ok (aclass, "HiliteMenuTest class could not be created\n");
2538 if (!aclass) return;
2539 hWnd = CreateWindowA( wclass.lpszClassName, "HiliteMenuTest",
2541 400, 200, NULL, NULL, wclass.hInstance, NULL);
2542 ok (hWnd != NULL, "HiliteMenuTest window could not be created\n");
2543 if (!hWnd) return;
2544
2545 hMenu = CreateMenu();
2546 hPopupMenu = CreatePopupMenu();
2547
2548 AppendMenuA(hMenu, MF_POPUP | MF_STRING, (UINT_PTR)hPopupMenu, "Popup");
2549
2550 AppendMenuA(hPopupMenu, MF_STRING, 101, "Item 1");
2551 AppendMenuA(hPopupMenu, MF_STRING, 102, "Item 2");
2552 AppendMenuA(hPopupMenu, MF_STRING, 103, "Item 3");
2553
2554 SetMenu(hWnd, hMenu);
2555
2556 /* test invalid arguments */
2557
2558 ok(!(GetMenuState(hPopupMenu, 1, MF_BYPOSITION) & MF_HILITE),
2559 "HiliteMenuItem: Item 2 is hilited\n");
2560
2561 SetLastError(0xdeadbeef);
2562 todo_wine
2563 {
2564 ok(!HiliteMenuItem(NULL, hPopupMenu, 1, MF_HILITE | MF_BYPOSITION),
2565 "HiliteMenuItem: call should have failed.\n");
2566 }
2567 ok(GetLastError() == 0xdeadbeef || /* 9x */
2569 "HiliteMenuItem: expected error ERROR_INVALID_WINDOW_HANDLE, got: %d\n", GetLastError());
2570
2571 SetLastError(0xdeadbeef);
2573 "HiliteMenuItem: call should have failed.\n");
2574 ok(GetLastError() == 0xdeadbeef || /* 9x */
2576 "HiliteMenuItem: expected error ERROR_INVALID_MENU_HANDLE, got: %d\n", GetLastError());
2577
2578 ok(!(GetMenuState(hPopupMenu, 1, MF_BYPOSITION) & MF_HILITE),
2579 "HiliteMenuItem: Item 2 is hilited\n");
2580
2581 /* either MF_HILITE or MF_UNHILITE *and* MF_BYCOMMAND or MF_BYPOSITION need to be set */
2582
2583 SetLastError(0xdeadbeef);
2584 ok(HiliteMenuItem(hWnd, hPopupMenu, 1, MF_BYPOSITION),
2585 "HiliteMenuItem: call should have succeeded.\n");
2586 ok(GetLastError() == 0xdeadbeef,
2587 "HiliteMenuItem: expected error 0xdeadbeef, got: %d\n", GetLastError());
2588
2589 ok(!(GetMenuState(hPopupMenu, 1, MF_BYPOSITION) & MF_HILITE),
2590 "HiliteMenuItem: Item 2 is hilited\n");
2591
2592 SetLastError(0xdeadbeef);
2593 todo_wine
2594 {
2595 ok(HiliteMenuItem(hWnd, hPopupMenu, 1, MF_HILITE),
2596 "HiliteMenuItem: call should have succeeded.\n");
2597 }
2598 ok(GetLastError() == 0xdeadbeef,
2599 "HiliteMenuItem: expected error 0xdeadbeef, got: %d\n", GetLastError());
2600
2601 ok(!(GetMenuState(hPopupMenu, 1, MF_BYPOSITION) & MF_HILITE),
2602 "HiliteMenuItem: Item 2 is hilited\n");
2603
2604 /* hilite a menu item (by position) */
2605
2606 SetLastError(0xdeadbeef);
2607 ok(HiliteMenuItem(hWnd, hPopupMenu, 1, MF_HILITE | MF_BYPOSITION),
2608 "HiliteMenuItem: call should not have failed.\n");
2609 ok(GetLastError() == 0xdeadbeef,
2610 "HiliteMenuItem: expected error 0xdeadbeef, got: %d\n", GetLastError());
2611
2612 todo_wine
2613 {
2614 ok(GetMenuState(hPopupMenu, 1, MF_BYPOSITION) & MF_HILITE,
2615 "HiliteMenuItem: Item 2 is not hilited\n");
2616 }
2617
2618 /* unhilite a menu item (by position) */
2619
2620 SetLastError(0xdeadbeef);
2621 ok(HiliteMenuItem(hWnd, hPopupMenu, 1, MF_UNHILITE | MF_BYPOSITION),
2622 "HiliteMenuItem: call should not have failed.\n");
2623 ok(GetLastError() == 0xdeadbeef,
2624 "HiliteMenuItem: expected error 0xdeadbeef, got: %d\n", GetLastError());
2625
2626 ok(!(GetMenuState(hPopupMenu, 1, MF_BYPOSITION) & MF_HILITE),
2627 "HiliteMenuItem: Item 2 is hilited\n");
2628
2629 /* hilite a menu item (by command) */
2630
2631 SetLastError(0xdeadbeef);
2632 ok(HiliteMenuItem(hWnd, hPopupMenu, 103, MF_HILITE | MF_BYCOMMAND),
2633 "HiliteMenuItem: call should not have failed.\n");
2634 ok(GetLastError() == 0xdeadbeef,
2635 "HiliteMenuItem: expected error 0xdeadbeef, got: %d\n", GetLastError());
2636
2637 todo_wine
2638 {
2639 ok(GetMenuState(hPopupMenu, 2, MF_BYPOSITION) & MF_HILITE,
2640 "HiliteMenuItem: Item 3 is not hilited\n");
2641 }
2642
2643 /* unhilite a menu item (by command) */
2644
2645 SetLastError(0xdeadbeef);
2646 ok(HiliteMenuItem(hWnd, hPopupMenu, 103, MF_UNHILITE | MF_BYCOMMAND),
2647 "HiliteMenuItem: call should not have failed.\n");
2648 ok(GetLastError() == 0xdeadbeef,
2649 "HiliteMenuItem: expected error 0xdeadbeef, got: %d\n", GetLastError());
2650
2651 ok(!(GetMenuState(hPopupMenu, 2, MF_BYPOSITION) & MF_HILITE),
2652 "HiliteMenuItem: Item 3 is hilited\n");
2653
2655}
WORD ATOM
Definition: dimm.idl:113
static LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: menu.c:2357
HBRUSH hbrBackground
Definition: winuser.h:3173
HICON hIcon
Definition: winuser.h:3171
HINSTANCE hInstance
Definition: winuser.h:3170
HCURSOR hCursor
Definition: winuser.h:3172
int cbWndExtra
Definition: winuser.h:3169
UINT style
Definition: winuser.h:3166
LPCSTR lpszMenuName
Definition: winuser.h:3174
LPCSTR lpszClassName
Definition: winuser.h:3175
WNDPROC lpfnWndProc
Definition: winuser.h:3167
int cbClsExtra
Definition: winuser.h:3168
#define CS_VREDRAW
Definition: winuser.h:658
#define MF_UNHILITE
Definition: winuser.h:206
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4318
#define CS_HREDRAW
Definition: winuser.h:653
BOOL WINAPI HiliteMenuItem(_In_ HWND, _In_ HMENU, _In_ UINT, _In_ UINT)
#define IDI_APPLICATION
Definition: winuser.h:704
HICON WINAPI LoadIconA(_In_opt_ HINSTANCE hInstance, _In_ LPCSTR lpIconName)
Definition: cursoricon.c:2112

Referenced by START_TEST().

◆ test_menu_input()

static void test_menu_input ( void  )
static

Definition at line 2429 of file menu.c.

2429 {
2430 MSG msg;
2431 WNDCLASSA wclass;
2434 DWORD tid;
2435 ATOM aclass;
2436 POINT orig_pos;
2437
2438 wclass.lpszClassName = "MenuTestClass";
2439 wclass.style = CS_HREDRAW | CS_VREDRAW;
2440 wclass.lpfnWndProc = WndProc;
2441 wclass.hInstance = hInstance;
2442 wclass.hIcon = LoadIconA( 0, (LPCSTR)IDI_APPLICATION );
2443 wclass.hCursor = LoadCursorA( 0, (LPCSTR)IDC_ARROW );
2444 wclass.hbrBackground = (HBRUSH)( COLOR_WINDOW + 1 );
2445 wclass.lpszMenuName = 0;
2446 wclass.cbClsExtra = 0;
2447 wclass.cbWndExtra = 0;
2448 aclass = RegisterClassA( &wclass );
2449 ok (aclass, "MenuTest class not created\n");
2450 if (!aclass) return;
2451 hWnd = CreateWindowA( wclass.lpszClassName, "MenuTest",
2453 400, 200, NULL, NULL, hInstance, NULL);
2454 ok (hWnd != NULL, "MenuTest window not created\n");
2455 if (!hWnd) return;
2456 /* fixed menus */
2457 hMenus[3] = CreatePopupMenu();
2458 AppendMenuA(hMenus[3], MF_STRING, 0, "&Enabled");
2459 AppendMenuA(hMenus[3], MF_STRING|MF_DISABLED, 0, "&Disabled");
2460
2461 hMenus[2] = CreatePopupMenu();
2462 AppendMenuA(hMenus[2], MF_STRING|MF_POPUP, (UINT_PTR) hMenus[3], "&Popup");
2463 AppendMenuA(hMenus[2], MF_STRING, 0, "&Enabled");
2464 AppendMenuA(hMenus[2], MF_STRING|MF_DISABLED, 0, "&Disabled");
2465
2466 hMenus[1] = CreateMenu();
2467 AppendMenuA(hMenus[1], MF_STRING|MF_POPUP, (UINT_PTR) hMenus[2], "&Menu");
2468 AppendMenuA(hMenus[1], MF_STRING, 0, "&Enabled");
2469 AppendMenuA(hMenus[1], MF_STRING|MF_DISABLED, 0, "&Disabled");
2470
2471 SetMenu(hWnd, hMenus[1]);
2474
2475 GetCursorPos(&orig_pos);
2476
2478 while(1)
2479 {
2481 break;
2482 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
2483 }
2484 SetCursorPos(orig_pos.x, orig_pos.y);
2486}
HINSTANCE hInstance
Definition: charmap.c:19
#define WAIT_TIMEOUT
Definition: dderror.h:14
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137
static TfClientId tid
static DWORD WINAPI test_menu_input_thread(LPVOID lpParameter)
Definition: menu.c:2298
HANDLE hThread
Definition: wizard.c:28
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2722
BOOL WINAPI SetCursorPos(_In_ int, _In_ int)
Definition: cursoricon.c:2714
BOOL WINAPI UpdateWindow(_In_ HWND)
#define SW_SHOW
Definition: winuser.h:778
#define MF_DISABLED
Definition: winuser.h:130

Referenced by START_TEST().

◆ test_menu_input_thread()

static DWORD WINAPI test_menu_input_thread ( LPVOID  lpParameter)
static

Definition at line 2298 of file menu.c.

2299{
2300 int i, j;
2301 HANDLE hWnd = lpParameter;
2302
2303 Sleep(500);
2304 /* mixed keyboard/mouse test */
2305 for (i = 0; menu_tests[i].type != -1; i++)
2306 {
2307 BOOL ret = TRUE;
2308 int elapsed;
2309
2310 got_input = i && menu_tests[i-1].bMenuVisible;
2311
2313 for (j = 0; menu_tests[i].wVk[j] != 0; j++)
2314 send_key(menu_tests[i].wVk[j]);
2315 else
2316 for (j = 0; menu_tests[i].menu_item_pairs[j].uMenu != 0; j++)
2317 {
2318 /* Maybe clicking too fast before menu is initialized. Sleep 100 ms and retry */
2319 elapsed = 0;
2320 while (!(ret = click_menu(hWnd, &menu_tests[i].menu_item_pairs[j])))
2321 {
2322 if (elapsed > 1000) break;
2323 elapsed += 100;
2324 Sleep(100);
2325 }
2326 }
2327
2328 if (!ret)
2329 {
2330 skip( "test %u: failed to send input\n", i );
2332 return 0;
2333 }
2334
2335 elapsed = 0;
2337 {
2338 if (elapsed > 200)
2339 break;
2340 elapsed += 20;
2341 Sleep(20);
2342 }
2343
2344 if (!got_input)
2345 {
2346 skip( "test %u: didn't receive input\n", i );
2348 return 0;
2349 }
2350
2351 todo_wine_if (menu_tests[i]._todo_wine)
2352 ok(menu_tests[i].bMenuVisible == bMenuVisible, "test %d\n", i);
2353 }
2354 return 0;
2355}
#define skip(...)
Definition: atltest.h:64
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define todo_wine_if(is_todo)
Definition: custom.c:86
static BOOL got_input
Definition: menu.c:69
static BOOL bMenuVisible
Definition: menu.c:67
static BOOL click_menu(HANDLE hWnd, struct menu_item_pair_s *mi)
Definition: menu.c:2269
static struct menu_mouse_tests_s menu_tests[]
static void send_key(WORD wVk)
Definition: menu.c:2259
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790

Referenced by test_menu_input().

◆ test_menu_iteminfo()

static void test_menu_iteminfo ( void  )
static

Definition at line 1393 of file menu.c.

1394{
1395 BOOL ansi = TRUE;
1396 char txtA[]="wine";
1397 char initA[]="XYZ";
1398 char emptyA[]="";
1399 WCHAR txtW[]={'W','i','n','e',0};
1400 WCHAR initW[]={'X','Y','Z',0};
1401 WCHAR emptyW[]={0};
1402 void *txt, *init, *empty, *string;
1403 HBITMAP hbm = CreateBitmap(1,1,1,1,NULL);
1404 char stringA[0x80];
1405 HMENU hmenu, submenu;
1406 HBITMAP dummy_hbm = (HBITMAP)(ULONG_PTR)0xdeadbeef;
1407
1408 do {
1409 if( ansi) {txt=txtA;init=initA;empty=emptyA;string=stringA;}
1410 else {txt=txtW;init=initW;empty=emptyW;string=stringA;}
1411 trace( "%s string %p hbm %p txt %p\n", ansi ? "ANSI tes