![]() |
Disabling a sub menu |
Post Reply
|
| Author | |
fishy
Newbie
Joined: 26 October 2005 Status: Offline Points: 17 |
Post Options
Thanks(0)
Quote Reply
Topic: Disabling a sub menuPosted: 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? |
|
![]() |
|
Oleg
Senior Member
Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
Quote Reply
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")) |
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
|
fishy
Newbie
Joined: 26 October 2005 Status: Offline Points: 17 |
Post Options
Thanks(0)
Quote Reply
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?
|
|
![]() |
|
Oleg
Senior Member
Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
Quote Reply
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 |
|
![]() |
|
fishy
Newbie
Joined: 26 October 2005 Status: Offline Points: 17 |
Post Options
Thanks(0)
Quote Reply
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 |
|
![]() |
|
Post Reply
|
|
|
Tweet
|
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |