Print Page | Close Window

LoadMenu discard the MFS_GRAYED flag?

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=1168
Printed Date: 06 November 2025 at 12:19pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: LoadMenu discard the MFS_GRAYED flag?
Posted By: blueseaing
Subject: LoadMenu discard the MFS_GRAYED flag?
Date Posted: 13 September 2004 at 1:44am

I have such code

  CMenu cMenu;
  VERIFY(cMenu.LoadMenu(IDR_FAVORITE_POPUP));
  CMenu* pPopup = cMenu.GetSubMenu(0); 
  pPopup->EnableMenuItem(ID_FAVORITE_DELETE,MF_GRAYED);
  CXTPCommandBars::TrackPopupMenu(pPopup,TPM_LEFTALIGN, point.x, point.y,this, NULL);

  but the MF_GRAYED not appeared, and if i use the winapi ::TrackPopupMenu() and the
effect will appear, so I study the source code of XTP,and added such code belows:

BOOL CXTPCommandBar::LoadMenu(CMenu* pMenu, BOOL bRemoveControls)
{
 if (!pMenu || !::IsMenu(pMenu->m_hMenu))
  return FALSE;

 if (bRemoveControls)
  m_pControls->RemoveAll();
 
 BOOL bSeparator = FALSE;
 for (int i = 0; i < ::GetMenuItemCount(pMenu->m_hMenu); i++)
 {
  // Check to see if the item is a separator, we don't want
  // to use GetMenuItemID(i) because it may not equal zero.
  MENUITEMINFO info = { sizeof(MENUITEMINFO), MIIM_TYPE };
  ::GetMenuItemInfo(pMenu->m_hMenu, i, TRUE, &info);

  if ((info.fType & MFT_SEPARATOR) == MFT_SEPARATOR)
   bSeparator = TRUE;
  else
  {
   CXTPControl* pControl = m_pControls->AddMenuItem(pMenu, i);

   if (pControl && bSeparator)
   {
    pControl->SetBeginGroup(TRUE);
    bSeparator = FALSE;
 
   }

   //added such code but the SetEnabled() function  don't effect ??? why??
   if (info.fState & MFS_GRAYED)
   {
    pControl->SetEnabled(FALSE);
    
   }
  }
 }
 CFrameWnd* pFrame = GetParentFrame();
 if (pFrame) pFrame->DelayRecalcLayout();
 return TRUE;
}

why?? does the xtp discard the MFS_GRAYED???

 




Replies:
Posted By: Oleg
Date Posted: 15 September 2004 at 11:53pm
it works with 9.10   with TPM_NONOTIFY flag

-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: blueseaing
Date Posted: 20 September 2004 at 7:35pm
how can i solve the promblem in xtp8.7, do have any hot fix? please help me.


Posted By: Oleg
Date Posted: 21 September 2004 at 6:57am

Add UPDATE handler for ID_FAVORITE_DELETE and call

pCmdUI->Enable(FALSE);



-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net