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

Go to the source code of this file.

Classes

struct  TEST_INPUT
 
struct  menu_item_pair_s
 
struct  menu_mouse_tests_s
 
struct  menu_data
 

Macros

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

Functions

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

Variables

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

Macro Definition Documentation

◆ compare_menu

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

◆ create_menu

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

◆ create_menuitem

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

◆ ER

#define ER   0

Definition at line 1390 of file menu.c.

◆ MOD_NRMENUS

#define MOD_NRMENUS   8

Definition at line 73 of file menu.c.

◆ MOD_SIZE

#define MOD_SIZE   10

Definition at line 72 of file menu.c.

◆ NR_MENUS

#define NR_MENUS   100

◆ OEMRESOURCE

#define OEMRESOURCE   /* For OBM_MNARROW */

Definition at line 27 of file menu.c.

◆ OK

#define OK   1

Definition at line 1389 of file menu.c.

◆ TMII_DONE

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

Definition at line 1375 of file menu.c.

◆ TMII_GMII

#define TMII_GMII (   c2,
  l2,
  d3,
  e3,
  f3,
  g3,
  h3,
  i3,
  j3,
  k3,
  l3,
  m3,
  expname,
  eret2,
  eret3 
)
Value:
check_menu_item_info( __LINE__, hmenu, ansi, c2, d3, e3, f3, g3, h3, i3, j3, k3, l2, l3, m3, \
expname, eret2, eret3 )
#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:1248

Definition at line 1369 of file menu.c.

◆ TMII_INSMI

#define TMII_INSMI (   c1,
  d1,
  e1,
  f1,
  g1,
  h1,
  i1,
  j1,
  k1,
  l1,
  m1,
  eret1 
)
Value:
submenu = CreateMenu();\
if(ansi)strcpy( string, init );\
else strcpyW( string, init );\
insert_menu_item( __LINE__, hmenu, ansi, c1, d1, e1, f1, g1, h1, i1, j1, k1, l1, m1, eret1 )
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:1211
#define f1(x, y, z)
Definition: sha1.c:30
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388

Definition at line 1361 of file menu.c.

◆ TMII_MODM

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

Definition at line 1381 of file menu.c.

◆ TMII_SMII

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

Definition at line 1385 of file menu.c.

Function Documentation

◆ check_menu_item_info()

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

Definition at line 1248 of file menu.c.

1252 {
1254  BOOL ret;
1255  WCHAR buffer[80];
1256 
1257  SetLastError( 0xdeadbeef );
1258  memset( &info, 0xcc, sizeof(info) );
1259  info.cbSize = sizeof(info);
1260  info.fMask = mask;
1261  info.dwTypeData = type_data;
1262  info.cch = in_len;
1263 
1264  ret = ansi ? GetMenuItemInfoA( hmenu, 0, TRUE, &info ) :
1266  if (!expect)
1267  {
1268  ok_(__FILE__, line)( !ret, "GetMenuItemInfo should have failed.\n" );
1269  return;
1270  }
1271  ok_(__FILE__, line)( ret, "GetMenuItemInfo failed, err %u\n", GetLastError());
1272  if (mask & MIIM_TYPE)
1273  ok_(__FILE__, line)( info.fType == type || info.fType == LOWORD(type),
1274  "wrong type %x/%x\n", info.fType, type );
1275  if (mask & MIIM_STATE)
1276  ok_(__FILE__, line)( info.fState == state || info.fState == LOWORD(state),
1277  "wrong state %x/%x\n", info.fState, state );
1278  if (mask & MIIM_ID)
1279  ok_(__FILE__, line)( info.wID == id || info.wID == LOWORD(id),
1280  "wrong id %x/%x\n", info.wID, id );
1281  if (mask & MIIM_SUBMENU)
1282  ok_(__FILE__, line)( info.hSubMenu == submenu || (ULONG_PTR)info.hSubMenu == LOWORD(submenu),
1283  "wrong submenu %p/%p\n", info.hSubMenu, submenu );
1284  if (mask & MIIM_CHECKMARKS)
1285  {
1286  ok_(__FILE__, line)( info.hbmpChecked == checked || (ULONG_PTR)info.hbmpChecked == LOWORD(checked),
1287  "wrong bmpchecked %p/%p\n", info.hbmpChecked, checked );
1288  ok_(__FILE__, line)( info.hbmpUnchecked == unchecked || (ULONG_PTR)info.hbmpUnchecked == LOWORD(unchecked),
1289  "wrong bmpunchecked %p/%p\n", info.hbmpUnchecked, unchecked );
1290  }
1291  if (mask & MIIM_DATA)
1292  ok_(__FILE__, line)( info.dwItemData == data || info.dwItemData == LOWORD(data),
1293  "wrong item data %lx/%lx\n", info.dwItemData, data );
1294  if (mask & MIIM_BITMAP)
1295  ok_(__FILE__, line)( info.hbmpItem == item || (ULONG_PTR)info.hbmpItem == LOWORD(item),
1296  "wrong bmpitem %p/%p\n", info.hbmpItem, item );
1297  ok_(__FILE__, line)( info.dwTypeData == type_data || (ULONG_PTR)info.dwTypeData == LOWORD(type_data),
1298  "wrong type data %p/%p\n", info.dwTypeData, type_data );
1299  ok_(__FILE__, line)( info.cch == out_len ||
1300  broken(! ansi && info.cch == 2 * out_len) /* East-Asian */,
1301  "wrong len %x/%x\n", info.cch, out_len );
1302  if (expname)
1303  {
1304  if(ansi)
1305  ok_(__FILE__, line)( !strncmp( expname, info.dwTypeData, out_len ),
1306  "menu item name differed from '%s' '%s'\n", expname, info.dwTypeData );
1307  else
1308  ok_(__FILE__, line)( !strncmpW( (WCHAR *)expname, (WCHAR *)info.dwTypeData, out_len ),
1309  "menu item name wrong\n" );
1310 
1311  SetLastError( 0xdeadbeef );
1312  ret = ansi ? GetMenuStringA( hmenu, 0, (char *)buffer, 80, MF_BYPOSITION ) :
1314  if (expstring)
1315  ok_(__FILE__, line)( ret, "GetMenuString failed, err %u\n", GetLastError());
1316  else
1317  ok_(__FILE__, line)( !ret, "GetMenuString should have failed\n" );
1318  }
1319 }
static HMENU hmenu
Definition: win.c:66
#define TRUE
Definition: types.h:120
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:1044
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:500
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:1204
#define ok_(x1, x2)
Definition: atltest.h:61

◆ check_menu_items()

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

Definition at line 2657 of file menu.c.

