Aracılığıyla paylaş


CMenu::CreateMenu

Bir menü oluşturur ve ekler CMenu nesnesi.

BOOL CreateMenu( );

Dönüş Değeri

Menü başarıyla oluşturulmuşsa, sıfır olmayan; Aksi halde 0.

Notlar

Menü başlangıçta boştur.Menü öğeleri kullanılarak eklenebilir AppendMenu veya InsertMenu üye işlevi.

Bir pencere menüsü atanırsa, otomatik olarak pencere bozulduğunda edilir.

Çıkmadan önce bir uygulama bir pencere menüsü atanmamış olması durumunda bir menüyle ilişkili sistem kaynaklarını boşaltın gerekir.Bir uygulama çağırarak menüsünü boşaltır DestroyMenu üye işlevi.

Örnek

// The code fragment below shows how to create a new menu for the
// application window using CreateMenu() and CreatePopupMenu().
// Then, the created menu will replace the current menu of the
// application. The old menu will be destroyed with DestroyMenu().
// NOTE: The code fragment below is done in a CFrameWnd-derived class.

// Create a new menu for the application window.
VERIFY(m_NewMenu.CreateMenu());

// Create a "File" popup menu and insert this popup menu to the
// new menu of the application window. The "File" menu has only
// one menu item, i.e. "Exit".
VERIFY(m_FileMenu.CreatePopupMenu());
m_FileMenu.AppendMenu(MF_STRING, ID_APP_EXIT, _T("E&xit"));
m_NewMenu.AppendMenu(MF_POPUP, (UINT_PTR)m_FileMenu.m_hMenu, _T("&File"));

// Remove and destroy old menu
SetMenu(NULL);
CMenu* old_menu = CMenu::FromHandle(m_hMenuDefault);
old_menu->DestroyMenu();

// Add new menu.
SetMenu(&m_NewMenu);

// Assign default menu
m_hMenuDefault = m_NewMenu.m_hMenu;

Gereksinimler

Başlık: afxwin.h

Ayrıca bkz.

Başvuru

CMenu sınıfı

Hiyerarşi grafik

CMenu::CMenu

CMenu::DestroyMenu

CMenu::InsertMenu

CWnd::SetMenu

CreateMenu

CMenu::AppendMenu