![]()  | 
 
Want to create all menus dynamically | 
 
    Post Reply  
   | 
  
| Author | |
   
   deepghosh  
   
   Groupie  
   Joined: 10 March 2006 Location: United States Status: Offline Points: 14  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Topic: Want to create all menus dynamicallyPosted: 10 March 2006 at 9:48am  | 
 
| 
   
    I want to add a new menu element dynamically and add submenus to it. I cannot use a resource. I am populating from a set of proprietary objects. So..the approach I am taking (maybe wrong - trying to learn from dynamicpopup sample - which is not really my case). Create a CXTPControlPopup derived and add it to command bar. (This part works). Now I am confused...Which ones I have to override..CalcDynamicSize,OnSetPopup or what? I can make my menu popup piece show up. But I cannot add children to it. This is simply because of lack of knowledge. I wish Dynamic Popup sample did not have the Undo bit on the main one already created then I could have just followed that example. HELP!!  | 
 |
![]()  | 
 |
   
   Oleg  
   
   Senior Member  
   Joined: 21 May 2003 Location: United States Status: Offline Points: 11234  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Posted: 10 March 2006 at 10:11am | 
 
| 
   
    
 Just add new controls in this popup's commandbar: pPopup->GetCommandBar()->GetControls()->Add(...);  | 
 |
| 
   
     
     Oleg, Support Team 
   
  CODEJOCK SOFTWARE SOLUTIONS  | 
 |
![]()  | 
 |
   
   deepghosh  
   
   Groupie  
   Joined: 10 March 2006 Location: United States Status: Offline Points: 14  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Posted: 10 March 2006 at 12:16pm | 
 
| 
   
    void CiListOfPopupMenus::AddMenu(CiMainFrame*pMain, CiPopupMenu* pIPopupMenu,LPCTSTR szTitle) -- UPTO THIS ALL OK CXTPCommandBar *pBar = pControlPopup->GetCommandBar();     BUT NOW I GET pBar AS NULL...WHY?  | 
 |
![]()  | 
 |
   
   Oleg  
   
   Senior Member  
   Joined: 21 May 2003 Location: United States Status: Offline Points: 11234  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Posted: 11 March 2006 at 12:47pm | 
 
