Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Creating Normal Menu on the fly
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Creating Normal Menu on the fly

 Post Reply Post Reply
Author
Message
lion View Drop Down
Groupie
Groupie


Joined: 04 March 2008
Status: Offline
Points: 22
Post Options Post Options   Thanks (0) Thanks(0)   Quote lion Quote  Post ReplyReply Direct Link To This Post Topic: Creating Normal Menu on the fly
    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

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 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
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 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
Back to Top
lion View Drop Down
Groupie
Groupie


Joined: 04 March 2008
Status: Offline
Points: 22
Post Options Post Options   Thanks (0) Thanks(0)   Quote lion Quote  Post ReplyReply Direct Link To This Post Posted: 06 April 2009 at 4:17am
thank you. that works fine now. thanks a lot  !
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.187 seconds.