2659 {
2660  INT i, count;
2661 
2663  ok (count != -1, "GetMenuItemCount returned -1\n");
2664 
2665  for (i = 0; i < count; i++)
2666  {
2667  BOOL ret;
2668  MENUITEMINFOA mii;
2669 
2670  memset(&mii, 0, sizeof(mii));
2671  mii.cbSize = sizeof(mii);
2673  ret = GetMenuItemInfoA(hmenu, i, TRUE, &mii);
2674  ok(ret, "GetMenuItemInfo(%u) failed\n", i);
2675 
2676  if (winetest_debug > 1)
2677  trace("item #%u: fType %04x, fState %04x, wID %u, hSubMenu %p\n",
2678  i, mii.fType, mii.fState, mii.wID, mii.hSubMenu);
2679 
2680  if (mii.hSubMenu)
2681  {
2682  ok(mii.wID == (UINT_PTR)mii.hSubMenu, "id %u: wID %x should be equal to hSubMenu %p\n",
2683  checked_cmd, mii.wID, mii.hSubMenu);
2684  if (!GetMenuItemCount(mii.hSubMenu))
2685  {
2686  ok(mii.fType == checked_type, "id %u: expected fType %04x, got %04x\n", checked_cmd, checked_type, mii.fType);
2687  ok(mii.fState == checked_state, "id %u: expected fState %04x, got %04x\n", checked_cmd, checked_state, mii.fState);
2688  }
2689  check_menu_items(mii.hSubMenu, checked_cmd, checked_type, checked_state);
2690  }
2691  else
2692  {
2693  if (mii.wID == checked_cmd)
2694  {
2695  ok(mii.fType == checked_type, "id %u: expected fType %04x, got %04x\n", checked_cmd, checked_type, mii.fType);
2696  ok(mii.fState == checked_state, "id %u: expected fState %04x, got %04x\n", checked_cmd, checked_state, mii.fState);
2697  ok(mii.wID != 0, "id %u: not expected wID 0\n", checked_cmd);
2698  }
2699  else
2700  {
2701  ok(mii.fType != MFT_RADIOCHECK, "id %u: not expected fType MFT_RADIOCHECK on cmd %u\n", checked_cmd, mii.wID);
2702 
2703  if (mii.fType == MFT_SEPARATOR)
2704  {
2705  ok(mii.fState == MFS_GRAYED, "id %u: expected fState MFS_GRAYED, got %04x\n", checked_cmd, mii.fState);
2706  ok(mii.wID == 0, "id %u: expected wID 0, got %u\n", checked_cmd, mii.wID);
2707  }
2708  else
2709  {
2710  ok(mii.fState == 0, "id %u: expected fState 0, got %04x\n", checked_cmd, mii.fState);
2711  ok(mii.wID != 0, "id %u: not expected wID 0\n", checked_cmd);
2712  }
2713  }
2714  }
2715  }
2716 }
int WINAPI GetMenuItemCount(HMENU hmenu)
Definition: menu.c:964
#define MIIM_FTYPE
Definition: winuser.h:724
static HMENU hmenu
Definition: win.c:66
#define TRUE
Definition: types.h:120
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define MFT_RADIOCHECK
Definition: winuser.h:737
int winetest_debug
int32_t INT
Definition: typedefs.h:58
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
static void check_menu_items(HMENU hmenu, UINT checked_cmd, UINT checked_type, UINT checked_state)
Definition: menu.c:2657
#define MIIM_ID
Definition: winuser.h:717
#define trace
Definition: atltest.h:70
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 ok(value,...)
Definition: atltest.h:57
#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 2718 of file menu.c.

2719 {
2720  BOOL ret;
2721  MENUITEMINFOA mii;
2722 
2723  memset(&mii, 0, sizeof(mii));
2724  mii.cbSize = sizeof(mii);
2725  mii.fMask = MIIM_FTYPE | MIIM_STATE;
2726  ret = SetMenuItemInfoA(hmenu, id, (flags & MF_BYPOSITION) != 0, &mii);
2727  ok(ret, "SetMenuItemInfo(%u) failed\n", id);
2728 }
#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
GLbitfield flags
Definition: glext.h:7161
int ret
#define ok(value,...)
Definition: atltest.h:57
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 2269 of file menu.c.

2270 {
2271  HMENU hMenu = hMenus[mi->uMenu];
2272  TEST_INPUT i[3];
2273  MSG msg;
2274  RECT r;
2275  int screen_w = GetSystemMetrics(SM_CXSCREEN);
2276  int screen_h = GetSystemMetrics(SM_CYSCREEN);
2277  BOOL ret = GetMenuItemRect(mi->uMenu > 2 ? NULL : hWnd, hMenu, mi->uItem, &r);
2278  if(!ret) return FALSE;
2279 
2280  memset(i, 0, sizeof(i));
2281  i[0].type = i[1].type = i[2].type = INPUT_MOUSE;
2282  i[0].u.mi.dx = i[1].u.mi.dx = i[2].u.mi.dx
2283  = ((r.left + 5) * 65535) / screen_w;
2284  i[0].u.mi.dy = i[1].u.mi.dy = i[2].u.mi.dy
2285  = ((r.top + 5) * 65535) / screen_h;
2286  i[0].u.mi.dwFlags = i[1].u.mi.dwFlags = i[2].u.mi.dwFlags
2288  i[0].u.mi.dwFlags |= MOUSEEVENTF_MOVE;
2289  i[1].u.mi.dwFlags |= MOUSEEVENTF_LEFTDOWN;
2290  i[2].u.mi.dwFlags |= MOUSEEVENTF_LEFTUP;
2291  ret = SendInput(3, (INPUT *) i, sizeof(INPUT));
2292 
2293  /* hack to prevent mouse message buildup in Wine */
2294  while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg );
2295  return ret;
2296 }
#define 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:70
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:7339
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
#define FALSE
Definition: types.h:117
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
UINT WINAPI SendInput(UINT, LPINPUT, int)
Definition: ntwrapper.h:344

Referenced by test_menu_input_thread().

◆ compare_menu_data()

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

Definition at line 2926 of file menu.c.

2927 {
2928  INT count, i;
2929  BOOL ret;
2930 
2932  ok(count == item_count, "expected %d, got %d menu items\n", count, item_count);
2933 
2934  for (i = 0; i < count; i++)
2935  {
2936  char buf[20];
2937  MENUITEMINFOA mii;
2938 
2939  memset(&mii, 0, sizeof(mii));
2940  mii.cbSize = sizeof(mii);
2941  mii.dwTypeData = buf;
2942  mii.cch = sizeof(buf);
2944  ret = GetMenuItemInfoA(hmenu, i, TRUE, &mii);
2945  ok(ret, "GetMenuItemInfo(%u) failed\n", i);
2946 
2947  if (winetest_debug > 1)
2948  trace("item #%u: fType %04x, fState %04x, wID %04x, hbmp %p\n",
2949  i, mii.fType, mii.fState, mii.wID, mii.hbmpItem);
2950 
2951  ok(mii.fType == item[i].type,
2952  "%u: expected fType %04x, got %04x\n", i, item[i].type, mii.fType);
2953  ok(mii.wID == item[i].id,
2954  "%u: expected wID %04x, got %04x\n", i, item[i].id, mii.wID);
2955  if (mii.hbmpItem || !item[i].str)
2956  /* For some reason Windows sets high word to not 0 for
2957  * not "magic" ids.
2958  */
2959  ok(LOWORD(mii.hbmpItem) == LOWORD(item[i].str),
2960  "%u: expected hbmpItem %p, got %p\n", i, item[i].str, mii.hbmpItem);
2961  else
2962  {
2963  ok(mii.cch == strlen(item[i].str),
2964  "%u: expected cch %u, got %u\n", i, (UINT)strlen(item[i].str), mii.cch);
2965  ok(!strcmp(mii.dwTypeData, item[i].str),
2966  "%u: expected dwTypeData %s, got %s\n", i, item[i].str, (LPCSTR)mii.dwTypeData);
2967  }
2968  }
2969 }
int WINAPI GetMenuItemCount(HMENU hmenu)
Definition: menu.c:964
#define MIIM_FTYPE
Definition: winuser.h:724
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
#define TRUE
Definition: types.h:120
GLuint GLuint GLsizei count
Definition: gl.h:1545
int winetest_debug
int32_t INT
Definition: typedefs.h:58
#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
const WCHAR * str
const char * LPCSTR
Definition: xmlstorage.h:183
#define MIIM_ID
Definition: winuser.h:717
#define trace
Definition: atltest.h:70
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
#define ok(value,...)
Definition: atltest.h:57
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:3226
#define LOWORD(l)
Definition: pedump.c:82

◆ create_menu_from_data()

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

Definition at line 2865 of file menu.c.

2866 {
2867  HMENU hmenu;
2868  INT i;
2869  BOOL ret;
2870 
2871  hmenu = CreateMenu();
2872  assert(hmenu != 0);
2873 
2874  for (i = 0; i < item_count; i++)
2875  {
2876  SetLastError(0xdeadbeef);
2877  ret = AppendMenuA(hmenu, item[i].type, item[i].id, item[i].str);
2878  ok(ret, "%d: AppendMenu(%04x, %04x, %p) error %u\n",
2879  i, item[i].type, item[i].id, item[i].str, GetLastError());
2880  }
2881  return hmenu;
2882 }
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:1044
int32_t INT
Definition: typedefs.h:58
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
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:500
int ret
static ATOM item
Definition: dde.c:856
#define ok(value,...)
Definition: atltest.h:57
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 2887 of file menu.c.

