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

Go to the source code of this file.

Classes

struct  TEST_INPUT
 
struct  menu_item_pair_s
 
struct  menu_mouse_tests_s
 
struct  menu_data
 

Macros

#define _WIN32_WINNT   0x0501
 
#define OEMRESOURCE   /* For OBM_MNARROW */
 
#define 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

◆ _WIN32_WINNT

#define _WIN32_WINNT   0x0501

Definition at line 23 of file menu.c.

◆ compare_menu

#define compare_menu (   h,
  a 
)    compare_menu_data((h), (a), 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 1394 of file menu.c.

◆ MOD_NRMENUS

#define MOD_NRMENUS   8

Definition at line 77 of file menu.c.

◆ MOD_SIZE

#define MOD_SIZE   10

Definition at line 76 of file menu.c.

◆ NR_MENUS

#define NR_MENUS   100

◆ OEMRESOURCE

#define OEMRESOURCE   /* For OBM_MNARROW */

Definition at line 31 of file menu.c.

◆ OK

#define OK   1

Definition at line 1393 of file menu.c.

◆ TMII_DONE

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

Definition at line 1379 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:1252

Definition at line 1373 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:1215
#define f1(x, y, z)
Definition: sha1.c:30
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388

Definition at line 1365 of file menu.c.

◆ TMII_MODM

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

Definition at line 1385 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 1389 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 1252 of file menu.c.

1256 {
1258  BOOL ret;
1259  WCHAR buffer[80];
1260 
1261  SetLastError( 0xdeadbeef );
1262  memset( &info, 0xcc, sizeof(info) );
1263  info.cbSize = sizeof(info);
1264  info.fMask = mask;
1265  info.dwTypeData = type_data;
1266  info.cch = in_len;
1267 
1268  ret = ansi ? GetMenuItemInfoA( hmenu, 0, TRUE, &info ) :
1270  if (!expect)
1271  {
1272  ok_(__FILE__, line)( !ret, "GetMenuItemInfo should have failed.\n" );
1273  return;
1274  }
1275  ok_(__FILE__, line)( ret, "GetMenuItemInfo failed, err %u\n", GetLastError());
1276  if (mask & MIIM_TYPE)
1277  ok_(__FILE__, line)( info.fType == type || info.fType == LOWORD(type),
1278  "wrong type %x/%x\n", info.fType, type );
1279  if (mask & MIIM_STATE)
1280  ok_(__FILE__, line)( info.fState == state || info.fState == LOWORD(state),
1281  "wrong state %x/%x\n", info.fState, state );
1282  if (mask & MIIM_ID)
1283  ok_(__FILE__, line)( info.wID == id || info.wID == LOWORD(id),
1284  "wrong id %x/%x\n", info.wID, id );
1285  if (mask & MIIM_SUBMENU)
1286  ok_(__FILE__, line)( info.hSubMenu == submenu || (ULONG_PTR)info.hSubMenu == LOWORD(submenu),
1287  "wrong submenu %p/%p\n", info.hSubMenu, submenu );
1288  if (mask & MIIM_CHECKMARKS)
1289  {
1290  ok_(__FILE__, line)( info.hbmpChecked == checked || (ULONG_PTR)info.hbmpChecked == LOWORD(checked),
1291  "wrong bmpchecked %p/%p\n", info.hbmpChecked, checked );
1292  ok_(__FILE__, line)( info.hbmpUnchecked == unchecked || (ULONG_PTR)info.hbmpUnchecked == LOWORD(unchecked),
1293  "wrong bmpunchecked %p/%p\n", info.hbmpUnchecked, unchecked );
1294  }
1295  if (mask & MIIM_DATA)
1296  ok_(__FILE__, line)( info.dwItemData == data || info.dwItemData == LOWORD(data),
1297  "wrong item data %lx/%lx\n", info.dwItemData, data );
1298  if (mask & MIIM_BITMAP)
1299  ok_(__FILE__, line)( info.hbmpItem == item || (ULONG_PTR)info.hbmpItem == LOWORD(item),
1300  "wrong bmpitem %p/%p\n", info.hbmpItem, item );
1301  ok_(__FILE__, line)( info.dwTypeData == type_data || (ULONG_PTR)info.dwTypeData == LOWORD(type_data),
1302  "wrong type data %p/%p\n", info.dwTypeData, type_data );
1303  ok_(__FILE__, line)( info.cch == out_len ||
1304  broken(! ansi && info.cch == 2 * out_len) /* East-Asian */,
1305  "wrong len %x/%x\n", info.cch, out_len );
1306  if (expname)
1307  {
1308  if(ansi)
1309  ok_(__FILE__, line)( !strncmp( expname, info.dwTypeData, out_len ),
1310  "menu item name differed from '%s' '%s'\n", expname, info.dwTypeData );
1311  else
1312  ok_(__FILE__, line)( !strncmpW( (WCHAR *)expname, (WCHAR *)info.dwTypeData, out_len ),
1313  "menu item name wrong\n" );
1314 
1315  SetLastError( 0xdeadbeef );
1316  ret = ansi ? GetMenuStringA( hmenu, 0, (char *)buffer, 80, MF_BYPOSITION ) :
1318  if (expstring)
1319  ok_(__FILE__, line)( ret, "GetMenuString failed, err %u\n", GetLastError());
1320  else
1321  ok_(__FILE__, line)( !ret, "GetMenuString should have failed\n" );
1322  }
1323 }
#define TRUE
Definition: types.h:120
static HMENU hmenu
Definition: win.c:66
int WINAPI GetMenuStringA(HMENU hMenu, UINT uIDItem, LPSTR lpString, int nMaxCount, UINT uFlag)
Definition: menu.c:1075
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
GLuint buffer
Definition: glext.h:5915
int WINAPI GetMenuStringW(HMENU hMenu, UINT uIDItem, LPWSTR lpString, int nMaxCount, UINT uFlag)
Definition: menu.c:1110
#define MIIM_BITMAP
Definition: winuser.h:723
struct _test_info info[]
Definition: SetCursorPos.c:19
#define MIIM_SUBMENU
Definition: winuser.h:718
GLenum GLint GLuint mask
Definition: glext.h:6028
#define MIIM_STATE
Definition: winuser.h:716
unsigned int BOOL
Definition: ntddk_ex.h:94
#define MF_BYPOSITION
Definition: winuser.h:203
BOOL WINAPI GetMenuItemInfoW(HMENU hMenu, UINT Item, BOOL bypos, LPMENUITEMINFOW lpmii)
Definition: menu.c:1020
Definition: parser.c:48
#define MIIM_ID
Definition: winuser.h:717
__wchar_t WCHAR
Definition: xmlstorage.h:180
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
#define SetLastError(x)
Definition: compat.h:417
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:1208
#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 2661 of file menu.c.

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

2723 {
2724  BOOL ret;
2725  MENUITEMINFOA mii;
2726 
2727  memset(&mii, 0, sizeof(mii));
2728  mii.cbSize = sizeof(mii);
2729  mii.fMask = MIIM_FTYPE | MIIM_STATE;
2730  ret = SetMenuItemInfoA(hmenu, id, (flags & MF_BYPOSITION) != 0, &mii);
2731  ok(ret, "SetMenuItemInfo(%u) failed\n", id);
2732 }
#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 2273 of file menu.c.

2274 {
2275  HMENU hMenu = hMenus[mi->uMenu];
2276  TEST_INPUT i[3];
2277  MSG msg;
2278  RECT r;
2279  int screen_w = GetSystemMetrics(SM_CXSCREEN);
2280  int screen_h = GetSystemMetrics(SM_CYSCREEN);
2281  BOOL ret = GetMenuItemRect(mi->uMenu > 2 ? NULL : hWnd, hMenu, mi->uItem, &r);
2282  if(!ret) return FALSE;
2283 
2284  memset(i, 0, sizeof(i));
2285  i[0].type = i[1].type = i[2].type = INPUT_MOUSE;
2286  i[0].u.mi.dx = i[1].u.mi.dx = i[2].u.mi.dx
2287  = ((r.left + 5) * 65535) / screen_w;
2288  i[0].u.mi.dy = i[1].u.mi.dy = i[2].u.mi.dy
2289  = ((r.top + 5) * 65535) / screen_h;
2290  i[0].u.mi.dwFlags = i[1].u.mi.dwFlags = i[2].u.mi.dwFlags
2292  i[0].u.mi.dwFlags |= MOUSEEVENTF_MOVE;
2293  i[1].u.mi.dwFlags |= MOUSEEVENTF_LEFTDOWN;
2294  i[2].u.mi.dwFlags |= MOUSEEVENTF_LEFTUP;
2295  ret = SendInput(3, (INPUT *) i, sizeof(INPUT));
2296 
2297  /* hack to prevent mouse message buildup in Wine */
2298  while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg );
2299  return ret;
2300 }
#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:74
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
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 2930 of file menu.c.

