![]() |
Popups within Popups - How? |
Post Reply ![]() |
Author | |
shrapnel ![]() Newbie ![]() Joined: 02 March 2006 Status: Offline Points: 8 |
![]() ![]() ![]() ![]() ![]() Posted: 02 March 2006 at 2:05pm |
I've successfully displayed a popup menu. The code is below pObjPopupBar = CXTPPopupBar::CreatePopupBar(0); CXTPControl* pControl = pObjPopupBar->GetControls()->Add(xtpControlButton, objMapIter->first); pControl->SetCaption(strMenuCaption); pControl->SetFlags(xtpFlagManualUpdate); UINT uintIconId = (objChildTypeIter->second).m_uintIconID; pControl->SetIconId(uintIconId); I then call the TrackPopupMenu. But how do you display a popup within a popup? Thanks Paul
|
|
![]() |
|
Oleg ![]() Admin Group ![]() Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
![]() ![]() ![]() ![]() ![]() |
Hello,
CXTPControlPopup* pControlPopup = (CXTPControlPopup)pObjPopupBar->GetControls()->Add(xtp ControlPopup, objMapIter->first); |
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
|
shrapnel ![]() Newbie ![]() Joined: 02 March 2006 Status: Offline Points: 8 |
![]() ![]() ![]() ![]() ![]() |
Thanks for responding but I'm a little confused. Wouldn't I need a another parent popup object to place the child popup into? Also, I'm a little confused about the id as well. I'm not creating any of the menus from resources - they are all created on the fly? Is the id the first control in the child popup bar? To be clear - I have my pObjPopupBar populated with a list of controls. I then want to place this popup inside another popup so that it has the following structure: The Add menu item in the parent displays all the menu items of pObjPopuBar. The parent popupbar will also have some non-nested menu items as well. What's throwing me off is the id in the Add method when added to the parent. What does this represent? I mean, it does popup another blank menu but it needs to popup the child - how is this connection made? I was thinking something like this - except I don't know what to put in for the id value: CXTPControlPopup* pControlPopup = (CXTPControlPopup)pObjParentPopupBar->GetControls()->A dd(xtp ControlPopup, ?????);
|
|
![]() |
|
shrapnel ![]() Newbie ![]() Joined: 02 March 2006 Status: Offline Points: 8 |
![]() ![]() ![]() ![]() ![]() |
Ok I seemed to figure how to place one menu inside the other. It's a mix of CMenu and codejock controls - definitely not an elegant. I prefer just using codejock controls so if you have an answer to my first reply it would be appreciated. One thing I don't understand with this solution is why the icons are being placed next to the caption of the sub menu since I'm no longer setting the icon id using the CXTPControl - I'm using a simple CMenu. A further problem is my sub menu is all grayed out - not sure why either. The code is below. int intMenuCmd = MENU_ID_CANCEL;CMenu objMainMenu, objSubMenu; BOOL bMenuCreated = FALSE; CPoint objPoint; BOOL bGetCursorPos = FALSE; CXTPPopupBar* pObjPopupBar; CXTPPopupBar* pObjParentPopupBar; CXTPFrameWnd* pFrame = (CXTPFrameWnd*)AfxGetMainWnd(); // Create the popup barspObjParentPopupBar = CXTPPopupBar::CreatePopupBar(0); pObjPopupBar = CXTPPopupBar::CreatePopupBar(0); // Create the top level menubMenuCreated = objMainMenu.CreatePopupMenu(); // Create the sub menubMenuCreated = objSubMenu.CreatePopupMenu(); // Obtain a list of supported document types. These types are specified // Load the menu into a popup barpObjPopupBar->LoadMenu(&objSubMenu); CXTPControls* pControls = pObjPopupBar->GetControls(); for( int i=0; i< pControls->GetCount(); i++ ){ CXTPControl* a = pControls->GetAt(i); a->SetEnabled(TRUE); } // Determine if the Add menu item should appear - Note: this menu item // contains a sub-menu if( objSubMenu.GetMenuItemCount() ){ objMainMenu.AppendMenu( MF_POPUP, (UINT)objSubMenu.m_hMenu, objResourceProvider.GetStringResource(IDS_SKSD_ADD)); CXTPControl* pControl = pObjParentPopupBar->GetControls()->AddMenuItem(&ob jMainMenu, objMainMenu.GetMenuItemCount()-1); pControl->SetCaption(objResourceProvider.GetStringResourc e(IDS_SKSD_ADD)); pControl->SetFlags(xtpFlagManualUpdate); } // Determine if the Delete menu item should appear if( pDocument->CanBeRemoved() ){ objMainMenu.AppendMenu( MF_STRING, IDS_SKSD_DELETE , objResourceProvider.GetStringResource(IDS_SKSD_DELETE)); CXTPControl* pControl = pObjParentPopupBar->GetControls()->AddMenuItem(&ob jMainMenu, objMainMenu.GetMenuItemCount()-1); pControl->SetCaption(objResourceProvider.GetStringResourc e(IDS_SKSD_DELETE)); //pControl->SetFlags(xtpFlagManualUpdate);} // Determine if the Rename menu item should appear if( pDocument->CanBeRenamed() ){ objMainMenu.AppendMenu( MF_STRING, IDS_SKSD_RENAME, objResourceProvider.GetStringResource(IDS_SKSD_RENAME)); CXTPControl* pControl = pObjParentPopupBar->GetControls()->AddMenuItem(&ob jMainMenu, objMainMenu.GetMenuItemCount()-1); pControl->SetCaption(objResourceProvider.GetStringResourc e(IDS_SKSD_RENAME)); pControl->SetFlags(xtpFlagManualUpdate); } UINT intCommand = CXTPCommandBars::TrackPopupMenu(pObjParentPopupBar, TPM_RETURNCMD, objPoint.x, objPoint.y, (CWnd*)m_pParentWnd); thanks |
|
![]() |
|
shrapnel ![]() Newbie ![]() Joined: 02 March 2006 Status: Offline Points: 8 |
![]() ![]() ![]() ![]() ![]() |
I'm sorry but I dont' understand this code. All I'm trying to do is place one CXTPPopupBar within another. That Add api clearly doesn't provide for this so I'm confused with the code snippet you gave me. Can you please provide an explanation of what should be placed in objMapiter->first when you don't have a resource id to use. CXTPControlPopup* pControlPopup = (CXTPControlPopup)pObjPopupBar->GetControls()->Add(xtp ControlPopup, objMapIter->first); Perhaps it because I'm new to the product but I'm not understanding how to do this. Regards,
Paul |
|
![]() |
|
Oleg ![]() Admin Group ![]() Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
![]() ![]() ![]() ![]() ![]() |
Hi, I just copied it from your first sample. use -1 as Id for popups. |
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
|
shrapnel ![]() Newbie ![]() Joined: 02 March 2006 Status: Offline Points: 8 |
![]() ![]() ![]() ![]() ![]() |
I think there is a miscommunication here. I already figured out how to create the sub menu by using the xtpControlPopup constant as the first argument. This returns a CXTPControl type so that you can modify the caption and other things. The problem is populating the sub menu. Here's my code snippet: map< int, CString >::const_iterator objMapIter = objDocTypeMap.begin(); int i=0; for( objMapIter; objMapIter != objDocTypeMap.end(); objMapIter++ ){ CString strMenuCaption = ""; objChildTypeIter = objDocumentTypeDetails.find(objMapIter->second); if ( objChildTypeIter != objDocumentTypeDetails.end() ){ strMenuCaption = (objChildTypeIter->second).m_strCaption; } else{ strMenuCaption = objMapIter->second; } // the document type map.UINT uintIconId = (objChildTypeIter->second).m_uintIconID; CXTPControlPopup* pControl = (CXTPControlPopup*)pObjPopupBar->GetControls()->Add(xt pControlButton, objMapIter->first); pControl->SetID(objMapIter->first); pControl->SetCaption(strMenuCaption); pControl->SetIconId(uintIconId); } This creates the inner sub menu. Then I do this to try and set a parent popup bar items: CXTPControlPopup* pPopupControl = (CXTPControlPopup*)pObjParentPopupBar->GetControls()->Add(xtpControlPopup,-1); pPopupControl->SetCaption(objResourceProvider.GetStringRe source(IDS_SKSD_ADD)); But how do I get my first menu inside the parent menu. I tried doing this: CXTPControl* aControl = pPopupcontrol->GetControls()->Add(xtpControlButton, 8900); However, this just menu item is created at the same level as the xtpControlPopup type listed above. This is quite simple to do with CMenu but it's becoming difficult with CodeJock. Regards, Paul
|
|
![]() |
|
shrapnel ![]() Newbie ![]() Joined: 02 March 2006 Status: Offline Points: 8 |
![]() ![]() ![]() ![]() ![]() |
I guess what I'm asking is can you provide an example of creating nested menus on the fly using the CXTPPopupBar class. No resources can be used. Thanks, Paul |
|
![]() |
|
Oleg ![]() Admin Group ![]() Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
![]() ![]() ![]() ![]() ![]() |
try: pPopupcontrol->GetCommandBar()->GetControls()->Add |
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
|
shrapnel ![]() Newbie ![]() Joined: 02 March 2006 Status: Offline Points: 8 |
![]() ![]() ![]() ![]() ![]() |
That did it thanks. I can't say that's very natural though. But thanks for the help. Paul |
|
![]() |
|
BruceW ![]() Newbie ![]() Joined: 05 April 2006 Location: United Kingdom Status: Offline Points: 21 |
![]() ![]() ![]() ![]() ![]() |
Hi,
I have the same requirement (completely dynamic menu with submenus). However I find the above examples very hard to follow. Is there a simple example somewhere which shows how to create a menu and within it a submenu. Thanks, Bruce. |
|
![]() |
|
BruceW ![]() Newbie ![]() Joined: 05 April 2006 Location: United Kingdom Status: Offline Points: 21 |
![]() ![]() ![]() ![]() ![]() |
Hi,
I have finally managed to get it to work. ... on to the next issue. Thanks. Bruce. |
|
![]() |
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 |