我打算在OnUpdateXXXX(CCmdUI* pCmdUI) 里取,可是参数不会设,一点菜单就非法操作。:(GetMenuString的参数怎么设呢??

解决方案 »

  1.   

    这是vb的说明,vc适当改变参数 类型及说明 
    hMenu Long,菜单句柄 
    wIDItem Long,欲接收的菜单条目的标识符。如果在wFlags参数中设置了MF_BYCOMMAND标志,这个参数就用于指定要改变的菜单条目的命令ID。如果设置的是MF_BYPOSITION标志,这个参数就用于指定条目在菜单中的位置(第一个条目的位置为0) 
    lpString String,指定一个预先定义好的字串缓冲区,以便为菜单条目装载字串 
    nMaxCount Long,载入lpString缓冲区中的最大字符数量+1 
    wFlag Long,常数MF_BYCOMMAND或MF_BYPOSITION,取决于wID参数的设置 
      

  2.   

    我知道那些东西,可我不知道在vc的mainframe里该用哪些参数来做那个函数的参数。
    我试过几个,都是非法操作。;
      

  3.   

    CMenu::GetMenuString 
    int GetMenuString( UINT nIDItem, LPTSTR lpString, int nMaxCount, UINT nFlags ) const;int GetMenuString( UINT nIDItem, CString& rString, UINT nFlags ) const;Return ValueSpecifies the actual number of bytes copied to the buffer, not including the null terminator.ParametersnIDItemSpecifies the integer identifier of the menu item or the offset of the menu item in the menu, depending on the value of nFlags.lpStringPoints to the buffer that is to receive the label.rStringA reference to a CString object that is to receive the copied menu string.nMaxCountSpecifies the maximum length (in bytes) of the label to be copied. If the label is longer than the maximum specified in nMaxCount, the extra characters are truncated.nFlagsSpecifies the interpretation of the nIDItem parameter. It can be one of the following values:nFlags Interpretation of nIDItem 
    MF_BYCOMMAND Specifies that the parameter gives the command ID of the existing menu item. This is the default if neither MF_BYCOMMAND nor MF_BYPOSITION is set. 
    MF_BYPOSITION Specifies that the parameter gives the position of the existing menu item. The first item is at position 0. 
    ResCopies the label of the specified menu item to the specified buffer. The nMaxCount parameter should be one larger than the number of characters in the label to accommodate the null character that terminates a string.不用我多说了巴:)
      

  4.   

    CMenu *pMenu = GetMenu();
    TCHAR buf[255];
    pMenu->GetMenuString(ID_FILE_OPEN, buf, 255, MF_BYCOMMAND);
      

  5.   

    呵呵,你们说的都对,可都不是我想要的,
    我说了我本来想在OnUpdateXXXX(CCmdUI* pCmdUI) 里取,可参数设的不对,
    比如楼上那种方法,我要是知道他的id是什么就好办了~我的意图是:打算将日志功能加入到OnUpdateXXXX(CCmdUI* pCmdUI) 里,
    这样你点那个菜单的时候……好像就可以取得那个菜单项的文本。
    可他只有settext没有gettext……:(