2931 {
2932  INT count, i;
2933  BOOL ret;
2934 
2936  ok(count == item_count, "expected %d, got %d menu items\n", count, item_count);
2937 
2938  for (i = 0; i < count; i++)
2939  {
2940  char buf[20];
2941  MENUITEMINFOA mii;
2942 
2943  memset(&mii, 0, sizeof(mii));
2944  mii.cbSize = sizeof(mii);
2945  mii.dwTypeData = buf;
2946  mii.cch = sizeof(buf);
2948  ret = GetMenuItemInfoA(hmenu, i, TRUE, &mii);
2949  ok(ret, "GetMenuItemInfo(%u) failed\n", i);
2950 
2951  if (winetest_debug > 1)
2952  trace("item #%u: fType %04x, fState %04x, wID %04x, hbmp %p\n",
2953  i, mii.fType, mii.fState, mii.wID, mii.hbmpItem);
2954 
2955  ok(mii.fType == item[i].type,
2956  "%u: expected fType %04x, got %04x\n", i, item[i].type, mii.fType);
2957  ok(mii.wID == item[i].id,
2958  "%u: expected wID %04x, got %04x\n", i, item[i].id, mii.wID);
2959  if (mii.hbmpItem || !item[i].str)
2960  /* For some reason Windows sets high word to not 0 for
2961  * not "magic" ids.
2962  */
2963  ok(LOWORD(mii.hbmpItem) == LOWORD(item[i].str),
2964  "%u: expected hbmpItem %p, got %p\n", i, item[i].str, mii.hbmpItem);
2965  else
2966  {
2967  ok(mii.cch == strlen(item[i].str),
2968  "%u: expected cch %u, got %u\n", i, (UINT)strlen(item[i].str), mii.cch);
2969  ok(!strcmp(mii.dwTypeData, item[i].str),
2970  "%u: expected dwTypeData %s, got %s\n", i, item[i].str, (LPCSTR)mii.dwTypeData);
2971  }
2972  }
2973 }
int WINAPI GetMenuItemCount(HMENU hmenu)
Definition: menu.c:964
#define MIIM_FTYPE
Definition: winuser.h:724
#define TRUE
Definition: types.h:120
static HMENU hmenu
Definition: win.c:66
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLuint GLuint GLsizei count
Definition: gl.h:1545
int winetest_debug
int32_t INT
Definition: typedefs.h:56
#define MIIM_BITMAP
Definition: winuser.h:723
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int BOOL
Definition: ntddk_ex.h:94
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 2869 of file menu.c.

2870 {
2871  HMENU hmenu;
2872  INT i;
2873  BOOL ret;
2874 
2875  hmenu = CreateMenu();
2876  assert(hmenu != 0);
2877 
2878  for (i = 0; i < item_count; i++)
2879  {
2880  SetLastError(0xdeadbeef);
2881  ret = AppendMenuA(hmenu, item[i].type, item[i].id, item[i].str);
2882  ok(ret, "%d: AppendMenu(%04x, %04x, %p) error %u\n",
2883  i, item[i].type, item[i].id, item[i].str, GetLastError());
2884  }
2885  return hmenu;
2886 }
static HMENU hmenu
Definition: win.c:66
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define assert(x)
Definition: debug.h:53
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
int32_t INT
Definition: typedefs.h:56
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
HMENU WINAPI CreateMenu(VOID)
Definition: menu.c:837
unsigned int BOOL
Definition: ntddk_ex.h:94
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:417
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 2891 of file menu.c.

