If you want to use the Microsoft Foundation Classes in your add-in, you must select the MFC option in the AppWizard when you create your project.
The effects of setting this option are:
As a result, you are able to use MFC classes and methods from within your XLL. (Note, however, that the Document/View framework is not available from an XLL.)
Programmers familiar with writing DLLs using MFC will know that certain internal MFC data structures must be initialised whenever they are used in a DLL. In standard MFC, the AFX_MANAGE_STATE macro is used for this purpose. In an XLL+ library, you should use the XLL_FIX_STATE macro.
What this means is that you must place the XLL_FIX_STATE macro in method that uses any MFC features. The XLL+ Function Wizard does this on your behalf in all XLL+ add-in functions. However, if you use the MFC in other methods, that are not called by add-in functions, then you will need to use the macro explicitly.
The CExcelWnd class acts as a link between Excel and MFC. Create a CExcelWnd object, and it will act as an MFC CWnd, corresponding to the Excel application window. You can use this object as a parent for any MFC windows and other objects you need to create.
The XLL+ run-time library contains its own implementation of the MFC string classes CString, CStringA and CStringW. (These are implemented as a thin layer around std::string and std::wstring.)
When you select the MFC run-time libraries in the XLL+ AppWizard, these string classes are excluded, and MFC's own classes are used.