2888 {
2889  HMENU hmenu;
2890  INT i;
2891  BOOL ret;
2892  MENUITEMINFOA mii = { sizeof( MENUITEMINFOA) };
2893 
2894  hmenu = CreateMenu();
2895  assert(hmenu != 0);
2896 
2897  for (i = 0; i < item_count; i++)
2898  {
2899  SetLastError(0xdeadbeef);
2900 
2901  mii.fMask = MIIM_FTYPE | MIIM_ID | MIIM_STATE;
2902  mii.fType = 0;
2903  if( item[i].type & MFT_BITMAP)
2904  {
2905  mii.fMask |= MIIM_BITMAP;
2906  mii.hbmpItem = (HBITMAP)item[i].str;
2907  }
2908  else if( item[i].type & MFT_SEPARATOR)
2909  mii.fType = MFT_SEPARATOR;
2910  else
2911  {
2912  mii.fMask |= MIIM_STRING;
2913  mii.dwTypeData = (LPSTR)item[i].str;
2914  mii.cch = strlen( item[i].str);
2915  }
2916  mii.fState = 0;
2917  if( item[i].type & MF_HELP) mii.fType |= MF_HELP;
2918  mii.wID = item[i].id;
2919  ret = InsertMenuItemA( hmenu, -1, TRUE, &mii);
2920  ok(ret, "%d: InsertMenuItem(%04x, %04x, %p) error %u\n",
2921  i, item[i].type, item[i].id, item[i].str, GetLastError());
2922  }
2923  return hmenu;
2924 }
#define MIIM_FTYPE
Definition: winuser.h:724
static HMENU hmenu
Definition: win.c:66
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define TRUE
Definition: types.h:120
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define assert(x)
Definition: debug.h:53
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define MFT_BITMAP
Definition: winuser.h:733
char * LPSTR
Definition: xmlstorage.h:182
int32_t INT
Definition: typedefs.h:58
#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
const WCHAR * str
#define MIIM_ID
Definition: winuser.h:717
#define SetLastError(x)
Definition: compat.h:500
#define MFT_SEPARATOR
Definition: winuser.h:739
int ret
#define MIIM_STRING
Definition: winuser.h:722
static ATOM item
Definition: dde.c:856
#define ok(value,...)
Definition: atltest.h:57
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:3226
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 3808 of file menu.c.

3809 {
3810  while (IsMenu( (HMENU)id )) id++;
3811  return (HMENU)id;
3812 }
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().

◆ insert_menu_item()

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

Definition at line 1218 of file menu.c.

1221 {
1223  BOOL ret;
1224 
1225  /* magic bitmap handle to test smaller cbSize */
1226  if (item == (HBITMAP)(ULONG_PTR)0xdeadbeef)
1227  info.cbSize = FIELD_OFFSET(MENUITEMINFOA,hbmpItem);
1228  else
1229  info.cbSize = sizeof(info);
1230  info.fMask = mask;
1231  info.fType = type;
1232  info.fState = state;
1233  info.wID = id;
1234  info.hSubMenu = submenu;
1235  info.hbmpChecked = checked;
1236  info.hbmpUnchecked = unchecked;
1237  info.dwItemData = data;
1238  info.dwTypeData = type_data;
1239  info.cch = len;
1240  info.hbmpItem = item;
1241  SetLastError( 0xdeadbeef );
1242  if (ansi) ret = InsertMenuItemA( hmenu, 0, TRUE, &info );
1243  else ret = InsertMenuItemW( hmenu, 0, TRUE, (MENUITEMINFOW*)&info );
1244  if (!expect) ok_(__FILE__, line)( !ret, "InsertMenuItem should have failed.\n" );
1245  else ok_(__FILE__, line)( ret, "InsertMenuItem failed, err %u\n", GetLastError());
1246 }
static HMENU hmenu
Definition: win.c:66
#define TRUE
Definition: types.h:120
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
struct _test_info info[]
Definition: SetCursorPos.c:19
uint32_t ULONG_PTR
Definition: typedefs.h:65
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:500
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:255
#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
#define ok_(x1, x2)
Definition: atltest.h:61

◆ menu_cancelmode_wnd_proc()

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

Definition at line 3457 of file menu.c.

3459 {
3460  switch (msg)
3461  {
3462  case WM_ENTERMENULOOP:
3463  g_got_enteridle = 0;
3464  return SendMessageA( g_hwndtosend, WM_CANCELMODE, 0, 0);
3465  case WM_ENTERIDLE:
3466  {
3467  if( g_got_enteridle++ == 0) {
3468  /* little hack to get another WM_ENTERIDLE message */
3469  PostMessageA( hwnd, WM_MOUSEMOVE, 0, 0);
3470  return SendMessageA( g_hwndtosend, WM_CANCELMODE, 0, 0);
3471  }
3472  EndMenu();
3473  return TRUE;
3474  }
3475  }
3476  return DefWindowProcA( hwnd, msg, wparam, lparam);
3477 }
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:3456
#define WM_ENTERMENULOOP
Definition: winuser.h:1786
static UINT WPARAM LPARAM lparam
Definition: combo.c:716
static int g_got_enteridle
Definition: menu.c:3455
#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 38 of file menu.c.

39 {
40  switch (msg)
41  {
42  case WM_ENTERMENULOOP:
43  /* mark window as having entered menu loop */
45  /* exit menu modal loop
46  * ( A SendMessage does not work on NT3.51 here ) */
47  return PostMessageA(hwnd, WM_CANCELMODE, 0, 0);
48  }
49  return DefWindowProcA(hwnd, msg, wparam, lparam);
50 }
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:5320
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 3708 of file menu.c.

3710 {
3711  HMENU hmenupopup;
3712  BOOL ret;
3713  switch (msg)
3714  {
3715  case WM_INITMENUPOPUP:
3717  hmenupopup = (HMENU) wparam;
3718  ret = AppendMenuA(hmenupopup, MF_STRING , 100, "item 1");
3719  ok(ret, "AppendMenu failed.\n");
3720  ret = AppendMenuA(hmenupopup, MF_STRING , 101, "item 2");
3721  ok(ret, "AppendMenu failed.\n");
3722  break;
3723  case WM_ENTERMENULOOP:
3725  break;
3726  case WM_INITMENU:
3727  gflag_initmenu++;
3728  break;
3729  case WM_ENTERIDLE:
3730  gflag_enteridle++;
3732  return TRUE;
3733  case WM_MENUSELECT:
3736  break;
3737  }
3738  return DefWindowProcA(hwnd, msg, wparam, lparam);
3739 }
static int gflag_enteridle
Definition: menu.c:95
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:95
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
static int gflag_initmenupopup
Definition: menu.c:95
BOOL WINAPI AppendMenuA(HMENU hMenu, UINT uFlags, UINT_PTR uIDNewItem, LPCSTR lpNewItem)
Definition: menu.c:684
static LPARAM selectitem_lp
Definition: menu.c:100
static WPARAM selectitem_wp
Definition: menu.c:99
#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:95
#define ok(value,...)
Definition: atltest.h:57
#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 103 of file menu.c.

