I have added a menu in my windows program using resource editor now I want to add a submenu under some specific condition. Below is piece of my code.
This is my Menu.h file
include
class CmainWn : public CFrameWnd
{
public :CmainWn();
DECLARE_MESSAGE_MAP()
afx_msg void OnAB();
};
class CApp : public CWinApp
{
public : BOOL InitInstance();
};
This is my Menu.cpp
include"Menu.h"
include"resource.h"
CmainWn ::CmainWn()
{
Create(NULL,"Menu Testing",WS_OVERLAPPEDWINDOW,rectDefault,NULL,(LPCTSTR)IDR_MENU1);
}
BOOL CApp :: InitInstance()
{
m_pMainWnd=new CmainWn();
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
return true;
}
void CmainWn::OnAB()
{
AfxMessageBox("Hello");
}
BEGIN_MESSAGE_MAP(CmainWn,CFrameWnd)
ON_COMMAND(ID_A_B, &CmainWn::OnAB)
END_MESSAGE_MAP()
CApp App;
As you can see the code I have created main menu named A and one submenu named B. I want to add one menu dynamically under B. How to do it ?