Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Disabling a sub menu
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Disabling a sub menu

 Post Reply Post Reply
Author
Message
fishy View Drop Down
Newbie
Newbie
Avatar

Joined: 26 October 2005
Status: Offline
Points: 17
Post Options Post Options   Thanks (0) Thanks(0)   Quote fishy Quote  Post ReplyReply Direct Link To This Post Topic: Disabling a sub menu
    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?
Back to Top
Oleg View Drop Down
Senior Member
Senior Member


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
fishy View Drop Down
Newbie
Newbie
Avatar

Joined: 26 October 2005
Status: Offline
Points: 17
Post Options Post Options   Thanks (0) Thanks(0)   Quote fishy Quote  Post ReplyReply Direct Link To This Post 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?
Back to Top
Oleg View Drop Down
Senior Member
Senior Member


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
fishy View Drop Down
Newbie
Newbie
Avatar

Joined: 26 October 2005
Status: Offline
Points: 17
Post Options Post Options   Thanks (0) Thanks(0)   Quote fishy Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.063 seconds.