| 
   
    Hello, right... sorry.. by default it is NULL, just add CXTPControlPopup* pControlPopup = new CXTPControlPopup();  pControlPopup->SetCommandBar(CXTPPopupBar::CreatePopupBar (pCommandBars); or you can automatically convrert CMenu to CommandBar CMenu* pMenu = ... pControlPopup->SetCommandBar(pMenu);  | 
 |
| 
   
     
     Oleg, Support Team 
   
  CODEJOCK SOFTWARE SOLUTIONS  | 
 |
![]()  | 
 |
   
   deepghosh  
   
   Groupie  
   Joined: 10 March 2006 Location: United States Status: Offline Points: 14  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Posted: 12 March 2006 at 10:10pm | 
 
| 
   
    Sorry Still does not work.     CXTPMenuBar*pMenuBar = pMain->GetMenuBar();     CXTPControl* pControl = new CXTPControlButton(); I did not know what you meant by pCommandBars (Understood it needs that type of object, so I replaced by pMain->GetCommandBars()) ..Maybe thats the problem? What I get is a disabled popup menu added with NO CHILDREN. However I appreciate all your help. I think we possibly need a sample app for which all the menus (or at least one menu) is constructed dynamically. I think I can usea CMenu object but do not intend to do so.  | 
 |
![]()  | 
 |
   
   deepghosh  
   
   Groupie  
   Joined: 10 March 2006 Location: United States Status: Offline Points: 14  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Posted: 12 March 2006 at 10:11pm | 
 
| 
   
    Also I wanted to add this. CXTPPopupBar was created with hWnd 0 , what means creation failed?  | 
 |
![]()  | 
 |
   
   deepghosh  
   
   Groupie  
   Joined: 10 March 2006 Location: United States Status: Offline Points: 14  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Posted: 13 March 2006 at 12:42am | 
 
| 
   
    Also Tried This..Still it is disabled (Enabled Items here) void CiListOfPopupMenus::AddMenu(CiMainFrame*pMain, CiPopupMenu* pIPopupMenu,LPCTSTR szTitle) 
     CXTPControl* pControl = new CXTPControlButton();  | 
 |
![]()  | 
 |
   
   Oleg  
   
   Senior Member  
   Joined: 21 May 2003 Location: United States Status: Offline Points: 11234  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Posted: 13 March 2006 at 5:53pm | 
 
| 
   
    You add pControlPopup with Id = 3 it means that you must use Update Handle to enable/disable it. Just use (-1) if you want to enable it.  | 
 |
| 
   
     
     Oleg, Support Team 
   
  CODEJOCK SOFTWARE SOLUTIONS  | 
 |
![]()  | 
 |
   
   deepghosh  
   
   Groupie  
   Joined: 10 March 2006 Location: United States Status: Offline Points: 14  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Posted: 14 March 2006 at 5:01pm | 
 
| 
   
    Oleg You are great. (Its fixed) I think we all appreciate your persistent help. Deep  | 
 |
![]()  | 
 |
   
   bambha  
   
   Newbie  
   Joined: 19 June 2006 Location: United States Status: Offline Points: 9  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Posted: 19 July 2006 at 7:38pm | 
 
| 
   
    
   How can disable a menu item? I have File->New, File->Exit. How can disable Exit if my menu is created using 
 
   
  CXTPCommandBars* pCommandBars = GetCommandBars(); 
pCommandBars->SetMenu(_T("Menu Bar"), IDR_MENU); 
    | 
 |
| 
   
     
     Manik Bambha
     
   
   | 
 |
![]()  | 
 |
   
   Oleg  
   
   Senior Member  
   Joined: 21 May 2003 Location: United States Status: Offline Points: 11234  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Posted: 20 July 2006 at 8:51am | 
 
| 
   
    Hello, 
Add update handlers. See how ON_UPDATE_COMMAND_UI work in any sample. 
    | 
 |
| 
   
     
     Oleg, Support Team 
   
  CODEJOCK SOFTWARE SOLUTIONS  | 
 |
![]()  | 
 |
   
   bambha  
   
   Newbie  
   Joined: 19 June 2006 Location: United States Status: Offline Points: 9  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Posted: 21 July 2006 at 12:05pm | 
 
| 
   
    
   Thanks Oleg. I am able to change the text and disable it. Do you know how to delete?
    
   
   | 
 |
| 
   
     
     Manik Bambha
     
   
   | 
 |
![]()  | 
 |
   
   Oleg  
   
   Senior Member  
   Joined: 21 May 2003 Location: United States Status: Offline Points: 11234  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Posted: 21 July 2006 at 2:51pm | 
 
| 
   
    Hi, See Notifications sample. 
    | 
 |
| 
   
     
     Oleg, Support Team 
   
  CODEJOCK SOFTWARE SOLUTIONS  | 
 |
![]()  | 
 |
   
   bambha  
   
   Newbie  
   Joined: 19 June 2006 Location: United States Status: Offline Points: 9  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Posted: 21 July 2006 at 4:08pm | 
 
| 
   
    
   Thanks Oleg. Its working for me now.
 
   
  For people here is the code  
CXTPCommandBar* pToolBar = (CXTPToolBar*)pCmdUI->m_pOther; if (pToolBar){ CXTPControl* pControl = pToolBar->GetControls()->GetAt(pCmdUI->m_nIndex); pControl->SetVisible(0); pToolBar->DelayLayout(); }  | 
 |
| 
   
     
     Manik Bambha
     
   
   | 
 |
![]()  | 
 |
   
   Oleg  
   
   Senior Member  
   Joined: 21 May 2003 Location: United States Status: Offline Points: 11234  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Posted: 21 July 2006 at 5:05pm | 
 
| 
   
    Hi, 
I'd replace it to: 
CXTPControl* pControl = CXTPControl::FromUI(pCmdUI); 
if (pControl) 
{      pControl->SetVisible(FALSE); 
} 
(SetVisible already have DelayLayout _if state is really changed_) 
 | 
 |
| 
   
     
     Oleg, Support Team 
   
  CODEJOCK SOFTWARE SOLUTIONS  | 
 |
![]()  | 
 |
    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  |