ReactOS  0.4.13-dev-651-g5dbc677
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 _WIN32_WINNT   0x0501
 
#define OEMRESOURCE   /* For OBM_MNARROW */
 
#define GET_PROC(func)
 
#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), sizeof(a)/sizeof((a)[0]))
 
#define create_menuitem(a)   create_menuitem_from_data((a), sizeof(a)/sizeof((a)[0]))
 
#define compare_menu(h, a)   compare_menu_data((h), (a), sizeof(a)/sizeof((a)[0]))
 
#define NR_MENUS   100
 

Functions

static BOOL (WINAPI *pGetMenuInfo)(HMENU
 
static UINT (WINAPI *pSendInput)(UINT
 
static void init_function_pointers (void)
 
static BOOL correct_behavior (void)
 
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_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 LPCMENUINFO
 
static LONG
 
static PMENUBARINFO
 
static INPUT size_t
 
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

◆ _WIN32_WINNT

#define _WIN32_WINNT   0x0501

Definition at line 23 of file menu.c.

◆ compare_menu

#define compare_menu (   h,
  a 
)    compare_menu_data((h), (a), sizeof(a)/sizeof((a)[0]))

◆ create_menu

#define create_menu (   a)    create_menu_from_data((a), sizeof(a)/sizeof((a)[0]))

◆ create_menuitem

#define create_menuitem (   a)    create_menuitem_from_data((a), sizeof(a)/sizeof((a)[0]))

◆ ER

#define ER   0

Definition at line 1425 of file menu.c.

◆ GET_PROC

#define GET_PROC (   func)
Value:
p ## func = (void*)GetProcAddress(hdll, #func); \
if(!p ## func) \
trace("GetProcAddress(%s) failed\n", #func);
GLenum func
Definition: glext.h:6028
static PVOID hdll
Definition: shimdbg.c:126
#define GetProcAddress(x, y)
Definition: compat.h:410
GLfloat GLfloat p
Definition: glext.h:8902

◆ MOD_NRMENUS

#define MOD_NRMENUS   8

Definition at line 126 of file menu.c.

◆ MOD_SIZE

#define MOD_SIZE   10

Definition at line 125 of file menu.c.

◆ NR_MENUS

#define NR_MENUS   100

◆ OEMRESOURCE

#define OEMRESOURCE   /* For OBM_MNARROW */

Definition at line 31 of file menu.c.

◆ OK

#define OK   1

Definition at line 1424 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 1410 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 )
#define f3(x, y, z)
Definition: sha1.c:32
static HMENU hmenu
Definition: win.c:66
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:1283

Definition at line 1404 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 )
static HMENU hmenu
Definition: win.c:66
static int init
Definition: wintirpc.c:33
HMENU WINAPI CreateMenu(VOID)
Definition: menu.c:837
static WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: menu.c:1246
#define f1(x, y, z)
Definition: sha1.c:30
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388

Definition at line 1396 of file menu.c.

◆ TMII_MODM

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

Definition at line 1416 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 1420 of file menu.c.

Function Documentation

◆ BOOL()

static BOOL ( WINAPI pGetMenuInfo)
static

◆ 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 1283 of file menu.c.

1287 {
1289  BOOL ret;
1290  WCHAR buffer[80];
1291 
1292  SetLastError( 0xdeadbeef );
1293  memset( &info, 0xcc, sizeof(info) );
1294  info.cbSize = sizeof(info);
1295  info.fMask = mask;
1296  info.dwTypeData = type_data;
1297  info.cch = in_len;
1298 
1299  ret = ansi ? GetMenuItemInfoA( hmenu, 0, TRUE, &info ) :
1301  if (!expect)
1302  {
1303  ok_(__FILE__, line)( !ret, "GetMenuItemInfo should have failed.\n" );
1304  return;
1305  }
1306  ok_(__FILE__, line)( ret, "GetMenuItemInfo failed, err %u\n", GetLastError());
1307  if (mask & MIIM_TYPE)
1308  ok_(__FILE__, line)( info.fType == type || info.fType == LOWORD(type),
1309  "wrong type %x/%x\n", info.fType, type );
1310  if (mask & MIIM_STATE)
1311  ok_(__FILE__, line)( info.fState == state || info.fState == LOWORD(state),
1312  "wrong state %x/%x\n", info.fState, state );
1313  if (mask & MIIM_ID)
1314  ok_(__FILE__, line)( info.wID == id || info.wID == LOWORD(id),
1315  "wrong id %x/%x\n", info.wID, id );
1316  if (mask & MIIM_SUBMENU)
1317  ok_(__FILE__, line)( info.hSubMenu == submenu || (ULONG_PTR)info.hSubMenu == LOWORD(submenu),
1318  "wrong submenu %p/%p\n", info.hSubMenu, submenu );
1319  if (mask & MIIM_CHECKMARKS)
1320  {
1321  ok_(__FILE__, line)( info.hbmpChecked == checked || (ULONG_PTR)info.hbmpChecked == LOWORD(checked),
1322  "wrong bmpchecked %p/%p\n", info.hbmpChecked, checked );
1323  ok_(__FILE__, line)( info.hbmpUnchecked == unchecked || (ULONG_PTR)info.hbmpUnchecked == LOWORD(unchecked),
1324  "wrong bmpunchecked %p/%p\n", info.hbmpUnchecked, unchecked );
1325  }
1326  if (mask & MIIM_DATA)
1327  ok_(__FILE__, line)( info.dwItemData == data || info.dwItemData == LOWORD(data),
1328  "wrong item data %lx/%lx\n", info.dwItemData, data );
1329  if (mask & MIIM_BITMAP)
1330  ok_(__FILE__, line)( info.hbmpItem == item || (ULONG_PTR)info.hbmpItem == LOWORD(item),
1331  "wrong bmpitem %p/%p\n", info.hbmpItem, item );
1332  ok_(__FILE__, line)( info.dwTypeData == type_data || (ULONG_PTR)info.dwTypeData == LOWORD(type_data),
1333  "wrong type data %p/%p\n", info.dwTypeData, type_data );
1334  ok_(__FILE__, line)( info.cch == out_len ||
1335  broken(! ansi && info.cch == 2 * out_len) /* East-Asian */,
1336  "wrong len %x/%x\n", info.cch, out_len );
1337  if (expname)
1338  {
1339  if(ansi)
1340  ok_(__FILE__, line)( !strncmp( expname, info.dwTypeData, out_len ),
1341  "menu item name differed from '%s' '%s'\n", expname, info.dwTypeData );
1342  else
1343  ok_(__FILE__, line)( !strncmpW( (WCHAR *)expname, (WCHAR *)info.dwTypeData, out_len ),
1344  "menu item name wrong\n" );
1345 
1346  SetLastError( 0xdeadbeef );
1347  ret = ansi ? GetMenuStringA( hmenu, 0, (char *)buffer, 80, MF_BYPOSITION ) :
1349  if (expstring)
1350  ok_(__FILE__, line)( ret, "GetMenuString failed, err %u\n", GetLastError());
1351  else
1352  ok_(__FILE__, line)( !ret, "GetMenuString should have failed\n" );
1353  }
1354 }
#define TRUE
Definition: types.h:120
static HMENU hmenu
Definition: win.c:66
#define ok_(x1, x2)
int WINAPI GetMenuStringA(HMENU hMenu, UINT uIDItem, LPSTR lpString, int nMaxCount, UINT uFlag)
Definition: menu.c:1075
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
GLuint buffer
Definition: glext.h:5915
int WINAPI GetMenuStringW(HMENU hMenu, UINT uIDItem, LPWSTR lpString, int nMaxCount, UINT uFlag)
Definition: menu.c:1110
#define MIIM_BITMAP
Definition: winuser.h:723
struct _test_info info[]
Definition: SetCursorPos.c:19
#define MIIM_SUBMENU
Definition: winuser.h:718
GLenum GLint GLuint mask
Definition: glext.h:6028
#define MIIM_STATE
Definition: winuser.h:716
unsigned int BOOL
Definition: ntddk_ex.h:94
#define MF_BYPOSITION
Definition: winuser.h:203
BOOL WINAPI GetMenuItemInfoW(HMENU hMenu, UINT Item, BOOL bypos, LPMENUITEMINFOW lpmii)
Definition: menu.c:1020
Definition: parser.c:48
#define MIIM_ID
Definition: winuser.h:717
__wchar_t WCHAR
Definition: xmlstorage.h:180
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
#define SetLastError(x)
Definition: compat.h:409
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
int ret
#define MIIM_TYPE
Definition: winuser.h:720
static int state
Definition: maze.c:121
BOOL WINAPI GetMenuItemInfoA(HMENU hmenu, UINT item, BOOL bypos, LPMENUITEMINFOA lpmii)
Definition: menu.c:989
#define MIIM_CHECKMARKS
Definition: winuser.h:719
#define broken(x)
Definition: _sntprintf.h:21
static ATOM item
Definition: dde.c:856
#define expect(expected, got)
Definition: combo.c:36
GLenum GLuint id
Definition: glext.h:5579
#define ULONG_PTR
Definition: config.h:101
#define MIIM_DATA
Definition: winuser.h:721
#define memset(x, y, z)
Definition: compat.h:39
#define LOWORD(l)
Definition: pedump.c:82
static int strncmpW(const WCHAR *str1, const WCHAR *str2, int n)
Definition: menu.c:1239

◆ check_menu_items()

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

Definition at line 2693 of file menu.c.

2695 {
2696  INT i, count;
2697 
2699  ok (count != -1, "GetMenuItemCount returned -1\n");
2700 
2701  for (i = 0; i < count; i++)
2702  {
2703  BOOL ret;
2704  MENUITEMINFOA mii;
2705 
2706  memset(&mii, 0, sizeof(mii));
2707  mii.cbSize = sizeof(mii);
2709  ret = GetMenuItemInfoA(hmenu, i, TRUE, &mii);
2710  ok(ret, "GetMenuItemInfo(%u) failed\n", i);
2711 
2712  if (winetest_debug > 1)
2713  trace("item #%u: fType %04x, fState %04x, wID %u, hSubMenu %p\n",
2714  i, mii.fType, mii.fState, mii.wID, mii.hSubMenu);
2715 
2716  if (mii.hSubMenu)
2717  {
2718  ok(mii.wID == (UINT_PTR)mii.hSubMenu, "id %u: wID %x should be equal to hSubMenu %p\n",
2719  checked_cmd, mii.wID, mii.hSubMenu);
2720  if (!GetMenuItemCount(mii.hSubMenu))
2721  {
2722  ok(mii.fType == checked_type, "id %u: expected fType %04x, got %04x\n", checked_cmd, checked_type, mii.fType);
2723  ok(mii.fState == checked_state, "id %u: expected fState %04x, got %04x\n", checked_cmd, checked_state, mii.fState);
2724  }
2725  check_menu_items(mii.hSubMenu, checked_cmd, checked_type, checked_state);
2726  }
2727  else
2728  {
2729  if (mii.wID == checked_cmd)
2730  {
2731  ok(mii.fType == checked_type, "id %u: expected fType %04x, got %04x\n", checked_cmd, checked_type, mii.fType);
2732  ok(mii.fState == checked_state, "id %u: expected fState %04x, got %04x\n", checked_cmd, checked_state, mii.fState);
2733  ok(mii.wID != 0, "id %u: not expected wID 0\n", checked_cmd);
2734  }
2735  else
2736  {
2737  ok(mii.fType != MFT_RADIOCHECK, "id %u: not expected fType MFT_RADIOCHECK on cmd %u\n", checked_cmd, mii.wID);
2738 
2739  if (mii.fType == MFT_SEPARATOR)
2740  {
2741  ok(mii.fState == MFS_GRAYED, "id %u: expected fState MFS_GRAYED, got %04x\n", checked_cmd, mii.fState);
2742  ok(mii.wID == 0, "id %u: expected wID 0, got %u\n", checked_cmd, mii.wID);
2743  }
2744  else
2745  {
2746  ok(mii.fState == 0, "id %u: expected fState 0, got %04x\n", checked_cmd, mii.fState);
2747  ok(mii.wID != 0, "id %u: not expected wID 0\n", checked_cmd);
2748  }
2749  }
2750  }
2751  }
2752 }
#define trace(...)
Definition: kmt_test.h:217
int WINAPI GetMenuItemCount(HMENU hmenu)
Definition: menu.c:964
#define MIIM_FTYPE
Definition: winuser.h:724
#define TRUE
Definition: types.h:120
static HMENU hmenu
Definition: win.c:66
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define MFT_RADIOCHECK
Definition: winuser.h:737
int winetest_debug
int32_t INT
Definition: typedefs.h:56
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
#define MIIM_SUBMENU
Definition: winuser.h:718
#define MIIM_STATE
Definition: winuser.h:716
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ok(value,...)
static void check_menu_items(HMENU hmenu, UINT checked_cmd, UINT checked_type, UINT checked_state)
Definition: menu.c:2693
#define MIIM_ID
Definition: winuser.h:717
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
#define MFT_SEPARATOR
Definition: winuser.h:739
int ret
#define MFS_GRAYED
Definition: winuser.h:746
BOOL WINAPI GetMenuItemInfoA(HMENU hmenu, UINT item, BOOL bypos, LPMENUITEMINFOA lpmii)
Definition: menu.c:989
#define memset(x, y, z)
Definition: compat.h:39

Referenced by 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 2754 of file menu.c.

2755 {
2756  BOOL ret;
2757  MENUITEMINFOA mii;
2758 
2759  memset(&mii, 0, sizeof(mii));
2760  mii.cbSize = sizeof(mii);
2761  mii.fMask = MIIM_FTYPE | MIIM_STATE;
2762  ret = SetMenuItemInfoA(hmenu, id, (flags & MF_BYPOSITION) != 0, &mii);
2763  ok(ret, "SetMenuItemInfo(%u) failed\n", id);
2764 }
#define MIIM_FTYPE
Definition: winuser.h:724
static HMENU hmenu
Definition: win.c:66
#define MIIM_STATE
Definition: winuser.h:716
unsigned int BOOL
Definition: ntddk_ex.h:94
#define MF_BYPOSITION
Definition: winuser.h:203
#define ok(value,...)
GLbitfield flags
Definition: glext.h:7161
int ret
BOOL WINAPI SetMenuItemInfoA(HMENU hmenu, UINT item, BOOL bypos, LPCMENUITEMINFOA lpmii)
Definition: menu.c:1551
#define memset(x, y, z)
Definition: compat.h:39

Referenced by test_CheckMenuRadioItem().

◆ click_menu()

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

Definition at line 2304 of file menu.c.

2305 {
2306  HMENU hMenu = hMenus[mi->uMenu];
2307  TEST_INPUT i[3];
2308  MSG msg;
2309  RECT r;
2310  int screen_w = GetSystemMetrics(SM_CXSCREEN);
2311  int screen_h = GetSystemMetrics(SM_CYSCREEN);
2312  BOOL ret = GetMenuItemRect(mi->uMenu > 2 ? NULL : hWnd, hMenu, mi->uItem, &r);
2313  if(!ret) return FALSE;
2314 
2315  memset(i, 0, sizeof(i));
2316  i[0].type = i[1].type = i[2].type = INPUT_MOUSE;
2317  i[0].u.mi.dx = i[1].u.mi.dx = i[2].u.mi.dx
2318  = ((r.left + 5) * 65535) / screen_w;
2319  i[0].u.mi.dy = i[1].u.mi.dy = i[2].u.mi.dy
2320  = ((r.top + 5) * 65535) / screen_h;
2321  i[0].u.mi.dwFlags = i[1].u.mi.dwFlags = i[2].u.mi.dwFlags
2323  i[0].u.mi.dwFlags |= MOUSEEVENTF_MOVE;
2324  i[1].u.mi.dwFlags |= MOUSEEVENTF_LEFTDOWN;
2325  i[2].u.mi.dwFlags |= MOUSEEVENTF_LEFTUP;
2326  ret = pSendInput(3, (INPUT *) i, sizeof(INPUT));
2327 
2328  /* hack to prevent mouse message buildup in Wine */
2329  while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg );
2330  return ret;
2331 }
#define MOUSEEVENTF_LEFTDOWN
Definition: winuser.h:1170
LRESULT WINAPI DispatchMessageA(_In_ const MSG *)
#define MOUSEEVENTF_ABSOLUTE
Definition: winuser.h:1180
static HMENU hMenus[4]
Definition: menu.c:123
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
HWND hWnd
Definition: settings.c:17
static MONITORINFO mi
Definition: win.c:7331
BOOL WINAPI PeekMessageA(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
#define SM_CXSCREEN
Definition: winuser.h:949
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
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define INPUT_MOUSE
Definition: winable.h:9
#define SM_CYSCREEN
Definition: winuser.h:950
int WINAPI GetSystemMetrics(_In_ int)
int ret
#define MOUSEEVENTF_LEFTUP
Definition: winuser.h:1171
#define MOUSEEVENTF_MOVE
Definition: winuser.h:1169
BOOL WINAPI GetMenuItemRect(_In_opt_ HWND, _In_ HMENU, _In_ UINT, _Out_ LPRECT)
#define msg(x)
Definition: auth_time.c:54
#define PM_REMOVE
Definition: winuser.h:1182
#define memset(x, y, z)
Definition: compat.h:39
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60

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 2963 of file menu.c.

2964 {
2965  INT count, i;
2966  BOOL ret;
2967 
2969  ok(count == item_count, "expected %d, got %d menu items\n", count, item_count);
2970 
2971  for (i = 0; i < count; i++)
2972  {
2973  char buf[20];
2974  MENUITEMINFOA mii;
2975 
2976  memset(&mii, 0, sizeof(mii));
2977  mii.cbSize = sizeof(mii);
2978  mii.dwTypeData = buf;
2979  mii.cch = sizeof(buf);
2981  ret = GetMenuItemInfoA(hmenu, i, TRUE, &mii);
2982  ok(ret, "GetMenuItemInfo(%u) failed\n", i);
2983 
2984  if (winetest_debug > 1)
2985  trace("item #%u: fType %04x, fState %04x, wID %04x, hbmp %p\n",
2986  i, mii.fType, mii.fState, mii.wID, mii.hbmpItem);
2987 
2988  ok(mii.fType == item[i].type,
2989  "%u: expected fType %04x, got %04x\n", i, item[i].type, mii.fType);
2990  ok(mii.wID == item[i].id,
2991  "%u: expected wID %04x, got %04x\n", i, item[i].id, mii.wID);
2992  if (mii.hbmpItem || !item[i].str)
2993  /* For some reason Windows sets high word to not 0 for
2994  * not "magic" ids.
2995  */
2996  ok(LOWORD(mii.hbmpItem) == LOWORD(item[i].str),
2997  "%u: expected hbmpItem %p, got %p\n", i, item[i].str, mii.hbmpItem);
2998  else
2999  {
3000  ok(mii.cch == strlen(item[i].str),
3001  "%u: expected cch %u, got %u\n", i, (UINT)strlen(item[i].str), mii.cch);
3002  ok(!strcmp(mii.dwTypeData, item[i].str),
3003  "%u: expected dwTypeData %s, got %s\n", i, item[i].str, (LPCSTR)mii.dwTypeData);
3004  }
3005  }
3006 }
#define trace(...)
Definition: kmt_test.h:217
int WINAPI GetMenuItemCount(HMENU hmenu)
Definition: menu.c:964
#define MIIM_FTYPE
Definition: winuser.h:724
#define TRUE
Definition: types.h:120
static HMENU hmenu
Definition: win.c:66
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLuint GLuint GLsizei count
Definition: gl.h:1545
int winetest_debug
int32_t INT
Definition: typedefs.h:56
#define MIIM_BITMAP
Definition: winuser.h:723
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
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ok(value,...)
const WCHAR * str
const char * LPCSTR
Definition: xmlstorage.h:183
#define MIIM_ID
Definition: winuser.h:717
int ret
BOOL WINAPI GetMenuItemInfoA(HMENU hmenu, UINT item, BOOL bypos, LPMENUITEMINFOA lpmii)
Definition: menu.c:989
#define MIIM_STRING
Definition: winuser.h:722
static ATOM item
Definition: dde.c:856
unsigned int UINT
Definition: ndis.h:50
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define memset(x, y, z)
Definition: compat.h:39
LPSTR dwTypeData
Definition: winuser.h:3225
#define LOWORD(l)
Definition: pedump.c:82

◆ correct_behavior()

static BOOL correct_behavior ( void  )
static

Definition at line 64 of file menu.c.

65 {
66  HMENU hmenu;
68  BOOL rc;
69 
70  hmenu = CreateMenu();
71 
72  memset(&info, 0, sizeof(MENUITEMINFOA));
73  info.cbSize= sizeof(MENUITEMINFOA);
74  SetLastError(0xdeadbeef);
75  rc = GetMenuItemInfoA(hmenu, 0, TRUE, &info);
76  /* Win9x : 0xdeadbeef
77  * NT4 : ERROR_INVALID_PARAMETER
78  * >= W2K : ERROR_MENU_ITEM_NOT_FOUND
79  */
81  {
82  win_skip("NT4 and below can't handle a bigger MENUITEMINFO struct\n");
84  return FALSE;
85  }
86 
88  return TRUE;
89 }
#define TRUE
Definition: types.h:120
static HMENU hmenu
Definition: win.c:66
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
struct _test_info info[]
Definition: SetCursorPos.c:19
HMENU WINAPI CreateMenu(VOID)
Definition: menu.c:837
unsigned int BOOL
Definition: ntddk_ex.h:94
#define SetLastError(x)
Definition: compat.h:409
#define ERROR_MENU_ITEM_NOT_FOUND
Definition: winerror.h:937
BOOL WINAPI GetMenuItemInfoA(HMENU hmenu, UINT item, BOOL bypos, LPMENUITEMINFOA lpmii)
Definition: menu.c:989
BOOL WINAPI DestroyMenu(_In_ HMENU)
struct tagMENUITEMINFOA MENUITEMINFOA
#define memset(x, y, z)
Definition: compat.h:39
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ create_menu_from_data()

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

Definition at line 2902 of file menu.c.

2903 {
2904  HMENU hmenu;
2905  INT i;
2906  BOOL ret;
2907 
2908  hmenu = CreateMenu();
2909  assert(hmenu != 0);
2910 
2911  for (i = 0; i < item_count; i++)
2912  {
2913  SetLastError(0xdeadbeef);
2914  ret = AppendMenuA(hmenu, item[i].type, item[i].id, item[i].str);
2915  ok(ret, "%d: AppendMenu(%04x, %04x, %p) error %u\n",
2916  i, item[i].type, item[i].id, item[i].str, GetLastError());
2917  }
2918  return hmenu;
2919 }
static HMENU hmenu
Definition: win.c:66
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define assert(x)
Definition: debug.h:53
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
int32_t INT
Definition: typedefs.h:56
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
HMENU WINAPI CreateMenu(VOID)
Definition: menu.c:837
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ok(value,...)
const WCHAR * str
BOOL WINAPI AppendMenuA(HMENU hMenu, UINT uFlags, UINT_PTR uIDNewItem, LPCSTR lpNewItem)
Definition: menu.c:684
#define SetLastError(x)
Definition: compat.h:409
int ret
static ATOM item
Definition: dde.c:856
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60

◆ create_menuitem_from_data()

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

Definition at line 2924 of file menu.c.

2925 {
2926  HMENU hmenu;
2927  INT i;
2928  BOOL ret;
2929  MENUITEMINFOA mii = { sizeof( MENUITEMINFOA) };
2930 
2931  hmenu = CreateMenu();
2932  assert(hmenu != 0);
2933 
2934  for (i = 0; i < item_count; i++)
2935  {
2936  SetLastError(0xdeadbeef);
2937 
2938  mii.fMask = MIIM_FTYPE | MIIM_ID | MIIM_STATE;
2939  mii.fType = 0;
2940  if( item[i].type & MFT_BITMAP)
2941  {
2942  mii.fMask |= MIIM_BITMAP;
2943  mii.hbmpItem = (HBITMAP)item[i].str;
2944  }
2945  else if( item[i].type & MFT_SEPARATOR)
2946  mii.fType = MFT_SEPARATOR;
2947  else
2948  {
2949  mii.fMask |= MIIM_STRING;
2950  mii.dwTypeData = (LPSTR)item[i].str;
2951  mii.cch = strlen( item[i].str);
2952  }
2953  mii.fState = 0;
2954  if( item[i].type & MF_HELP) mii.fType |= MF_HELP;
2955  mii.wID = item[i].id;
2956  ret = InsertMenuItemA( hmenu, -1, TRUE, &mii);
2957  ok(ret, "%d: InsertMenuItem(%04x, %04x, %p) error %u\n",
2958  i, item[i].type, item[i].id, item[i].str, GetLastError());
2959  }
2960  return hmenu;
2961 }
#define MIIM_FTYPE
Definition: winuser.h:724
#define TRUE
Definition: types.h:120
static HMENU hmenu
Definition: win.c:66
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define assert(x)
Definition: debug.h:53
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define MFT_BITMAP
Definition: winuser.h:733
char * LPSTR
Definition: xmlstorage.h:182
int32_t INT
Definition: typedefs.h:56
#define MIIM_BITMAP
Definition: winuser.h:723
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
HMENU WINAPI CreateMenu(VOID)
Definition: menu.c:837
#define MIIM_STATE
Definition: winuser.h:716
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ok(value,...)
const WCHAR * str
#define MIIM_ID
Definition: winuser.h:717
#define SetLastError(x)
Definition: compat.h:409
#define MFT_SEPARATOR
Definition: winuser.h:739
int ret
#define MIIM_STRING
Definition: winuser.h:722
static ATOM item
Definition: dde.c:856
BOOL WINAPI InsertMenuItemA(HMENU hMenu, UINT uItem, BOOL fByPosition, LPCMENUITEMINFOA lpmii)
Definition: menu.c:1219
struct tagMENUITEMINFOA MENUITEMINFOA
static HBITMAP
Definition: button.c:44
#define MF_HELP
Definition: winuser.h:142
LPSTR dwTypeData
Definition: winuser.h:3225
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60

◆ get_bad_hmenu()

static HMENU get_bad_hmenu ( UINT_PTR  id)
static

Definition at line 3857 of file menu.c.

3858 {
3859  while (IsMenu( (HMENU)id )) id++;
3860  return (HMENU)id;
3861 }
BOOL WINAPI IsMenu(HMENU Menu)
Definition: menu.c:1331
GLenum GLuint id
Definition: glext.h:5579
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60

Referenced by test_AppendMenu().

◆ init_function_pointers()

static void init_function_pointers ( void  )
static

Definition at line 47 of file menu.c.

48 {
49  HMODULE hdll = GetModuleHandleA("user32");
50 
51 #define GET_PROC(func) \
52  p ## func = (void*)GetProcAddress(hdll, #func); \
53  if(!p ## func) \
54  trace("GetProcAddress(%s) failed\n", #func);
55 
60 
61 #undef GET_PROC
62 }
#define GET_PROC(func)
BOOL WINAPI GetMenuBarInfo(_In_ HWND, _In_ LONG, _In_ LONG, _Inout_ PMENUBARINFO)
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:819
BOOL WINAPI SetMenuInfo(HMENU hmenu, LPCMENUINFO lpcmi)
Definition: menu.c:1508
static PVOID hdll
Definition: shimdbg.c:126
BOOL WINAPI GetMenuInfo(HMENU hmenu, LPMENUINFO lpcmi)
Definition: menu.c:928
UINT WINAPI SendInput(UINT, LPINPUT, int)
Definition: ntwrapper.h:344

Referenced by START_TEST().

◆ 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 1253 of file menu.c.

1256 {
1258  BOOL ret;
1259 
1260  /* magic bitmap handle to test smaller cbSize */
1261  if (item == (HBITMAP)(ULONG_PTR)0xdeadbeef)
1262  info.cbSize = FIELD_OFFSET(MENUITEMINFOA,hbmpItem);
1263  else
1264  info.cbSize = sizeof(info);
1265  info.fMask = mask;
1266  info.fType = type;
1267  info.fState = state;
1268  info.wID = id;
1269  info.hSubMenu = submenu;
1270  info.hbmpChecked = checked;
1271  info.hbmpUnchecked = unchecked;
1272  info.dwItemData = data;
1273  info.dwTypeData = type_data;
1274  info.cch = len;
1275  info.hbmpItem = item;
1276  SetLastError( 0xdeadbeef );
1277  if (ansi) ret = InsertMenuItemA( hmenu, 0, TRUE, &info );
1278  else ret = InsertMenuItemW( hmenu, 0, TRUE, (MENUITEMINFOW*)&info );
1279  if (!expect) ok_(__FILE__, line)( !ret, "InsertMenuItem should have failed.\n" );
1280  else ok_(__FILE__, line)( ret, "InsertMenuItem failed, err %u\n", GetLastError());
1281 }
#define TRUE
Definition: types.h:120
static HMENU hmenu
Definition: win.c:66
#define ok_(x1, x2)
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
struct _test_info info[]
Definition: SetCursorPos.c:19
uint32_t ULONG_PTR
Definition: typedefs.h:63
GLenum GLint GLuint mask
Definition: glext.h:6028
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: parser.c:48
#define SetLastError(x)
Definition: compat.h:409
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
int ret
static int state
Definition: maze.c:121
GLenum GLsizei len
Definition: glext.h:6722
static ATOM item
Definition: dde.c:856
BOOL WINAPI InsertMenuItemA(HMENU hMenu, UINT uItem, BOOL fByPosition, LPCMENUITEMINFOA lpmii)
Definition: menu.c:1219
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
#define expect(expected, got)
Definition: combo.c:36
BOOL WINAPI InsertMenuItemW(HMENU hMenu, UINT uItem, BOOL fByPosition, LPCMENUITEMINFOW lpmii)
Definition: menu.c:1262
GLenum GLuint id
Definition: glext.h:5579
static HBITMAP
Definition: button.c:44

◆ menu_cancelmode_wnd_proc()

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

Definition at line 3506 of file menu.c.

3508 {
3509  switch (msg)
3510  {
3511  case WM_ENTERMENULOOP:
3512  g_got_enteridle = 0;
3513  return SendMessageA( g_hwndtosend, WM_CANCELMODE, 0, 0);
3514  case WM_ENTERIDLE:
3515  {
3516  if( g_got_enteridle++ == 0) {
3517  /* little hack to get another WM_ENTERIDLE message */
3518  PostMessageA( hwnd, WM_MOUSEMOVE, 0, 0);
3519  return SendMessageA( g_hwndtosend, WM_CANCELMODE, 0, 0);
3520  }
3521  EndMenu();
3522  return TRUE;
3523  }
3524  }
3525  return DefWindowProcA( hwnd, msg, wparam, lparam);
3526 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
BOOL WINAPI PostMessageA(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static HWND g_hwndtosend
Definition: menu.c:3505
#define WM_ENTERMENULOOP
Definition: winuser.h:1786
static UINT WPARAM LPARAM lparam
Definition: combo.c:716
static int g_got_enteridle
Definition: menu.c:3504
#define WM_ENTERIDLE
Definition: winuser.h:1731
#define WM_CANCELMODE
Definition: winuser.h:1617
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_MOUSEMOVE
Definition: winuser.h:1757
#define msg(x)
Definition: auth_time.c:54
BOOL WINAPI EndMenu(void)
static UINT WPARAM wparam
Definition: combo.c:716

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 91 of file menu.c.

92 {
93  switch (msg)
94  {
95  case WM_ENTERMENULOOP:
96  /* mark window as having entered menu loop */
98  /* exit menu modal loop
99  * ( A SendMessage does not work on NT3.51 here ) */
100  return PostMessageA(hwnd, WM_CANCELMODE, 0, 0);
101  }
102  return DefWindowProcA(hwnd, msg, wparam, lparam);
103 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
BOOL WINAPI PostMessageA(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_ENTERMENULOOP
Definition: winuser.h:1786
static UINT WPARAM LPARAM lparam
Definition: combo.c:716
#define GWLP_USERDATA
Definition: treelist.c:63
#define WM_CANCELMODE
Definition: winuser.h:1617
#define SetWindowLongPtrA
Definition: winuser.h:5246
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define msg(x)
Definition: auth_time.c:54
static UINT WPARAM wparam
Definition: combo.c:716

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 3757 of file menu.c.

3759 {
3760  HMENU hmenupopup;
3761  BOOL ret;
3762  switch (msg)
3763  {
3764  case WM_INITMENUPOPUP:
3766  hmenupopup = (HMENU) wparam;
3767  ret = AppendMenuA(hmenupopup, MF_STRING , 100, "item 1");
3768  ok(ret, "AppendMenu failed.\n");
3769  ret = AppendMenuA(hmenupopup, MF_STRING , 101, "item 2");
3770  ok(ret, "AppendMenu failed.\n");
3771  break;
3772  case WM_ENTERMENULOOP:
3774  break;
3775  case WM_INITMENU:
3776  gflag_initmenu++;
3777  break;
3778  case WM_ENTERIDLE:
3779  gflag_enteridle++;
3781  return TRUE;
3782  case WM_MENUSELECT:
3785  break;
3786  }
3787  return DefWindowProcA(hwnd, msg, wparam, lparam);
3788 }
static int gflag_enteridle
Definition: menu.c:148
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
BOOL WINAPI PostMessageA(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_INITMENUPOPUP
Definition: winuser.h:1728
#define MF_STRING
Definition: winuser.h:138
static int gflag_initmenu
Definition: menu.c:148
unsigned int BOOL
Definition: ntddk_ex.h:94
#define WM_ENTERMENULOOP
Definition: winuser.h:1786
static UINT WPARAM LPARAM lparam
Definition: combo.c:716
#define WM_MENUSELECT
Definition: winuser.h:1729
#define ok(value,...)
static int gflag_initmenupopup
Definition: menu.c:148
BOOL WINAPI AppendMenuA(HMENU hMenu, UINT uFlags, UINT_PTR uIDNewItem, LPCSTR lpNewItem)
Definition: menu.c:684
static LPARAM selectitem_lp
Definition: menu.c:153
static WPARAM selectitem_wp
Definition: menu.c:152
#define WM_ENTERIDLE
Definition: winuser.h:1731
int ret
#define WM_CANCELMODE
Definition: winuser.h:1617
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_INITMENU
Definition: winuser.h:1727
static int gflag_entermenuloop
Definition: menu.c:148
#define msg(x)
Definition: auth_time.c:54
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
static UINT WPARAM wparam
Definition: combo.c:716

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 156 of file menu.c.

158 {
159  static HMENU hmenupopup;
160  switch (msg)
161  {
162  case WM_INITMENUPOPUP:
164  hmenupopup = (HMENU) wparam;
165  break;
166  case WM_ENTERMENULOOP:
168  break;
169  case WM_INITMENU:
170  gflag_initmenu++;
171  break;
172  case WM_MEASUREITEM:
173  {
175  if (winetest_debug > 1)
176  trace("WM_MEASUREITEM received data %lx size %dx%d\n",
177  pmis->itemData, pmis->itemWidth, pmis->itemHeight);
178  ok( !wparam, "wrong wparam %lx\n", wparam );
179  ok( pmis->CtlType == ODT_MENU, "wrong type %x\n", pmis->CtlType );
180  MOD_odheight = pmis->itemHeight;
181  pmis->itemWidth = MODsizes[pmis->itemData].cx;
182  pmis->itemHeight = MODsizes[pmis->itemData].cy;
183  return TRUE;
184  }
185  case WM_DRAWITEM:
186  {
187  DRAWITEMSTRUCT * pdis;
188  TEXTMETRICA tm;
189  HPEN oldpen;
190  char chrs[]="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
191  SIZE sz;
192  int i;
193  pdis = (DRAWITEMSTRUCT *) lparam;
194  if (winetest_debug > 1) {
195  RECT rc;
196  GetMenuItemRect( hwnd, (HMENU)pdis->hwndItem, pdis->itemData ,&rc);
197  trace("WM_DRAWITEM received hwnd %p hmenu %p itemdata %ld item %d rc %s itemrc: %s\n",
198  hwnd, pdis->hwndItem, pdis->itemData, pdis->itemID,
200  oldpen=SelectObject( pdis->hDC, GetStockObject(
202  Rectangle( pdis->hDC, pdis->rcItem.left,pdis->rcItem.top,
203  pdis->rcItem.right,pdis->rcItem.bottom );
204  SelectObject( pdis->hDC, oldpen);
205  }
206  ok( !wparam, "wrong wparam %lx\n", wparam );
207  ok( pdis->CtlType == ODT_MENU, "wrong type %x\n", pdis->CtlType );
208  /* calculate widths of some menu texts */
209  if( ! MOD_txtsizes[0].size.cx)
210  for(i = 0; MOD_txtsizes[i].text; i++) {
211  char buf[100], *p;
212  RECT rc={0,0,0,0};
214  if( ( p = strchr( buf, '\t'))) {
215  *p = '\0';
216  DrawTextA( pdis->hDC, p + 1, -1, &rc,
218  MOD_txtsizes[i].sc_size.cx= rc.right - rc.left;
219  MOD_txtsizes[i].sc_size.cy= rc.bottom - rc.top;
220  }
221  DrawTextA( pdis->hDC, buf, -1, &rc,
223  MOD_txtsizes[i].size.cx= rc.right - rc.left;
224  MOD_txtsizes[i].size.cy= rc.bottom - rc.top;
225  }
226 
227  if( pdis->itemData > MOD_maxid) return TRUE;
228  /* store the rectangle */
229  MOD_rc[pdis->itemData] = pdis->rcItem;
230  /* calculate average character width */
231  GetTextExtentPointA( pdis->hDC, chrs, 52, &sz );
232  MOD_avec = (sz.cx + 26)/52;
233  GetTextMetricsA( pdis->hDC, &tm);
234  MOD_hic = tm.tmHeight;
236  return TRUE;
237  }
238  case WM_ENTERIDLE:
239  {
240  gflag_enteridle++;
241  ok( lparam || broken(!lparam), /* win9x, nt4 */
242  "Menu window handle is NULL!\n");
243  if( lparam) {
245  ok( hmenupopup == hmenu, "MN_GETHMENU returns %p expected %p\n",
246  hmenu, hmenupopup);
247  }
249  return TRUE;
250  }
251  case WM_MENUSELECT:
254  break;
255  }
256  return DefWindowProcA(hwnd, msg, wparam, lparam);
257 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
static int gflag_enteridle
Definition: menu.c:148
static BOOL MOD_GotDrawItemMsg
Definition: menu.c:147
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define trace(...)
Definition: kmt_test.h:217
#define TRUE
Definition: types.h:120
static SIZE MODsizes[MOD_NRMENUS]
Definition: menu.c:145
static HMENU hmenu
Definition: win.c:66
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
BOOL WINAPI PostMessageA(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_INITMENUPOPUP
Definition: winuser.h:1728
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI GetTextExtentPointA(_In_ HDC hdc, _In_reads_(c) LPCSTR lpString, _In_ int c, _Out_ LPSIZE lpsz)
#define WHITE_PEN
Definition: wingdi.h:904
#define ODT_MENU
Definition: winuser.h:2512
LONG top
Definition: windef.h:292
ULONG_PTR itemData
Definition: winuser.h:3067
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
static int MOD_avec
Definition: menu.c:143
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
int winetest_debug
#define MN_GETHMENU
Definition: winuser.h:1755
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 int gflag_initmenu
Definition: menu.c:148
#define DT_CALCRECT
Definition: winuser.h:526
#define WM_ENTERMENULOOP
Definition: winuser.h:1786
static UINT WPARAM LPARAM lparam
Definition: combo.c:716
#define WM_MENUSELECT
Definition: winuser.h:1729
#define ok(value,...)
static int gflag_initmenupopup
Definition: menu.c:148
LONG cx
Definition: windef.h:319
static LPARAM selectitem_lp
Definition: menu.c:153
BOOL WINAPI GetTextMetricsA(_In_ HDC, _Out_ LPTEXTMETRICA)
Definition: text.c:200
static int MOD_hic
Definition: menu.c:143
static WPARAM selectitem_wp
Definition: menu.c:152
#define WM_ENTERIDLE
Definition: winuser.h:1731
GLsizeiptr size
Definition: glext.h:5919
static struct @1658 MOD_txtsizes[]
static int MOD_odheight
Definition: menu.c:144
const char * wine_dbgstr_rect(const RECT *rect)
#define WM_MEASUREITEM
Definition: winuser.h:1628
static RECT MOD_rc[MOD_NRMENUS]
Definition: menu.c:142
#define WM_CANCELMODE
Definition: winuser.h:1617
ULONG_PTR itemData
Definition: winuser.h:3620
static unsigned int MOD_maxid
Definition: menu.c:141
Definition: time.h:76
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define broken(x)
Definition: _sntprintf.h:21
#define DT_SINGLELINE
Definition: winuser.h:540
INT WINAPI DrawTextA(HDC hdc, LPCSTR str, INT count, LPRECT rect, UINT flags)
Definition: font.c:373
#define WM_INITMENU
Definition: winuser.h:1727
static int gflag_entermenuloop
Definition: menu.c:148
#define BLACK_PEN
Definition: wingdi.h:902
BOOL WINAPI GetMenuItemRect(_In_opt_ HWND, _In_ HMENU, _In_ UINT, _Out_ LPRECT)
char * strchr(const char *String, int ch)
Definition: utclib.c:501
#define WM_DRAWITEM
Definition: winuser.h:1627
#define msg(x)
Definition: auth_time.c:54
#define ODS_SELECTED
Definition: winuser.h:2520
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
LPCSTR text
Definition: menu.c:130
LONG bottom
Definition: windef.h:294
GLfloat GLfloat p
Definition: glext.h:8902
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
LONG cy
Definition: windef.h:320
static UINT WPARAM wparam
Definition: combo.c:716

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 3453 of file menu.c.

3454 {
3455  switch (msg)
3456  {
3457  case WM_ENTERMENULOOP:
3458  {
3459  BOOL ret;
3460 
3461  /* try a recursive call */
3462  SetLastError(0xdeadbeef);
3463  ret = TrackPopupMenu(g_hmenu, 0, 100, 100, 0, hwnd, NULL);
3464  ok(ret == FALSE, "got %d\n", ret);
3466  broken(GetLastError() == 0xdeadbeef) /* W9x */, "got %d\n", GetLastError());
3467 
3468  /* exit menu modal loop
3469  * ( A SendMessage does not work on NT3.51 here ) */
3470  return PostMessageA(hwnd, WM_CANCELMODE, 0, 0);
3471  }
3472  }
3473  return DefWindowProcA(hwnd, msg, wparam, lparam);
3474 }
BOOL WINAPI TrackPopupMenu(HMENU Menu, UINT Flags, int x, int y, int Reserved, HWND Wnd, CONST RECT *Rect)
Definition: menu.c:1652
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
BOOL WINAPI PostMessageA(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
unsigned int BOOL
Definition: ntddk_ex.h:94
#define WM_ENTERMENULOOP
Definition: winuser.h:1786
#define ERROR_POPUP_ALREADY_ACTIVE
Definition: winerror.h:927
static UINT WPARAM LPARAM lparam
Definition: combo.c:716
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
#define SetLastError(x)
Definition: compat.h:409
int ret
#define WM_CANCELMODE
Definition: winuser.h:1617
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define broken(x)
Definition: _sntprintf.h:21
#define msg(x)
Definition: auth_time.c:54
static HMENU g_hmenu
Definition: menu.c:3451
static UINT WPARAM wparam
Definition: combo.c:716

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 1356 of file menu.c.

1357 {
1358  BOOL ret;
1359 
1360  SetLastError( 0xdeadbeef );
1361  if (ansi) ret = ModifyMenuA( hmenu, 0, flags, id, data );
1362  else ret = ModifyMenuW( hmenu, 0, flags, id, data );
1363  ok_(__FILE__,line)( ret, "ModifyMenuA failed, err %u\n", GetLastError());
1364 }
static HMENU hmenu
Definition: win.c:66
#define ok_(x1, x2)
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL WINAPI ModifyMenuA(HMENU hMenu, UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, LPCSTR lpNewItem)
Definition: menu.c:1423
BOOL WINAPI ModifyMenuW(HMENU hMenu, UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem)
Definition: menu.c:1463
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: parser.c:48
#define SetLastError(x)
Definition: compat.h:409
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLbitfield flags
Definition: glext.h:7161
int ret

◆ MyTrackPopupMenu()

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

Definition at line 3330 of file menu.c.

3331 {
3332  return ex
3333  ? TrackPopupMenuEx( hmenu, flags, x, y, hwnd, ptpm)
3334  : TrackPopupMenu( hmenu, flags, x, y, 0, hwnd, NULL);
3335 }
BOOL WINAPI TrackPopupMenu(HMENU Menu, UINT Flags, int x, int y, int Reserved, HWND Wnd, CONST RECT *Rect)
Definition: menu.c:1652
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
Definition: comerr.c:44
static HMENU hmenu
Definition: win.c:66
BOOL WINAPI TrackPopupMenuEx(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _In_ HWND, _In_opt_ LPTPMPARAMS)
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
smooth NULL
Definition: ftsmooth.c:416
GLbitfield flags
Definition: glext.h:7161
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548

Referenced by test_menu_trackpopupmenu().

◆ register_menu_check_class()

static void register_menu_check_class ( void  )
static

Definition at line 259 of file menu.c.

260 {
261  WNDCLASSA wc =
262  {
263  0,
265  0,
266  0,
268  NULL,
270  (HBRUSH)(COLOR_BTNFACE+1),
271  NULL,
272  "WineMenuCheck",
273  };
274 
276 }
static ATOM atomMenuCheckClass
Definition: menu.c:40
smooth NULL
Definition: ftsmooth.c:416
const char * LPCSTR
Definition: xmlstorage.h:183
#define COLOR_BTNFACE
Definition: winuser.h:918
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:819
HCURSOR WINAPI LoadCursorA(_In_opt_ HINSTANCE, _In_ LPCSTR)
Definition: cursoricon.c:2059
static LRESULT WINAPI menu_check_wnd_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: menu.c:91
#define IDC_ARROW
Definition: winuser.h:682
ATOM WINAPI RegisterClassA(_In_ CONST WNDCLASSA *)

Referenced by START_TEST().

◆ send_key()

static void send_key ( WORD  wVk)
static

Definition at line 2294 of file menu.c.

2295 {
2296  TEST_INPUT i[2];
2297  memset(i, 0, sizeof(i));
2298  i[0].type = i[1].type = INPUT_KEYBOARD;
2299  i[0].u.ki.wVk = i[1].u.ki.wVk = wVk;
2300  i[1].u.ki.dwFlags = KEYEVENTF_KEYUP;
2301  pSendInput(2, (INPUT *) i, sizeof(INPUT));
2302 }
#define KEYEVENTF_KEYUP
Definition: winuser.h:1092
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
#define INPUT_KEYBOARD
Definition: winable.h:10
#define memset(x, y, z)
Definition: compat.h:39

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 1366 of file menu.c.

1370 {
1372  BOOL ret;
1373 
1374  /* magic bitmap handle to test smaller cbSize */
1375  if (item == (HBITMAP)(ULONG_PTR)0xdeadbeef)
1376  info.cbSize = FIELD_OFFSET(MENUITEMINFOA,hbmpItem);
1377  else
1378  info.cbSize = sizeof(info);
1379  info.fMask = mask;
1380  info.fType = type;
1381  info.fState = state;
1382  info.wID = id;
1383  info.hSubMenu = submenu;
1384  info.hbmpChecked = checked;
1385  info.hbmpUnchecked = unchecked;
1386  info.dwItemData = data;
1387  info.dwTypeData = type_data;
1388  info.cch = len;
1389  info.hbmpItem = item;
1390  SetLastError( 0xdeadbeef );
1391  if (ansi) ret = SetMenuItemInfoA( hmenu, 0, TRUE, &info );
1392  else ret = SetMenuItemInfoW( hmenu, 0, TRUE, (MENUITEMINFOW*)&info );
1393  ok_(__FILE__, line)( ret, "SetMenuItemInfo failed, err %u\n", GetLastError());
1394 }
#define TRUE
Definition: types.h:120
static HMENU hmenu
Definition: win.c:66
#define ok_(x1, x2)
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
struct _test_info info[]
Definition: SetCursorPos.c:19
uint32_t ULONG_PTR
Definition: typedefs.h:63
GLenum GLint GLuint mask
Definition: glext.h:6028
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI SetMenuItemInfoW(HMENU hMenu, UINT uItem, BOOL fByPosition, LPCMENUITEMINFOW lpmii)
Definition: menu.c:1599
Definition: parser.c:48
#define SetLastError(x)
Definition: compat.h:409
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
int ret
static int state
Definition: maze.c:121
GLenum GLsizei len
Definition: glext.h:6722
static ATOM item
Definition: dde.c:856
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
BOOL WINAPI SetMenuItemInfoA(HMENU hmenu, UINT item, BOOL bypos, LPCMENUITEMINFOA lpmii)
Definition: menu.c:1551
GLenum GLuint id
Definition: glext.h:5579
static HBITMAP
Definition: button.c:44

◆ START_TEST()

START_TEST ( menu  )

Definition at line 4299 of file menu.c.

4300 {
4303 
4304  /* Wine defines MENUITEMINFO for W2K and above. NT4 and below can't
4305  * handle that.
4306  */
4307  if (correct_behavior())
4308  {
4314  test_InsertMenu();
4315  test_menualign();
4316  test_system_menu();
4317  }
4318 
4326  test_menu_input();
4327  test_menu_flags();
4328 
4335  test_emptypopup();
4336  test_AppendMenu();
4337 }
static void test_InsertMenu(void)
Definition: menu.c:3008
static void test_emptypopup(void)
Definition: menu.c:3790
static void test_AppendMenu(void)
Definition: menu.c:3863
static void test_menu_search_bycommand(void)
Definition: menu.c:1922
static void test_menu_hilitemenuitem(void)
Definition: menu.c:2555
static void test_subpopup_locked_by_menu(void)
Definition: menu.c:637
static void test_menu_flags(void)
Definition: menu.c:2524
static void init_function_pointers(void)
Definition: menu.c:47
static void test_menu_bmp_and_string(void)
Definition: menu.c:982
static void test_menu_resource_layout(void)
Definition: menu.c:2813
static void test_system_menu(void)
Definition: menu.c:400
static void test_menu_getmenuinfo(void)
Definition: menu.c:3124
static void test_menu_iteminfo(void)
Definition: menu.c:1428
static void test_menu_add_string(void)
Definition: menu.c:1101
static void test_menualign(void)
Definition: menu.c:3655
static void test_menu_trackpopupmenu(void)
Definition: menu.c:3342
static void test_menu_trackagain(void)
Definition: menu.c:3476
static void test_menu_maxdepth(void)
Definition: menu.c:3597
static void test_menu_circref(void)
Definition: menu.c:3625
static void test_CheckMenuRadioItem(void)
Definition: menu.c:2766
static void test_menu_setmenuinfo(void)
Definition: menu.c:3175
static void test_menu_ownerdraw(void)
Definition: menu.c:719
static void test_menu_input(void)
Definition: menu.c:2459
static void test_getmenubarinfo(void)
Definition: menu.c:278
static void test_menu_cancelmode(void)
Definition: menu.c:3528
static BOOL correct_behavior(void)
Definition: menu.c:64
static void test_menu_locked_by_window(void)
Definition: menu.c:587
static void register_menu_check_class(void)
Definition: menu.c:259

◆ strcpyW()

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

Definition at line 1246 of file menu.c.

1247 {
1248  WCHAR *p = dst;
1249  while ((*p++ = *src++));
1250  return dst;
1251 }
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
GLfloat GLfloat p
Definition: glext.h:8902

◆ strncmpW()

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

Definition at line 1239 of file menu.c.

1240 {
1241  if (n <= 0) return 0;
1242  while ((--n > 0) && *str1 && (*str1 == *str2)) { str1++; str2++; }
1243  return *str1 - *str2;
1244 }
GLdouble n
Definition: glext.h:7729

Referenced by check_menu_item_info().

◆ subpopuplocked_wnd_proc()

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

Definition at line 621 of file menu.c.

622 {
623  HWND hwndmenu;
624  switch (msg)
625  {
626  case WM_ENTERIDLE:
627  hwndmenu = GetCapture();
628  if( hwndmenu) {
629  PostMessageA( hwndmenu, WM_KEYDOWN, VK_DOWN, 0);
630  PostMessageA( hwndmenu, WM_KEYDOWN, VK_RIGHT, 0);
631  PostMessageA( hwndmenu, WM_KEYDOWN, VK_RETURN, 0);
632  }
633  }
634  return DefWindowProcA(hwnd, msg, wparam, lparam);
635 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
BOOL WINAPI PostMessageA(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define VK_DOWN
Definition: winuser.h:2202
#define VK_RETURN
Definition: winuser.h:2176
static UINT WPARAM LPARAM lparam
Definition: combo.c:716
HWND WINAPI GetCapture(void)
Definition: message.c:2879
#define WM_KEYDOWN
Definition: winuser.h:1697
#define WM_ENTERIDLE
Definition: winuser.h:1731
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define VK_RIGHT
Definition: winuser.h:2201
#define msg(x)
Definition: auth_time.c:54
static UINT WPARAM wparam
Definition: combo.c:716

Referenced by test_subpopup_locked_by_menu().

◆ test_AppendMenu()

static void test_AppendMenu ( void  )
static

Definition at line 3863 of file menu.c.

3864 {
3865  static char string[] = "string";
3866  MENUITEMINFOA mii;
3867  HMENU hmenu, hsubmenu;
3868  HBITMAP hbmp;
3869  char buf[16];
3870  BOOL ret;
3871 
3872  hmenu = CreateMenu();
3873  ok(hmenu != 0, "CreateMenu failed\n");
3874  ret = AppendMenuA(hmenu, MF_OWNERDRAW, 201, "item 1");
3875  ok(ret, "AppendMenu failed\n");
3877  DestroyMenu(hmenu);
3878 
3879  hmenu = CreateMenu();
3880  ok(hmenu != 0, "CreateMenu failed\n");
3881  hsubmenu = get_bad_hmenu( 202 );
3882  ret = AppendMenuA(hmenu, MF_POPUP, (UINT_PTR)hsubmenu, "item 1");
3883  ok(ret, "AppendMenu failed\n");
3884  check_menu_items(hmenu, (UINT_PTR)hsubmenu, MF_STRING, 0);
3885  DestroyMenu(hmenu);
3886 
3887  hmenu = CreateMenu();
3888  ok(hmenu != 0, "CreateMenu failed\n");
3889  hsubmenu = get_bad_hmenu( 203 );
3890  ret = AppendMenuA(hmenu, MF_OWNERDRAW | MF_POPUP, (UINT_PTR)hsubmenu, "item 1");
3891  ok(ret, "AppendMenu failed\n");
3892  check_menu_items(hmenu, (UINT_PTR)hsubmenu, MF_OWNERDRAW, 0);
3893  DestroyMenu(hmenu);
3894 
3895  hmenu = CreateMenu();
3896  ok(hmenu != 0, "CreateMenu failed\n");
3897  hsubmenu = CreateMenu();
3898  ok(hsubmenu != 0, "CreateMenu failed\n");
3899  ret = AppendMenuA(hmenu, MF_OWNERDRAW, (UINT_PTR)hsubmenu, "item 1");
3900  ok(ret, "AppendMenu failed\n");
3901  check_menu_items(hmenu, (UINT_PTR)hsubmenu, MF_OWNERDRAW, 0);
3902  DestroyMenu(hmenu);
3903  DestroyMenu(hsubmenu);
3904 
3905  hmenu = CreateMenu();
3906  ok(hmenu != 0, "CreateMenu failed\n");
3907  hsubmenu = CreateMenu();
3908  ok(hsubmenu != 0, "CreateMenu failed\n");
3909  ret = AppendMenuA(hmenu, MF_POPUP, (UINT_PTR)hsubmenu, "item 1");
3910  ok(ret, "AppendMenu failed\n");
3911  check_menu_items(hmenu, (UINT_PTR)hsubmenu, MF_STRING, 0);
3912  DestroyMenu(hmenu);
3913  DestroyMenu(hsubmenu);
3914 
3915  hmenu = CreateMenu();
3916  ok(hmenu != 0, "CreateMenu failed\n");
3917  hsubmenu = CreateMenu();
3918  ok(hsubmenu != 0, "CreateMenu failed\n");
3919  ret = AppendMenuA(hmenu, MF_OWNERDRAW | MF_POPUP, (UINT_PTR)hsubmenu, "item 1");
3920  ok(ret, "AppendMenu failed\n");
3921  check_menu_items(hmenu, (UINT_PTR)hsubmenu, MF_OWNERDRAW, 0);
3922  DestroyMenu(hmenu);
3923  DestroyMenu(hsubmenu);
3924 
3925  hmenu = CreateMenu();
3926  ok(hmenu != 0, "CreateMenu failed\n");
3927  hsubmenu = CreatePopupMenu();
3928  ok(hsubmenu != 0, "CreatePopupMenu failed\n");
3929  ret = AppendMenuA(hmenu, MF_OWNERDRAW, (UINT_PTR)hsubmenu, "item 1");
3930  ok(ret, "AppendMenu failed\n");
3931  check_menu_items(hmenu, (UINT_PTR)hsubmenu, MF_OWNERDRAW, 0);
3932  DestroyMenu(hmenu);
3933  DestroyMenu(hsubmenu);
3934 
3935  hmenu = CreateMenu();
3936  ok(hmenu != 0, "CreateMenu failed\n");
3937  hsubmenu = CreatePopupMenu();
3938  ok(hsubmenu != 0, "CreatePopupMenu failed\n");
3939  ret = AppendMenuA(hmenu, MF_POPUP, (UINT_PTR)hsubmenu, "item 1");
3940  ok(ret, "AppendMenu failed\n");
3941  check_menu_items(hmenu, (UINT_PTR)hsubmenu, MF_STRING, 0);
3942  DestroyMenu(hmenu);
3943  DestroyMenu(hsubmenu);
3944 
3945  hmenu = CreateMenu();
3946  ok(hmenu != 0, "CreateMenu failed\n");
3947  hsubmenu = CreatePopupMenu();
3948  ok(hsubmenu != 0, "CreatePopupMenu failed\n");
3949  ret = AppendMenuA(hmenu, MF_OWNERDRAW | MF_POPUP, (UINT_PTR)hsubmenu, "item 1");
3950  ok(ret, "AppendMenu failed\n");
3951  check_menu_items(hmenu, (UINT_PTR)hsubmenu, MF_OWNERDRAW, 0);
3952  DestroyMenu(hmenu);
3953  DestroyMenu(hsubmenu);
3954 
3955  hmenu = CreateMenu();
3956  ok(hmenu != 0, "CreateMenu failed\n");
3957  ret = AppendMenuA(hmenu, MF_STRING, 204, "item 1");
3958  ok(ret, "AppendMenu failed\n");
3959  check_menu_items(hmenu, 204, MF_STRING, 0);
3960  hsubmenu = get_bad_hmenu( 205 );
3961  ret = ModifyMenuA(hmenu, 0, MF_POPUP | MF_BYPOSITION, (UINT_PTR)hsubmenu, "item 2");
3962  ok(ret, "ModifyMenu failed\n");
3963  check_menu_items(hmenu, (UINT_PTR)hsubmenu, MF_STRING, 0);
3964  memset(&mii, 0, sizeof(mii));
3965  mii.cbSize = sizeof(mii);
3966  mii.fMask = MIIM_SUBMENU;
3967  mii.hSubMenu = get_bad_hmenu( 204 );
3968  ret = InsertMenuItemA(hmenu, 0, TRUE, &mii);
3969  ok(!ret, "InsertMenuItem should fail\n");
3970  ret = SetMenuItemInfoA(hmenu, 0, TRUE, &mii);
3971  ok(!ret, "SetMenuItemInfo should fail\n");
3972  mii.fMask = MIIM_ID;
3973  mii.wID = 206;
3974  ret = InsertMenuItemA(hmenu, 0, TRUE, &mii);
3975  ok(ret, "InsertMenuItem failed\n");
3976 if (0) /* FIXME: uncomment once Wine is fixed */ {
3978 }
3979  mii.wID = 207;
3980  ret = SetMenuItemInfoA(hmenu, 0, TRUE, &mii);
3981  ok(ret, "SetMenuItemInfo failed\n");
3982 if (0) /* FIXME: uncomment once Wine is fixed */ {
3984 }
3985  DestroyMenu(hmenu);
3986 
3987  hbmp = CreateBitmap(1, 1, 1, 1, NULL);
3988  hmenu = CreateMenu();
3989  ok(hmenu != 0, "CreateMenu failed\n");
3990 
3991  /* menu item with a string and a bitmap */
3992  memset(&mii, 0, sizeof(mii));
3993  mii.cbSize = sizeof(mii);
3994  mii.fMask = MIIM_STRING | MIIM_BITMAP;
3995  mii.dwTypeData = string;
3996  mii.cch = strlen(string);
3997  mii.hbmpItem = hbmp;
3998  ret = InsertMenuItemA(hmenu, 0, TRUE, &mii);
3999  ok(ret, "InsertMenuItem failed\n");
4000  memset(&mii, 0x81, sizeof(mii));
4001  memset(buf, 0x81, sizeof(buf));
4002  mii.cbSize = sizeof(mii);
4004  mii.dwTypeData = buf;
4005  mii.cch = sizeof(buf);
4006  mii.dwItemData = 0x81818181;
4007  ret = GetMenuItemInfoA(hmenu, 0, TRUE, &mii);
4008  ok(ret, "GetMenuItemInfo failed\n");
4009  ok(mii.fType == MF_STRING, "expected MF_STRING, got %#x\n", mii.fType);
4010  ok(mii.fState == MF_ENABLED, "expected MF_ENABLED, got %#x\n", mii.fState);
4011  ok(mii.wID == 0, "expected 0, got %#x\n", mii.wID);
4012  ok(mii.hSubMenu == 0, "expected 0, got %p\n", mii.hSubMenu);
4013  ok(mii.dwItemData == 0x81818181, "expected 0x81818181, got %#lx\n", mii.dwItemData);
4014  ok(mii.dwTypeData == buf, "expected %p, got %p\n", buf, mii.dwTypeData);
4015  ok(mii.cch == 6, "expected 6, got %u\n", mii.cch);
4016  ok(!strcmp(buf, string), "expected %s, got %s\n", string, buf);
4017  ok(mii.hbmpItem == hbmp, "expected %p, got %p\n", hbmp, mii.hbmpItem);
4018 
4019  memset(&mii, 0x81, sizeof(mii));
4020  mii.cbSize = sizeof(mii);
4021  mii.fMask = MIIM_TYPE;
4022  mii.dwItemData = 0x81818181;
4023  ret = GetMenuItemInfoA(hmenu, 0, TRUE, &mii);
4024  ok(ret, "GetMenuItemInfo failed\n");
4025  ok(mii.fType == MF_BITMAP, "expected MF_BITMAP, got %#x\n", mii.fType);
4026  ok(mii.fState == 0x81818181, "expected 0x81818181, got %#x\n", mii.fState);
4027  ok(mii.wID == 0x81818181, "expected 0x81818181, got %#x\n", mii.wID);
4028  ok(mii.hSubMenu == 0, "expected 0, got %p\n", mii.hSubMenu);
4029  ok(mii.dwItemData == 0x81818181, "expected 0x81818181, got %#lx\n", mii.dwItemData);
4030  ok(mii.dwTypeData == (LPSTR)hbmp, "expected %p, got %p\n", hbmp, mii.dwTypeData);
4031  ok(mii.cch == 6, "expected 6, got %u\n", mii.cch);
4032  ok(mii.hbmpItem == hbmp, "expected %p, got %p\n", hbmp, mii.hbmpItem);
4033 
4034  memset(&mii, 0x81, sizeof(mii));
4035  memset(buf, 0x81, sizeof(buf));
4036  mii.cbSize = sizeof(mii);
4038  mii.dwTypeData = buf;
4039  mii.cch = sizeof(buf);
4040  mii.dwItemData = 0x81818181;
4041  ret = GetMenuItemInfoA(hmenu, 0, TRUE, &mii);
4042  ok(ret, "GetMenuItemInfo failed\n");
4043  ok(mii.fType == MF_BITMAP, "expected MF_BITMAP, got %#x\n", mii.fType);
4044  ok(mii.fState == MF_ENABLED, "expected MF_ENABLED, got %#x\n", mii.fState);
4045  ok(mii.wID == 0, "expected 0, got %#x\n", mii.wID);
4046  ok(mii.hSubMenu == 0, "expected 0, got %p\n", mii.hSubMenu);
4047  ok(mii.dwItemData == 0, "expected 0, got %#lx\n", mii.dwItemData);
4048  ok(mii.dwTypeData == (LPSTR)hbmp, "expected %p, got %p\n", hbmp, mii.dwTypeData);
4049  ok(mii.cch == 6, "expected 6, got %u\n", mii.cch);
4050  ok(mii.hbmpItem == hbmp, "expected %p, got %p\n", hbmp, mii.hbmpItem);
4051 
4052  DestroyMenu(hmenu);
4053  DeleteObject(hbmp);
4054 
4055  hmenu = CreateMenu();
4056  ok(hmenu != 0, "CreateMenu failed\n");
4057 
4058  /* menu item with a string and a "magic" bitmap */
4059  memset(&mii, 0, sizeof(mii));
4060  mii.cbSize = sizeof(mii);
4061  mii.fMask = MIIM_STRING | MIIM_BITMAP;
4062  mii.dwTypeData = string;
4063  mii.cch = strlen(string);
4064  mii.hbmpItem = HBMMENU_POPUP_RESTORE;
4065  ret = InsertMenuItemA(hmenu, 0, TRUE, &mii);
4066  ok(ret, "InsertMenuItem failed\n");
4067  memset(&mii, 0x81, sizeof(mii));
4068  memset(buf, 0x81, sizeof(buf));
4069  mii.cbSize = sizeof(mii);
4071  mii.dwTypeData = buf;
4072  mii.cch = sizeof(buf);
4073  mii.dwItemData = 0x81818181;
4074  ret = GetMenuItemInfoA(hmenu, 0, TRUE, &mii);
4075  ok(ret, "GetMenuItemInfo failed\n");
4076  ok(mii.fType == MF_STRING, "expected MF_STRING, got %#x\n", mii.fType);
4077  ok(mii.fState == MF_ENABLED, "expected MF_ENABLED, got %#x\n", mii.fState);
4078  ok(mii.wID == 0, "expected 0, got %#x\n", mii.wID);
4079  ok(mii.hSubMenu == 0, "expected 0, got %p\n", mii.hSubMenu);
4080  ok(mii.dwItemData == 0x81818181, "expected 0x81818181, got %#lx\n", mii.dwItemData);
4081  ok(mii.dwTypeData == buf, "expected %p, got %p\n", buf, mii.dwTypeData);
4082  ok(mii.cch == 6, "expected 6, got %u\n", mii.cch);
4083  ok(!strcmp(buf, string), "expected %s, got %s\n", string, buf);
4084  ok(mii.hbmpItem == HBMMENU_POPUP_RESTORE, "expected HBMMENU_POPUP_RESTORE, got %p\n", mii.hbmpItem);
4085 
4086  memset(&mii, 0x81, sizeof(mii));
4087  mii.cbSize = sizeof(mii);
4088  mii.fMask = MIIM_TYPE;
4089  mii.dwTypeData = buf;
4090  mii.cch = sizeof(buf);
4091  mii.dwItemData = 0x81818181;
4092  ret = GetMenuItemInfoA(hmenu, 0, TRUE, &mii);
4093  ok(ret, "GetMenuItemInfo failed\n");
4094  ok(mii.fType == MF_STRING, "expected MF_STRING, got %#x\n", mii.fType);
4095  ok(mii.fState == 0x81818181, "expected 0x81818181, got %#x\n", mii.fState);
4096  ok(mii.wID == 0x81818181, "expected 0x81818181, got %#x\n", mii.wID);
4097  ok(mii.hSubMenu == 0, "expected 0, got %p\n", mii.hSubMenu);
4098  ok(mii.dwItemData == 0x81818181, "expected 0x81818181, got %#lx\n", mii.dwItemData);
4099  ok(mii.dwTypeData == buf, "expected %p, got %p\n", buf, mii.dwTypeData);
4100  ok(mii.cch == 6, "expected 6, got %u\n", mii.cch);
4101  ok(!strcmp(buf, string), "expected %s, got %s\n", string, buf);
4102  ok(mii.hbmpItem == HBMMENU_POPUP_RESTORE, "expected HBMMENU_POPUP_RESTORE, got %p\n", mii.hbmpItem);
4103 
4104  memset(&mii, 0x81, sizeof(mii));
4105  memset(buf, 0x81, sizeof(buf));
4106  mii.cbSize = sizeof(mii);
4108  mii.dwTypeData = buf;
4109  mii.cch = sizeof(buf);
4110  mii.dwItemData = 0x81818181;
4111  ret = GetMenuItemInfoA(hmenu, 0, TRUE, &mii);
4112  ok(ret, "GetMenuItemInfo failed\n");
4113  ok(mii.fType == MF_STRING, "expected MF_STRING, got %#x\n", mii.fType);
4114  ok(mii.fState == MF_ENABLED, "expected MF_ENABLED, got %#x\n", mii.fState);
4115  ok(mii.wID == 0, "expected 0, got %#x\n", mii.wID);
4116  ok(mii.hSubMenu == 0, "expected 0, got %p\n", mii.hSubMenu);
4117  ok(mii.dwItemData == 0, "expected 0, got %#lx\n", mii.dwItemData);
4118  ok(mii.dwTypeData == buf, "expected %p, got %p\n", buf, mii.dwTypeData);
4119  ok(mii.cch == 6, "expected 6, got %u\n", mii.cch);
4120  ok(!strcmp(buf, string), "expected %s, got %s\n", string, buf);
4121  ok(mii.hbmpItem == HBMMENU_POPUP_RESTORE, "expected HBMMENU_POPUP_RESTORE, got %p\n", mii.hbmpItem);
4122 
4123  DestroyMenu(hmenu);
4124 
4125  hbmp = CreateBitmap(1, 1, 1, 1, NULL);
4126  hmenu = CreateMenu();
4127  ok(hmenu != 0, "CreateMenu failed\n");
4128 
4129  /* menu item with a string */
4130  memset(&mii, 0, sizeof(mii));
4131  mii.cbSize = sizeof(mii);
4133  mii.dwItemData = (ULONG_PTR)hbmp;
4134  mii.dwTypeData = string;
4135  mii.cch = strlen(string);
4136  mii.hbmpItem = hbmp;
4137  ret = InsertMenuItemA(hmenu, 0, TRUE, &mii);
4138  ok(ret, "InsertMenuItem failed\n");
4139  memset(&mii, 0x81, sizeof(mii));
4140  memset(buf, 0x81, sizeof(buf));
4141  mii.cbSize = sizeof(mii);
4143  mii.dwTypeData = buf;
4144  mii.cch = sizeof(buf);
4145  mii.dwItemData = 0x81818181;
4146  ret = GetMenuItemInfoA(hmenu, 0, TRUE, &mii);
4147  ok(ret, "GetMenuItemInfo failed\n");
4148  ok(mii.fType == MF_STRING, "expected MF_STRING, got %#x\n", mii.fType);
4149  ok(mii.fState == MF_ENABLED, "expected MF_ENABLED, got %#x\n", mii.fState);
4150  ok(mii.wID == 0, "expected 0, got %#x\n", mii.wID);
4151  ok(mii.hSubMenu == 0, "expected 0, got %p\n", mii.hSubMenu);
4152  ok(mii.dwItemData == (ULONG_PTR)hbmp, "expected %p, got %#lx\n", hbmp, mii.dwItemData);
4153  ok(mii.dwTypeData == buf, "expected %p, got %p\n", buf, mii.dwTypeData);
4154  ok(mii.cch == 6, "expected 6, got %u\n", mii.cch);
4155  ok(!strcmp(buf, string), "expected %s, got %s\n", string, buf);
4156  ok(mii.hbmpItem == 0, "expected 0, got %p\n", mii.hbmpItem);
4157 
4158  memset(&mii, 0x81, sizeof(mii));
4159  memset(buf, 0x81, sizeof(buf));
4160  mii.cbSize = sizeof(mii);
4161  mii.fMask = MIIM_TYPE;
4162  mii.dwTypeData = buf;
4163  mii.cch = sizeof(buf);
4164  mii.dwItemData = 0x81818181;
4165  ret = GetMenuItemInfoA(hmenu, 0, TRUE, &mii);
4166  ok(ret, "GetMenuItemInfo failed\n");
4167  ok(mii.fType == MF_STRING, "expected MF_STRING, got %#x\n", mii.fType);
4168  ok(mii.fState == 0x81818181, "expected 0x81818181, got %#x\n", mii.fState);
4169  ok(mii.wID == 0x81818181, "expected 0x81818181, got %#x\n", mii.wID);
4170  ok(mii.hSubMenu == 0, "expected 0, got %p\n", mii.hSubMenu);
4171  ok(mii.dwItemData == 0x81818181, "expected 0x81818181, got %#lx\n", mii.dwItemData);
4172  ok(mii.dwTypeData == buf, "expected %p, got %p\n", buf, mii.dwTypeData);
4173  ok(mii.cch == 6, "expected 6, got %u\n", mii.cch);
4174  ok(!strcmp(buf, string), "expected %s, got %s\n", string, buf);
4175  ok(mii.hbmpItem == 0, "expected 0, got %p\n", mii.hbmpItem);
4176 
4177  DestroyMenu(hmenu);
4178  DeleteObject(hbmp);
4179 
4180  /* menu item with a string */
4181  hbmp = CreateBitmap(1, 1, 1, 1, NULL);
4182  hmenu = CreateMenu();
4183  ok(hmenu != 0, "CreateMenu failed\n");
4184  memset(&mii, 0, sizeof(mii));
4185  mii.cbSize = sizeof(mii);
4186  mii.fMask = MIIM_STRING;
4187  mii.dwTypeData = string;
4188  mii.cch = strlen(string);
4189  ret = InsertMenuItemA(hmenu, 0, TRUE, &mii);
4190  ok(ret, "InsertMenuItem failed\n");
4191  memset(&mii, 0x81, sizeof(mii));
4192  memset(buf, 0x81, sizeof(buf));
4193  mii.cbSize = sizeof(mii);
4195  mii.dwTypeData = buf;
4196  mii.cch = sizeof(buf);
4197  mii.dwItemData = 0x81818181;
4198  ret = GetMenuItemInfoA(hmenu, 0, TRUE, &mii);
4199  ok(ret, "GetMenuItemInfo failed\n");
4200  ok(mii.fType == MF_STRING, "expected MF_STRING, got %#x\n", mii.fType);
4201  ok(mii.fState == MF_ENABLED, "expected MF_ENABLED, got %#x\n", mii.fState);
4202  ok(mii.wID == 0, "expected 0, got %#x\n", mii.wID);
4203  ok(mii.hSubMenu == 0, "expected 0, got %p\n", mii.hSubMenu);
4204  ok(mii.dwItemData == 0x81818181, "expected 0x81818181, got %#lx\n", mii.dwItemData);
4205  ok(mii.dwTypeData == buf, "expected %p, got %p\n", buf, mii.dwTypeData);
4206  ok(mii.cch == 6, "expected 6, got %u\n", mii.cch);
4207  ok(!strcmp(buf, string), "expected %s, got %s\n", string, buf);
4208  ok(mii.hbmpItem == 0, "expected 0, got %p\n", mii.hbmpItem);
4209 
4210  /* add "magic" bitmap to a menu item */
4211  mii.fMask = MIIM_BITMAP;
4212  mii.hbmpItem = HBMMENU_POPUP_RESTORE;
4213  ret = SetMenuItemInfoA(hmenu, 0, TRUE, &mii);
4214  ok(ret, "SetMenuItemInfo failed\n");
4215  memset(&mii, 0x81, sizeof(mii));
4216  memset(buf, 0x81, sizeof(buf));
4217  mii.cbSize = sizeof(mii);
4219  mii.dwTypeData = buf;
4220  mii.cch = sizeof(buf);
4221  mii.dwItemData = 0x81818181;
4222  ret = GetMenuItemInfoA(hmenu, 0, TRUE, &mii);
4223  ok(ret, "GetMenuItemInfo failed\n");
4224  ok(mii.fType == MF_STRING, "expected MF_STRING, got %#x\n", mii.fType);
4225  ok(mii.fState == MF_ENABLED, "expected MF_ENABLED, got %#x\n", mii.fState);
4226  ok(mii.wID == 0, "expected 0, got %#x\n", mii.wID);
4227  ok(mii.hSubMenu == 0, "expected 0, got %p\n", mii.hSubMenu);
4228  ok(mii.dwItemData == 0x81818181, "expected 0x81818181, got %#lx\n", mii.dwItemData);
4229  ok(mii.dwTypeData == buf, "expected %p, got %p\n", buf, mii.dwTypeData);
4230  ok(mii.cch == 6, "expected 6, got %u\n", mii.cch);
4231  ok(!strcmp(buf, string), "expected %s, got %s\n", string, buf);
4232  ok(mii.hbmpItem == HBMMENU_POPUP_RESTORE, "expected HBMMENU_POPUP_RESTORE, got %p\n", mii.hbmpItem);
4233 
4234  memset(&mii, 0x81, sizeof(mii));
4235  memset(buf, 0x81, sizeof(buf));
4236  mii.cbSize = sizeof(mii);
4237  mii.fMask = MIIM_TYPE;
4238  mii.dwTypeData = buf;
4239  mii.cch = sizeof(buf);
4240  mii.dwItemData = 0x81818181;
4241  ret = GetMenuItemInfoA(hmenu, 0, TRUE, &mii);
4242  ok(ret, "GetMenuItemInfo failed\n");
4243  ok(mii.fType == MF_STRING, "expected MF_STRING, got %#x\n", mii.fType);
4244  ok(mii.fState == 0x81818181, "expected 0x81818181, got %#x\n", mii.fState);
4245  ok(mii.wID == 0x81818181, "expected 0x81818181, got %#x\n", mii.wID);
4246  ok(mii.hSubMenu == 0, "expected 0, got %p\n", mii.hSubMenu);
4247  ok(mii.dwItemData == 0x81818181, "expected 0x81818181, got %#lx\n", mii.dwItemData);
4248  ok(mii.dwTypeData == buf, "expected %p, got %p\n", buf, mii.dwTypeData);
4249  ok(mii.cch == 6, "expected 6, got %u\n", mii.cch);
4250  ok(!strcmp(buf, string), "expected %s, got %s\n", string, buf);
4251  ok(mii.hbmpItem == HBMMENU_POPUP_RESTORE, "expected HBMMENU_POPUP_RESTORE, got %p\n", mii.hbmpItem);
4252 
4253  /* replace "magic" bitmap by a normal one */
4254  mii.fMask = MIIM_BITMAP;
4255  mii.hbmpItem = hbmp;
4256  ret = SetMenuItemInfoA(hmenu, 0, TRUE, &mii);
4257  ok(ret, "SetMenuItemInfo failed\n");
4258  memset(&mii, 0x81, sizeof(mii));
4259  memset(buf, 0x81, sizeof(buf));
4260  mii.cbSize = sizeof(mii);
4262  mii.dwTypeData = buf;
4263  mii.cch = sizeof(buf);
4264  mii.dwItemData = 0x81818181;
4265  ret = GetMenuItemInfoA(hmenu, 0, TRUE, &mii);
4266  ok(ret, "GetMenuItemInfo failed\n");
4267  ok(mii.fType == MF_STRING, "expected MF_STRING, got %#x\n", mii.fType);
4268  ok(mii.fState == MF_ENABLED, "expected MF_ENABLED, got %#x\n", mii.fState);
4269  ok(mii.wID == 0, "expected 0, got %#x\n", mii.wID);
4270  ok(mii.hSubMenu == 0, "expected 0, got %p\n", mii.hSubMenu);
4271  ok(mii.dwItemData == 0x81818181, "expected 0x81818181, got %#lx\n", mii.dwItemData);
4272  ok(mii.dwTypeData == buf, "expected %p, got %p\n", buf, mii.dwTypeData);
4273  ok(mii.cch == 6, "expected 6, got %u\n", mii.cch);
4274  ok(!strcmp(buf, string), "expected %s, got %s\n", string, buf);
4275  ok(mii.hbmpItem == hbmp, "expected %p, got %p\n", hbmp, mii.hbmpItem);
4276 
4277  memset(&mii, 0x81, sizeof(mii));
4278  memset(buf, 0x81, sizeof(buf));
4279  mii.cbSize = sizeof(mii);
4280  mii.fMask = MIIM_TYPE;
4281  mii.dwTypeData = buf;
4282  mii.cch = sizeof(buf);
4283  mii.dwItemData = 0x81818181;
4284  ret = GetMenuItemInfoA(hmenu, 0, TRUE, &mii);
4285  ok(ret, "GetMenuItemInfo failed\n");
4286  ok(mii.fType == MF_BITMAP, "expected MF_BITMAP, got %#x\n", mii.fType);
4287  ok(mii.fState == 0x81818181, "expected 0x81818181, got %#x\n", mii.fState);
4288  ok(mii.wID == 0x81818181, "expected 0x81818181, got %#x\n", mii.wID);
4289  ok(mii.hSubMenu == 0, "expected 0, got %p\n", mii.hSubMenu);
4290  ok(mii.dwItemData == 0x81818181, "expected 0x81818181, got %#lx\n", mii.dwItemData);
4291  ok(mii.dwTypeData == (LPSTR)hbmp, "expected %p, got %p\n", hbmp, mii.dwTypeData);
4292  ok(mii.cch == 6, "expected 6, got %u\n", mii.cch);
4293  ok(mii.hbmpItem == hbmp, "expected %p, got %p\n", hbmp, mii.hbmpItem);
4294 
4295  DestroyMenu(hmenu);
4296  DeleteObject(hbmp);
4297 }
#define MIIM_FTYPE
Definition: winuser.h:724
#define TRUE
Definition: types.h:120
static HMENU get_bad_hmenu(UINT_PTR id)
Definition: menu.c:3857
#define HBMMENU_POPUP_RESTORE
Definition: winuser.h:2613
static HMENU hmenu
Definition: win.c:66
ULONG_PTR dwItemData
Definition: winuser.h:3224
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define MF_STRING
Definition: winuser.h:138
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
BOOL WINAPI ModifyMenuA(HMENU hMenu, UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, LPCSTR lpNewItem)
Definition: menu.c:1423
char * LPSTR
Definition: xmlstorage.h:182
HMENU WINAPI CreatePopupMenu(VOID)
Definition: menu.c:846
#define MIIM_BITMAP
Definition: winuser.h:723
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define MIIM_SUBMENU
Definition: winuser.h:718
HMENU WINAPI CreateMenu(VOID)
Definition: menu.c:837
#define MIIM_STATE
Definition: winuser.h:716
unsigned int BOOL
Definition: ntddk_ex.h:94
#define MF_BYPOSITION
Definition: winuser.h:203
#define ok(value,...)
#define MF_OWNERDRAW
Definition: winuser.h:135
smooth NULL
Definition: ftsmooth.c:416
static void check_menu_items(HMENU hmenu, UINT checked_cmd, UINT checked_type, UINT checked_state)
Definition: menu.c:2693
#define MF_SEPARATOR
Definition: winuser.h:137
BOOL WINAPI AppendMenuA(HMENU hMenu, UINT uFlags, UINT_PTR uIDNewItem, LPCSTR lpNewItem)
Definition: menu.c:684
#define MIIM_ID
Definition: winuser.h:717
HBITMAP hbmp
#define MF_ENABLED
Definition: winuser.h:128
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
int ret
#define MF_POPUP
Definition: winuser.h:136
#define MFS_GRAYED
Definition: winuser.h:746
#define MIIM_TYPE
Definition: winuser.h:720
BOOL WINAPI GetMenuItemInfoA(HMENU hmenu, UINT item, BOOL bypos, LPMENUITEMINFOA lpmii)
Definition: menu.c:989
#define MF_BITMAP
Definition: winuser.h:131
char string[160]
Definition: util.h:11
BOOL WINAPI DestroyMenu(_In_ HMENU)
#define MIIM_STRING
Definition: winuser.h:722
BOOL WINAPI InsertMenuItemA(HMENU hMenu, UINT uItem, BOOL fByPosition, LPCMENUITEMINFOA lpmii)
Definition: menu.c:1219
BOOL WINAPI SetMenuItemInfoA(HMENU hmenu, UINT item, BOOL bypos, LPCMENUITEMINFOA lpmii)
Definition: menu.c:1551
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define ULONG_PTR
Definition: config.h:101
static HBITMAP
Definition: button.c:44
#define MIIM_DATA
Definition: winuser.h:721
#define memset(x, y, z)
Definition: compat.h:39
LPSTR dwTypeData
Definition: winuser.h:3225
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)

Referenced by START_TEST().

◆ test_CheckMenuRadioItem()

static void test_CheckMenuRadioItem ( void  )
static

Definition at line 2766 of file menu.c.

2767 {
2768  BOOL ret;
2769  HMENU hmenu;
2770 
2772  assert(hmenu != 0);
2773 
2774  check_menu_items(hmenu, -1, 0, 0);
2775 
2776  ret = CheckMenuRadioItem(hmenu, 100, 100, 100, MF_BYCOMMAND);
2777  ok(ret, "CheckMenuRadioItem failed\n");
2779 
2780  /* MSDN is wrong, Windows does not remove MFT_RADIOCHECK */
2781  ret = CheckMenuRadioItem(hmenu, 100, 100, -1, MF_BYCOMMAND);
2782  ok(!ret, "CheckMenuRadioItem should return FALSE\n");
2784 
2785  /* clear check */
2787  check_menu_items(hmenu, -1, 0, 0);
2788 
2789  /* first and checked items are on different menus */
2790  ret = CheckMenuRadioItem(hmenu, 0, 300, 202, MF_BYCOMMAND);
2791  ok(!ret, "CheckMenuRadioItem should return FALSE\n");
2792  check_menu_items(hmenu, -1, 0, 0);
2793 
2794  ret = CheckMenuRadioItem(hmenu, 200, 300, 202, MF_BYCOMMAND);
2795  ok(ret, "CheckMenuRadioItem failed\n");
2797 
2798  /* MSDN is wrong, Windows does not remove MFT_RADIOCHECK */
2799  ret = CheckMenuRadioItem(hmenu, 202, 202, -1, MF_BYCOMMAND);
2800  ok(!ret, "CheckMenuRadioItem should return FALSE\n");
2802 
2803  /* clear check */
2805  check_menu_items(hmenu, -1, 0, 0);
2806 
2807  /* just for fun, try to check separator */
2808  ret = CheckMenuRadioItem(hmenu, 0, 300, 0, MF_BYCOMMAND);
2809  ok(!ret, "CheckMenuRadioItem should return FALSE\n");
2810  check_menu_items(hmenu, -1, 0, 0);
2811 }
#define MF_BYCOMMAND
Definition: winuser.h:202
static HMENU hmenu
Definition: win.c:66
#define MFT_RADIOCHECK
Definition: winuser.h:737
#define assert(x)
Definition: debug.h:53
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
static void check_menu_items(HMENU hmenu, UINT checked_cmd, UINT checked_type, UINT checked_state)
Definition: menu.c:2693
BOOL WINAPI CheckMenuRadioItem(HMENU hMenu, UINT first, UINT last, UINT check, UINT bypos)
Definition: menu.c:773
int ret
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:819
static void clear_ftype_and_state(HMENU hmenu, UINT id, UINT flags)
Definition: menu.c:2754
HMENU WINAPI LoadMenuA(HINSTANCE hInstance, LPCSTR lpMenuName)
Definition: menu.c:1342
#define MFS_CHECKED
Definition: winuser.h:742
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60

Referenced by START_TEST().

◆ test_emptypopup()

static void test_emptypopup ( void  )
static

Definition at line 3790 of file menu.c.

3791 {
3792  BOOL ret;
3793  HMENU hmenu;
3794 
3797  NULL, NULL, NULL, NULL);
3798  ok(hwnd != NULL, "CreateWindowEx failed with error %d\n", GetLastError());
3800 
3801  hmenu = CreatePopupMenu();
3802  ok(hmenu != NULL, "CreateMenu failed with error %d\n", GetLastError());
3803 
3805  selectitem_wp = 0xdeadbeef;
3806  selectitem_lp = 0xdeadbeef;
3807 
3808  ret = TrackPopupMenu( hmenu, TPM_RETURNCMD, 100,100, 0, hwnd, NULL);
3809  ok(ret == 0, "got %i\n", ret);
3810 
3811  ok(gflag_initmenupopup == 1, "got %i\n", gflag_initmenupopup);
3812  ok(gflag_entermenuloop == 1, "got %i\n", gflag_entermenuloop);
3813  ok(gflag_initmenu == 1, "got %i\n", gflag_initmenu);
3814  ok(gflag_enteridle == 0, "got %i\n", gflag_initmenu);
3815 
3816  ok(selectitem_wp == 0xdeadbeef, "got %lx\n", selectitem_wp);
3817  ok(selectitem_lp == 0xdeadbeef, "got %lx\n", selectitem_lp);
3818 
3820  selectitem_wp = 0xdeadbeef;
3821  selectitem_lp = 0xdeadbeef;
3822 
3823  ret = TrackPopupMenu( hmenu, 0, 100,100, 0, hwnd, NULL);
3824  ok(ret == 0, "got %i\n", ret);
3825 
3826  ok(gflag_initmenupopup == 1, "got %i\n", gflag_initmenupopup);
3827  ok(gflag_entermenuloop == 1, "got %i\n", gflag_entermenuloop);
3828  ok(gflag_initmenu == 1, "got %i\n", gflag_initmenu);
3829  ok(gflag_enteridle == 0, "got %i\n", gflag_initmenu);
3830 
3831  ok(selectitem_wp == 0xdeadbeef, "got %lx\n", selectitem_wp);
3832  ok(selectitem_lp == 0xdeadbeef, "got %lx\n", selectitem_lp);
3833 
3835 
3837  selectitem_wp = 0xdeadbeef;
3838  selectitem_lp = 0xdeadbeef;
3839 
3840  ret = TrackPopupMenu( hmenu, 0, 100,100, 0, hwnd, NULL);
3841  ok(ret == 1, "got %i\n", ret);
3842 
3843  ok(gflag_initmenupopup == 1, "got %i\n", gflag_initmenupopup);
3844  ok(gflag_entermenuloop == 1, "got %i\n", gflag_entermenuloop);
3845  ok(gflag_initmenu == 1, "got %i\n", gflag_initmenu);
3846  ok(gflag_enteridle == 1, "got %i\n", gflag_initmenu);
3847 
3848  ok(selectitem_wp == 0xffff0000, "got %lx\n", selectitem_wp);
3849  ok(selectitem_lp == 0, "got %lx\n", selectitem_lp);
3850 
3852 
3853  ret = DestroyMenu(hmenu);
3854  ok(ret, "DestroyMenu failed with error %d\n", GetLastError());
3855 }
static int gflag_enteridle
Definition: menu.c:148
BOOL WINAPI TrackPopupMenu(HMENU Menu, UINT Flags, int x, int y, int Reserved, HWND Wnd, CONST RECT *Rect)
Definition: menu.c:1652
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
static HMENU hmenu
Definition: win.c:66
static ATOM atomMenuCheckClass
Definition: menu.c:40
#define TPM_RETURNCMD
Definition: winuser.h:2362
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
HMENU WINAPI CreatePopupMenu(VOID)
Definition: menu.c:846
BOOL WINAPI DestroyWindow(_In_ HWND)
static LRESULT WINAPI menu_fill_in_init(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: menu.c:3757
static int gflag_initmenu
Definition: menu.c:148
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ok(value,...)
#define CW_USEDEFAULT
Definition: winuser.h:225
smooth NULL
Definition: ftsmooth.c:416
static int gflag_initmenupopup
Definition: menu.c:148
static LPARAM selectitem_lp
Definition: menu.c:153
static LRESULT WINAPI menu_ownerdraw_wnd_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: menu.c:156
const char * LPCSTR
Definition: xmlstorage.h:183
static WPARAM selectitem_wp
Definition: menu.c:152
int ret
#define SetWindowLongPtrA
Definition: winuser.h:5246
#define GWLP_WNDPROC
Definition: treelist.c:66
BOOL WINAPI DestroyMenu(_In_ HMENU)
static int gflag_entermenuloop
Definition: menu.c:148
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
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 WS_VISIBLE
Definition: pedump.c:620
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
#define MAKEINTATOM(i)
Definition: winbase.h:1416

Referenced by START_TEST().

◆ test_getmenubarinfo()

static void test_getmenubarinfo ( void  )
static

Definition at line 278 of file menu.c.

279 {
280  BOOL ret;
281  HMENU hmenu;
282  MENUBARINFO mbi;
283  RECT rcw, rci;
284  HWND hwnd;
285  INT err;
286 
287  if (!pGetMenuBarInfo) {
288  win_skip("GetMenuBarInfo is not available\n");
289  return;
290  }
291 
292  mbi.cbSize = sizeof(MENUBARINFO);
293 
296  NULL, NULL, NULL, NULL);
297  ok(hwnd != NULL, "CreateWindowEx failed with error %d\n", GetLastError());
298 
299  /* no menu: getmenubarinfo should fail */
300  SetLastError(0xdeadbeef);
301  ret = pGetMenuBarInfo(hwnd, OBJID_MENU, 0, &mbi);
302  err = GetLastError();
303  ok(ret == FALSE, "GetMenuBarInfo should not have been successful\n");
304  ok(err == 0xdeadbeef, "err = %d\n", err);
305 
306  /* create menubar, no items yet */
307  hmenu = CreateMenu();
308  ok(hmenu != NULL, "CreateMenu failed with error %d\n", GetLastError());
309 
310  ret = SetMenu(hwnd, hmenu);
311  ok(ret, "SetMenu failed with error %d\n", GetLastError());
312 
313  SetLastError(0xdeadbeef);
314  ret = pGetMenuBarInfo(NULL, OBJID_CLIENT, 0, &mbi);
315  err = GetLastError();
316  ok(!ret, "GetMenuBarInfo succeeded\n");
317  ok(err == ERROR_INVALID_WINDOW_HANDLE, "err = %d\n", err);
318 
319  SetLastError(0xdeadbeef);
320  ret = pGetMenuBarInfo(hwnd, OBJID_CLIENT, 0, &mbi);
321  err = GetLastError();
322  ok(!ret, "GetMenuBarInfo succeeded\n");
323  ok(err==ERROR_INVALID_MENU_HANDLE || broken(err==0xdeadbeef) /* NT, W2K, XP */, "err = %d\n", err);
324 
325  SetLastError(0xdeadbeef);
326  ret = pGetMenuBarInfo(hwnd, OBJID_MENU, -1, &mbi);
327  err = GetLastError();
328  ok(ret == FALSE, "GetMenuBarInfo should have failed\n");
329  ok(err == 0xdeadbeef, "err = %d\n", err);
330 
331  mbi.cbSize = 1000;
332  SetLastError(0xdeadbeef);
333  ret = pGetMenuBarInfo(hwnd, OBJID_MENU, 0, &mbi);
334  err = GetLastError();
335  ok(ret == FALSE, "GetMenuBarInfo should have failed\n");
336  ok(err == ERROR_INVALID_PARAMETER, "err = %d\n", err);
337  mbi.cbSize = sizeof(MENUBARINFO);
338 
339  SetLastError(0xdeadbeef);
340  ret = pGetMenuBarInfo(hwnd, 123, 0, &mbi);
341  err = GetLastError();
342  ok(ret == FALSE, "GetMenuBarInfo should have failed\n");
343  ok(err == 0xdeadbeef, "err = %d\n", err);
344 
345  ret = pGetMenuBarInfo(hwnd, OBJID_MENU, 0, &mbi);
346  ok(ret, "GetMenuBarInfo failed with error %d\n", GetLastError());
347 
348  ok(mbi.rcBar.left == 0 && mbi.rcBar.top == 0 && mbi.rcBar.bottom == 0 && mbi.rcBar.right == 0,
349  "rcBar: Expected (0,0)-(0,0), got: %s\n", wine_dbgstr_rect(&mbi.rcBar));
350  ok(mbi.hMenu == hmenu, "hMenu: Got %p instead of %p\n",
351  mbi.hMenu, hmenu);
352  ok(mbi.fBarFocused == 0, "fBarFocused: Got %d instead of 0.\n", mbi.fBarFocused);
353  ok(mbi.fFocused == 0, "fFocused: Got %d instead of 0.\n", mbi.fFocused);
354 
355  /* add some items */
356  ret = AppendMenuA(hmenu, MF_STRING , 100, "item 1");
357  ok(ret, "AppendMenu failed.\n");
358  ret = AppendMenuA(hmenu, MF_STRING , 101, "item 2");
359  ok(ret, "AppendMenu failed.\n");
360  ret = SetMenu(hwnd, hmenu);
361  ok(ret, "SetMenu failed with error %d\n", GetLastError());
362 
363  SetLastError(0xdeadbeef);
364  ret = pGetMenuBarInfo(hwnd, OBJID_MENU, 200, &mbi);
365  err = GetLastError();
366  ok(ret == FALSE, "GetMenuBarInfo should have failed\n");
367  ok(err == 0xdeadbeef, "err = %d\n", err);
368 
369  /* get info for the whole menu */
370  ret = pGetMenuBarInfo(hwnd, OBJID_MENU, 0, &mbi);
371  ok(ret, "GetMenuBarInfo failed with error %d\n", GetLastError());
372 
373  /* calculate menu rectangle, from window rectangle and the position of the first item */
374  ret = GetWindowRect(hwnd, &rcw);
375  ok(ret, "GetWindowRect failed.\n");
376  ret = GetMenuItemRect(hwnd, hmenu, 0, &rci);
377  ok(ret, "GetMenuItemRect failed.\n");
378  todo_wine ok(mbi.rcBar.left == rci.left && mbi.rcBar.top == rci.top &&
379  mbi.rcBar.bottom == rci.bottom && mbi.rcBar.right == rcw.right - rci.left + rcw.left,
380  "rcBar: Got %s instead of (%d,%d)-(%d,%d)\n", wine_dbgstr_rect(&mbi.rcBar),
381  rci.left, rci.top, rcw.right - rci.left + rcw.left, rci.bottom);
382  ok(mbi.hMenu == hmenu, "hMenu: Got %p instead of %p\n", mbi.hMenu, hmenu);
383  ok(mbi.fBarFocused == 0, "fBarFocused: got %d instead of 0\n", mbi.fBarFocused);
384  ok(mbi.fFocused == 0, "fFocused: got %d instead of 0\n", mbi.fFocused);
385 
386  /* get info for item nr.2 */
387  ret = pGetMenuBarInfo(hwnd, OBJID_MENU, 2, &mbi);
388  ok(ret, "GetMenuBarInfo failed with error %d\n", GetLastError());
389  ret = GetMenuItemRect(hwnd, hmenu, 1, &rci);
390  ok(ret, "GetMenuItemRect failed.\n");
391  ok(EqualRect(&mbi.rcBar, &rci), "rcBar: Got %s instead of %s\n", wine_dbgstr_rect(&mbi.rcBar),
392  wine_dbgstr_rect(&rci));
393  ok(mbi.hMenu == hmenu, "hMenu: Got %p instead of %p\n", mbi.hMenu, hmenu);
394  ok(mbi.fBarFocused == 0, "fBarFocused: got %d instead of 0\n", mbi.fBarFocused);
395  ok(mbi.fFocused == 0, "fFocused: got %d instead of 0\n", mbi.fFocused);
396 
398 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
static HMENU hmenu
Definition: win.c:66
static ATOM atomMenuCheckClass
Definition: menu.c:40
BOOL WINAPI SetMenu(HWND hWnd, HMENU hMenu)
Definition: menu.c:1497
#define MF_STRING
Definition: winuser.h:138
LONG top
Definition: windef.h:292
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
BOOL WINAPI DestroyWindow(_In_ HWND)
int32_t INT
Definition: typedefs.h:56
HMENU WINAPI CreateMenu(VOID)
Definition: menu.c:837
unsigned int BOOL
Definition: ntddk_ex.h:94
struct tagMENUBARINFO MENUBARINFO
#define ERROR_INVALID_MENU_HANDLE
Definition: winerror.h:882
#define ok(value,...)
#define CW_USEDEFAULT
Definition: winuser.h:225
smooth NULL
Definition: ftsmooth.c:416
BOOL fBarFocused
Definition: winuser.h:3704
BOOL WINAPI AppendMenuA(HMENU hMenu, UINT uFlags, UINT_PTR uIDNewItem, LPCSTR lpNewItem)
Definition: menu.c:684
const char * LPCSTR
Definition: xmlstorage.h:183
#define OBJID_CLIENT
Definition: winable.h:19
#define ERROR_INVALID_WINDOW_HANDLE
Definition: winerror.h:881
const char * wine_dbgstr_rect(const RECT *rect)
#define SetLastError(x)
Definition: compat.h:409
int ret
#define todo_wine
Definition: test.h:154
#define err(...)
#define broken(x)
Definition: _sntprintf.h:21
BOOL WINAPI EqualRect(_In_ LPCRECT, _In_ LPCRECT)
BOOL WINAPI GetMenuItemRect(_In_opt_ HWND, _In_ HMENU, _In_ UINT, _Out_ LPRECT)
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)
LONG bottom
Definition: windef.h:294
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define OBJID_MENU
Definition: winable.h:18
#define WS_VISIBLE
Definition: pedump.c:620
#define WS_SYSMENU
Definition: pedump.c:629
DWORD cbSize
Definition: winuser.h:3700
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
#define win_skip
Definition: test.h:141
#define MAKEINTATOM(i)
Definition: winbase.h:1416

Referenced by START_TEST().

◆ test_InsertMenu()

static void test_InsertMenu ( void  )
static

Definition at line 3008 of file menu.c.

3009 {
3010  HBITMAP hbm = CreateBitmap(1,1,1,1,NULL);
3011  /* Note: XP treats only bitmap handles 1 - 6 as "magic" ones
3012  * regardless of their id.
3013  */
3014  static const struct menu_data in1[] =
3015  {
3016  { MF_STRING, 1, "File" },
3018  { MF_STRING|MF_HELP, 2, "Help" }
3019  };
3020  static const struct menu_data out1[] =
3021  {
3022  { MF_STRING, 1, "File" },
3023  { MF_STRING|MF_HELP, 2, "Help" },
3025  };
3026  static const struct menu_data out1a[] =
3027  {
3028  { MF_STRING, 1, "File" },
3029  { MF_STRING|MF_HELP, 2, "Help" },
3031  };
3032  const struct menu_data in2[] =
3033  {
3034  { MF_STRING, 1, "File" },
3035  { MF_BITMAP|MF_HELP, SC_CLOSE, (char*)hbm },
3036  { MF_STRING|MF_HELP, 2, "Help" }
3037  };
3038  const struct menu_data out2[] =
3039  {
3040  { MF_STRING, 1, "File" },
3041  { MF_BITMAP|MF_HELP, SC_CLOSE, (char*)hbm },
3042  { MF_STRING|MF_HELP, 2, "Help" }
3043  };
3044  const struct menu_data out2a[] =
3045  {
3046  { MF_STRING, 1, "File" },
3047  { MF_HELP, SC_CLOSE, (char*)hbm },
3048  { MF_STRING|MF_HELP, 2, "Help" }
3049  };
3050  static const struct menu_data in3[] =
3051  {
3052  { MF_STRING, 1, "File" },
3054  { MF_STRING|MF_HELP, 2, "Help" }
3055  };
3056  static const struct menu_data out3[] =
3057  {
3058  { MF_STRING, 1, "File" },
3060  { MF_STRING|MF_HELP, 2, "Help" },
3061  };
3062  static const struct menu_data in4[] =
3063  {
3064  { MF_STRING, 1, "File" },
3065  { MF_BITMAP|MF_HELP, 1, MAKEINTRESOURCEA(1) },
3066  { MF_STRING|MF_HELP, 2, "Help" }
3067  };
3068  static const struct menu_data out4[] =
3069  {
3070  { MF_STRING, 1, "File" },
3071  { MF_STRING|MF_HELP, 2, "Help" },
3073  };
3074  static const struct menu_data out4a[] =
3075  {
3076  { MF_STRING, 1, "File" },
3077  { MF_STRING|MF_HELP, 2, "Help" },
3078  { MF_HELP, 1, MAKEINTRESOURCEA(1) }
3079  };
3080  HMENU hmenu;
3081 
3082 #define create_menu(a) create_menu_from_data((a), sizeof(a)/sizeof((a)[0]))
3083 #define create_menuitem(a) create_menuitem_from_data((a), sizeof(a)/sizeof((a)[0]))
3084 #define compare_menu(h, a) compare_menu_data((h), (a), sizeof(a)/sizeof((a)[0]))
3085 
3086  hmenu = create_menu(in1);
3087  compare_menu(hmenu, out1);
3088  DestroyMenu(hmenu);
3089 
3090  hmenu = create_menu(in2);
3091  compare_menu(hmenu, out2);
3092  DestroyMenu(hmenu);
3093 
3094  hmenu = create_menu(in3);
3095  compare_menu(hmenu, out3);
3096  DestroyMenu(hmenu);
3097 
3098  hmenu = create_menu(in4);
3099  compare_menu(hmenu, out4);
3100  DestroyMenu(hmenu);
3101 
3102  /* now using InsertMenuItemInfo */
3103  hmenu = create_menuitem(in1);
3104  compare_menu(hmenu, out1a);
3105  DestroyMenu(hmenu);
3106 
3107  hmenu = create_menuitem(in2);
3108  compare_menu(hmenu, out2a);
3109  DestroyMenu(hmenu);
3110 
3111  hmenu = create_menuitem(in3);
3112  compare_menu(hmenu, out3);
3113  DestroyMenu(hmenu);
3114 
3115  hmenu = create_menuitem(in4);
3116  compare_menu(hmenu, out4a);
3117  DestroyMenu(hmenu);
3118 
3119 #undef create_menu
3120 #undef create_menuitem
3121 #undef compare_menu
3122 }
static HMENU hmenu
Definition: win.c:66
#define create_menuitem(a)
#define MF_STRING
Definition: winuser.h:138
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581
#define compare_menu(h, a)
smooth NULL
Definition: ftsmooth.c:416
#define MF_SEPARATOR
Definition: winuser.h:137
#define MF_BITMAP
Definition: winuser.h:131
BOOL WINAPI DestroyMenu(_In_ HMENU)
_In_ HBITMAP hbm
Definition: ntgdi.h:2776
#define SC_CLOSE
Definition: winuser.h:2567
static HBITMAP
Definition: button.c:44
#define MF_HELP
Definition: winuser.h:142
#define create_menu(a)
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)

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 826 of file menu.c.

829 {
830  BOOL ret;
831  HMENU hmenu, submenu;
832  MENUITEMINFOA mii={ sizeof( MENUITEMINFOA )};
833  MENUINFO mi;
834  RECT rc;
835  CHAR text_copy[16];
836  int hastab, expect;
837  BOOL failed = FALSE;
838 
841  mii.fType = 0;
842  /* check the menu item unless MNS_CHECKORBMP is set */
843  mii.fState = (mnuopt != 2 ? MFS_CHECKED : MFS_UNCHECKED);
844  mii.dwItemData =0;
845  MODsizes[0] = bmpsize;
846  hastab = 0;
847  if( text ) {
848  char *p;
849  mii.fMask |= MIIM_STRING;
850  strcpy(text_copy, text);
851  mii.dwTypeData = text_copy; /* structure member declared non-const */
852  if( ( p = strchr( text, '\t'))) {
853  hastab = *(p + 1) ? 2 : 1;
854  }
855  }
856  /* tabs don't make sense in menubars */
857  if(hastab && !ispop) return;
858  if( hbmp) {
859  mii.fMask |= MIIM_BITMAP;
860  mii.hbmpItem = hbmp;
861  }
862  submenu = CreateMenu();
863  ok( submenu != 0, "CreateMenu failed with error %d\n", GetLastError());
864  if( ispop)
866  else
867  hmenu = CreateMenu();
868  ok( hmenu != 0, "Create{Popup}Menu failed with error %d\n", GetLastError());
869  if( hassub) {
870  mii.fMask |= MIIM_SUBMENU;
871  mii.hSubMenu = submenu;
872  }
873  if( mnuopt) {
874  mi.cbSize = sizeof(mi);
875  mi.fMask = MIM_STYLE;
876  pGetMenuInfo( hmenu, &mi);
877  if( mnuopt) mi.dwStyle |= mnuopt == 1 ? MNS_NOCHECK : MNS_CHECKORBMP;
878  ret = pSetMenuInfo( hmenu, &mi);
879  ok( ret, "SetMenuInfo failed with error %d\n", GetLastError());
880  }
881  ret = InsertMenuItemA( hmenu, 0, FALSE, &mii);
882  ok( ret, "InsertMenuItem failed with error %d\n", GetLastError());
883  failed = !ret;
884  if( winetest_debug) {
885  HDC hdc=GetDC(hwnd);
886  RECT rc = {100, 50, 400, 70};
887  char buf[100];
888 
889  sprintf( buf,"%d text \"%s\" mnuopt %d", count, text ? text: "(nil)", mnuopt);
890  FillRect( hdc, &rc, (HBRUSH) COLOR_WINDOW);
891  TextOutA( hdc, 10, 50, buf, strlen( buf));
892  ReleaseDC( hwnd, hdc);
893  }
894  if(ispop)
895  TrackPopupMenu( hmenu, TPM_RETURNCMD, 100,100, 0, hwnd, NULL);
896  else {
897  ret = SetMenu( hwnd, hmenu);
898  ok(ret, "SetMenu failed with error %d\n", GetLastError());
899  DrawMenuBar( hwnd);
900  }
901  ret = GetMenuItemRect( hwnd, hmenu, 0, &rc);
902  ok(ret, "GetMenuItemRect failed with error %d\n", GetLastError());
903 
904  if (0) /* comment out menu size checks, behavior is different in almost every Windows version */
905  /* the tests should however succeed on win2000, XP and Wine (at least up to 1.1.15) */
906  /* with a variety of dpis and desktop font sizes */
907  {
908  /* check menu width */
909  if( ispop)
910  expect = ( text || hbmp ?
911  4 + (mnuopt != 1 ? GetSystemMetrics(SM_CXMENUCHECK) : 0)
912  : 0) +
913  arrowwidth + MOD_avec + (hbmp ?
914  ((INT_PTR)hbmp<0||(INT_PTR)hbmp>12 ? bmpsize.cx + 2 : GetSystemMetrics( SM_CXMENUSIZE) + 2)
915  : 0) +
916  (text && hastab ? /* TAB space */
917  MOD_avec + ( hastab==2 ? sc_size.cx : 0) : 0) +
918  (text ? 2 + (text[0] ? size.cx :0): 0) ;
919  else
920  expect = !(text || hbmp) ? 0 :
921  ( hbmp ? (text ? 2:0) + bmpsize.cx : 0 ) +
922  (text ? 2 * MOD_avec + (text[0] ? size.cx :0): 0) ;
923  ok( rc.right - rc.left == expect,
924  "menu width wrong, got %d expected %d\n", rc.right - rc.left, expect);
925  failed = failed || !(rc.right - rc.left == expect);
926  /* check menu height */
927  if( ispop)
928  expect = max( ( !(text || hbmp) ? GetSystemMetrics( SM_CYMENUSIZE)/2 : 0),
929  max( (text ? max( 2 + size.cy, MOD_hic + 4) : 0),
930  (hbmp ?
931  ((INT_PTR)hbmp<0||(INT_PTR)hbmp>12 ?
932  bmpsize.cy + 2
934  : 0)));
935  else
936  expect = ( !(text || hbmp) ? GetSystemMetrics( SM_CYMENUSIZE)/2 :
937  max( GetSystemMetrics( SM_CYMENU) - 1, (hbmp ? bmpsize.cy : 0)));
938  ok( rc.bottom - rc.top == expect,
939  "menu height wrong, got %d expected %d (%d)\n",
941  failed = failed || !(rc.bottom - rc.top == expect);
943  /* check the position of the bitmap */
944  /* horizontal */
945  if (!ispop)
946  expect = 3;
947  else if (mnuopt == 0)
949  else if (mnuopt == 1)
950  expect = 4;
951  else /* mnuopt == 2 */
952  expect = 2;
953  ok( expect == MOD_rc[0].left,
954  "bitmap left is %d expected %d\n", MOD_rc[0].left, expect);
955  failed = failed || !(expect == MOD_rc[0].left);
956  /* vertical */
957  expect = (rc.bottom - rc.top - MOD_rc[0].bottom + MOD_rc[0].top) / 2;
958  ok( expect == MOD_rc[0].top,
959  "bitmap top is %d expected %d\n", MOD_rc[0].top, expect);
960  failed = failed || !(expect == MOD_rc[0].top);
961  }
962  }
963  /* if there was a failure, report details */
964  if( failed) {
965  trace("*** count %d %s text \"%s\" bitmap %p bmsize %d,%d textsize %d+%d,%d mnuopt %d hastab %d\n",
966  count, (ispop? "POPUP": "MENUBAR"),text ? text: "(nil)", hbmp, bmpsize.cx, bmpsize.cy,
967  size.cx, size.cy, sc_size.cx, mnuopt, hastab);
968  trace(" check %d,%d arrow %d avechar %d\n",
971  if( hbmp == HBMMENU_CALLBACK)
972  trace( " rc %s bmp.rc %s\n", wine_dbgstr_rect(&rc), wine_dbgstr_rect(&MOD_rc[0]));
973  }
974  /* clean up */
975  ret = DestroyMenu(submenu);
976  ok(ret, "DestroyMenu failed with error %d\n", GetLastError());
977  ret = DestroyMenu(hmenu);
978  ok(ret, "DestroyMenu failed with error %d\n", GetLastError());
979 }
BOOL WINAPI TrackPopupMenu(HMENU Menu, UINT Flags, int x, int y, int Reserved, HWND Wnd, CONST RECT *Rect)
Definition: menu.c:1652
static BOOL MOD_GotDrawItemMsg
Definition: menu.c:147
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define trace(...)
Definition: kmt_test.h:217
#define max(a, b)
Definition: svc.c:63
#define MIIM_FTYPE
Definition: winuser.h:724
static SIZE MODsizes[MOD_NRMENUS]
Definition: menu.c:145
#define SM_CYMENUSIZE
Definition: winuser.h:1008
static HMENU hmenu
Definition: win.c:66
ULONG_PTR dwItemData
Definition: winuser.h:3224
#define MNS_CHECKORBMP
Definition: winuser.h:755
HDC WINAPI GetDC(_In_opt_ HWND)
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
BOOL WINAPI SetMenu(HWND hWnd, HMENU hMenu)
Definition: menu.c:1497
#define TPM_RETURNCMD
Definition: winuser.h:2362
GLuint GLuint GLsizei count
Definition: gl.h:1545
char CHAR
Definition: xmlstorage.h:175
static HDC
Definition: imagelist.c:92
#define SM_CXMENUCHECK
Definition: winuser.h:1021
LONG top
Definition: windef.h:292
SIZE sc_size
Definition: menu.c:132
static int MOD_avec
Definition: menu.c:143
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
static MONITORINFO mi
Definition: win.c:7331
LONG left
Definition: windef.h:291
int32_t INT_PTR
Definition: typedefs.h:62
HMENU WINAPI CreatePopupMenu(VOID)
Definition: menu.c:846
LONG right
Definition: windef.h:293
#define COLOR_WINDOW
Definition: winuser.h:908
int winetest_debug
#define MIIM_BITMAP
Definition: winuser.h:723
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define MIIM_SUBMENU
Definition: winuser.h:718
HMENU WINAPI CreateMenu(VOID)
Definition: menu.c:837
#define SM_CYMENUCHECK
Definition: winuser.h:1022
#define MIIM_STATE
Definition: winuser.h:716
unsigned int BOOL
Definition: ntddk_ex.h:94
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
LONG cx
Definition: windef.h:319
HBITMAP hbmp
static int MOD_hic
Definition: menu.c:143
BOOL WINAPI DrawMenuBar(HWND hWnd)
Definition: menu.c:855
#define HBMMENU_CALLBACK
Definition: winuser.h:2605
GLsizeiptr size
Definition: glext.h:5919
const char * wine_dbgstr_rect(const RECT *rect)
int WINAPI GetSystemMetrics(_In_ int)
GLint left
Definition: glext.h:7726
int ret
static RECT MOD_rc[MOD_NRMENUS]
Definition: menu.c:142
HDC hdc
Definition: main.c:9
BOOL WINAPI DestroyMenu(_In_ HMENU)
#define MIIM_STRING
Definition: winuser.h:722
#define MFS_UNCHECKED
Definition: winuser.h:748
#define MNS_NOCHECK
Definition: winuser.h:750
DWORD cbSize
Definition: winuser.h:3758
BOOL WINAPI InsertMenuItemA(HMENU hMenu, UINT uItem, BOOL fByPosition, LPCMENUITEMINFOA lpmii)
Definition: menu.c:1219
#define expect(expected, got)
Definition: combo.c:36
BOOL WINAPI TextOutA(_In_ HDC hdc, _In_ int x, _In_ int y, _In_reads_(c) LPCSTR lpString, _In_ int c)
BOOL WINAPI GetMenuItemRect(_In_opt_ HWND, _In_ HMENU, _In_ UINT, _Out_ LPRECT)
char * strchr(const char *String, int ch)
Definition: utclib.c:501
struct tagMENUITEMINFOA MENUITEMINFOA
_Out_opt_ int * cx
Definition: commctrl.h:570
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
LPCSTR text
Definition: menu.c:130
LONG bottom
Definition: windef.h:294
#define SM_CYMENU
Definition: winuser.h:966
#define MFS_CHECKED
Definition: winuser.h:742
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
GLfloat GLfloat p
Definition: glext.h:8902
#define MIIM_DATA
Definition: winuser.h:721
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
LPSTR dwTypeData
Definition: winuser.h:3225
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
LONG cy
Definition: windef.h:320
#define SM_CXMENUSIZE
Definition: winuser.h:1007

Referenced by test_menu_bmp_and_string().

◆ test_menu_add_string()

static void test_menu_add_string ( void  )
static

Definition at line 1101 of file menu.c.

1102 {
1103  HMENU hmenu;
1105  BOOL rc;
1106  int ret;
1107 
1108  char string[0x80];
1109  char string2[0x80];
1110 
1111  char strback[0x80];
1112  WCHAR strbackW[0x80];
1113  static CHAR blah[] = "blah";
1114  static const WCHAR expectedString[] = {'D','u','m','m','y',' ','s','t','r','i','n','g', 0};
1115 
1116  hmenu = CreateMenu();
1117 
1118  memset( &info, 0, sizeof info );
1119  info.cbSize = sizeof info;
1121  info.dwTypeData = blah;
1122  info.cch = 6;
1123  info.dwItemData = 0;
1124  info.wID = 1;
1125  info.fState = 0;
1126  InsertMenuItemA(hmenu, 0, TRUE, &info );
1127 
1128  memset( &info, 0, sizeof info );
1129  info.cbSize = sizeof info;
1131  info.dwTypeData = string;
1132  info.cch = sizeof string;
1133  string[0] = 0;
1134  GetMenuItemInfoA( hmenu, 0, TRUE, &info );
1135 
1136  ok( !strcmp( string, "blah" ), "menu item name differed\n");
1137 
1138  /* Test combination of ownerdraw and strings with GetMenuItemString(A/W) */
1139  strcpy(string, "Dummy string");
1140  memset(&info, 0x00, sizeof(info));
1141  info.cbSize= sizeof(MENUITEMINFOA);
1142  info.fMask= MIIM_FTYPE | MIIM_STRING; /* Set OwnerDraw + typeData */
1143  info.fType= MFT_OWNERDRAW;
1144  info.dwTypeData= string;
1145  rc = InsertMenuItemA( hmenu, 0, TRUE, &info );
1146  ok (rc, "InsertMenuItem failed\n");
1147 
1148  strcpy(string,"Garbage");
1149  ok (GetMenuStringA( hmenu, 0, strback, 99, MF_BYPOSITION), "GetMenuString on ownerdraw entry failed\n");
1150  ok (!strcmp( strback, "Dummy string" ), "Menu text from Ansi version incorrect\n");
1151 
1152  SetLastError(0xdeadbeef);
1153  ret = GetMenuStringW( hmenu, 0, strbackW, 99, MF_BYPOSITION );
1155  win_skip("GetMenuStringW is not implemented\n");
1156  else
1157  {
1158  ok (ret, "GetMenuStringW on ownerdraw entry failed\n");
1159  ok (!lstrcmpW( strbackW, expectedString ), "Menu text from Unicode version incorrect\n");
1160  }
1161 
1162  /* Just try some invalid parameter tests */
1163  SetLastError(0xdeadbeef);
1164  rc = SetMenuItemInfoA( hmenu, 0, TRUE, NULL );
1165  ret = GetLastError();
1166  ok (!rc, "SetMenuItemInfoA succeeded unexpectedly\n");
1167  ok (ret == ERROR_INVALID_PARAMETER, "Expected 87, got %d\n", ret);
1168 
1169  SetLastError(0xdeadbeef);
1170  rc = SetMenuItemInfoA( hmenu, 0, FALSE, NULL );
1171  ret = GetLastError();
1172  ok (!rc, "SetMenuItemInfoA succeeded unexpectedly\n");
1173  ok (ret == ERROR_INVALID_PARAMETER, "Expected 87, got %d\n", ret);
1174 
1175  /* Just change ftype to string and see what text is stored */
1176  memset(&info, 0x00, sizeof(info));
1177  info.cbSize= sizeof(MENUITEMINFOA);
1178  info.fMask= MIIM_FTYPE; /* Set string type */
1179  info.fType= MFT_STRING;
1180  info.dwTypeData= (char *)0xdeadbeef;
1181  rc = SetMenuItemInfoA( hmenu, 0, TRUE, &info );
1182  ok (rc, "SetMenuItemInfo failed\n");
1183 
1184  /* Did we keep the old dwTypeData? */
1185  ok (GetMenuStringA( hmenu, 0, strback, 99, MF_BYPOSITION), "GetMenuString on ownerdraw entry failed\n");
1186  ok (!strcmp( strback, "Dummy string" ), "Menu text from Ansi version incorrect\n");
1187 
1188  /* Ensure change to bitmap type fails */
1189  memset(&info, 0x00, sizeof(info));
1190  info.cbSize= sizeof(MENUITEMINFOA);
1191  info.fMask= MIIM_FTYPE; /* Set as bitmap type */
1192  info.fType= MFT_BITMAP;
1193  info.dwTypeData= (char *)0xdeadbee2;
1194  rc = SetMenuItemInfoA( hmenu, 0, TRUE, &info );
1195  ok (!rc, "SetMenuItemInfo unexpectedly worked\n");
1196 
1197  /* Just change ftype back and ensure data hasn't been freed */
1198  info.fType= MFT_OWNERDRAW; /* Set as ownerdraw type */
1199  info.dwTypeData= (char *)0xdeadbee3;
1200  rc = SetMenuItemInfoA( hmenu, 0, TRUE, &info );
1201  ok (rc, "SetMenuItemInfo failed\n");
1202 
1203  /* Did we keep the old dwTypeData? */
1204  ok (GetMenuStringA( hmenu, 0, strback, 99, MF_BYPOSITION), "GetMenuString on ownerdraw entry failed\n");
1205  ok (!strcmp( strback, "Dummy string" ), "Menu text from Ansi version incorrect\n");
1206 
1207  /* Just change string value (not type) */
1208  memset(&info, 0x00, sizeof(info));
1209  info.cbSize= sizeof(MENUITEMINFOA);
1210  info.fMask= MIIM_STRING; /* Set typeData */
1211  strcpy(string2, "string2");
1212  info.dwTypeData= string2;
1213  rc = SetMenuItemInfoA( hmenu, 0, TRUE, &info );
1214  ok (rc, "SetMenuItemInfo failed\n");
1215 
1216  ok (GetMenuStringA( hmenu, 0, strback, 99, MF_BYPOSITION), "GetMenuString on ownerdraw entry failed\n");
1217  ok (!strcmp( strback, "string2" ), "Menu text from Ansi version incorrect\n");
1218 
1219  /* crashes with wine 0.9.5 */
1220  memset(&info, 0x00, sizeof(info));
1221  info.cbSize= sizeof(MENUITEMINFOA);
1222  info.fMask= MIIM_FTYPE | MIIM_STRING; /* Set OwnerDraw + typeData */
1223  info.fType= MFT_OWNERDRAW;
1224  rc = InsertMenuItemA( hmenu, 0, TRUE, &info );
1225  ok (rc, "InsertMenuItem failed\n");
1227  "GetMenuString on ownerdraw entry succeeded.\n");
1228  SetLastError(0xdeadbeef);
1231  win_skip("GetMenuStringW is not implemented\n");
1232  else