Print Page | Close Window

Creating Normal Menu on the fly

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=13889
Printed Date: 27 September 2024 at 11:16am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Creating Normal Menu on the fly
Posted By: lion
Subject: Creating Normal Menu on the fly
Date 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




Replies:
Posted By: Oleg
Date Posted: 02 April 2009 at 4:58am
Hi,
 
Replace
CXTPPopupToolBar* pBar = CXTPPopupToolBar::CreatePopupToolBar(pMenuBar->GetCommandBars());
to
CXTPPopupBar* pBar = CXTPPopupBar::CreatePopupBar(pMenuBar->GetCommandBars());
 


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: Oleg
Date Posted: 02 April 2009 at 4:59am
ps.
After line
    pMyCtrl->SetCommandBar(pBar);
you also need release pBar:
pBar->InternalRelease();
to avoid leak.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: lion
Date Posted: 06 April 2009 at 4:17am
thank you. that works fine now. thanks a lot  !



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net