EnableMenuItem dosn't work ?
Kent Fonager Kristensen -- KFK@SIEMENS.DK Thursday, January 30, 1997 Environment: VC++ 4.0, NT3.51, NT 4.0 Hi everybody !! I have this problem, when working with popup-menu's : I have a popupmenu, where one of the item's state is dependent on another event, eg. "Is this selection valid ?"... I try to control this, using the code below... ... CMenu menu; VERIFY(menu.LoadMenu(IDR_POPUP_TOPOLOGY_VIEW)); CMenu* pPopup = menu.GetSubMenu(0); ASSERT(pPopup != NULL); // if not valid, disable/gray the item, at pos. 2 if(!Valid_Selection) pPopup->EnableMenuItem( ITEM_2, MF_BYPOSITION|MF_DISABLED|MF_GRAYED ); CWnd* pWndPopupOwner = this; while (pWndPopupOwner->GetStyle() & WS_CHILD) pWndPopupOwner = pWndPopupOwner->GetParent(); pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, pWndPopupOwner); ... But nothing at all happens... I've implementet the eventhandler for the ITEM_2, and m_bAutoMenuEnable is set to default (enabled). I've talked to another MFC-programmer in the company, and he faced the same problem, months ago !! Hope that someone can help !! Thanks in advance,.. Kent Fonager Software Engineer ET317, Energy & Traffics Division Siemens A/S, Technical Department Phone : +45 4477 5934 Fax : +45 4477 4013 Email, business : kfk@siemens.dk Email, private : kfonager@post3.tele.dk
Michael -- Michael.Dunphy@HBC.honeywell.com Saturday, February 01, 1997 KFK@SIEMENS.DK wrote: // if not valid, disable/gray the item, at pos. 2 if(!Valid_Selection) pPopup->EnableMenuItem( ITEM_2, MF_BYPOSITION|MF_DISABLED|MF_GRAYED ); Your first and second arguments to EnableMenuItem don't match. Try pPopup->EnableMenuItem( ITEM_2, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED ); or pPopup->EnableMenuItem( 2, MF_BYPOSITION | MF_DISABLED | MF_GRAYED ); - Mike Dunphy
Amir Salzberg -- amir@cryptont.com Tuesday, February 04, 1997 >KFK@SIEMENS.DK wrote: > > // if not valid, disable/gray the item, at pos. 2 > if(!Valid_Selection) > pPopup->EnableMenuItem( ITEM_2, MF_BYPOSITION|MF_DISABLED|MF_GRAYED ); > >Your first and second arguments to EnableMenuItem don't match. Try > pPopup->EnableMenuItem( ITEM_2, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED >); >or > pPopup->EnableMenuItem( 2, MF_BYPOSITION | MF_DISABLED | MF_GRAYED ); > > > - Mike Dunphy > > In addition to that, Try to write at the constructor of your CMainFrame class: m_bAutoMenuEnable = FALSE; That should work;
| Вернуться в корень Архива |