|  | 
| [SOLVED] HOWTO: Remove popup menu item | 
| Post Reply   | 
| Author | ||
| mgampi   Senior Member     Joined: 14 July 2003 Status: Offline Points: 1210 |  Post Options  Thanks(0)  Quote  Reply  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: 
 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 | ||
|  | ||
| mgampi   Senior Member     Joined: 14 July 2003 Status: Offline Points: 1210 |  Post Options  Thanks(0)  Quote  Reply  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 | ||
|  | ||
| Oleg   Senior Member   Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |  Post Options  Thanks(0)  Quote  Reply  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 | ||
|  | ||
| mgampi   Senior Member     Joined: 14 July 2003 Status: Offline Points: 1210 |  Post Options  Thanks(0)  Quote  Reply  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 
 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 | ||
|  | ||
| Oleg   Senior Member   Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |  Post Options  Thanks(0)  Quote  Reply  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 | ||
|  | ||
| mgampi   Senior Member     Joined: 14 July 2003 Status: Offline Points: 1210 |  Post Options  Thanks(0)  Quote  Reply  Posted: 09 January 2009 at 4:16pm | |
| 
 OK! Once again many thanks ... 
 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 | ||
|  | ||
| Oleg   Senior Member   Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |  Post Options  Thanks(0)  Quote  Reply  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 | ||
|  | ||
| mgampi   Senior Member     Joined: 14 July 2003 Status: Offline Points: 1210 |  Post Options  Thanks(0)  Quote  Reply  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 | ||
|  | ||
| 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 |