Creating Normal Menu on the fly |
Post Reply |
Author | |
lion
Groupie Joined: 04 March 2008 Status: Offline Points: 22 |
Post Options
Thanks(0)
Posted: 01 April 2009 at 6:06am |
Hi,
I would appriciate some help! all I want to do is build a menu on the fly... this is what I do so far: VoidT CreateMenuBar(HWND wnd, HMENU hMenu) { CMenu* pMenu = CMenu::FromHandle(hMenu); CXTPCommandBar* pMenuBar = pFrame->GetCommandBars()->GetMenuBar(); pMenuBar->LoadMenu(pMenu); CXTPMyControlPopup* pMyCtrl = CXTPMyControlPopup::CreateMyControlPopup(xtpControlPopup); pMyCtrl->SetCaption((LPCTSTR)"MyCtrl"); pMenuBar->GetControls()->Add(pMyCtrl); CXTPPopupToolBar* pBar = CXTPPopupToolBar::CreatePopupToolBar(pMenuBar->GetCommandBars()); pMyCtrl->SetCommandBar(pBar); ... } that works fine so far and I get a very nice additional button in the main menu bar of the app. but now I want to add menu entries... at the moment I am doing that in the "OnCalcDynamicSize()" Function of "CXTPMyControlPopup::CXTPControlPopup" : ... CXTPControlButton *pControl = (CXTPControlButton*)GetCommandBar()->GetControls()->Add(xtpControlButton, MY_ID, "MyMenuEntry"); pControl->SetCaption("MyMenuEntry"); pControl->SetFlags(xtpFlagManualUpdate); pControl->SetEnabled(true); ... this way I get a lot of nice buttons, but unfortunatly they dont look like menus at all. What do I need to do to generate menus that look like menus this way? Thanx for your help. Cheers Bjoern |
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
Hi,
Replace
CXTPPopupToolBar* pBar = CXTPPopupToolBar::CreatePopupToolBar(pMenuBar->GetCommandBars());
to CXTPPopupBar* pBar = CXTPPopupBar::CreatePopupBar(pMenuBar->GetCommandBars());
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
ps.
After line
pMyCtrl->SetCommandBar(pBar);
you also need release pBar: pBar->InternalRelease();
to avoid leak.
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
lion
Groupie Joined: 04 March 2008 Status: Offline Points: 22 |
Post Options
Thanks(0)
|
thank you. that works fine now. thanks a lot !
|
|
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 |