Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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

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);

2 Answers  


How to handle RTTI in MFC ?

1 Answers  


How to create a Modeless Dialog?

5 Answers  


What is CALLBACK? How it work? what is the advantage of CALLBACK, please explain with an example

6 Answers  


what is the difference between SDI and MDI

15 Answers   CMC, HCL, Siemens,


Explain Doc/View architecture

6 Answers   Huawei,


What is the use of CObject::Dump function ?

4 Answers  


What is a message map, and what is the advantage of a message map over virtual functions?

1 Answers  


1)why we cant create more than one instance of the class Derived from CWinApp

5 Answers   Alstom,


How can update edit control data of an executing application from other application?

3 Answers   HP,


In MFC By Using Communication Between Dialog Boxes,How Can We Send Message Of one Dialog Box To Another Dialog.?

3 Answers   Financial Technologies,


What is mfc class hierarchy?

0 Answers  


Categories