So, i right click inside my child view i see Option1, Option2, and when i click on either i can see message window popping up, meaning that they work.
However, if you noticed, when i click Option 1, it must disable this same option in menu (it must be grayed out) but that does not happen.
What is the proper way to get it to work?
to give additonal details, when i right click and select Option 1, i do see message about it, and as i mentioned above I do not see it grayed out, however when i click it again, no message appears, which means (i assume) that menu is already disabled, but not grayed out..so how to permanently disable/gray it out?
the CmEnableViewOption1 occurs only when i do View-> from top bar menu, there i see Option 1 and Option2 popping down.
However, when i mouse right click from inside ChildView window i do see |Option1,2 menu popping up but inside debugger it does not enter the CmEnableViewOption1, meaning that this function does not run.
In that case my question would be, why when i click directly inside top frame menu that function is called, but when i right click from child view window and properly getting that menu and can even run its commands, but CmEnableViewOption1 is not executed?
Have you checked that your ON_UPDATE_COMMAND_UI in the FrameWnd class gets called? It's a long time since I used MFC but I do not recall ever seeing this problem. Take a look at the area where you create and display the popup menu.
In the child window i can successfully do a MouseRight click and popup of some menu with its submenus from the main menu bar.
So you are using a popup (context) menu here and not the menu of the main frame (only the menu items / resources are re-used).
Then you should handle enabling/disabling when opening the popup menu and pass AfxGetMainWnd() as the owner window (see code comments):
CMenu *pMenu = new CMenu;
// Get the pop-up menu.
CMenu *pPopupMenu = pMenu->GetSubMenu(0);
// Enable disable an item by ID.
pPopupMenu->EnableMenuItem(CM_VIEW_OPTION1, CMViewOption1Enabled ? 0 : MF_GRAYED);
// Show context menu and wait for selection.// Advantages of passing AfxGetMainWnd():// - Calls provided OnUpdate() functions to determine state of items.// NOTE: Items can be only disabled using the OnUpdate handlers!// So there must be handlers for those items that may be disabled!// If no update handlers are present, items are enabled by default// (by existance of command handlers).// - Shows short info about items in status bar// - Processes F1 help
pPopupMenu->TrackPopupMenuEx(flags, x, y, AfxGetMainWnd(), NULL);
A dynamic update is not necessary here when the popup menu closes with the first click. Otherwise make pPopupMenu a member of your child view so that it can be used to change items and/or their state dynamically.
I am using version C++ 6.0 (and ported another application to VS2008 and I have the same problem). I have multiple dialogs in my application. It has been in use for years and now it has been noticed that if a edit box, checkbox, etc. is changed and then the dialog is dragged to more than 1/2 off the monitor's screen, that the data is reset. This is confusing to me. It seems like it has something to do with Paint, but I am not able to figure it out. Any assistance would be appreciated.
I have a bizarre problem with a dialog. I created a dialog to move items between two lists. The left list box has the pool of possible items that are unused on the left and the items being used on the right. In between the two are a bunch of buttons to move selected items left or right, or move the entire list from one box to the other.
The code for loading and handling the boxes is the same with just the names of the boxes changed. For example the move right button handling code extracts an item from the left box and puts in the the right and the move left button does the opposite.
Moving an item from the left box to the right works as expected. The code to get the item from the left box is:
for(i=0; i<nCount; i++)
idx = aryListBoxSel.GetAt(i);
val = (float)m_lstLeft.GetItemData(idx);
// does stuff with val here
If idx 2, the third item in the list ends up in val as expected.
However, moving from right to left, using a mirror image of the same code:
idx = aryListBoxSel.GetAt(i);
val = (float)m_lstRight.GetItemData(idx);
val is always the last item in the list, no matter what idx is.
I compared the code and everything is a mirror image of the other. The two lists are defined the same way, loaded the same way, and accessed the same way.
What could possibly be wrong? As far as I can tell, I am setting up two identical list boxes and getting two different results.
modified 8-Jan-16 4:01am.
Last Visit: 31-Dec-99 18:00 Last Update: 26-Oct-21 15:57