Search
Important Notes for Visual C++ Users

To use FlowChartX in Visual C++ version 6.0 follow these steps:

  • Open "Project\Add To Project\Component and Controls" menu
  • Open "Registered ActiveX Controls" folder
  • Choose "FlowChartX Control 1.0" from the list and click Insert
  • From "Confirm Classes" dialog box select all available classes and click OK

The wizard generates C++ wrapper classes for the objects from FlowChartX type library and an item for the control is added to "Controls toolbox". Now you can start using the control.

 Note

In Visual C++ 7.0 there is a problem importing ActiveX controls in general and FlowChartX particularly: unlike version 6 importing the control through MFC wizard will not generate wrapper classes for the whole FlowChartX object hierarchy. If you use the "Add class from ActiveX control" wizard it will generate a class just for the FlowChart object, but not for Box, Arrow, Boxes and Arrows collections. Respectively "Add class from Type Library" wizard generates a class for all FlowChartX objects but with faults - FlowChartX properties and methods' parameters that are object references are declared as LPDISPATCH instead of CBoxItem, CArrowItem, CBoxes or CArrows as in Visual C++ 6.0.

In order to help you workaround these problems we have included in FlowChartX installation the control wrapper classes as generated by Visual C++ 6. You can find them in "MFC wrapper" subfolder in your root installation folder. Following steps describe how to use them in Visual C++ 7.0 projects:

  • Open "Dialog editor"
  • From Toolbox context menu choose "Customize…"
  • Add FlowChartX control 1.0
  • Drag the new FlowChartX object that has appeared in Toolbox to the form
  • Right-click it and choose "Add variable" from the context menu
  • Name the MFC wrapper class CFlowChart and its files - flowchart.h and flowchart.cpp
  • Copy all files from "MFC wrapper" folder to your project folder, overwriting flowchart.h and flowchart.cpp
  • From "Project->Add Existing Item..." add all the files to your project.

You can also use these files in Visual C++ 6.0, since we have manually added the enumeration constants. SetPolyShape is fixed too because it was not correctly imported by Visual C++ 6.0 due to parameter type conversion error.

Event handling

Remember to pay special attention to event handling in all Visual C++ versions. Event methods that receive as parameter reference to a box, table or arrow object should not change its reference count. Still the COleDispatchDriver-derived wrapper classes by default call the attached COM object Release function in their destructor, which decreases the reference count. As a result the count might go to zero and the item be destroyed unexpectedly. To avoid this, either set the wrapper object m_bAutoRelease member to FALSE, or call Detach method  before the object goes out of scope:

C++  Copy Code

void App::OnTableCreated(LPDISPATCH pTableItem)
{
    TableItem table = pTableItem;

    table.SetCellBorders(cbNone);
    table.DetachDispatch();
}

Validation events and MFC wizard-generated handler prototypes

All Request* validation events have a VARIANT_BOOL output pointer argument, but the event wizard erroneously declares that argument as a pointer to BOOL. Size of the VARIANT_BOOL type is 2 bytes, and that of BOOL is 4 bytes. Assigning a BOOL TRUE or FALSE constant value directly to the output argument would cause a big mess in the stack, potentially overwriting the method return address or local variables of other methods. To work-around that, cast the argument to VARIANT_BOOL pointer and assign VARIANT_TRUE or VARIANT_FALSE values as shown below:

C++  Copy Code

void CTreeLayoutDlg::RequestSelectArrow(LPDISPATCH arrow, BOOL* pbSelect)
{
    // NOTE: the event wizard erroneously declares pbSelect as BOOL*;
    // pbSelect is pointing to VARIANT_BOOL, which is 2 bytes long, e.g. short;
    // setting it to BOOL FALSE (4 bytes) would cause a big mess in the stack
    *(VARIANT_BOOL*)pbSelect = VARIANT_FALSE;
}

#import

The #import compiler directive works fine in both versions of Visual C++ and imports the whole object hierarchy. It will generate smart pointers for the FlowChartX objects but it's harder to use them in a MFC application because FlowChartPtr object is not derived from CWnd. Anyway if you develop C++ application without using the MFC library then #import is your best choice.