How can i implement the dynamic menus in MFC plz give the
code
Answers were Sorted based on User's Feedback
Answer / surendra mishra
Create a CMenu object on the stack frame as a local, then
call CMenu’s member functions to manipulate the new menu as
needed. Use the following function to create the same
1. LoadMenu,SetMenu or TrackPopupMenu function
Is This Answer Correct ? | 6 Yes | 0 No |
Answer / igor polivanyi
The code would look like this:
BEGIN_MESSAGE_MAP(CSomeCtrl, COleControl)
//{{AFX_MSG_MAP(CSomeCtrl)
//}}AFX_MSG_MAP
ON_COMMAND(IDM_MENU_ITEM, OnPopupMenuItem)
END_MESSAGE_MAP()
LRESULT CSomeCtrl::OnPopupMenuItem(WORD wNotifyCode, WORD
wID, HWND hWndCtl, BOOL& bHandled)
{
// Implementation of the menu command handler...
return S_OK;
}
{
// Dynamic creation...
CMenu mnuZoomOutPopUp;
mnuZoomOutPopUp.CreatePopupMenu();
CString strMenuItem;
strMenuItem.LoadString(IDM_MENU_ITEM);
mnuZoomOutPopUp.AppendMenu( MF_STRING | MF_ENABLED,
IDM_MENU_ITEM, strMenuItem );
mnuZoomOutPopUp.AppendMenu( MF_SEPARATOR, 0, "" );
// nLeftPos, nTopPos -- screen coordinates of pop-up menu
placement ...
mnuZoomOutPopUp.TrackPopupMenu( TPM_LEFTALIGN, nLeftPos,
nTopPos, this );
mnuZoomOutPopUp.DestroyMenu();
}
Is This Answer Correct ? | 3 Yes | 1 No |
What types of threads are supported by MFC framework?
How you create a button dynamically?
Tell me the work of HTREDUCE and HTZOOM
What is the difference between Extension DLL and Regular DLL?
what are the feauters of CObject
plzz tell me what we can do and dont in tally ERP & sap business one?
I want recent paper pattern for HP company?
What are the differences between MFC Exception macros and C++ exception keywords?
Do you have an idea about MFC?
How can server communicate with more than one client
How WM_PAINT message gets called in MFC,please explain it . a)Who calls the WM_PAINT message? b)When it gets called? c)how it comes to message queue? Please Explain it
i have created runtime menu -- ( admistrator ->managepackage,manage module). but now i want to open a dialog when i select manage package and any other diaolg when selecting manage module ( whole selection is at run time only ) . Please HELP .its urgently required