Search
Important Notes for Delphi Users

OLE drag and drop

In order to use FlowChartX drag and drop methods, your application has to initialize the OLE libraries first. That is done by calling the OleInitialize API function, as shown below.

Delphi  Copy Code

procedure TForm1.FormShow(Sender: TObject);
begin

    fcx.Graphics.StartUp(geGdiPlus);

    // enable drag'n'drop
    OleInitialize(nil);
    fcx.RegisterDragDrop();

end;

procedure TForm1.FormHide(Sender: TObject);
begin

    fcx.RevokeDragDrop();
    OleUninitialize();
    fcx.Graphics.ShutDown();

end;

ActiveX types

In order to use FlowChartX properties of type Font, Picture, Color or SAFEARRAY, you must include reference to the unit ActiveX in the uses clause.

To convert from Delphi native TFont type to the ActiveX font type, use this procedure:

Delphi  Copy Code

procedure GetOleFont(Font: TFont; var OleFont: IFontDisp);

To change the font of the active box' text you might use code like this:

Delphi  Copy Code

var

    fontOle: IFontDisp;
    font: TFont;
    box: IBoxItem;

begin

    font := TFont.Create;
    font.Size := 22;
    font.Name := 'Arial';
    GetOleFont(font, fontOle);

    box := FlowChart1.ActiveBox;

    if box <> nil then
    begin

        box.Font := fontOle;
        box.Text := 'Some text';

    end;

    font.Destroy;

end;

To convert from Delphi native TPicture type to ActiveX picture type, use this procedure:

Delphi  Copy Code

procedure GetOlePicture(Picture: TPicture; var OlePicture: IPictureDisp);

To display an image in the active box use code like this:

Delphi  Copy Code

var

    picOle: IPictureDisp;
    pic: TPicture;
    box: IBoxItem;

begin

    pic := TPicture.Create;
    pic.LoadFromFile('e:\pictures\genie\aura.bmp');
    GetOlePicture(pic, picOle);

    box := FlowChart1.ActiveBox;
    if box <> nil then
        box.Picture := picOle;

    pic.Destroy;

end;

The procedure below shows how to change the active box' fill color.

Delphi  Copy Code

var

    colOle: OLE_COLOR;
    box: IBoxItem;

begin

    colOle := clPurple;

    box := FlowChart1.ActiveBox;
    if box <> nil then
        box.FillColor := colOle;

end;

Arguments to the automatic layout algorithms are passed to the ArrangeDiagram method via instances of TreeLayout, LayeredLayout or SpringLayout structures. Those can be created like this:

Delphi  Copy Code

procedure TForm1.layoutTree(dir: ETreeLayoutDirection);

var tl: TreeLayout;

begin

    tl := CoTreeLayout.Create();
    tl.Root := root;
    tl.Type_ := tltCentralized;
    tl.Direction := tldTopToBottom;
    tl.ArrowStyle := tlaStraight;
    tl.LevelSpacing := 30;
    tl.NodeSpacing := 15;
    tl.KeepRootPos := true;
    tl.ReversedArrows := false;
    fcx.ArrangeDiagram(tl);

end;