How can i implement the dynamic menus in MFC plz give the
code

Answers were Sorted based on User's Feedback



How can i implement the dynamic menus in MFC plz give the code..

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

How can i implement the dynamic menus in MFC plz give the code..

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

Post New Answer

More MFC Interview Questions

What types of threads are supported by MFC framework?

2 Answers  


How you create a button dynamically?

2 Answers  


Tell me the work of HTREDUCE and HTZOOM

1 Answers   E Logic,


What is the difference between Extension DLL and Regular DLL?

6 Answers   GE,


what are the feauters of CObject

4 Answers   Siemens, Wipro,






plzz tell me what we can do and dont in tally ERP & sap business one?

0 Answers  


I want recent paper pattern for HP company?

0 Answers   HP,


What are the differences between MFC Exception macros and C++ exception keywords?

2 Answers  


Do you have an idea about MFC?

0 Answers   C DAC, CDAC,


How can server communicate with more than one client

2 Answers   Invensys,


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

8 Answers  


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

3 Answers   Patni,


Categories