I have an MFC MDI Doc/View app. The main frame window has several menus, some standard, some I have created. I access these menus by using code such as
CMenu *pMenu = pM->GetMenu(); // get the main frame window's menu
CMenu *pMenuI = pMenu->GetSubMenu(iMenu);
iMenu
is the left-to-right sequence of the menu on the main frame window's menu bar, e g, 0 is File, 1 is View, etc. This all works as expected.
My view is derived from CScrollView
. If I load data, and click the maximize button in the system menu of the view, the view is maximized as expected, covering the entire client area of the main frame window.
But after maximizing, if I attempt to access the menus, I find that the numbering of the menus has changed. A new menu 0 has been added, and the menus I specified in the resource editor are numbered one higher, e g, now 1 is File, 2 is View, etc.
The new menu added is the system menu (&Restore, &Move, &Size, etc). The new menu does not appear on the main frame's menu bar.
What is the explanation for this behavior, and how can I avoid having my menus renumbered, or is there another way to identify them that doesn't depend on their left-to-right order?
Windows 11 VS2022 C++ 64-bit