2892 {
2893  HMENU hmenu;
2894  INT i;
2895  BOOL ret;
2896  MENUITEMINFOA mii = { sizeof( MENUITEMINFOA) };
2897 
2898  hmenu = CreateMenu();
2899  assert(hmenu != 0);
2900 
2901  for (i = 0; i < item_count; i++)
2902  {
2903  SetLastError(0xdeadbeef);
2904 
2905  mii.fMask = MIIM_FTYPE | MIIM_ID | MIIM_STATE;
2906  mii.fType = 0;
2907  if( item[i].type & MFT_BITMAP)
2908  {
2909  mii.fMask |= MIIM_BITMAP;
2910  mii.hbmpItem = (HBITMAP)item[i].str;
2911  }
2912  else if( item[i].type & MFT_SEPARATOR)
2913  mii.fType = MFT_SEPARATOR;
2914  else
2915  {
2916  mii.fMask |= MIIM_STRING;
2917  mii.dwTypeData = (LPSTR)item[i].str;
2918  mii.cch = strlen( item[i].str);
2919  }
2920  mii.fState = 0;
2921  if( item[i].type & MF_HELP) mii.fType |= MF_HELP;
2922  mii.wID = item[i].id;
2923  ret = InsertMenuItemA( hmenu, -1, TRUE, &mii);
2924  ok(ret, "%d: InsertMenuItem(%04x, %04x, %p) error %u\n",
2925  i, item[i].type, item[i].id, item[i].str, GetLastError());
2926  }
2927  return hmenu;
2928 }
#define MIIM_FTYPE
Definition: winuser.h:724
#define TRUE
Definition: types.h:120
static HMENU hmenu
Definition: win.c:66
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define assert(x)
Definition: debug.h:53
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define MFT_BITMAP
Definition: winuser.h:733
char * LPSTR
Definition: xmlstorage.h:182
int32_t INT
Definition: typedefs.h:56
#define MIIM_BITMAP
Definition: winuser.h:723
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
HMENU WINAPI CreateMenu(VOID)
Definition: menu.c:837
#define MIIM_STATE
Definition: winuser.h:716
unsigned int BOOL
Definition: ntddk_ex.h:94
const WCHAR * str
#define MIIM_ID
Definition: winuser.h:717
#define SetLastError(x)
Definition: compat.h:417
#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 3812 of file menu.c.

3813 {
3814  while (IsMenu( (HMENU)id )) id++;
3815  return (HMENU)id;
3816 }
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 1222 of file menu.c.

1225 {
1227  BOOL ret;
1228 
1229  /* magic bitmap handle to test smaller cbSize */
1230  if (item == (HBITMAP)(ULONG_PTR)0xdeadbeef)
1231  info.cbSize = FIELD_OFFSET(MENUITEMINFOA,hbmpItem);
1232  else
1233  info.cbSize = sizeof(info);
1234  info.fMask = mask;
1235  info.fType = type;
1236  info.fState = state;
1237  info.wID = id;
1238  info.hSubMenu = submenu;
1239  info.hbmpChecked = checked;
1240  info.hbmpUnchecked = unchecked;
1241  info.dwItemData = data;
1242  info.dwTypeData = type_data;
1243  info.cch = len;
1244  info.hbmpItem = item;
1245  SetLastError( 0xdeadbeef );
1246  if (ansi) ret = InsertMenuItemA( hmenu, 0, TRUE, &info );
1247  else ret = InsertMenuItemW( hmenu, 0, TRUE, (MENUITEMINFOW*)&info );
1248  if (!expect) ok_(__FILE__, line)( !ret, "InsertMenuItem should have failed.\n" );
1249  else ok_(__FILE__, line)( ret, "InsertMenuItem failed, err %u\n", GetLastError());
1250 }
#define TRUE
Definition: types.h:120
static HMENU hmenu
Definition: win.c:66
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
struct _test_info info[]
Definition: SetCursorPos.c:19
uint32_t ULONG_PTR
Definition: typedefs.h:63
GLenum GLint GLuint mask
Definition: glext.h:6028
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: parser.c:48
#define SetLastError(x)
Definition: compat.h:417
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
int ret
static int state
Definition: maze.c:121
GLenum GLsizei len
Definition: glext.h:6722
static ATOM item
Definition: dde.c:856
BOOL WINAPI InsertMenuItemA(HMENU hMenu, UINT uItem, BOOL fByPosition, LPCMENUITEMINFOA lpmii)
Definition: menu.c:1219
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
#define expect(expected, got)
Definition: combo.c:36
BOOL WINAPI InsertMenuItemW(HMENU hMenu, UINT uItem, BOOL fByPosition, LPCMENUITEMINFOW lpmii)
Definition: menu.c:1262
GLenum GLuint id
Definition: glext.h:5579
static HBITMAP
Definition: button.c:44
#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 3461 of file menu.c.

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

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

3714 {
3715  HMENU hmenupopup;
3716  BOOL ret;
3717  switch (msg)
3718  {
3719  case WM_INITMENUPOPUP:
3721  hmenupopup = (HMENU) wparam;
3722  ret = AppendMenuA(hmenupopup, MF_STRING , 100, "item 1");
3723  ok(ret, "AppendMenu failed.\n");
3724  ret = AppendMenuA(hmenupopup, MF_STRING , 101, "item 2");
3725  ok(ret, "AppendMenu failed.\n");
3726  break;
3727  case WM_ENTERMENULOOP:
3729  break;
3730  case WM_INITMENU:
3731  gflag_initmenu++;
3732  break;
3733  case WM_ENTERIDLE:
3734  gflag_enteridle++;
3736  return TRUE;
3737  case WM_MENUSELECT:
3740  break;
3741  }
3742  return DefWindowProcA(hwnd, msg, wparam, lparam);
3743 }
static int gflag_enteridle
Definition: menu.c:99
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:99
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:99
BOOL WINAPI AppendMenuA(HMENU hMenu, UINT uFlags, UINT_PTR uIDNewItem, LPCSTR lpNewItem)
Definition: menu.c:684
static LPARAM selectitem_lp
Definition: menu.c:104
static WPARAM selectitem_wp
Definition: menu.c:103
#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:99
#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 107 of file menu.c.

