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 |
Explain Doc/View architecture
Tell us something about MFC?
Will there be any difference in the image buffer size if it is loaded in from CString to LPTSTR using GetBuffer()? lptstr = string.GetBuffer(0);
What is the difference between Struts and JSF? Pls list some most suitable differences.
1)set the Title for The File DialogBox, in MFC?
Whats is DDX & DDV in MFC?
If there is more than 100 control in a window how we can change the Taborder of a controls
1) Enable or disable a Cancel button at run time?
What is LPCTSTR? What does LP denote it?
What is the difference between the Encapsulation and Abstraction
25 Answers HCL, Invensys, TCS, Wipro,
What is CArchive class dowes?
Can you explaing the relashionship between document,frame and view ?