POPUP菜单项的菜单ID无效(主应用程序菜单)

问题描述:

不是紧急问题,更是一个问题...



使用VS2008,直接从向导使用MFC / MDI项目;没有自定义代码。





打开菜单时,打开*菜单时我会在输出菜单中显示此信息(点击时在菜单栏中的*菜单项上。



警告:没有ID 0x0000的消息行提示。



这来自我们(MFC框架)尝试在状态栏中显示消息时。



通常所有菜单项都有与之关联的ID;但是对于POPUP没有ID,当框架尝试获取相关的字符串资源时,它会失败,因为ID为零。



BOOL CMFCToolBarButton :: SetACCData(CWnd * pParent,CAccessibilityData& data);



这将调用

virtual void CFrameWnd :: GetMessageString(UINT nID,CString& rMessage)const;



我可以覆盖GetMessageString删除警告的方法,但这只会隐藏问题。



这是正常的吗?



有任何想法吗 ?



资源摘录

Not an urgent issue, more a question...

Using VS2008, with a MFC/MDI project directly from the wizard; no custom code.


When opening a menu, I have this message in the output menu when opening a top level menu (when clicking on a top level menu item in the menubar).

Warning: no message line prompt for ID 0x0000.

This comes from when we (the MFC framework) try to display a message in the status bar.

Normally all menu items have IDs associated with them; but for the POPUP there is no ID, and when the framework try to get the associated string resources it fails because the ID is zero in

BOOL CMFCToolBarButton::SetACCData(CWnd* pParent, CAccessibilityData& data);

and that will call
virtual void CFrameWnd::GetMessageString(UINT nID, CString& rMessage) const;

I could override the GetMessageString method to remove the warning, but that would only hide the issue.

Is this normal ?

Any ideas ?

resource excerpt

IDR_MAINFRAME MENU
BEGIN
	POPUP "&File"
	BEGIN
		MENUITEM "&New\tCtrl+N",                ID_FILE_NEW
		MENUITEM "&Open...\tCtrl+O",            ID_FILE_OPEN
		MENUITEM "&Close",                      ID_FILE_CLOSE
		MENUITEM SEPARATOR
		MENUITEM "P&rint Setup...",             ID_FILE_PRINT_SETUP
		MENUITEM SEPARATOR
		MENUITEM "Recent File",                 ID_FILE_MRU_FILE1,GRAYED
		MENUITEM SEPARATOR
		MENUITEM "E&xit",                       ID_APP_EXIT
	END
...







谢谢。



最大。




Thanks.

Max.

当菜单中的项目被触摸时,MFC会尝试根据其ID值显示与菜单项对应的描述性文本。某些系统提供的ID有默认值,但不是全部,而且通常由(你)程序员定义的任何ID都没有。



对于此处提供的示例菜单项,您需要添加字符串来描述菜单选项。在.RC或.RC2文件中,添加以下部分:



When an item in a menu is 'touched', MFC attempts to display the descriptive text corresponding to the menu item based on its ID value. There are default values for some of the system-provided IDs, but not all of them, and not for any that would normally be defined by (you) the programmer.

For the example menu items you provide here, you need to add strings to describe the menu choices. In your .RC or .RC2 file, add the following section:

STRINGTABLE
BEGIN
    ID_FILE_NEW             "Create a new document\nNew"
    ID_FILE_OPEN            "Open an existing document\nOpen"
    ID_FILE_CLOSE           "Close the active document\nClose"
    ID_FILE_SAVE            "Save the active document\nSave"
    ID_FILE_SAVE_AS         "Save the active document with a new name\nSave As"
    ID_FILE_PAGE_SETUP      "Change the printing options\nPage Setup"
    ID_FILE_PRINT_SETUP     "Change the printer and printing options\nPrint Setup"
    ID_FILE_PRINT           "Print the active document\nPrint"
    ID_FILE_PRINT_PREVIEW   "Display full pages\nPrint Preview"
    ID_FILE_MRU_FILE1       "Open first file\nFirst file"
    ID_APP_EXIT             "Sayonara\nBye now"
END





这是记事本版本;您也可以使用资源编辑器编辑...



This is the notepad version; you can also edit with the resource editor...