|
ok so here is a thing,
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.
|
|
|
|
|
Member 11203277 wrote: 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;
pMenu->LoadMenu(IDR_OF_MENU);
CMenu *pPopupMenu = pMenu->GetSubMenu(0);
pPopupMenu->EnableMenuItem(CM_VIEW_OPTION1, CMViewOption1Enabled ? 0 : MF_GRAYED);
pPopupMenu->TrackPopupMenuEx(flags, x, y, AfxGetMainWnd(), NULL);
delete pMenu;
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.
|
|
|
|
|
Perfect! I did almost exactly what you suggested with slight difference;
void ChildView::OnRButtonDown(UINT, CPoint point) {
CWnd* pMain = AfxGetMainWnd();
CMenu *ptrmenu = pMain->GetMenu(); CMenu *ptrpopup = ptrmenu->GetSubMenu(1); ClientToScreen(&point);
ptrpopup->EnableMenuItem(CM_VIEW_OPTION1, CMViewOption1Enabled ? 0 : MF_GRAYED);
ptrpopup->TrackPopupMenu(0, point.x, point.y, AfxGetMainWnd(), 0);
}
Now it works great! thanks
|
|
|
|
|
HI all,
can anybody please suggest me can i change the alignment of text in CStatic label.
i want to change the alignment of text at runtime.
please help me for this.
thanks in advance.
|
|
|
|
|
|
sir have already use this.
but its not working properly\
m_st_label.ModifyStyle(0,SS_CENTER);
|
|
|
|
|
Le@rner wrote: not working properly What does that mean? Are you sure there are no style settings to be removed?
|
|
|
|
|
it means when i change alignment from left to center its shown but again when i change in any other alignment nothing is shown here.
|
|
|
|
|
You should use your debugger to check what options are set each time you make a change, and remember to remove the ones not needed. You also need to refresh the Window after making any changes.
|
|
|
|
|
How to determine whether the disk is bitlocker or or truecrypt?
|
|
|
|
|
|
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.
Thanks.
Walt
modified 8-Jan-16 18:30pm.
|
|
|
|
|
Is there an OnActivate handler that might be getting called which is resetting the controls?
What message handlers have been implemented for the dialog?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Richard,
Thanks for the reply. I checked my code and I do not have any OnActivate handlers.
Thanks.
Walt
|
|
|
|
|
How to analyze what time Windows 7(XP) once run any program?
modified 8-Jan-16 4:07am.
|
|
|
|
|
|
|
Member 2980860 wrote: ...once run any program?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
yes,once run any program.
|
|
|
|
|
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 boxes are defined as:
CListBox m_lstLeft;
CListBox m_lstRight;
In the .RC file the boxes are defined as follows:
LISTBOX IDC_LSEL_LSTLEFT,7,25,115,186,LBS_MULTIPLESEL | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
LISTBOX IDC_LSEL_LSTRIGHT,178,25,115,186,LBS_MULTIPLESEL | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
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:
CArray<int,int> aryListBoxSel;
aryListBoxSel.SetSize(nCount);
m_lstLeft.GetSelItems(nCount, aryListBoxSel.GetData());
for(i=0; i<nCount; i++)
{
idx = aryListBoxSel.GetAt(i);
val = (float)m_lstLeft.GetItemData(idx);
}
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.
|
|
|
|
|
I have edited your question so all the information is visble. In future please use <pre> tags around code blocks.
|
|
|
|
|
Thank you. I was just going to post a message that he should do that.
|
|
|
|
|
If you always get the same data value regardless of the index, all items may have the same data value. So check the code portions that set the item data of the right list box.
|
|
|
|
|
Sorry about the formatting, it was the first time I posted anything with code here.
The value is not always the same, it's whatever is last on the list. If the right list has the following strings:
"1"
"2"
"4"
"7"
"10"
"11"
Selecting "2" and clicking on the move left button will get the "11" and it will be moved to the left. If you then select the "2" again (or anything else on the list) and click on the move left button, the "10" will be selected and moved.
What gets selected is whatever is last on the list. The code for moving from the left box to the right is identical except for the control name and selecting the "2" would actually fetch the "2" from index 1 and move it.
The index fetched in both cases is correct. What isn't working is the code that gets the value for the index.
I'm completely baffled. The two are coded the same.
|
|
|
|