Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - [SOLVED] HOWTO: Remove popup menu item
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

[SOLVED] HOWTO: Remove popup menu item

 Post Reply Post Reply
Author
Message
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1198
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post Topic: [SOLVED] HOWTO: Remove popup menu item
    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 19.0.0, new Projects v 19.1.0
Platform: Windows 10 v 1909 (64bit)
Language: VC++ 2017
Back to Top
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1198
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post 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 19.0.0, new Projects v 19.1.0
Platform: Windows 10 v 1909 (64bit)
Language: VC++ 2017
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


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: 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
Back to Top
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1198
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post 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 19.0.0, new Projects v 19.1.0
Platform: Windows 10 v 1909 (64bit)
Language: VC++ 2017
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


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: 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
Back to Top
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1198
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post 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 19.0.0, new Projects v 19.1.0
Platform: Windows 10 v 1909 (64bit)
Language: VC++ 2017
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


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: 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
Back to Top
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1198
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post 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 19.0.0, new Projects v 19.1.0
Platform: Windows 10 v 1909 (64bit)
Language: VC++ 2017
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.266 seconds.