A FlowChart object represents a diagram composed of linked nodes. That could be a workflow diagram, a database diagram, organizational chart, genealogy tree, a network diagram, etc.
VB6
![]() |
---|
Public Class FlowChart |
C++
![]() |
---|
class FlowChart |
Nodes are instances of the Box or Table classes. A link between two nodes is defined via an Arrow instance. Access to diagram elements is provided via the Boxes, Tables and Arrows arrays. There might be one focused or active diagram element. Its type can be determined via the ActiveItemType property. A type-safe access to the active object is provided by ActiveBox, ActiveTable and ActiveArrow properties.
Diagrams might be created programmatically or drawn by end-users interactively. There are many default values exposed as properties of FlowChart that are used to initialize new nodes and links. Those initialization properties are used both when an object is drawn interactively or programmatically.
To create nodes via code, invoke the CreateBox or CreateTable methods. To link nodes call CreateArrow, CreateRelation or CreateLink methods, depending on the types of objects to link. To delete existing diagram elements call DeleteItem or ClearAll.
If you need to find what diagram item lies at a specific location of the document, call the generic ObjectFromPoint method. Call the GetBoxAt, GetTableAt or GetArrowAt method to find specific type of items by their position. You can also search for items with a specific Tag value using the FindBox, FindTable and FindArrow methods.
The Behavior property defines how FlowChartX interprets users input when diagrams are created interactively. Users interaction might be disabled completely by setting StaticMode to true. There are more properties for validation of users actions, such as AllowMultiSel, AllowLinksRepeat, ArrowEndsMovable, etc.
Depending on the Behavior property, users can select objects by dragging the mouse, clicking objects, clicking with Ctrl key pressed or dragging with Ctrl key pressed. Selection can be modified programmatically via the AddToSelection, RemoveFromSelection and ClearSelection methods. Selected objects can be enumerated via the SelectedBoxes, SelectedTables and SelectedArrows collections.
FlowChart documents can be serialized in binary form using the SaveToFile and LoadFromFile methods. Flowcharts can also be stored as XML documents by means of the SaveToXml and LoadFromXml methods. Use XML serialization if you need to read or modify flowchart files from an external application without using the FlowChartX API. Otherwise, use binary serialization, since it is faster and requires less memory. To store a diagram in a database field or as part of an XML file, use the SaveToString and LoadFromString methods. They might be used also to transfer a diagram between a web server and a browser as a value of a 'hidden' HTML field.
To print a FlowChart document call PrintDiagram. To display print-preview window call PreviewDiagram. Both methods use setting defined in PrintOptions. Use the CreateBitmap or SaveToBitmap method to export a flowchart to an image file.
This overview lists a small part of all available properties and methods of the FlowChart class. For a complete list, please follow the thematic topics in the Programming Interface Overview section, or browse the reference below.
FlowChartX exposes many events, which allow executing application code in response to users actions. The complete list of events can be seen here.
Some aspects of how events are raised can be changed via the EventFlags property of the FlowChart class.
Most events are raised only in response to users actions. If you need to execute the same code after user actions and API calls, move the common code to a method and invoke the method both in the respective event handler and after the API method or property setter call. A notable exception is the *Deleted set of events, which are also raised when items are deleted programmatically, because in some circumstances deleting an item could delete other items related to it.
When a user starts drawing a new item with the mouse, the control raises an initialization event to let you set the appearance properties of the item. E.g. for a box, the control raises InitializeBox. When the user releases the mouse button, a validation event is raised to let you cancel the item creation (e.g. RequestCreateBox). If the action is not cancelled, a creation event is raised to let your application know about the new item (e.g. BoxCreated).There are events raised when users modify items, e.g. BoxModified / TableModified, or a common ObjectModified event. When a user presses the DEL key, there is a validation event raised to let you confirm that an item should be deleted (e.g. RequestDeleteBox), and if not cancelled, there is an item-deleted event raised (e.g. BoxDeleted).
Pay special attention to event handling when using MFC wrapper classes for FlowChartX item interfaces. Event methods that receive as parameter reference to a box, table or arrow item 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++
![]() |
---|
void App::OnTableCreated(LPDISPATCH pTableItem) |
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++
![]() |
---|
void CTreeLayoutDlg::RequestSelectArrow(LPDISPATCH arrow, BOOL* pbSelect) |