我怎样得到菜单的文字信息(比如'打开','编辑','查看'等等)(还有子菜单的文字信息)
最好有代码?

解决方案 »

  1.   

    用api函数GetMenuStringThe GetMenuString function copies the text string of the specified menu item into the specified buffer. Note  The GetMenuString function has been superseded. Use the GetMenuItemInfo function to retrieve the menu item text.int GetMenuString(
      HMENU hMenu,      // handle to the menu
      UINT uIDItem,     // menu item identifier
      LPTSTR lpString,  // buffer for the string
      int nMaxCount,    // maximum length of string
      UINT uFlag        // options
    );
    Parameters
    hMenu 
    [in] Handle to the menu. 
    uIDItem 
    [in] Specifies the menu item to be changed, as determined by the uFlag parameter. 
    lpString 
    [out] Pointer to the buffer that receives the null-terminated string. If the string is as long or longer than lpString, the string is truncated and the NULL terminator is added. 
    If lpString is NULL, the function returns the length of the menu string. nMaxCount 
    [in] Specifies the maximum length, in characters, of the string to be copied. If the string is longer than the maximum specified in the nMaxCount parameter, the extra characters are truncated. 
    If nMaxCount is 0, the function returns the length of the menu string. uFlag 
    [in] Specifies how the uIDItem parameter is interpreted. This parameter must be one of the following values. Value Meaning 
    MF_BYCOMMAND Indicates that uIDItem gives the identifier of the menu item. If neither the MF_BYCOMMAND nor MF_BYPOSITION flag is specified, the MF_BYCOMMAND flag is the default flag. 
    MF_BYPOSITION Indicates that uIDItem gives the zero-based relative position of the menu item. 
    Return Values
    If the function succeeds, the return value specifies the number of characters copied to the buffer, not including the terminating null character.If the function fails, the return value is zero. If the specified item is not of type MFT_STRING, then the return value is zero.Windows 98/Me and Windows 2000/XP: MIIM_STRING supersedes MFT_STRING. Res
    The nMaxCount parameter must be one larger than the number of characters in the text string to accommodate the terminating null character. If nMaxCount is 0, the function returns the length of the menu string.Windows 95/98/Me: GetMenuStringW is supported by the Microsoft Layer for Unicode. To use this, you must add certain files to your application, as outlined in Microsoft Layer for Unicode on Windows 95/98/Me Systems.Example Code
    For an example, see Creating User-Editable Accelerators. Requirements 
      Windows NT/2000/XP: Included in Windows NT 3.1 and later.
      Windows 95/98/Me: Included in Windows 95 and later.
      Header: Declared in Winuser.h; include Windows.h.
      Library: Use User32.lib.
      Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000/XP. Also supported by Microsoft Layer for Unicode.
      

  2.   

    你先给你要显示汉字信息的菜单放上一个名字,比如:打开 你在属性页里把它的name的值改为
    Mn,你要得到汉字信息可以这样:Mn.Caption就可以得到你要的资料!
    不知道你要的是不是这个??????????????????????????
      

  3.   

    不是,我的具体要求是:我把鼠标移到菜单上面,在得到菜单的文字信息,也就是说,要获得文字信息的菜单是不固定的,我的设想是先按一个鼠标钩子,利用全局的鼠标钩子得到菜单的文字信息.但不知道用什么函数可以得到我想要的文字.我知道有一个API函数,GETMENUSTRING,但不知道他的第二个参数怎么设值?