Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - Popups within Popups - How?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Popups within Popups - How?

 Post Reply Post Reply
Author
Message
shrapnel View Drop Down
Newbie
Newbie


Joined: 02 March 2006
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote shrapnel Quote  Post ReplyReply Direct Link To This Post Topic: Popups within Popups - How?
    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

 

 

 

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: 02 March 2006 at 3:42pm

Hello,

 

CXTPControlPopup* pControlPopup = (CXTPControlPopup)pObjPopupBar->GetControls()->Add(xtp ControlPopup, objMapIter->first);

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
shrapnel View Drop Down
Newbie
Newbie


Joined: 02 March 2006
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote shrapnel Quote  Post ReplyReply Direct Link To This Post Posted: 03 March 2006 at 9:13am

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, ?????);

 

 

Back to Top
shrapnel View Drop Down
Newbie
Newbie


Joined: 02 March 2006
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote shrapnel Quote  Post ReplyReply Direct Link To This Post Posted: 03 March 2006 at 10:41am

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 bars

pObjParentPopupBar = CXTPPopupBar::CreatePopupBar(0);

pObjPopupBar = CXTPPopupBar::CreatePopupBar(0);

// Create the top level menu

bMenuCreated = objMainMenu.CreatePopupMenu();

// Create the sub menu

bMenuCreated = objSubMenu.CreatePopupMenu();

// Obtain a list of supported document types. These types are specified

// Load the menu into a popup bar

pObjPopupBar->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

Back to Top
shrapnel View Drop Down
Newbie
Newbie


Joined: 02 March 2006
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote shrapnel Quote  Post ReplyReply Direct Link To This Post Posted: 03 March 2006 at 2:16pm

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

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: 06 March 2006 at 10:51am

Hi,

I just copied it from your first sample. use -1 as Id for popups.

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
shrapnel View Drop Down
Newbie
Newbie


Joined: 02 March 2006
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote shrapnel Quote  Post ReplyReply Direct Link To This Post Posted: 06 March 2006 at 1:19pm

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

 

Back to Top
shrapnel View Drop Down
Newbie
Newbie


Joined: 02 March 2006
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote shrapnel Quote  Post ReplyReply Direct Link To This Post Posted: 06 March 2006 at 1:28pm

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 

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: 06 March 2006 at 1:29pm

try:

pPopupcontrol->GetCommandBar()->GetControls()->Add

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
shrapnel View Drop Down
Newbie
Newbie


Joined: 02 March 2006
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote shrapnel Quote  Post ReplyReply Direct Link To This Post Posted: 06 March 2006 at 1:37pm

That did it thanks.  I can't say that's very natural though.

But thanks for the help.

Paul

Back to Top
BruceW View Drop Down
Newbie
Newbie


Joined: 05 April 2006
Location: United Kingdom
Status: Offline
Points: 21
Post Options Post Options   Thanks (0) Thanks(0)   Quote BruceW Quote  Post ReplyReply Direct Link To This Post Posted: 06 April 2006 at 11:32am
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.
Back to Top
BruceW View Drop Down
Newbie
Newbie


Joined: 05 April 2006
Location: United Kingdom
Status: Offline
Points: 21
Post Options Post Options   Thanks (0) Thanks(0)   Quote BruceW Quote  Post ReplyReply Direct Link To This Post Posted: 06 April 2006 at 12:50pm
Hi,

I have finally managed to get it to work.

... on to the next issue.

Thanks.

Bruce.
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.203 seconds.