Add menu items or buttons to a GUI from a dll

Posted on 2010-01-07
Last Modified: 2013-11-20
I have an MFC GUI program that's distributed throughout the company. Every month or two, a new device comes in that the program has to work with, and I issue a new dll for that device and it uses the GUI as the interface. Then everyone who needs to work with the new device adds the new dll and the front end stays the same.

With the newest device, I'd like to add a new menu selection, or at least 2 radio buttons, to the GUI. Can I do this from the dll? I'm trying to avoid having everyone update the GUI.
Question by:apostrophe27
    LVL 46

    Expert Comment

    LVL 7

    Expert Comment

    you can't do it with reasonable efforts. the handlers for the radio buttons or menu items should be added to the class they belong to. and the resource should also be updated.
    LVL 43

    Accepted Solution

    If the radion buttons are permantently available on the main GUI then you would have to recode it anyway to support that.  If they can be on a modal dialog that could reside in the dll (assuming the main app calls a function in the dll for settings).
    LVL 49

    Expert Comment

    You can put an entire dialog or multiple-page PropertySheet in a DLL.  It can have as many radio buttons and other hoo-ha as you want.
    But it will be difficult to change the actions of the main EXE retroactively by modifying only the DLL.
    LVL 4

    Expert Comment

    One solution sketch can be:
    The DLL expose a Function to retrieve Any specialized Items.
    The Exe call this function and if NULL is returned just use the standard menu.

    But to keep backwards compatibility, your EXE have to check a DLL version number or if the DLL support  this function exist before calling it.  
    use  getprocaddress
    good luck


    LVL 1

    Expert Comment

    Extending the solution provided by DanRollins the following can be done.
    Your existing MFC GUI program may be developed using MFC ATL project or simply MFC DLL. Then add new resource dialog (Right click on the project, select Add-> Resource) and place whatever control you want. Create an class of the resource dialog.
    Now in case of ATL project you need to write an method that invoke the dialog. This method will be part of the existing interface.
    And in case of MFC DLL write an exported function __declspec (dllexport) and invoke the dialog in this function.
    Then the EXE program that use this DLL can call this specific method to show the dialog.
    This is what we can understand from your query and also please let us know how did you create your existing MFC GUI program.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
    If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now