exg2antt - sample code

How can I add a bar and some text inside, in the chart area?

VBA (MS Access, Excell...)

With G2antt1
	.Columns.Add "Task"
	.Chart.FirstVisibleDate = #1/1/2001#
	With .Items
		.AddBar .AddItem("Task 1"),"Task",#1/2/2001#,#1/6/2001#,0,"<bgcolor=FF0000> to do </bgcolor>"
	End With
End With

VB6

With G2antt1
	.Columns.Add "Task"
	.Chart.FirstVisibleDate = #1/1/2001#
	With .Items
		.AddBar .AddItem("Task 1"),"Task",#1/2/2001#,#1/6/2001#,0,"<bgcolor=FF0000> to do </bgcolor>"
	End With
End With

VB.NET

With Exg2antt1
	.Columns.Add("Task")
	.Chart.FirstVisibleDate = #1/1/2001#
	With .Items
		.AddBar(.AddItem("Task 1"),"Task",#1/2/2001#,#1/6/2001#,0,"<bgcolor=FF0000> to do </bgcolor>")
	End With
End With

VB.NET for /COM

With AxG2antt1
	.Columns.Add("Task")
	.Chart.FirstVisibleDate = #1/1/2001#
	With .Items
		.AddBar(.AddItem("Task 1"),"Task",#1/2/2001#,#1/6/2001#,0,"<bgcolor=FF0000> to do </bgcolor>")
	End With
End With

C++

/*
	Copy and paste the following directives to your header file as
	it defines the namespace 'EXG2ANTTLib' for the library: 'ExG2antt 1.0 Control Library'

	#import <ExG2antt.dll>
	using namespace EXG2ANTTLib;
*/
EXG2ANTTLib::IG2anttPtr spG2antt1 = GetDlgItem(IDC_G2ANTT1)->GetControlUnknown();
spG2antt1->GetColumns()->Add(L"Task");
spG2antt1->GetChart()->PutFirstVisibleDate("1/1/2001");
EXG2ANTTLib::IItemsPtr var_Items = spG2antt1->GetItems();
	var_Items->AddBar(var_Items->AddItem("Task 1"),"Task","1/2/2001","1/6/2001",long(0),"<bgcolor=FF0000> to do </bgcolor>");

C++ Builder

G2antt1->Columns->Add(L"Task");
G2antt1->Chart->set_FirstVisibleDate(TVariant(TDateTime(2001,1,1).operator double()));
Exg2anttlib_tlb::IItemsPtr var_Items = G2antt1->Items;
	var_Items->AddBar(var_Items->AddItem(TVariant("Task 1")),TVariant("Task"),TVariant(TDateTime(2001,1,2).operator double()),TVariant(TDateTime(2001,1,6).operator double()),TVariant(0),TVariant("<bgcolor=FF0000> to do </bgcolor>"));

C#

exg2antt1.Columns.Add("Task");
exg2antt1.Chart.FirstVisibleDate = Convert.ToDateTime("1/1/2001",System.Globalization.CultureInfo.GetCultureInfo("en-US"));
exontrol.EXG2ANTTLib.Items var_Items = exg2antt1.Items;
	var_Items.AddBar(var_Items.AddItem("Task 1"),"Task",Convert.ToDateTime("1/2/2001",System.Globalization.CultureInfo.GetCultureInfo("en-US")),Convert.ToDateTime("1/6/2001",System.Globalization.CultureInfo.GetCultureInfo("en-US")),0,"<bgcolor=FF0000> to do </bgcolor>");

JavaScript

<OBJECT classid="clsid:CD481F4D-2D25-4759-803F-752C568F53B7" id="G2antt1"></OBJECT>

<SCRIPT LANGUAGE="JScript">
	G2antt1.Columns.Add("Task");
	G2antt1.Chart.FirstVisibleDate = "1/1/2001";
	var var_Items = G2antt1.Items;
		var_Items.AddBar(var_Items.AddItem("Task 1"),"Task","1/2/2001","1/6/2001",0,"<bgcolor=FF0000> to do </bgcolor>");
</SCRIPT>

C# for /COM

axG2antt1.Columns.Add("Task");
axG2antt1.Chart.FirstVisibleDate = Convert.ToDateTime("1/1/2001",System.Globalization.CultureInfo.GetCultureInfo("en-US"));
EXG2ANTTLib.Items var_Items = axG2antt1.Items;
	var_Items.AddBar(var_Items.AddItem("Task 1"),"Task",Convert.ToDateTime("1/2/2001",System.Globalization.CultureInfo.GetCultureInfo("en-US")),Convert.ToDateTime("1/6/2001",System.Globalization.CultureInfo.GetCultureInfo("en-US")),0,"<bgcolor=FF0000> to do </bgcolor>");

X++ (Dynamics Ax 2009)

public void init()
{
	COM com_Items;
	anytype var_Items;
	;

	super();

	exg2antt1.Columns().Add("Task");
	exg2antt1.Chart().FirstVisibleDate(COMVariant::createFromDate(str2Date("1/1/2001",213)));
	var_Items = exg2antt1.Items(); com_Items = var_Items;
		com_Items.AddBar(com_Items.AddItem("Task 1"),"Task",COMVariant::createFromDate(str2Date("1/2/2001",213)), COMVariant::createFromDate(str2Date("1/6/2001",213)), COMVariant::createFromInt(0),"<bgcolor=FF0000> to do </bgcolor>");
}

Delphi 8 (.NET only)

with AxG2antt1 do
begin
	Columns.Add('Task');
	Chart.FirstVisibleDate := '1/1/2001';
	with Items do
	begin
		AddBar(AddItem('Task 1'),'Task','1/2/2001','1/6/2001',TObject(0),'<bgcolor=FF0000> to do </bgcolor>');
	end;
end

Delphi (standard)

with G2antt1 do
begin
	Columns.Add('Task');
	Chart.FirstVisibleDate := '1/1/2001';
	with Items do
	begin
		AddBar(AddItem('Task 1'),'Task','1/2/2001','1/6/2001',OleVariant(0),'<bgcolor=FF0000> to do </bgcolor>');
	end;
end

VFP

with thisform.G2antt1
	.Columns.Add("Task")
	.Chart.FirstVisibleDate = {^2001-1-1}
	with .Items
		.AddBar(.AddItem("Task 1"),"Task",{^2001-1-2},{^2001-1-6},0,"<bgcolor=FF0000> to do </bgcolor>")
	endwith
endwith

dBASE Plus

local oG2antt,var_Items

oG2antt = form.Activex1.nativeObject
oG2antt.Columns.Add("Task")
oG2antt.Chart.FirstVisibleDate = "01/01/2001"
var_Items = oG2antt.Items
	var_Items.AddBar(var_Items.AddItem("Task 1"),"Task","01/02/2001","01/06/2001",0,"<bgcolor=FF0000> to do </bgcolor>")

XBasic (Alpha Five)

Dim oG2antt as P
Dim var_Items as P

oG2antt = topparent:CONTROL_ACTIVEX1.activex
oG2antt.Columns.Add("Task")
oG2antt.Chart.FirstVisibleDate = {01/01/2001}
var_Items = oG2antt.Items
	var_Items.AddBar(var_Items.AddItem("Task 1"),"Task",{01/02/2001},{01/06/2001},0,"<bgcolor=FF0000> to do </bgcolor>")

Visual Objects

local var_Items as IItems

oDCOCX_Exontrol1:Columns:Add("Task")
oDCOCX_Exontrol1:Chart:FirstVisibleDate := SToD("20010101")
var_Items := oDCOCX_Exontrol1:Items
	var_Items:AddBar(var_Items:AddItem("Task 1"),"Task",SToD("20010102"),SToD("20010106"),0,"<bgcolor=FF0000> to do </bgcolor>")

PowerBuilder

OleObject oG2antt,var_Items

oG2antt = ole_1.Object
oG2antt.Columns.Add("Task")
oG2antt.Chart.FirstVisibleDate = 2001-01-01
var_Items = oG2antt.Items
	var_Items.AddBar(var_Items.AddItem("Task 1"),"Task",2001-01-02,2001-01-06,0,"<bgcolor=FF0000> to do </bgcolor>")

Visual DataFlex

Procedure OnCreate
	Forward Send OnCreate
	Variant voColumns
	Get ComColumns to voColumns
	Handle hoColumns
	Get Create (RefClass(cComColumns)) to hoColumns
	Set pvComObject of hoColumns to voColumns
		Get ComAdd of hoColumns "Task" to Nothing
	Send Destroy to hoColumns
	Variant voChart
	Get ComChart to voChart
	Handle hoChart
	Get Create (RefClass(cComChart)) to hoChart
	Set pvComObject of hoChart to voChart
		Set ComFirstVisibleDate of hoChart to "1/1/2001"
	Send Destroy to hoChart
	Variant voItems
	Get ComItems to voItems
	Handle hoItems
	Get Create (RefClass(cComItems)) to hoItems
	Set pvComObject of hoItems to voItems
		Send ComAddBar of hoItems (ComAddItem(hoItems,"Task 1")) "Task" "1/2/2001" "1/6/2001" 0 "<bgcolor=FF0000> to do </bgcolor>"
	Send Destroy to hoItems
End_Procedure

XBase++

#include "AppEvent.ch"
#include "ActiveX.ch"

PROCEDURE Main
 	LOCAL oForm
	LOCAL nEvent := 0, mp1 := NIL, mp2 := NIL, oXbp := NIL
	LOCAL oG2antt
	LOCAL oItems

	oForm := XbpDialog():new( AppDesktop() )
	oForm:drawingArea:clipChildren := .T.
	oForm:create( ,,{100,100}, {640,480},, .F. )
	oForm:close  := {|| PostAppEvent( xbeP_Quit )}

	oG2antt := XbpActiveXControl():new( oForm:drawingArea )
	oG2antt:CLSID  := "Exontrol.G2antt.1" /*{CD481F4D-2D25-4759-803F-752C568F53B7}*/
	oG2antt:create(,, {10,60},{610,370} )

		oG2antt:Columns():Add("Task")
		oG2antt:Chart():FirstVisibleDate := "01/01/2001"
		oItems := oG2antt:Items()
			oItems:AddBar(oItems:AddItem("Task 1"),"Task","01/02/2001","01/06/2001",0,"<bgcolor=FF0000> to do </bgcolor>")

	oForm:Show()
	DO WHILE nEvent != xbeP_Quit
		nEvent := AppEvent( @mp1, @mp2, @oXbp )
		oXbp:handleEvent( nEvent, mp1, mp2 )
	ENDDO 
RETURN