// MyMenuBar.cpp: implementation of the CMyMenuBar class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "DynamicMenu.h"
#include "MyMenuBar.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CMyMenuBar::CMyMenuBar()
{

}

CMyMenuBar::~CMyMenuBar()
{

}

void CMyMenuBar::CreateFromMenu (HMENU hMenu, BOOL bDefaultMenu, BOOL bForceUpdate)
{
	// modify the incoming menu
	// you should create IDR_DYNAMIC_MENU menu in resource editir first
	CMenu menu;
	menu.LoadMenu (IDR_DYNAMIC_MENU); 

	CMenu* pMenuToModify = CMenu::FromHandle (hMenu);
	pMenuToModify->AppendMenu (MF_POPUP, (UINT) menu.Detach (), _T ("&DynamicMenu"));
	
	// call the base class with bForceUpdate set to TRUE to prevent blinking
	CBCGPMenuBar::CreateFromMenu (pMenuToModify->GetSafeHmenu (), bDefaultMenu, TRUE);
}