Step 1: Creating an IlvGraphicCOMAdapter Object
This step creates the IlvGraphicCOMAdapter object. Because the graphic object uses the ATL Control Hosting API, you may specify the identifier of the object in one of three ways. You can specify creating from a:
*CLSID – the default
*ProgID – define as SECOND_VERSION
*URL – define as THIRD_VERSION
You can test any of these by simply recompiling the file specific.cpp, after defining as shown if not using the default.
The example uses the Microsoft Calendar Control. If it is not available on your computer, you may modifiy the values of DefaultIdentifier.
The creation of the object is very simple:
IlvGraphic* obj = new IlvGraphicCOMAdapter(size, identifier, getDisplay());
where:
*size is the size of the object.
*identifier is the identifier of the control as explained above. Here are examples of the values that you can attach to the identifier:
*CLSID: "{8E27C92B-1264-101C-8A2F-040224009C02}"
*ProgID: "MSCAL.Calendar"
*URL: "http://www.roguewave.com"
You also have to include the following header file in order to get the definition of the class IlvGraphicAdapter, and to add either the library Ilvcomstat.lib or ilvcomdyn.lib:
#include <ilviews/windows/comgadap.h>
You must also include the oledlg.h file in order to be able to use the common ActiveX dialog.
The following code is called in the doIt member function of the MakeNodeInteractor class:
void
MakeNodeInteractor::doIt(IlvRect& size)
{
// the manager should actually be a grapher.
IlvGrapher* grapher = ILVDYNAMICCAST(IlvGrapher*, manager());
if (!grapher)
return;
// Creates the new IlvGraphicCOMAdapter object.
const char* identifier = DefaultIdentifier;
IlvGraphic* obj = new IlvGraphicCOMAdapter(size, identifier, getDisplay());
// Deselects the previous object(s) if any.
grapher->deSelect();
// Adds the new object as a node into the grapher.
grapher->addNode(obj, IlvTrue, grapher->getInsertionLayer());
// Selects it.
grapher->makeSelected(obj);
// Deals with the commands if needed.
if (grapher->isUndoEnabled())
grapher->addCommand(new IlvAddNodeCommand(grapher,
obj,
grapher
->getInsertionLayer()));
}
In order to be able to use this class you have to include several header files:
*ilviews/grapher/commands.h that contains the definition of the class IlvAddNodeCommand used in the member function doIt of MakeNodeInteractor. For more details, see the Managers section.
*makenode.h that contains the definition of the class MakeNodeInteractor;
Here is the definition of the class MakeNodeInteractor:
class MakeNodeInteractor : public IlvMakeRectangleInteractor
{
public:
MakeNodeInteractor(IlvManager* manager, IlvView* view)
: IlvMakeRectangleInteractor(manager, view)
{
}
MakeNodeInteractor() : IlvMakeRectangleInteractor() {}
 
void doIt(IlvRect&);
};
Published date: 05/24/2022
Last modified date: 02/24/2022