SetMenuInfo 函数没有定义 怎么解决?
VC6.0环境
我想改变菜单的背景颜色;代码如下:
MENUINFO mi; 
mi.cbSize=sizeof(MENUINFO);
mi.fMask=MIM_BACKGROUND;
mi.hbrBack=hBrush;
SetMenuInfo(hMenu,&mi);错误如下:
error C2065: 'MENUINFO' : undeclared identifier
error C2065: 'mi' : undeclared identifier
error C2065: 'MIM_BACKGROUND' : undeclared identifier
error C2065: 'SetMenuInfo' : undeclared identifier查了很多资料,说在#include <windows.h> 前加 #define WINVER 0x0501, 但是编译还是一样错误
求高手解决 !!!!

解决方案 »

  1.   

     #define WINVER 0x0501把所有的0x0400 都改成0x0500以上!
      

  2.   

    stdafx.h文件中#define VC_EXTRALEAN前加上下面的
    #undef WINVER
    #define WINVER 0X500
      

  3.   


    // stdafx.h : include file for standard system include files,
    //  or project specific include files that are used frequently, but
    //      are changed infrequently
    //#if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
    #define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_#if _MSC_VER > 1000
    #pragma once
    #endif // _MSC_VER > 1000#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
    #include <windows.h>//#define _WIN32_WINNT 0x0501 //#define WINVER 0x0501 
    // TODO: reference additional headers your program requires here//{{AFX_INSERT_LOCATION}}
    // Microsoft Visual C++ will insert additional declarations immediately before the previous line.#endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
    stdafx。h的头文件中!   是什么意思? 以上代码是我的stdafx。h的头文件
      

  4.   

    #ifndef WINVER 
    #define WINVER 0x0501 
    #endif 
    #ifndef _WIN32_WINDOWS 
    #define _WIN32_WINDOWS 0x0501 
    #endif 
    #ifndef _WIN32_WINNT 
    #define _WIN32_WINNT   0x0501 
    #endif 
    #ifndef _WIN32_IE 
    #define _WIN32_IE      0x0600 
    #endif #include <windows.h>
    加了这些在stdafx.h的头文件中  为什么还报错?
      

  5.   

    在 ‘winuser.h’ 中:
    typedef struct tagMENUINFO
    {
        DWORD   cbSize;
        DWORD   fMask;
        DWORD   dwStyle;
        UINT    cyMax;
        HBRUSH  hbrBack;
        DWORD   dwContextHelpID;
        DWORD   dwMenuData;
    }   MENUINFO, FAR *LPMENUINFO;
    typedef MENUINFO CONST FAR *LPCMENUINFO;
    #define MIM_MAXHEIGHT               0x00000001
    #define MIM_BACKGROUND              0x00000002
    #define MIM_HELPID                  0x00000004
    #define MIM_MENUDATA                0x00000008
    #define MIM_STYLE                   0x00000010
    #define MIM_APPLYTOSUBMENUS         0x80000000 自己加 上面的 定义。 或者:// stdafx.h : include file for standard system include files,
    //  or project specific include files that are used frequently, but
    //      are changed infrequently
    //#if !defined(AFX_STDAFX_H__31A230CF_F805_418F_8D90_51D3E98B66DB__INCLUDED_)
    #define AFX_STDAFX_H__31A230CF_F805_418F_8D90_51D3E98B66DB__INCLUDED_#if _MSC_VER > 1000
    #pragma once
    #endif // _MSC_VER > 1000#ifndef WINVER    // 允许使用 Windows 95 和 Windows NT 4 或更高版本的特定功能。
    #define WINVER 0x0500  //为 Windows98 和 Windows 2000 及更新版本改变为适当的值。
    #endif