Click here to Skip to main content
15,897,371 members
Articles / Programming Languages / C++

How to add dynamic menus to your application using DLLs

Rate me:
Please Sign up or sign in to vote.
4.08/5 (16 votes)
25 Nov 20054 min read 45.6K   1.3K   44  
How to add dynamic menus to your application using DLLs, if you want to support add-ons to your base application.
#include "stdafx.h"
#include "main.h"
// Linker directive to export MyExportedFunction, and in its completely 
// undecorated form 

_declspec(dllexport) int __cdecl NumberOfMenus()
{
	return NUMBER_OF_MENUS;
}
_declspec(dllexport) bool __cdecl MenuText(int n, CString& str)
{
	if (n < 0 || n>=NUMBER_OF_MENUS) return false;
	str.Format("Menu # %d",n);
	return true;
}
_declspec(dllexport) bool __cdecl MenuFunction(int n)
{
	if (n < 0 || n>=NUMBER_OF_MENUS) return false;
	CString str;
	str.Format("From DLL **********Menu #%d selected**********",n);
	MessageBox(NULL,str,"From DLL",MB_OK);
	return true;
}
_declspec(dllexport) bool __cdecl MenuTitle(CString& str)
{
	str="The DLL";
	return true;
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United Kingdom United Kingdom
I am a visual C++ programmer, currently working in Industrial Control Systems in Sheffield, United Kingdom as a Senior Programmer and Researcher. You can contact me by sending email to farhat_aisha2000@yahoo.com

Comments and Discussions