Attaches an existing Windows menu to a CMenu object.
BOOL Attach( HMENU hMenu );
- Specifies a handle to a Windows menu.
Nonzero if the operation was successful; otherwise 0.
This function should not be called if a menu is already attached to the CMenu object. The menu handle is stored in the m_hMenu data member.
If the menu you want to manipulate is already associated with a window, you can use the CWnd::GetMenu function to get a handle to the menu.
CMenu mnu; HMENU hmnu = AfxGetMainWnd()->GetMenu()->GetSafeHmenu(); mnu.Attach( hmnu ); // Now you can manipulate the window's menu as a CMenu // object...