109 {
110  static HMENU hmenupopup;
111  switch (msg)
112  {
113  case WM_INITMENUPOPUP:
115  hmenupopup = (HMENU) wparam;
116  break;
117  case WM_ENTERMENULOOP:
119  break;
120  case WM_INITMENU:
121  gflag_initmenu++;
122  break;
123  case WM_MEASUREITEM:
124  {
126  if (winetest_debug > 1)
127  trace("WM_MEASUREITEM received data %lx size %dx%d\n",
128  pmis->itemData, pmis->itemWidth, pmis->itemHeight);
129  ok( !wparam, "wrong wparam %lx\n", wparam );
130  ok( pmis->CtlType == ODT_MENU, "wrong type %x\n", pmis->CtlType );
131  MOD_odheight = pmis->itemHeight;
132  pmis->itemWidth = MODsizes[pmis->itemData].cx;
133  pmis->itemHeight = MODsizes[pmis->itemData].cy;
134  return TRUE;
135  }
136  case WM_DRAWITEM:
137  {
138  DRAWITEMSTRUCT * pdis;
139  TEXTMETRICA tm;
140  HPEN oldpen;
141  char chrs[]="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
142  SIZE sz;
143  int i;
144  pdis = (DRAWITEMSTRUCT *) lparam;
145  if (winetest_debug > 1) {
146  RECT rc;
147  GetMenuItemRect( hwnd, (HMENU)pdis->hwndItem, pdis->itemData ,&rc);
148  trace("WM_DRAWITEM received hwnd %p hmenu %p itemdata %ld item %d rc %s itemrc: %s\n",
149  hwnd, pdis->hwndItem, pdis->itemData, pdis->itemID,
151  oldpen=SelectObject( pdis->hDC, GetStockObject(
153  Rectangle( pdis->hDC, pdis->rcItem.left,pdis->rcItem.top,
154  pdis->rcItem.right,pdis->rcItem.bottom );
155  SelectObject( pdis->hDC, oldpen);
156  }
157  ok( !wparam, "wrong wparam %lx\n", wparam );
158  ok( pdis->CtlType == ODT_MENU, "wrong type %x\n", pdis->CtlType );
159  /* calculate widths of some menu texts */
160  if( ! MOD_txtsizes[0].size.cx)
161  for(i = 0; MOD_txtsizes[i].text; i++) {
162  char buf[100], *p;
163  RECT rc={0,0,0,0};
165  if( ( p = strchr( buf, '\t'))) {
166  *p = '\0';
167  DrawTextA( pdis->hDC, p + 1, -1, &rc,
169  MOD_txtsizes[i].sc_size.cx= rc.right - rc.left;
170  MOD_txtsizes[i].sc_size.cy= rc.bottom - rc.top;
171  }
172  DrawTextA( pdis->hDC, buf, -1, &rc,
174  MOD_txtsizes[i].size.cx= rc.right - rc.left;
175  MOD_txtsizes[i].size.cy= rc.bottom - rc.top;
176  }
177 
178  if( pdis->itemData > MOD_maxid) return TRUE;
179  /* store the rectangle */
180  MOD_rc[pdis->itemData] = pdis->rcItem;
181  /* calculate average character width */
182  GetTextExtentPointA( pdis->hDC, chrs, 52, &sz );
183  MOD_avec = (sz.cx + 26)/52;
184  GetTextMetricsA( pdis->hDC, &tm);
185  MOD_hic = tm.tmHeight;
187  return TRUE;
188  }
189  case WM_ENTERIDLE:
190  {
191  gflag_enteridle++;
192  ok( lparam || broken(!lparam), /* win9x, nt4 */
193  "Menu window handle is NULL!\n");
194  if( lparam) {
196  ok( hmenupopup == hmenu, "MN_GETHMENU returns %p expected %p\n",
197  hmenu, hmenupopup);
198  }
200  return TRUE;
201  }
202  case WM_MENUSELECT:
205  break;
206  }
207  return DefWindowProcA(hwnd, msg, wparam, lparam);
208 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
static int gflag_enteridle
Definition: menu.c:99
static BOOL MOD_GotDrawItemMsg
Definition: menu.c:98
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
static SIZE MODsizes[MOD_NRMENUS]
Definition: menu.c:96
static HMENU hmenu
Definition: win.c:66
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
BOOL WINAPI PostMessageA(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_INITMENUPOPUP
Definition: winuser.h:1728
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI GetTextExtentPointA(_In_ HDC hdc, _In_reads_(c) LPCSTR lpString, _In_ int c, _Out_ LPSIZE lpsz)
#define WHITE_PEN
Definition: wingdi.h:904
#define ODT_MENU
Definition: winuser.h:2512
LONG top
Definition: windef.h:307
ULONG_PTR itemData
Definition: winuser.h:3068
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
static int MOD_avec
Definition: menu.c:94
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:99
#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:99
LONG cx
Definition: windef.h:334
static LPARAM selectitem_lp
Definition: menu.c:104
static struct @1678 MOD_txtsizes[]
BOOL WINAPI GetTextMetricsA(_In_ HDC, _Out_ LPTEXTMETRICA)
Definition: text.c:200
static int MOD_hic
Definition: menu.c:94
static WPARAM selectitem_wp
Definition: menu.c:103
#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:95
const char * wine_dbgstr_rect(const RECT *rect)
#define WM_MEASUREITEM
Definition: winuser.h:1628
static RECT MOD_rc[MOD_NRMENUS]
Definition: menu.c:93
#define WM_CANCELMODE
Definition: winuser.h:1617
ULONG_PTR itemData
Definition: winuser.h:3621
static unsigned int MOD_maxid
Definition: menu.c:92
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:99
#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:81
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 3408 of file menu.c.

3409 {
3410  switch (msg)
3411  {
3412  case WM_ENTERMENULOOP:
3413  {
3414  BOOL ret;
3415 
3416  /* try a recursive call */
3417  SetLastError(0xdeadbeef);
3418  ret = TrackPopupMenu(g_hmenu, 0, 100, 100, 0, hwnd, NULL);
3419  ok(ret == FALSE, "got %d\n", ret);
3421  broken(GetLastError() == 0xdeadbeef) /* W9x */, "got %d\n", GetLastError());
3422 
3423  /* exit menu modal loop
3424  * ( A SendMessage does not work on NT3.51 here ) */
3425  return PostMessageA(hwnd, WM_CANCELMODE, 0, 0);
3426  }
3427  }
3428  return DefWindowProcA(hwnd, msg, wparam, lparam);
3429 }
BOOL WINAPI TrackPopupMenu(HMENU Menu, UINT Flags, int x, int y, int Reserved, HWND Wnd, CONST RECT *Rect)
Definition: menu.c:1652
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
BOOL WINAPI PostMessageA(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
unsigned int BOOL
Definition: ntddk_ex.h:94
#define WM_ENTERMENULOOP
Definition: winuser.h:1786
#define ERROR_POPUP_ALREADY_ACTIVE
Definition: winerror.h:927
static UINT WPARAM LPARAM lparam
Definition: combo.c:716
smooth NULL
Definition: ftsmooth.c:416
#define SetLastError(x)
Definition: compat.h:417
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:3406
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 1325 of file menu.c.

1326 {
1327  BOOL ret;
1328 
1329  SetLastError( 0xdeadbeef );
1330  if (ansi) ret = ModifyMenuA( hmenu, 0, flags, id, data );
1331  else ret = ModifyMenuW( hmenu, 0, flags, id, data );
1332  ok_(__FILE__,line)( ret, "ModifyMenuA failed, err %u\n", GetLastError());
1333 }
static HMENU hmenu
Definition: win.c:66
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL WINAPI ModifyMenuA(HMENU hMenu, UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, LPCSTR lpNewItem)
Definition: menu.c:1423
BOOL WINAPI ModifyMenuW(HMENU hMenu, UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem)
Definition: menu.c:1463
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: parser.c:48
#define SetLastError(x)
Definition: compat.h:417
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 3285 of file menu.c.

3286 {
3287  return ex
3288  ? TrackPopupMenuEx( hmenu, flags, x, y, hwnd, ptpm)
3289  : TrackPopupMenu( hmenu, flags, x, y, 0, hwnd, NULL);
3290 }
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 210 of file menu.c.

211 {
212  WNDCLASSA wc =
213  {
214  0,
216  0,
217  0,
219  NULL,
221  (HBRUSH)(COLOR_BTNFACE+1),
222  NULL,
223  "WineMenuCheck",
224  };
225 
227 }
static ATOM atomMenuCheckClass
Definition: menu.c:40
smooth NULL
Definition: ftsmooth.c:416
const char * LPCSTR
Definition: xmlstorage.h:183
#define COLOR_BTNFACE
Definition: winuser.h:918
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:821
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:42
#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 2263 of file menu.c.

2264 {
2265  TEST_INPUT i[2];
2266  memset(i, 0, sizeof(i));
2267  i[0].type = i[1].type = INPUT_KEYBOARD;
2268  i[0].u.ki.wVk = i[1].u.ki.wVk = wVk;
2269  i[1].u.ki.dwFlags = KEYEVENTF_KEYUP;
2270  SendInput(2, (INPUT *) i, sizeof(INPUT));
2271 }
#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 1335 of file menu.c.

1339 {
1341  BOOL ret;
1342 
1343  /* magic bitmap handle to test smaller cbSize */
1344  if (item == (HBITMAP)(ULONG_PTR)0xdeadbeef)
1345  info.cbSize = FIELD_OFFSET(MENUITEMINFOA,hbmpItem);
1346  else
1347  info.cbSize = sizeof(info);
1348  info.fMask = mask;
1349  info.fType = type;
1350  info.fState = state;
1351  info.wID = id;
1352  info.hSubMenu = submenu;
1353  info.hbmpChecked = checked;
1354  info.hbmpUnchecked = unchecked;
1355  info.dwItemData = data;
1356  info.dwTypeData = type_data;
1357  info.cch = len;
1358  info.hbmpItem = item;
1359  SetLastError( 0xdeadbeef );
1360  if (ansi) ret = SetMenuItemInfoA( hmenu, 0, TRUE, &info );
1361  else ret = SetMenuItemInfoW( hmenu, 0, TRUE, (MENUITEMINFOW*)&info );
1362  ok_(__FILE__, line)( ret, "SetMenuItemInfo failed, err %u\n", GetLastError());
1363 }
#define TRUE
Definition: types.h:120
static HMENU hmenu
Definition: win.c:66
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
struct _test_info info[]
Definition: SetCursorPos.c:19
uint32_t ULONG_PTR
Definition: typedefs.h:63
GLenum GLint GLuint mask
Definition: glext.h:6028
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI SetMenuItemInfoW(HMENU hMenu, UINT uItem, BOOL fByPosition, LPCMENUITEMINFOW lpmii)
Definition: menu.c:1599
Definition: parser.c:48
#define SetLastError(x)
Definition: compat.h:417
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
int ret
static int state
Definition: maze.c:121
GLenum GLsizei len
Definition: glext.h:6722
static ATOM item
Definition: dde.c:856
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
BOOL WINAPI SetMenuItemInfoA(HMENU hmenu, UINT item, BOOL bypos, LPCMENUITEMINFOA lpmii)
Definition: menu.c:1551
GLenum GLuint id
Definition: glext.h:5579
static HBITMAP
Definition: button.c:44
#define ok_(x1, x2)
Definition: atltest.h:61

◆ START_TEST()

START_TEST ( menu  )

Definition at line 4254 of file menu.c.

4255 {
4257 
4263  test_InsertMenu();
4264  test_menualign();
4265  test_system_menu();
4266 
4275  test_menu_input();
4276  test_menu_flags();
4277 
4284  test_emptypopup();
4285  test_AppendMenu();
4286 }
static void test_InsertMenu(void)
Definition: menu.c:2975
static void test_emptypopup(void)
Definition: menu.c:3745
static void test_AppendMenu(void)
Definition: menu.c:3818
static void test_menu_search_bycommand(void)
Definition: menu.c:1891
static void test_menu_hilitemenuitem(void)
Definition: menu.c:2523
static void test_subpopup_locked_by_menu(void)
Definition: menu.c:639
static void test_menu_flags(void)
Definition: menu.c:2492
static void test_menu_bmp_and_string(void)
Definition: menu.c:967
static void test_menu_resource_layout(void)
Definition: menu.c:2781
static void test_system_menu(void)
Definition: menu.c:402
static void test_menu_getmenuinfo(void)
Definition: menu.c:3091
static void test_menu_iteminfo(void)
Definition: menu.c:1397
static void test_menu_add_string(void)
Definition: menu.c:1080
static void test_menualign(void)
Definition: menu.c:3610
static void test_menu_trackpopupmenu(void)
Definition: menu.c:3297
static void test_menu_trackagain(void)
Definition: menu.c:3431
static void test_menu_maxdepth(void)
Definition: menu.c:3552
static void test_menu_circref(void)
Definition: menu.c:3580
static void test_CheckMenuRadioItem(void)
Definition: menu.c:2734
static void test_menu_setmenuinfo(void)
Definition: menu.c:3136
static void test_menu_ownerdraw(void)
Definition: menu.c:704
static void test_menu_input(void)
Definition: menu.c:2433
static void test_GetMenuItemRect(void)
Definition: menu.c:346
static void test_getmenubarinfo(void)
Definition: menu.c:229
static void test_menu_cancelmode(void)
Definition: menu.c:3483
static void test_menu_locked_by_window(void)
Definition: menu.c:589
static void register_menu_check_class(void)
Definition: menu.c:210

◆ strcpyW()

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

Definition at line 1215 of file menu.c.

1216 {
1217  WCHAR *p = dst;
1218  while ((*p++ = *src++));
1219  return dst;
1220 }
__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 1208 of file menu.c.

1209 {
1210  if (n <= 0) return 0;
1211  while ((--n > 0) && *str1 && (*str1 == *str2)) { str1++; str2++; }
1212  return *str1 - *str2;
1213 }
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 623 of file menu.c.

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

Referenced by test_subpopup_locked_by_menu().

◆ test_AppendMenu()

static void test_AppendMenu ( void  )
static

Definition at line 3818 of file menu.c.

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

2735 {
2736  BOOL ret;
2737  HMENU hmenu;
2738 
2740  assert(hmenu != 0);
2741 
2742  check_menu_items(hmenu, -1, 0, 0);
2743 
2744  ret = CheckMenuRadioItem(hmenu, 100, 100, 100, MF_BYCOMMAND);
2745  ok(ret, "CheckMenuRadioItem failed\n");
2747 
2748  /* MSDN is wrong, Windows does not remove MFT_RADIOCHECK */
2749  ret = CheckMenuRadioItem(hmenu, 100, 100, -1, MF_BYCOMMAND);
2750  ok(!ret, "CheckMenuRadioItem should return FALSE\n");
2752 
2753  /* clear check */
2755  check_menu_items(hmenu, -1, 0, 0);
2756 
2757  /* first and checked items are on different menus */
2758  ret = CheckMenuRadioItem(hmenu, 0, 300, 202, MF_BYCOMMAND);
2759  ok(!ret, "CheckMenuRadioItem should return FALSE\n");
2760  check_menu_items(hmenu, -1, 0, 0);
2761 
2762  ret = CheckMenuRadioItem(hmenu, 200, 300, 202, MF_BYCOMMAND);
2763  ok(ret, "CheckMenuRadioItem failed\n");
2765 
2766  /* MSDN is wrong, Windows does not remove MFT_RADIOCHECK */
2767  ret = CheckMenuRadioItem(hmenu, 202, 202, -1, MF_BYCOMMAND);
2768  ok(!ret, "CheckMenuRadioItem should return FALSE\n");
2770 
2771  /* clear check */
2773  check_menu_items(hmenu, -1, 0, 0);
2774 
2775  /* just for fun, try to check separator */
2776  ret = CheckMenuRadioItem(hmenu, 0, 300, 0, MF_BYCOMMAND);
2777  ok(!ret, "CheckMenuRadioItem should return FALSE\n");
2778  check_menu_items(hmenu, -1, 0, 0);
2779 }
#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:2661
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:821
#define ok(value,...)
Definition: atltest.h:57
static void clear_ftype_and_state(HMENU hmenu, UINT id, UINT flags)
Definition: menu.c:2722
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 3745 of file menu.c.

3746 {
3747  BOOL ret;
3748  HMENU hmenu;
3749 
3752  NULL, NULL, NULL, NULL);
3753  ok(hwnd != NULL, "CreateWindowEx failed with error %d\n", GetLastError());
3755 
3756  hmenu = CreatePopupMenu();
3757  ok(hmenu != NULL, "CreateMenu failed with error %d\n", GetLastError());
3758 
3760  selectitem_wp = 0xdeadbeef;
3761  selectitem_lp = 0xdeadbeef;
3762 
3763  ret = TrackPopupMenu( hmenu, TPM_RETURNCMD, 100,100, 0, hwnd, NULL);
3764  ok(ret == 0, "got %i\n", ret);
3765 
3766  ok(gflag_initmenupopup == 1, "got %i\n", gflag_initmenupopup);
3767  ok(gflag_entermenuloop == 1, "got %i\n", gflag_entermenuloop);
3768  ok(gflag_initmenu == 1, "got %i\n", gflag_initmenu);
3769  ok(gflag_enteridle == 0, "got %i\n", gflag_initmenu);
3770 
3771  ok(selectitem_wp == 0xdeadbeef, "got %lx\n", selectitem_wp);
3772  ok(selectitem_lp == 0xdeadbeef, "got %lx\n", selectitem_lp);
3773 
3775  selectitem_wp = 0xdeadbeef;
3776  selectitem_lp = 0xdeadbeef;
3777 
3778  ret = TrackPopupMenu( hmenu, 0, 100,100, 0, hwnd, NULL);
3779  ok(ret == 0, "got %i\n", ret);
3780 
3781  ok(gflag_initmenupopup == 1, "got %i\n", gflag_initmenupopup);
3782  ok(gflag_entermenuloop == 1, "got %i\n", gflag_entermenuloop);
3783  ok(gflag_initmenu == 1, "got %i\n", gflag_initmenu);
3784  ok(gflag_enteridle == 0, "got %i\n", gflag_initmenu);
3785 
3786  ok(selectitem_wp == 0xdeadbeef, "got %lx\n", selectitem_wp);
3787  ok(selectitem_lp == 0xdeadbeef, "got %lx\n", selectitem_lp);
3788 
3790 
3792  selectitem_wp = 0xdeadbeef;
3793  selectitem_lp = 0xdeadbeef;
3794 
3795  ret = TrackPopupMenu( hmenu, 0, 100,100, 0, hwnd, NULL);
3796  ok(ret == 1, "got %i\n", ret);
3797 
3798  ok(gflag_initmenupopup == 1, "got %i\n", gflag_initmenupopup);
3799  ok(gflag_entermenuloop == 1, "got %i\n", gflag_entermenuloop);
3800  ok(gflag_initmenu == 1, "got %i\n", gflag_initmenu);
3801  ok(gflag_enteridle == 1, "got %i\n", gflag_initmenu);
3802 
3803  ok(selectitem_wp == 0xffff0000, "got %lx\n", selectitem_wp);
3804  ok(selectitem_lp == 0, "got %lx\n", selectitem_lp);
3805 
3807 
3808  ret = DestroyMenu(hmenu);
3809  ok(ret, "DestroyMenu failed with error %d\n", GetLastError());
3810 }
static int gflag_enteridle
Definition: menu.c:99
BOOL WINAPI TrackPopupMenu(HMENU Menu, UINT Flags, int x, int y, int Reserved, HWND Wnd, CONST RECT *Rect)
Definition: menu.c:1652
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
static HMENU hmenu
Definition: win.c:66
static ATOM atomMenuCheckClass
Definition: menu.c:40
#define TPM_RETURNCMD
Definition: winuser.h:2362
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
HMENU WINAPI CreatePopupMenu(VOID)
Definition: menu.c:846
BOOL WINAPI DestroyWindow(_In_ HWND)
static LRESULT WINAPI menu_fill_in_init(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: menu.c:3712
static int gflag_initmenu
Definition: menu.c:99
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:99
static LPARAM selectitem_lp
Definition: menu.c:104
static LRESULT WINAPI menu_ownerdraw_wnd_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: menu.c:107
const char * LPCSTR
Definition: xmlstorage.h:183
static WPARAM selectitem_wp
Definition: menu.c:103
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:99
#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:1423

Referenced by START_TEST().

◆ test_getmenubarinfo()

static void test_getmenubarinfo ( void  )
static

Definition at line 229 of file menu.c.

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

Referenced by START_TEST().

◆ test_GetMenuItemRect()

static void test_GetMenuItemRect ( void  )
static

Definition at line 346 of file menu.c.

347 {
348  HWND hwnd;
349  HMENU hmenu;
350  HMENU popup_hmenu;
351  RECT window_rect;
352  RECT item_rect;
353  POINT client_top_left;
354  INT caption_height;
355  BOOL ret;
356 
358  NULL, NULL, NULL);
359  ok(hwnd != NULL, "CreateWindow failed with error %d\n", GetLastError());
360  hmenu = CreateMenu();
361  ok(hmenu != NULL, "CreateMenu failed with error %d\n", GetLastError());
362  popup_hmenu = CreatePopupMenu();
363  ok(popup_hmenu != NULL, "CreatePopupMenu failed with error %d\n", GetLastError());
364  ret = AppendMenuA(popup_hmenu, MF_STRING, 0, "Popup");
365  ok(ret, "AppendMenu failed with error %d\n", GetLastError());
366  ret = AppendMenuA(hmenu, MF_STRING | MF_POPUP, (UINT_PTR)popup_hmenu, "Menu");
367  ok(ret, "AppendMenu failed with error %d\n", GetLastError());
368  ret = SetMenu(hwnd, hmenu);
369  ok(ret, "SetMenu failed with error %d\n", GetLastError());
370 
371  /* Get the menu item rectangle of the displayed sysmenu item */
372  ret = GetMenuItemRect(hwnd, hmenu, 0, &item_rect);
373  ok(ret, "GetMenuItemRect failed with error %d\n", GetLastError());
374  GetWindowRect(hwnd, &window_rect);
375  /* Get the screen coordinate of the left top corner of the client rectangle */
376  client_top_left.x = 0;
377  client_top_left.y = 0;
378  MapWindowPoints(hwnd, 0, &client_top_left, 1);
380 
381  ok(item_rect.left == client_top_left.x, "Expect item_rect.left %d == %d\n", item_rect.left, client_top_left.x);
382  ok(item_rect.right <= window_rect.right, "Expect item_rect.right %d <= %d\n", item_rect.right, window_rect.right);
383  /* A gap of 1 pixel is added deliberately in commit 75f9e64, so using equal operator would fail on Wine.
384  * Check that top and bottom are correct with 1 pixel margin tolerance */
385  ok(item_rect.top - (window_rect.top + caption_height) <= 1, "Expect item_rect.top %d - %d <= 1\n", item_rect.top,
386  window_rect.top + caption_height);
387  ok(item_rect.bottom - (client_top_left.y - 1) <= 1, "Expect item_rect.bottom %d - %d <= 1\n", item_rect.bottom,
388  client_top_left.y - 1);
389 
390  /* Get the item rectangle of the not yet displayed popup menu item. */
391  ret = GetMenuItemRect(hwnd, popup_hmenu, 0, &item_rect);
392  ok(ret, "GetMenuItemRect failed with error %d\n", GetLastError());
393  ok(item_rect.left == client_top_left.x, "Expect item_rect.left %d == %d\n", item_rect.left, client_top_left.x);
394  ok(item_rect.right == client_top_left.x, "Expect item_rect.right %d == %d\n", item_rect.right, client_top_left.x);
395  ok(item_rect.top == client_top_left.y, "Expect item_rect.top %d == %d\n", item_rect.top, client_top_left.y);
396  ok(item_rect.bottom == client_top_left.y, "Expect item_rect.bottom %d == %d\n", item_rect.bottom,
397  client_top_left.y);
398 
400 }
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:40
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:1059
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:56
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:1423

Referenced by START_TEST().

◆ test_InsertMenu()

static void test_InsertMenu ( void  )
static

Definition at line 2975 of file menu.c.

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

814 {
815  BOOL ret;
816  HMENU hmenu, submenu;
817  MENUITEMINFOA mii={ sizeof( MENUITEMINFOA )};
818  MENUINFO mi;
819  RECT rc;
820  CHAR text_copy[16];
821  int hastab, expect;
822  BOOL failed = FALSE;
823 
826  mii.fType = 0;
827  /* check the menu item unless MNS_CHECKORBMP is set */
828  mii.fState = (mnuopt != 2 ? MFS_CHECKED : MFS_UNCHECKED);
829  mii.dwItemData =0;
830  MODsizes[0] = bmpsize;
831  hastab = 0;
832  if( text ) {
833  char *p;
834  mii.fMask |= MIIM_STRING;
835  strcpy(text_copy, text);
836  mii.dwTypeData = text_copy; /* structure member declared non-const */
837  if( ( p = strchr( text, '\t'))) {
838  hastab = *(p + 1) ? 2 : 1;
839  }
840  }
841  /* tabs don't make sense in menubars */
842  if(hastab && !ispop) return;
843  if( hbmp) {
844  mii.fMask |= MIIM_BITMAP;
845  mii.hbmpItem = hbmp;
846  }
847  submenu = CreateMenu();
848  ok( submenu != 0, "CreateMenu failed with error %d\n", GetLastError());
849  if( ispop)
851  else
852  hmenu = CreateMenu();
853  ok( hmenu != 0, "Create{Popup}Menu failed with error %d\n", GetLastError());
854  if( hassub) {
855  mii.fMask |= MIIM_SUBMENU;
856  mii.hSubMenu = submenu;
857  }
858  if( mnuopt) {
859  mi.cbSize = sizeof(mi);
860  mi.fMask = MIM_STYLE;
861  GetMenuInfo( hmenu, &mi);
862  if( mnuopt) mi.dwStyle |= mnuopt == 1 ? MNS_NOCHECK : MNS_CHECKORBMP;
863  ret = SetMenuInfo( hmenu, &mi);
864  ok( ret, "SetMenuInfo failed with error %d\n", GetLastError());
865  }
866  ret = InsertMenuItemA( hmenu, 0, FALSE, &mii);
867  ok( ret, "InsertMenuItem failed with error %d\n", GetLastError());
868  failed = !ret;
869  if( winetest_debug) {
870  HDC hdc=GetDC(hwnd);
871  RECT rc = {100, 50, 400, 70};
872  char buf[100];
873 
874  sprintf( buf,"%d text \"%s\" mnuopt %d", count, text ? text: "(nil)", mnuopt);
875  FillRect( hdc, &rc, (HBRUSH) COLOR_WINDOW);
876  TextOutA( hdc, 10, 50, buf, strlen( buf));
877  ReleaseDC( hwnd, hdc);
878  }
879  if(ispop)
880  TrackPopupMenu( hmenu, TPM_RETURNCMD, 100,100, 0, hwnd, NULL);
881  else {
882  ret = SetMenu( hwnd, hmenu);
883  ok(ret, "SetMenu failed with error %d\n", GetLastError());
884  DrawMenuBar( hwnd);
885  }
886  ret = GetMenuItemRect( hwnd, hmenu, 0, &rc);
887  ok(ret, "GetMenuItemRect failed with error %d\n", GetLastError());
888 
889  if (0) /* comment out menu size checks, behavior is different in almost every Windows version */
890  /* the tests should however succeed on win2000, XP and Wine (at least up to 1.1.15) */
891  /* with a variety of dpis and desktop font sizes */
892  {
893  /* check menu width */
894  if( ispop)
895  expect = ( text || hbmp ?
896  4 + (mnuopt != 1 ? GetSystemMetrics(SM_CXMENUCHECK) : 0)
897  : 0) +
898  arrowwidth + MOD_avec + (hbmp ?
899  ((INT_PTR)hbmp<0||(INT_PTR)hbmp>12 ? bmpsize.cx + 2 : GetSystemMetrics( SM_CXMENUSIZE) + 2)
900  : 0) +
901  (text && hastab ? /* TAB space */
902  MOD_avec + ( hastab==2 ? sc_size.cx : 0) : 0) +
903  (text ? 2 + (text[0] ? size.cx :0): 0) ;
904  else
905  expect = !(text || hbmp) ? 0 :
906  ( hbmp ? (text ? 2:0) + bmpsize.cx : 0 ) +
907  (text ? 2 * MOD_avec + (text[0] ? size.cx :0): 0) ;
908  ok( rc.right - rc.left == expect,
909  "menu width wrong, got %d expected %d\n", rc.right - rc.left, expect);
910  failed = failed || !(rc.right - rc.left == expect);
911  /* check menu height */
912  if( ispop)
913  expect = max( ( !(text || hbmp) ? GetSystemMetrics( SM_CYMENUSIZE)/2 : 0),
914  max( (text ? max( 2 + size.cy, MOD_hic + 4) : 0),
915  (hbmp ?
916  ((INT_PTR)hbmp<0||(INT_PTR)hbmp>12 ?
917  bmpsize.cy + 2
919  : 0)));
920  else
921  expect = ( !(text || hbmp) ? GetSystemMetrics( SM_CYMENUSIZE)/2 :
922  max( GetSystemMetrics( SM_CYMENU) - 1, (hbmp ? bmpsize.cy : 0)));
923  ok( rc.bottom - rc.top == expect,
924  "menu height wrong, got %d expected %d (%d)\n",
926  failed = failed || !(rc.bottom - rc.top == expect);
928  /* check the position of the bitmap */
929  /* horizontal */
930  if (!ispop)
931  expect = 3;
932  else if (mnuopt == 0)
934  else if (mnuopt == 1)
935  expect = 4;
936  else /* mnuopt == 2 */
937  expect = 2;
938  ok( expect == MOD_rc[0].left,
939  "bitmap left is %d expected %d\n", MOD_rc[0].left, expect);
940  failed = failed || !(expect == MOD_rc[0].left);
941  /* vertical */
942  expect = (rc.bottom - rc.top - MOD_rc[0].bottom + MOD_rc[0].top) / 2;
943  ok( expect == MOD_rc[0].top,
944  "bitmap top is %d expected %d\n", MOD_rc[0].top, expect);
945  failed = failed || !(expect == MOD_rc[0].top);
946  }
947  }
948  /* if there was a failure, report details */
949  if( failed) {
950  trace("*** count %d %s text \"%s\" bitmap %p bmsize %d,%d textsize %d+%d,%d mnuopt %d hastab %d\n",
951  count, (ispop? "POPUP": "MENUBAR"),text ? text: "(nil)", hbmp, bmpsize.cx, bmpsize.cy,
952  size.cx, size.cy, sc_size.cx, mnuopt, hastab);
953  trace(" check %d,%d arrow %d avechar %d\n",
956  if( hbmp == HBMMENU_CALLBACK)
957  trace( " rc %s bmp.rc %s\n", wine_dbgstr_rect(&rc), wine_dbgstr_rect(&MOD_rc[0]));
958  }
959  /* clean up */
960  ret = DestroyMenu(submenu);
961  ok(ret, "DestroyMenu failed with error %d\n", GetLastError());
962  ret = DestroyMenu(hmenu);
963  ok(ret, "DestroyMenu failed with error %d\n", GetLastError());
964 }
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:98
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:96
#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:83
static int MOD_avec
Definition: menu.c:94
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
static MONITORINFO mi
Definition: win.c:7339
LONG left
Definition: windef.h:306
int32_t INT_PTR
Definition: typedefs.h:62
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 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:94
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:93
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:81
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 1080 of file menu.c.

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