Print Page | Close Window

Disabling a sub menu

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=3938
Printed Date: 10 November 2025 at 7:48am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Disabling a sub menu
Posted By: fishy
Subject: Disabling a sub menu
Date Posted: 04 April 2006 at 7:39am
Hello,
I would like to disable a sub-menu, not an item itself, the actual menu.  For example, in Outlook there is a File->New->Mail message, File->New->Folder, etc...  It is easy to disable the "Mail message" and "Folder" menu items with an update ui handler.  It is not so easy however, to disable the "New" sub-menu.  I have tried using OnInitCommandsPopup but this doesn't get me very far since I can't tell what sub-menu i want to disable (they seem to all have an ID of 0).  I can check the text of the sub menu itself and disable it if the text matches, but this is not an acceptable solution since the text can be different (languages, etc..).  What is the proper solution for this problem?



Replies:
Posted By: Oleg
Date Posted: 04 April 2006 at 9:15am

Hello,

Solution is to catch OnCreateControl event and assign some id to use it for Update handler:

  if (lpCreateControl->controlType == xtpControlPopup && lpCreateControl->strCaption == _T("&Copy"))
  {
   //lpCreateControl->controlType = xtpControlSplitButtonPopup;
   lpCreateControl->nID = ID_EDIT_COPY;
   return TRUE;
  }



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


Posted By: fishy
Date Posted: 04 April 2006 at 1:43pm
Oleg, you missed the point. Your "solution" includes checking the caption string!  I don't want to do anything hackish like this.  (I can't rely on the caption string being anything fixed -- think about the case with different languages.).  Also, in OnCreateControl, when you assign an ID ( lpCreateControl->nID = SOME_ID ) to a sub-menu (not the leaf item itself), then in OnInitCommandsPopup, GetBarID() returns 0, not the ID you assigned.  I still haven't found a solution to this, any more help?


Posted By: Oleg
Date Posted: 04 April 2006 at 2:13pm

Hello,

Other solutions don't exist. When you create menus in IDE Menu editor you only specify Caption and Index, so you can determine Popup only by caption or index. No other ways instead of manually create all menus without IDE's editor.

so you can try to check index of popup :

if (lpCreateControl->nindex == xxx)...



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


Posted By: fishy
Date Posted: 04 April 2006 at 2:53pm
Oleg, thanks. 
I am actually doing just that right now (checking the index).  It works okay (until I add something to the menu and forget to change the index in the code).  Its unfortunate that this is the only other solution.  I think codejock could provide a better way to do this in the command bars implementation.  If I could set some 32 bit user-defined value to a menu item in OnCreateControl then in OnInitCommandsPopup I could check that value to determine which menu item I was actually working with.

- fishy



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