Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Functions for Buttons and Menus

Status
Not open for further replies.

mpsoutine

Programmer
Jan 6, 2003
87
US
Hi,

I have a button and menu item that carry out the same procedure. My question is the proper way to code for this. Currently I have two seperate functions OnEdit()for the button Edit and OnEditPerson() for the menu item Edit. Is this the acceptable way to code. Both functions are in my View class.

Thanks,

Matthew
 
Assuming you're using MFC, if you have a resource ID for the button and the menu item, you can use the ON_COMMAND and ON_BN_CLICKED macros in your class's message map.

BEGIN_MESSAGE_MAP(CYourClass, CView)
ON_BN_CLICKED(IDNUMOFBUTTON, OnDoThis)
ON_COMMAND(IDNUMOFYOURMENUITEM, OnDoThis)
END_MESSAGE_MAP()

In the .h file:
void OnDoThis(void);

In the .cpp file:
void OnDoThis(void)
{
//Put your common code here
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top