Hello.
I want to add a menu dynamically.
Even if, after LoadFrame, I add a menu
It is not displayed.
Please teach a method to add dynamically.
CMainFrame* pFrame = new CMainFrame;
m_pMainWnd = pFrame;
if( ! pFrame->LoadFrame(
IDR_MAINFRAME,
// IDR_NXBKTYPE,
WS_OVERLAPPEDWINDOW|FWS_ADDTOTITLE,
NULL,
NULL
)
)
return FALSE;
// window placement persistence
:
:
:
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if( CExtNCW < CFrameWnd > :: OnCreate( lpCreateStruct ) == -1 )
return -1;
// メニューバーの作成
if( ! m_wndMenuBar.Create(
NULL,
this,
ID_VIEW_MENUBAR
)
)
{
TRACE0("Failed to create menubar\n");
return -1;
}
m_wndMenuBar.InitMenuMCB();
:
:
:
void CNxbkMenuControlBar::InitMenuMCB()
{
CMenu popupMenu;
BOOL bCreate;
bCreate = popupMenu.CreatePopupMenu ();
// メインメニュー
bCreate = popupMenu.AppendMenu ( MF_STRING, 123 , "aaa" );
bCreate = popupMenu.AppendMenu ( MFT_SEPARATOR );
bCreate = popupMenu.AppendMenu ( MF_STRING, 444 , "bbbb" );
bCreate = popupMenu.AppendMenu ( MFT_SEPARATOR );
CMenu* pMenu = GetMenu();
bCreate = pMenu->AppendMenu ( MF_POPUP, ( UINT ) popupMenu.Detach() , "AddMenu" );
}