Print Page | Close Window

[SOLVED] HOWTO: Remove popup menu item

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=13112
Printed Date: 15 November 2024 at 7:10pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: [SOLVED] HOWTO: Remove popup menu item
Posted By: mgampi
Subject: [SOLVED] HOWTO: Remove popup menu item
Date Posted: 08 January 2009 at 9:25am
Hi;

Does anyone know how to remove a popup menu item? I know all the Add()/Remove() functions but my biggest problem is how to find the popup menu item within the collection of all CXTPControl(s).

I use the code in OnInitCommandsPopup:

    // get the list of commands for the popup.
    CXTPControls* pCommandList = pCommandBar->GetControls();

    // Remove "New" menu item from the File menu.
    CXTPControl* pCommandNew = pCommandList->FindControl(...); ?
    if (pCommandNew)
        pCommandList->Remove(pCommandNew);


but I don't know what to set in FindControl to get the pointer to the popup item?
Within the submenu I have several popup menu items so I can't look only for an item of type xtpControlPopup and additional the caption of the item depends on user selected languages.

Any help is very welcome!


-------------
Martin

Product: Xtreme Toolkit v 22.1.0, new Projects v 24.0.0
Platform: Windows 10 v 22H2 (64bit)
Language: VC++ 2022



Replies:
Posted By: mgampi
Date Posted: 08 January 2009 at 11:31am
Update:

Now I'm using actions to show/hide menu items on startup. But I still have the problem to not be able to remove empty popup menu items!


-------------
Martin

Product: Xtreme Toolkit v 22.1.0, new Projects v 24.0.0
Platform: Windows 10 v 22H2 (64bit)
Language: VC++ 2022


Posted By: Oleg
Date Posted: 09 January 2009 at 1:57am
Hi,
 
Most easy way is also add some Id or assign Action for popup menu item.
 
In resource editor you can add Id in caption to separate it with "\t" :
 
"File\t100"
it will assign 100 id to File item.


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


Posted By: mgampi
Date Posted: 09 January 2009 at 3:05pm
Many thanks Oleg!

Assigning the ID to the popup item in resource file works fine.
But now two more questions:

1. What do you mean with "assign action for popup menu item"? How can this be done?
2. Let's suppose a menu defined in resource as shown

...
MENUITEM "Item 1", ID_ITEM1
MENUITEM "Item 2", ID_ITEM2
MENUITEM SEPARATOR
MENUITEM "Item 3", ID_ITEM3
MENUITEM SEPARATOR
MENUITEM "Item 4", ID_ITEM4
MENUITEM "Item 5", ID_ITEM5
...

Now I remove ID_ITEM2, ID_ITEM3 and ID_ITEM4 in code by CXTPControlAction::SetVisible(FALSE) actions. Unfortunately both of the separators are also removed. How can I prevent the second separator from being removed when hiding the both mentioned items?

Thanks in advance


-------------
Martin

Product: Xtreme Toolkit v 22.1.0, new Projects v 24.0.0
Platform: Windows 10 v 22H2 (64bit)
Language: VC++ 2022


Posted By: Oleg
Date Posted: 09 January 2009 at 3:55pm

Hi,

1. You said you use actions for menu items - if you add Id for Popup item you will be able hide it with actions too.
 
2. Sorry there is no easy way :(


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


Posted By: mgampi
Date Posted: 09 January 2009 at 4:16pm
Originally posted by oleg oleg wrote:

Hi,

1. You said you use actions for menu items - if you add Id for Popup item you will be able hide it with actions too.

OK! Once again many thanks ...
Originally posted by oleg oleg wrote:


2. Sorry there is no easy way :(

And the hard way? Any hints?


-------------
Martin

Product: Xtreme Toolkit v 22.1.0, new Projects v 24.0.0
Platform: Windows 10 v 22H2 (64bit)
Language: VC++ 2022


Posted By: Oleg
Date Posted: 10 January 2009 at 9:56am
Hi,
 
Hard way is manually call pControl->SetBeginGroup(TRUE/FALSE) for visible item.
for example with Action you can find all instances of control (pAction->GetControl(i) and update its SetBeginGroup.


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


Posted By: mgampi
Date Posted: 12 January 2009 at 4:51am
Thanks Oleg!

I'll give it a try - perhaps the effort isn't worth the result, but customer is king!


-------------
Martin

Product: Xtreme Toolkit v 22.1.0, new Projects v 24.0.0
Platform: Windows 10 v 22H2 (64bit)
Language: VC++ 2022



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