How CMenu :: Insertmenu or AppnedMenu to dynamically add menu child ?

Category: VC/MFC -> UI Author: btsoo7 Date: 2004-05-24 10:35:38
 
btsoo7
2004-05-24 10:35:38
I have a menu resource IDR_MENU1
operation monitoring exit
I think in the "Operation " and " Monitor " menu item dynamically add sub- menu items (menuitem), rather than added to the "Exit " behind , how achieve ?
qwer09876
2004-05-24 10:38:41
had answered a question
look
cat330683
2004-05-24 10:56:00
InsertMenu (  UINT   nPosition,   UINT   nFlags,   UINT   nIDNewItem   =   0,   LPCTSTR   lpszNewItem   =   NULL  ); ID & nbsp
monitoring ; ID IDC_CONTROL
new menu   IDC_NEWITEM    
first in Resource.h inside Join # define   IDC_NEWITEM   1003
tMenu.InsertMenu (IDC_CONTROL, MF_BYCOMMAND, IDC_NEWITEM, " new menu items ");
pass152811
2004-05-24 11:05:39
CMenu *   pMenu;
int   i ;
pMenu   =   AfxGetMainWnd () - > GetMenu ();
i   =   pMenu- > GetMenuItemCount ();
pMenu- > InsertMenu (i, MF_BYCOMMAND , 0, " hello ");
(pMenu- > GetSubMenu (4)) - > AppendMenu (MF_STRING, ID_MY_NEWMENU, _T (" my   creat   menu "));
( pMenu- > GetSubMenu (1)) - > AppendMenu (MF_SEPARATOR);
(pMenu- > GetSubMenu (1)) - > AppendMenu (MF_STRING, ID_MY_MENU, _T (" my   menu ")) ;
DrawMenuBar ();

this short program , you test your program to try and look at the results , you should know how you changed .
of course, a few id you want to define the resource in themselves .