105 {
106  static HMENU hmenupopup;
107  switch (msg)
108  {
109  case WM_INITMENUPOPUP:
111  hmenupopup = (HMENU) wparam;
112  break;
113  case WM_ENTERMENULOOP:
115  break;
116  case WM_INITMENU:
117  gflag_initmenu++;
118  break;
119  case WM_MEASUREITEM:
120  {
122  if (winetest_debug > 1)
123  trace("WM_MEASUREITEM received data %lx size %dx%d\n",
124  pmis->itemData, pmis->itemWidth, pmis->itemHeight);
125  ok( !wparam, "wrong wparam %lx\n", wparam );
126  ok( pmis->CtlType == ODT_MENU, "wrong type %x\n", pmis->CtlType );
127  MOD_odheight = pmis->itemHeight;
128  pmis->itemWidth = MODsizes[pmis->itemData].cx;
129  pmis->itemHeight = MODsizes[pmis->itemData].cy;
130  return TRUE;
131  }
132  case WM_DRAWITEM:
133  {
134  DRAWITEMSTRUCT * pdis;
135  TEXTMETRICA tm;
136  HPEN oldpen;
137  char chrs[]="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
138  SIZE sz;
139  int i;
140  pdis = (DRAWITEMSTRUCT *) lparam;
141  if (winetest_debug > 1) {
142  RECT rc;
143  GetMenuItemRect( hwnd, (HMENU)pdis->hwndItem, pdis->itemData ,&rc);
144  trace("WM_DRAWITEM received hwnd %p hmenu %p itemdata %ld item %d rc %s itemrc: %s\n",
145  hwnd, pdis->hwndItem, pdis->itemData, pdis->itemID,
147  oldpen=SelectObject( pdis->hDC, GetStockObject(
149  Rectangle( pdis->hDC, pdis->rcItem.left,pdis->rcItem.top,
150  pdis->rcItem.right,pdis->rcItem.bottom );
151  SelectObject( pdis->hDC, oldpen);
152  }
153  ok( !wparam, "wrong wparam %lx\n", wparam );
154  ok( pdis->CtlType == ODT_MENU, "wrong type %x\n", pdis->CtlType );
155  /* calculate widths of some menu texts */
156  if( ! MOD_txtsizes[0].size.cx)
157  for(i = 0; MOD_txtsizes[i].text; i++) {
158  char buf[100], *p;
159  RECT rc={0,0,0,0};
161  if( ( p = strchr( buf, '\t'))) {
162  *p = '\0';
163  DrawTextA( pdis->hDC, p + 1, -1, &rc,
165  MOD_txtsizes[i].sc_size.cx= rc.right - rc.left;
166  MOD_txtsizes[i].sc_size.cy= rc.bottom - rc.top;
167  }
168  DrawTextA( pdis->hDC, buf, -1, &rc,
170  MOD_txtsizes[i].size.cx= rc.right - rc.left;
171  MOD_txtsizes[i].size.cy= rc.bottom - rc.top;
172  }
173 
174  if( pdis->itemData > MOD_maxid) return TRUE;
175  /* store the rectangle */
176  MOD_rc[pdis->itemData] = pdis->rcItem;
177  /* calculate average character width */
178  GetTextExtentPointA( pdis->hDC, chrs, 52, &sz );
179  MOD_avec = (sz.cx + 26)/52;
180  GetTextMetricsA( pdis->hDC, &tm);
181  MOD_hic = tm.tmHeight;
183  return TRUE;
184  }
185  case WM_ENTERIDLE:
186  {
187  gflag_enteridle++;
188  ok( lparam || broken(!lparam), /* win9x, nt4 */
189  "Menu window handle is NULL!\n");
190  if( lparam) {
192  ok( hmenupopup == hmenu, "MN_GETHMENU returns %p expected %p\n",
193  hmenu, hmenupopup);
194  }
196  return TRUE;
197  }
198  case WM_MENUSELECT:
201  break;
202  }
203  return DefWindowProcA(hwnd, msg, wparam, lparam);
204 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
static int gflag_enteridle
Definition: menu.c:95
static BOOL MOD_GotDrawItemMsg
Definition: menu.c:94
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
static SIZE MODsizes[MOD_NRMENUS]
Definition: menu.c:92
static HMENU hmenu
Definition: win.c:66
static struct @1702 MOD_txtsizes[]
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#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
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:307
ULONG_PTR itemData
Definition: winuser.h:3068
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1499
static int MOD_avec
Definition: menu.c:90
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
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:95
#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
static int gflag_initmenupopup
Definition: menu.c:95
LONG cx
Definition: windef.h:334
static LPARAM selectitem_lp
Definition: menu.c:100
BOOL WINAPI GetTextMetricsA(_In_ HDC, _Out_ LPTEXTMETRICA)
Definition: text.c:200
static int MOD_hic
Definition: menu.c:90
static WPARAM selectitem_wp
Definition: menu.c:99
#define WM_ENTERIDLE
Definition: winuser.h:1731
GLsizeiptr size
Definition: glext.h:5919
#define trace
Definition: atltest.h:70
static int MOD_odheight
Definition: menu.c:91
const char * wine_dbgstr_rect(const RECT *rect)
#define WM_MEASUREITEM
Definition: winuser.h:1628
static RECT MOD_rc[MOD_NRMENUS]
Definition: menu.c:89
#define WM_CANCELMODE
Definition: winuser.h:1617
ULONG_PTR itemData
Definition: winuser.h:3621
static unsigned int MOD_maxid
Definition: menu.c:88
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:95
#define BLACK_PEN
Definition: wingdi.h:902
#define ok(value,...)
Definition: atltest.h:57
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:77
LONG bottom
Definition: windef.h:309
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:335
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 3404 of file menu.c.

3405 {
3406  switch (msg)
3407  {
3408  case WM_ENTERMENULOOP:
3409  {
3410  BOOL ret;
3411 
3412  /* try a recursive call */
3413  SetLastError(0xdeadbeef);
3414  ret = TrackPopupMenu(g_hmenu, 0, 100, 100, 0, hwnd, NULL);
3415  ok(ret == FALSE, "got %d\n", ret);
3417  broken(GetLastError() == 0xdeadbeef) /* W9x */, "got %d\n", GetLastError());
3418 
3419  /* exit menu modal loop
3420  * ( A SendMessage does not work on NT3.51 here ) */
3421  return PostMessageA(hwnd, WM_CANCELMODE, 0, 0);
3422  }
3423  }
3424  return DefWindowProcA(hwnd, msg, wparam, lparam);
3425 }
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:1044
#define FALSE
Definition: types.h:117
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
smooth NULL
Definition: ftsmooth.c:416
#define SetLastError(x)
Definition: compat.h:500
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 ok(value,...)
Definition: atltest.h:57
#define msg(x)
Definition: auth_time.c:54
static HMENU g_hmenu
Definition: menu.c:3402
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 1321 of file menu.c.

1322 {
1323  BOOL ret;
1324 
1325  SetLastError( 0xdeadbeef );
1326  if (ansi) ret = ModifyMenuA( hmenu, 0, flags, id, data );
1327  else ret = ModifyMenuW( hmenu, 0, flags, id, data );
1328  ok_(__FILE__,line)( ret, "ModifyMenuA failed, err %u\n", GetLastError());
1329 }
static HMENU hmenu
Definition: win.c:66
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
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:500
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLbitfield flags
Definition: glext.h:7161
int ret
#define ok_(x1, x2)
Definition: atltest.h:61

◆ MyTrackPopupMenu()

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

Definition at line 3281 of file menu.c.

3282 {
3283  return ex
3284  ? TrackPopupMenuEx( hmenu, flags, x, y, hwnd, ptpm)
3285  : TrackPopupMenu( hmenu, flags, x, y, 0, hwnd, NULL);
3286 }
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 206 of file menu.c.

207 {
208  WNDCLASSA wc =
209  {
210  0,
212  0,
213  0,
215  NULL,
217  (HBRUSH)(COLOR_BTNFACE+1),
218  NULL,
219  "WineMenuCheck",
220  };
221 
223 }
static ATOM atomMenuCheckClass
Definition: menu.c:36
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:812
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:38
#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 2259 of file menu.c.

2260 {
2261  TEST_INPUT i[2];
2262  memset(i, 0, sizeof(i));
2263  i[0].type = i[1].type = INPUT_KEYBOARD;
2264  i[0].u.ki.wVk = i[1].u.ki.wVk = wVk;
2265  i[1].u.ki.dwFlags = KEYEVENTF_KEYUP;
2266  SendInput(2, (INPUT *) i, sizeof(INPUT));
2267 }
#define 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
UINT WINAPI SendInput(UINT, LPINPUT, int)
Definition: ntwrapper.h:344

Referenced by test_menu_input_thread().

◆ set_menu_item_info()

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

Definition at line 1331 of file menu.c.

1335 {
1337  BOOL ret;
1338 
1339  /* magic bitmap handle to test smaller cbSize */
1340  if (item == (HBITMAP)(ULONG_PTR)0xdeadbeef)
1341  info.cbSize = FIELD_OFFSET(MENUITEMINFOA,hbmpItem);
1342  else
1343  info.cbSize = sizeof(info);
1344  info.fMask = mask;
1345  info.fType = type;
1346  info.fState = state;
1347  info.wID = id;
1348  info.hSubMenu = submenu;
1349  info.hbmpChecked = checked;
1350  info.hbmpUnchecked = unchecked;
1351  info.dwItemData = data;
1352  info.dwTypeData = type_data;
1353  info.cch = len;
1354  info.hbmpItem = item;
1355  SetLastError( 0xdeadbeef );
1356  if (ansi) ret = SetMenuItemInfoA( hmenu, 0, TRUE, &info );
1357  else ret = SetMenuItemInfoW( hmenu, 0, TRUE, (MENUITEMINFOW*)&info );
1358  ok_(__FILE__, line)( ret, "SetMenuItemInfo failed, err %u\n", GetLastError());
1359 }
static HMENU hmenu
Definition: win.c:66
#define TRUE
Definition: types.h:120
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
struct _test_info info[]
Definition: SetCursorPos.c:19
uint32_t ULONG_PTR
Definition: typedefs.h:65
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:500
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:255
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
#define ok_(x1, x2)
Definition: atltest.h:61

◆ START_TEST()

START_TEST ( menu  )

Definition at line 4250 of file menu.c.

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

◆ strcpyW()

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

Definition at line 1211 of file menu.c.

1212 {
1213  WCHAR *p = dst;
1214  while ((*p++ = *src++));
1215  return dst;
1216 }
__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 1204 of file menu.c.

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

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

620 {
621  HWND hwndmenu;
622  switch (msg)
623  {
624  case WM_ENTERIDLE:
625  hwndmenu = GetCapture();
626  if( hwndmenu) {
627  PostMessageA( hwndmenu, WM_KEYDOWN, VK_DOWN, 0);
628  PostMessageA( hwndmenu, WM_KEYDOWN, VK_RIGHT, 0);
629  PostMessageA( hwndmenu, WM_KEYDOWN, VK_RETURN, 0);
630  }
631  }
632  return DefWindowProcA(hwnd, msg, wparam, lparam);
633 }
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:2880
#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 3814 of file menu.c.

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

2731 {
2732  BOOL ret;
2733  HMENU hmenu;
2734 
2736  assert(hmenu != 0);
2737 
2738  check_menu_items(hmenu, -1, 0, 0);
2739 
2740  ret = CheckMenuRadioItem(hmenu, 100, 100, 100, MF_BYCOMMAND);
2741  ok(ret, "CheckMenuRadioItem failed\n");
2743 
2744  /* MSDN is wrong, Windows does not remove MFT_RADIOCHECK */
2745  ret = CheckMenuRadioItem(hmenu, 100, 100, -1, MF_BYCOMMAND);
2746  ok(!ret, "CheckMenuRadioItem should return FALSE\n");
2748 
2749  /* clear check */
2751  check_menu_items(hmenu, -1, 0, 0);
2752 
2753  /* first and checked items are on different menus */
2754  ret = CheckMenuRadioItem(hmenu, 0, 300, 202, MF_BYCOMMAND);
2755  ok(!ret, "CheckMenuRadioItem should return FALSE\n");
2756  check_menu_items(hmenu, -1, 0, 0);
2757 
2758  ret = CheckMenuRadioItem(hmenu, 200, 300, 202, MF_BYCOMMAND);
2759  ok(ret, "CheckMenuRadioItem failed\n");
2761 
2762  /* MSDN is wrong, Windows does not remove MFT_RADIOCHECK */
2763  ret = CheckMenuRadioItem(hmenu, 202, 202, -1, MF_BYCOMMAND);
2764  ok(!ret, "CheckMenuRadioItem should return FALSE\n");
2766 
2767  /* clear check */
2769  check_menu_items(hmenu, -1, 0, 0);
2770 
2771  /* just for fun, try to check separator */
2772  ret = CheckMenuRadioItem(hmenu, 0, 300, 0, MF_BYCOMMAND);
2773  ok(!ret, "CheckMenuRadioItem should return FALSE\n");
2774  check_menu_items(hmenu, -1, 0, 0);
2775 }
#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
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:2657
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:812
#define ok(value,...)
Definition: atltest.h:57
static void clear_ftype_and_state(HMENU hmenu, UINT id, UINT flags)
Definition: menu.c:2718
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 3741 of file menu.c.

3742 {
3743  BOOL ret;
3744  HMENU hmenu;
3745 
3748  NULL, NULL, NULL, NULL);
3749  ok(hwnd != NULL, "CreateWindowEx failed with error %d\n", GetLastError());
3751 
3752  hmenu = CreatePopupMenu();
3753  ok(hmenu != NULL, "CreateMenu failed with error %d\n", GetLastError());
3754 
3756  selectitem_wp = 0xdeadbeef;
3757  selectitem_lp = 0xdeadbeef;
3758 
3759  ret = TrackPopupMenu( hmenu, TPM_RETURNCMD, 100,100, 0, hwnd, NULL);
3760  ok(ret == 0, "got %i\n", ret);
3761 
3762  ok(gflag_initmenupopup == 1, "got %i\n", gflag_initmenupopup);
3763  ok(gflag_entermenuloop == 1, "got %i\n", gflag_entermenuloop);
3764  ok(gflag_initmenu == 1, "got %i\n", gflag_initmenu);
3765  ok(gflag_enteridle == 0, "got %i\n", gflag_initmenu);
3766 
3767  ok(selectitem_wp == 0xdeadbeef, "got %lx\n", selectitem_wp);
3768  ok(selectitem_lp == 0xdeadbeef, "got %lx\n", selectitem_lp);
3769 
3771  selectitem_wp = 0xdeadbeef;
3772  selectitem_lp = 0xdeadbeef;
3773 
3774  ret = TrackPopupMenu( hmenu, 0, 100,100, 0, hwnd, NULL);
3775  ok(ret == 0, "got %i\n", ret);
3776 
3777  ok(gflag_initmenupopup == 1, "got %i\n", gflag_initmenupopup);
3778  ok(gflag_entermenuloop == 1, "got %i\n", gflag_entermenuloop);
3779  ok(gflag_initmenu == 1, "got %i\n", gflag_initmenu);
3780  ok(gflag_enteridle == 0, "got %i\n", gflag_initmenu);
3781 
3782  ok(selectitem_wp == 0xdeadbeef, "got %lx\n", selectitem_wp);
3783  ok(selectitem_lp == 0xdeadbeef, "got %lx\n", selectitem_lp);
3784 
3786 
3788  selectitem_wp = 0xdeadbeef;
3789  selectitem_lp = 0xdeadbeef;
3790 
3791  ret = TrackPopupMenu( hmenu, 0, 100,100, 0, hwnd, NULL);
3792  ok(ret == 1, "got %i\n", ret);
3793 
3794  ok(gflag_initmenupopup == 1, "got %i\n", gflag_initmenupopup);
3795  ok(gflag_entermenuloop == 1, "got %i\n", gflag_entermenuloop);
3796  ok(gflag_initmenu == 1, "got %i\n", gflag_initmenu);
3797  ok(gflag_enteridle == 1, "got %i\n", gflag_initmenu);
3798 
3799  ok(selectitem_wp == 0xffff0000, "got %lx\n", selectitem_wp);
3800  ok(selectitem_lp == 0, "got %lx\n", selectitem_lp);
3801 
3803 
3804  ret = DestroyMenu(hmenu);
3805  ok(ret, "DestroyMenu failed with error %d\n", GetLastError());
3806 }
static int gflag_enteridle
Definition: menu.c:95
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:36
#define TPM_RETURNCMD
Definition: winuser.h:2362
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
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:3708
static int gflag_initmenu
Definition: menu.c:95
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CW_USEDEFAULT
Definition: winuser.h:225
smooth NULL
Definition: ftsmooth.c:416
static int gflag_initmenupopup
Definition: menu.c:95
static LPARAM selectitem_lp
Definition: menu.c:100
static LRESULT WINAPI menu_ownerdraw_wnd_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: menu.c:103
const char * LPCSTR
Definition: xmlstorage.h:183
static WPARAM selectitem_wp
Definition: menu.c:99
int ret
#define SetWindowLongPtrA
Definition: winuser.h:5320
#define GWLP_WNDPROC
Definition: treelist.c:66
BOOL WINAPI DestroyMenu(_In_ HMENU)
static int gflag_entermenuloop
Definition: menu.c:95
#define ok(value,...)
Definition: atltest.h:57
__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:1429

Referenced by START_TEST().

◆ test_getmenubarinfo()

static void test_getmenubarinfo ( void  )
static

Definition at line 225 of file menu.c.

226 {
227  BOOL ret;
228  HMENU hmenu;
229  MENUBARINFO mbi;
230  RECT rcw, rci;
231  HWND hwnd;
232  INT err;
233 
234  mbi.cbSize = sizeof(MENUBARINFO);
235 
238  NULL, NULL, NULL, NULL);
239  ok(hwnd != NULL, "CreateWindowEx failed with error %d\n", GetLastError());
240 
241  /* no menu: getmenubarinfo should fail */
242  SetLastError(0xdeadbeef);
243  ret = GetMenuBarInfo(hwnd, OBJID_MENU, 0, &mbi);
244  err = GetLastError();
245  ok(ret == FALSE, "GetMenuBarInfo should not have been successful\n");
246  ok(err == 0xdeadbeef, "err = %d\n", err);
247 
248  /* create menubar, no items yet */
249  hmenu = CreateMenu();
250  ok(hmenu != NULL, "CreateMenu failed with error %d\n", GetLastError());
251 
252  ret = SetMenu(hwnd, hmenu);
253  ok(ret, "SetMenu failed with error %d\n", GetLastError());
254 
255  SetLastError(0xdeadbeef);
256  ret = GetMenuBarInfo(NULL, OBJID_CLIENT, 0, &mbi);
257  err = GetLastError();
258  ok(!ret, "GetMenuBarInfo succeeded\n");
259  ok(err == ERROR_INVALID_WINDOW_HANDLE, "err = %d\n", err);
260 
261  SetLastError(0xdeadbeef);
262  ret = GetMenuBarInfo(hwnd, OBJID_CLIENT, 0, &mbi);
263  err = GetLastError();
264  ok(!ret, "GetMenuBarInfo succeeded\n");
265  ok(err==ERROR_INVALID_MENU_HANDLE || broken(err==0xdeadbeef) /* NT, W2K, XP */, "err = %d\n", err);
266 
267  SetLastError(0xdeadbeef);
268  ret = GetMenuBarInfo(hwnd, OBJID_MENU, -1, &mbi);
269  err = GetLastError();
270  ok(ret == FALSE, "GetMenuBarInfo should have failed\n");
271  ok(err == 0xdeadbeef, "err = %d\n", err);
272 
273  mbi.cbSize = 1000;
274  SetLastError(0xdeadbeef);
275  ret = GetMenuBarInfo(hwnd, OBJID_MENU, 0, &mbi);
276  err = GetLastError();
277  ok(ret == FALSE, "GetMenuBarInfo should have failed\n");
278  ok(err == ERROR_INVALID_PARAMETER, "err = %d\n", err);
279  mbi.cbSize = sizeof(MENUBARINFO);
280 
281  SetLastError(0xdeadbeef);
282  ret = GetMenuBarInfo(hwnd, 123, 0, &mbi);
283  err = GetLastError();
284  ok(ret == FALSE, "GetMenuBarInfo should have failed\n");
285  ok(err == 0xdeadbeef, "err = %d\n", err);
286 
287  ret = GetMenuBarInfo(hwnd, OBJID_MENU, 0, &mbi);
288  ok(ret, "GetMenuBarInfo failed with error %d\n", GetLastError());
289 
290  ok(mbi.rcBar.left == 0 && mbi.rcBar.top == 0 && mbi.rcBar.bottom == 0 && mbi.rcBar.right == 0,
291  "rcBar: Expected (0,0)-(0,0), got: %s\n", wine_dbgstr_rect(&mbi.rcBar));
292  ok(mbi.hMenu == hmenu, "hMenu: Got %p instead of %p\n",
293  mbi.hMenu, hmenu);
294  ok(mbi.fBarFocused == 0, "fBarFocused: Got %d instead of 0.\n", mbi.fBarFocused);
295  ok(mbi.fFocused == 0, "fFocused: Got %d instead of 0.\n", mbi.fFocused);
296 
297  /* add some items */
298  ret = AppendMenuA(hmenu, MF_STRING , 100, "item 1");
299  ok(ret, "AppendMenu failed.\n");
300  ret = AppendMenuA(hmenu, MF_STRING , 101, "item 2");
301  ok(ret, "AppendMenu failed.\n");
302  ret = SetMenu(hwnd, hmenu);
303  ok(ret, "SetMenu failed with error %d\n", GetLastError());
304 
305  SetLastError(0xdeadbeef);
306  ret = GetMenuBarInfo(hwnd, OBJID_MENU, 200, &mbi);
307  err = GetLastError();
308  ok(ret == FALSE, "GetMenuBarInfo should have failed\n");
309  ok(err == 0xdeadbeef, "err = %d\n", err);
310 
311  /* get info for the whole menu */
312  ret = GetMenuBarInfo(hwnd, OBJID_MENU, 0, &mbi);
313  ok(ret, "GetMenuBarInfo failed with error %d\n", GetLastError());
314 
315  /* calculate menu rectangle, from window rectangle and the position of the first item */
316  ret = GetWindowRect(hwnd, &rcw);
317  ok(ret, "GetWindowRect failed.\n");
318  ret = GetMenuItemRect(hwnd, hmenu, 0, &rci);
319  ok(ret, "GetMenuItemRect failed.\n");
320  todo_wine ok(mbi.rcBar.left == rci.left && mbi.rcBar.top == rci.top &&
321  mbi.rcBar.bottom == rci.bottom && mbi.rcBar.right == rcw.right - rci.left + rcw.left,
322  "rcBar: Got %s instead of (%d,%d)-(%d,%d)\n", wine_dbgstr_rect(&mbi.rcBar),
323  rci.left, rci.top, rcw.right - rci.left + rcw.left, rci.bottom);
324  ok(mbi.hMenu == hmenu, "hMenu: Got %p instead of %p\n", mbi.hMenu, hmenu);
325  ok(mbi.fBarFocused == 0, "fBarFocused: got %d instead of 0\n", mbi.fBarFocused);
326  ok(mbi.fFocused == 0, "fFocused: got %d instead of 0\n", mbi.fFocused);
327 
328  /* get info for item nr.2 */
329  ret = GetMenuBarInfo(hwnd, OBJID_MENU, 2, &mbi);
330  ok(ret, "GetMenuBarInfo failed with error %d\n", GetLastError());
331  ret = GetMenuItemRect(hwnd, hmenu, 1, &rci);
332  ok(ret, "GetMenuItemRect failed.\n");
333  ok(EqualRect(&mbi.rcBar, &rci), "rcBar: Got %s instead of %s\n", wine_dbgstr_rect(&mbi.rcBar),
334  wine_dbgstr_rect(&rci));
335  ok(mbi.hMenu == hmenu, "hMenu: Got %p instead of %p\n", mbi.hMenu, hmenu);
336  ok(mbi.fBarFocused == 0, "fBarFocused: got %d instead of 0\n", mbi.fBarFocused);
337  ok(mbi.fFocused == 0, "fFocused: got %d instead of 0\n", mbi.fFocused);
338 
340 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
static HMENU hmenu
Definition: win.c:66
static ATOM atomMenuCheckClass
Definition: menu.c:36
BOOL WINAPI SetMenu(HWND hWnd, HMENU hMenu)
Definition: menu.c:1497
#define MF_STRING
Definition: winuser.h:138
LONG top
Definition: windef.h:307
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
BOOL WINAPI DestroyWindow(_In_ HWND)
int32_t INT
Definition: typedefs.h:58
HMENU WINAPI CreateMenu(VOID)
Definition: menu.c:837
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
struct tagMENUBARINFO MENUBARINFO
#define ERROR_INVALID_MENU_HANDLE
Definition: winerror.h:882
#define CW_USEDEFAULT
Definition: winuser.h:225
smooth NULL
Definition: ftsmooth.c:416
BOOL fBarFocused
Definition: winuser.h:3705
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
BOOL WINAPI GetMenuBarInfo(_In_ HWND, _In_ LONG, _In_ LONG, _Inout_ PMENUBARINFO)
const char * wine_dbgstr_rect(const RECT *rect)
#define SetLastError(x)
Definition: compat.h:500
int ret
#define todo_wine
Definition: test.h:162
#define err(...)
#define broken(x)
Definition: _sntprintf.h:21
BOOL WINAPI EqualRect(_In_ LPCRECT, _In_ LPCRECT)
#define ok(value,...)
Definition: atltest.h:57
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:309
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:3701
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:1429

Referenced by START_TEST().

◆ test_GetMenuItemRect()

static void test_GetMenuItemRect ( void  )
static

Definition at line 342 of file menu.c.

343 {
344  HWND hwnd;
345  HMENU hmenu;
346  HMENU popup_hmenu;
347  RECT window_rect;
348  RECT item_rect;
349  POINT client_top_left;
350  INT caption_height;
351  BOOL ret;
352 
354  NULL, NULL, NULL);
355  ok(hwnd != NULL, "CreateWindow failed with error %d\n", GetLastError());
356  hmenu = CreateMenu();
357  ok(hmenu != NULL, "CreateMenu failed with error %d\n", GetLastError());
358  popup_hmenu = CreatePopupMenu();
359  ok(popup_hmenu != NULL, "CreatePopupMenu failed with error %d\n", GetLastError());
360  ret = AppendMenuA(popup_hmenu, MF_STRING, 0, "Popup");
361  ok(ret, "AppendMenu failed with error %d\n", GetLastError());
362  ret = AppendMenuA(hmenu, MF_STRING | MF_POPUP, (UINT_PTR)popup_hmenu, "Menu");
363  ok(ret, "AppendMenu failed with error %d\n", GetLastError());
364  ret = SetMenu(hwnd, hmenu);
365  ok(ret, "SetMenu failed with error %d\n", GetLastError());
366 
367  /* Get the menu item rectangle of the displayed sysmenu item */
368  ret = GetMenuItemRect(hwnd, hmenu, 0, &item_rect);
369  ok(ret, "GetMenuItemRect failed with error %d\n", GetLastError());
370  GetWindowRect(hwnd, &window_rect);
371  /* Get the screen coordinate of the left top corner of the client rectangle */
372  client_top_left.x = 0;
373  client_top_left.y = 0;
374  MapWindowPoints(hwnd, 0, &client_top_left, 1);
376 
377  ok(item_rect.left == client_top_left.x, "Expect item_rect.left %d == %d\n", item_rect.left, client_top_left.x);
378  ok(item_rect.right <= window_rect.right, "Expect item_rect.right %d <= %d\n", item_rect.right, window_rect.right);
379  /* A gap of 1 pixel is added deliberately in commit 75f9e64, so using equal operator would fail on Wine.
380  * Check that top and bottom are correct with 1 pixel margin tolerance */
381  ok(item_rect.top - (window_rect.top + caption_height) <= 1, "Expect item_rect.top %d - %d <= 1\n", item_rect.top,
382  window_rect.top + caption_height);
383  ok(item_rect.bottom - (client_top_left.y - 1) <= 1, "Expect item_rect.bottom %d - %d <= 1\n", item_rect.bottom,
384  client_top_left.y - 1);
385 
386  /* Get the item rectangle of the not yet displayed popup menu item. */
387  ret = GetMenuItemRect(hwnd, popup_hmenu, 0, &item_rect);
388  ok(ret, "GetMenuItemRect failed with error %d\n", GetLastError());
389  ok(item_rect.left == client_top_left.x, "Expect item_rect.left %d == %d\n", item_rect.left, client_top_left.x);
390  ok(item_rect.right == client_top_left.x, "Expect item_rect.right %d == %d\n", item_rect.right, client_top_left.x);
391  ok(item_rect.top == client_top_left.y, "Expect item_rect.top %d == %d\n", item_rect.top, client_top_left.y);
392  ok(item_rect.bottom == client_top_left.y, "Expect item_rect.bottom %d == %d\n", item_rect.bottom,
393  client_top_left.y);
394 
396 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
long y
Definition: polytest.cpp:48
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
static HMENU hmenu
Definition: win.c:66
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
long x
Definition: polytest.cpp:48
static ATOM atomMenuCheckClass
Definition: menu.c:36
BOOL WINAPI SetMenu(HWND hWnd, HMENU hMenu)
Definition: menu.c:1497
#define MF_STRING
Definition: winuser.h:138
LONG top
Definition: windef.h:307
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
LONG left
Definition: windef.h:306
#define SM_CYFRAME
Definition: winuser.h:986
HMENU WINAPI CreatePopupMenu(VOID)
Definition: menu.c:846
LONG right
Definition: windef.h:308
BOOL WINAPI DestroyWindow(_In_ HWND)
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4291
int32_t INT
Definition: typedefs.h:58
HMENU WINAPI CreateMenu(VOID)
Definition: menu.c:837
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI AppendMenuA(HMENU hMenu, UINT uFlags, UINT_PTR uIDNewItem, LPCSTR lpNewItem)
Definition: menu.c:684
#define SM_CYCAPTION
Definition: winuser.h:953
int WINAPI GetSystemMetrics(_In_ int)
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
int ret
#define MF_POPUP
Definition: winuser.h:136
#define ok(value,...)
Definition: atltest.h:57
BOOL WINAPI GetMenuItemRect(_In_opt_ HWND, _In_ HMENU, _In_ UINT, _Out_ LPRECT)
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
LONG bottom
Definition: windef.h:309
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
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:1429

Referenced by START_TEST().

◆ test_InsertMenu()

static void test_InsertMenu ( void  )
static

Definition at line 2971 of file menu.c.

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

810 {
811  BOOL ret;
812  HMENU hmenu, submenu;
813  MENUITEMINFOA mii={ sizeof( MENUITEMINFOA )};
814  MENUINFO mi;
815  RECT rc;
816  CHAR text_copy[16];
817  int hastab, expect;
818  BOOL failed = FALSE;
819 
822  mii.fType = 0;
823  /* check the menu item unless MNS_CHECKORBMP is set */
824  mii.fState = (mnuopt != 2 ? MFS_CHECKED : MFS_UNCHECKED);
825  mii.dwItemData =0;
826  MODsizes[0] = bmpsize;
827  hastab = 0;
828  if( text ) {
829  char *p;
830  mii.fMask |= MIIM_STRING;
831  strcpy(text_copy, text);
832  mii.dwTypeData = text_copy; /* structure member declared non-const */
833  if( ( p = strchr( text, '\t'))) {
834  hastab = *(p + 1) ? 2 : 1;
835  }
836  }
837  /* tabs don't make sense in menubars */
838  if(hastab && !ispop) return;
839  if( hbmp) {
840  mii.fMask |= MIIM_BITMAP;
841  mii.hbmpItem = hbmp;
842  }
843  submenu = CreateMenu();
844  ok( submenu != 0, "CreateMenu failed with error %d\n", GetLastError());
845  if( ispop)
847  else
848  hmenu = CreateMenu();
849  ok( hmenu != 0, "Create{Popup}Menu failed with error %d\n", GetLastError());
850  if( hassub) {
851  mii.fMask |= MIIM_SUBMENU;
852  mii.hSubMenu = submenu;
853  }
854  if( mnuopt) {
855  mi.cbSize = sizeof(mi);
856  mi.fMask = MIM_STYLE;
857  GetMenuInfo( hmenu, &mi);
858  if( mnuopt) mi.dwStyle |= mnuopt == 1 ? MNS_NOCHECK : MNS_CHECKORBMP;
859  ret = SetMenuInfo( hmenu, &mi);
860  ok( ret, "SetMenuInfo failed with error %d\n", GetLastError());
861  }
862  ret = InsertMenuItemA( hmenu, 0, FALSE, &mii);
863  ok( ret, "InsertMenuItem failed with error %d\n", GetLastError());
864  failed = !ret;
865  if( winetest_debug) {
866  HDC hdc=GetDC(hwnd);
867  RECT rc = {100, 50, 400, 70};
868  char buf[100];
869 
870  sprintf( buf,"%d text \"%s\" mnuopt %d", count, text ? text: "(nil)", mnuopt);
871  FillRect( hdc, &rc, (HBRUSH) COLOR_WINDOW);
872  TextOutA( hdc, 10, 50, buf, strlen( buf));
873  ReleaseDC( hwnd, hdc);
874  }
875  if(ispop)
876  TrackPopupMenu( hmenu, TPM_RETURNCMD, 100,100, 0, hwnd, NULL);
877  else {
878  ret = SetMenu( hwnd, hmenu);
879  ok(ret, "SetMenu failed with error %d\n", GetLastError());
880  DrawMenuBar( hwnd);
881  }
882  ret = GetMenuItemRect( hwnd, hmenu, 0, &rc);
883  ok(ret, "GetMenuItemRect failed with error %d\n", GetLastError());
884 
885  if (0) /* comment out menu size checks, behavior is different in almost every Windows version */
886  /* the tests should however succeed on win2000, XP and Wine (at least up to 1.1.15) */
887  /* with a variety of dpis and desktop font sizes */
888  {
889  /* check menu width */
890  if( ispop)
891  expect = ( text || hbmp ?
892  4 + (mnuopt != 1 ? GetSystemMetrics(SM_CXMENUCHECK) : 0)
893  : 0) +
894  arrowwidth + MOD_avec + (hbmp ?
895  ((INT_PTR)hbmp<0||(INT_PTR)hbmp>12 ? bmpsize.cx + 2 : GetSystemMetrics( SM_CXMENUSIZE) + 2)
896  : 0) +
897  (text && hastab ? /* TAB space */
898  MOD_avec + ( hastab==2 ? sc_size.cx : 0) : 0) +
899  (text ? 2 + (text[0] ? size.cx :0): 0) ;
900  else
901  expect = !(text || hbmp) ? 0 :
902  ( hbmp ? (text ? 2:0) + bmpsize.cx : 0 ) +
903  (text ? 2 * MOD_avec + (text[0] ? size.cx :0): 0) ;
904  ok( rc.right - rc.left == expect,
905  "menu width wrong, got %d expected %d\n", rc.right - rc.left, expect);
906  failed = failed || !(rc.right - rc.left == expect);
907  /* check menu height */
908  if( ispop)
909  expect = max( ( !(text || hbmp) ? GetSystemMetrics( SM_CYMENUSIZE)/2 : 0),
910  max( (text ? max( 2 + size.cy, MOD_hic + 4) : 0),
911  (hbmp ?
912  ((INT_PTR)hbmp<0||(INT_PTR)hbmp>12 ?
913  bmpsize.cy + 2
915  : 0)));
916  else
917  expect = ( !(text || hbmp) ? GetSystemMetrics( SM_CYMENUSIZE)/2 :
918  max( GetSystemMetrics( SM_CYMENU) - 1, (hbmp ? bmpsize.cy : 0)));
919  ok( rc.bottom - rc.top == expect,
920  "menu height wrong, got %d expected %d (%d)\n",
922  failed = failed || !(rc.bottom - rc.top == expect);
924  /* check the position of the bitmap */
925  /* horizontal */
926  if (!ispop)
927  expect = 3;
928  else if (mnuopt == 0)
930  else if (mnuopt == 1)
931  expect = 4;
932  else /* mnuopt == 2 */
933  expect = 2;
934  ok( expect == MOD_rc[0].left,
935  "bitmap left is %d expected %d\n", MOD_rc[0].left, expect);
936  failed = failed || !(expect == MOD_rc[0].left);
937  /* vertical */
938  expect = (rc.bottom - rc.top - MOD_rc[0].bottom + MOD_rc[0].top) / 2;
939  ok( expect == MOD_rc[0].top,
940  "bitmap top is %d expected %d\n", MOD_rc[0].top, expect);
941  failed = failed || !(expect == MOD_rc[0].top);
942  }
943  }
944  /* if there was a failure, report details */
945  if( failed) {
946  trace("*** count %d %s text \"%s\" bitmap %p bmsize %d,%d textsize %d+%d,%d mnuopt %d hastab %d\n",
947  count, (ispop? "POPUP": "MENUBAR"),text ? text: "(nil)", hbmp, bmpsize.cx, bmpsize.cy,
948  size.cx, size.cy, sc_size.cx, mnuopt, hastab);
949  trace(" check %d,%d arrow %d avechar %d\n",
952  if( hbmp == HBMMENU_CALLBACK)
953  trace( " rc %s bmp.rc %s\n", wine_dbgstr_rect(&rc), wine_dbgstr_rect(&MOD_rc[0]));
954  }
955  /* clean up */
956  ret = DestroyMenu(submenu);
957  ok(ret, "DestroyMenu failed with error %d\n", GetLastError());
958  ret = DestroyMenu(hmenu);
959  ok(ret, "DestroyMenu failed with error %d\n", GetLastError());
960 }
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:94
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define max(a, b)
Definition: svc.c:63
#define MIIM_FTYPE
Definition: winuser.h:724
static SIZE MODsizes[MOD_NRMENUS]
Definition: menu.c:92
#define SM_CYMENUSIZE
Definition: winuser.h:1008
static HMENU hmenu
Definition: win.c:66
ULONG_PTR dwItemData
Definition: winuser.h:3225
#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:307
SIZE sc_size
Definition: menu.c:79
static int MOD_avec
Definition: menu.c:90
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
static MONITORINFO mi
Definition: win.c:7339
LONG left
Definition: windef.h:306
int32_t INT_PTR
Definition: typedefs.h:64
HMENU WINAPI CreatePopupMenu(VOID)
Definition: menu.c:846
LONG right
Definition: windef.h:308
#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 FALSE
Definition: types.h:117
#define MIIM_STATE
Definition: winuser.h:716
unsigned int BOOL
Definition: ntddk_ex.h:94
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
smooth NULL
Definition: ftsmooth.c:416
LONG cx
Definition: windef.h:334
HBITMAP hbmp
static int MOD_hic
Definition: menu.c:90
BOOL WINAPI DrawMenuBar(HWND hWnd)
Definition: menu.c:855
#define HBMMENU_CALLBACK
Definition: winuser.h:2605
GLsizeiptr size
Definition: glext.h:5919
#define trace
Definition: atltest.h:70
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:89
HDC hdc
Definition: main.c:9
BOOL WINAPI SetMenuInfo(HMENU hmenu, LPCMENUINFO lpcmi)
Definition: menu.c:1508
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:3759
#define ok(value,...)
Definition: atltest.h:57
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:581
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
LPCSTR text
Definition: menu.c:77
LONG bottom
Definition: windef.h:309
#define SM_CYMENU
Definition: winuser.h:966
#define MFS_CHECKED
Definition: winuser.h:742
BOOL WINAPI GetMenuInfo(HMENU hmenu, LPMENUINFO lpcmi)
Definition: menu.c:928
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:3226
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
LONG cy
Definition: windef.h:335
#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 1076 of file menu.c.

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