method Layers.Add ([Key as Variant])
Adds a Layer object to the collection and returns a reference to the newly created object.

TypeDescription
Key as Variant [Optional] A VARIANT expression that indicates the key to identify the newly create layer.
ReturnDescription
LayerA Layer object that indicates the newly created layer.
The Add method adds a new layer to the control. The Count property specifies the number of layers in the control. The PicturesPath Specifies the path to load the pictures from. The PicturesName property specifies the expression that indicates the name of the picture to be loaded on each layer. The Item property of the Layers collection accesses a Layer giving its index or key. The Index property is read-only and zero-based, which indicates that the layer with the Index property 0, it is the first layer, while the layer with the index Count - 1, is the last layer in the control ( in z-order ). The Background object holds pictures to be shown on the layer's background. The Foreground property of the Layer access the layer's Foreground object. The for each statement can be used to enumerate Layer objects in the Layers collection. The ShowLayers property indicates the only layers to be shown on the control.

The following properties can be used to add / remove layers within the control:

The following properties can be used to access Layer objects in the control:

The following sample creates a view from two pictures: "Guage_Background.png" and "Guage_Needle.png" from the C:\Program Files\Exontrol\ExGauge\Sample\Design\Circular\Guage.

The sample shows how to add two new layers with the keys: "background" and "needle"

VBA (MS Access, Excell...)

With Gauge1
	.BeginUpdate 
	.PicturesPath = "C:\Program Files\Exontrol\ExGauge\Sample\Design\Circular\Guage"
	.Layers.Add("background").Background.Picture.Name = "Guage_Background.png"
	.Layers.Add("needle").Background.Picture.Name = "Guage_Needle.png"
	.EndUpdate 
End With

VB6

With Gauge1
	.BeginUpdate 
	.PicturesPath = "C:\Program Files\Exontrol\ExGauge\Sample\Design\Circular\Guage"
	.Layers.Add("background").Background.Picture.Name = "Guage_Background.png"
	.Layers.Add("needle").Background.Picture.Name = "Guage_Needle.png"
	.EndUpdate 
End With

VB.NET

With Exgauge1
	.BeginUpdate()
	.PicturesPath = "C:\Program Files\Exontrol\ExGauge\Sample\Design\Circular\Guage"
	.Layers.Add("background").Background.Picture.Name = "Guage_Background.png"
	.Layers.Add("needle").Background.Picture.Name = "Guage_Needle.png"
	.EndUpdate()
End With

VB.NET for /COM

With AxGauge1
	.BeginUpdate()
	.PicturesPath = "C:\Program Files\Exontrol\ExGauge\Sample\Design\Circular\Guage"
	.Layers.Add("background").Background.Picture.Name = "Guage_Background.png"
	.Layers.Add("needle").Background.Picture.Name = "Guage_Needle.png"
	.EndUpdate()
End With

C++

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

	#import <ExGauge.dll>
	using namespace EXGAUGELib;
*/
EXGAUGELib::IGaugePtr spGauge1 = GetDlgItem(IDC_GAUGE1)->GetControlUnknown();
spGauge1->BeginUpdate();
spGauge1->PutPicturesPath(L"C:\\Program Files\\Exontrol\\ExGauge\\Sample\\Design\\Circular\\Guage");
spGauge1->GetLayers()->Add("background")->GetBackground()->GetPicture()->PutName("Guage_Background.png");
spGauge1->GetLayers()->Add("needle")->GetBackground()->GetPicture()->PutName("Guage_Needle.png");
spGauge1->EndUpdate();

C++ Builder

Gauge1->BeginUpdate();
Gauge1->PicturesPath = L"C:\\Program Files\\Exontrol\\ExGauge\\Sample\\Design\\Circular\\Guage";
Gauge1->Layers->Add(TVariant("background"))->Background->Picture->set_Name(TVariant("Guage_Background.png"));
Gauge1->Layers->Add(TVariant("needle"))->Background->Picture->set_Name(TVariant("Guage_Needle.png"));
Gauge1->EndUpdate();

C#

exgauge1.BeginUpdate();
exgauge1.PicturesPath = "C:\\Program Files\\Exontrol\\ExGauge\\Sample\\Design\\Circular\\Guage";
exgauge1.Layers.Add("background").Background.Picture.Name = "Guage_Background.png";
exgauge1.Layers.Add("needle").Background.Picture.Name = "Guage_Needle.png";
exgauge1.EndUpdate();

JScript/JavaScript

<BODY onload="Init()">
<OBJECT CLASSID="clsid:91628F12-393C-44EF-A558-83ED1790AAD3" id="Gauge1"></OBJECT>

<SCRIPT LANGUAGE="JScript">
function Init()
{
	Gauge1.BeginUpdate();
	Gauge1.PicturesPath = "C:\\Program Files\\Exontrol\\ExGauge\\Sample\\Design\\Circular\\Guage";
	Gauge1.Layers.Add("background").Background.Picture.Name = "Guage_Background.png";
	Gauge1.Layers.Add("needle").Background.Picture.Name = "Guage_Needle.png";
	Gauge1.EndUpdate();
}
</SCRIPT>
</BODY>

VBScript

<BODY onload="Init()">
<OBJECT CLASSID="clsid:91628F12-393C-44EF-A558-83ED1790AAD3" id="Gauge1"></OBJECT>

<SCRIPT LANGUAGE="VBScript">
Function Init()
	With Gauge1
		.BeginUpdate 
		.PicturesPath = "C:\Program Files\Exontrol\ExGauge\Sample\Design\Circular\Guage"
		.Layers.Add("background").Background.Picture.Name = "Guage_Background.png"
		.Layers.Add("needle").Background.Picture.Name = "Guage_Needle.png"
		.EndUpdate 
	End With
End Function
</SCRIPT>
</BODY>

C# for /COM

axGauge1.BeginUpdate();
axGauge1.PicturesPath = "C:\\Program Files\\Exontrol\\ExGauge\\Sample\\Design\\Circular\\Guage";
axGauge1.Layers.Add("background").Background.Picture.Name = "Guage_Background.png";
axGauge1.Layers.Add("needle").Background.Picture.Name = "Guage_Needle.png";
axGauge1.EndUpdate();

X++ (Dynamics Ax 2009)

public void init()
{
	COM com_Background,com_Layer,com_Picture;
	anytype var_Background,var_Layer,var_Picture;
	;

	super();

	exgauge1.BeginUpdate();
	exgauge1.PicturesPath("C:\\Program Files\\Exontrol\\ExGauge\\Sample\\Design\\Circular\\Guage");
	var_Layer = COM::createFromObject(exgauge1.Layers()).Add("background"); com_Layer = var_Layer;
	var_Background = COM::createFromObject(com_Layer).Background(); com_Background = var_Background;
	var_Picture = COM::createFromObject(com_Background).Picture(); com_Picture = var_Picture;
	com_Picture.Name("Guage_Background.png");
	var_Layer = COM::createFromObject(exgauge1.Layers()).Add("needle"); com_Layer = var_Layer;
	var_Background = COM::createFromObject(com_Layer).Background(); com_Background = var_Background;
	var_Picture = COM::createFromObject(com_Background).Picture(); com_Picture = var_Picture;
	com_Picture.Name("Guage_Needle.png");
	exgauge1.EndUpdate();
}

Delphi 8 (.NET only)

with AxGauge1 do
begin
	BeginUpdate();
	PicturesPath := 'C:\Program Files\Exontrol\ExGauge\Sample\Design\Circular\Guage';
	Layers.Add('background').Background.Picture.Name := 'Guage_Background.png';
	Layers.Add('needle').Background.Picture.Name := 'Guage_Needle.png';
	EndUpdate();
end

Delphi (standard)

with Gauge1 do
begin
	BeginUpdate();
	PicturesPath := 'C:\Program Files\Exontrol\ExGauge\Sample\Design\Circular\Guage';
	Layers.Add('background').Background.Picture.Name := 'Guage_Background.png';
	Layers.Add('needle').Background.Picture.Name := 'Guage_Needle.png';
	EndUpdate();
end

VFP

with thisform.Gauge1
	.BeginUpdate
	.PicturesPath = "C:\Program Files\Exontrol\ExGauge\Sample\Design\Circular\Guage"
	.Layers.Add("background").Background.Picture.Name = "Guage_Background.png"
	.Layers.Add("needle").Background.Picture.Name = "Guage_Needle.png"
	.EndUpdate
endwith

dBASE Plus

local oGauge,var_Picture,var_Picture1

oGauge = form.EXGAUGEACTIVEXCONTROL1.nativeObject
oGauge.BeginUpdate()
oGauge.PicturesPath = "C:\Program Files\Exontrol\ExGauge\Sample\Design\Circular\Guage"
// oGauge.Layers.Add("background").Background.Picture.Name = "Guage_Background.png"
var_Picture = oGauge.Layers.Add("background").Background.Picture
with (oGauge)
	TemplateDef = [dim var_Picture]
	TemplateDef = var_Picture
	Template = [var_Picture.Name = "Guage_Background.png"]
endwith
// oGauge.Layers.Add("needle").Background.Picture.Name = "Guage_Needle.png"
var_Picture1 = oGauge.Layers.Add("needle").Background.Picture
with (oGauge)
	TemplateDef = [dim var_Picture1]
	TemplateDef = var_Picture1
	Template = [var_Picture1.Name = "Guage_Needle.png"]
endwith
oGauge.EndUpdate()

XBasic (Alpha Five)

Dim oGauge as P
Dim var_Picture as local
Dim var_Picture1 as local

oGauge = topparent:CONTROL_ACTIVEX1.activex
oGauge.BeginUpdate()
oGauge.PicturesPath = "C:\Program Files\Exontrol\ExGauge\Sample\Design\Circular\Guage"
' oGauge.Layers.Add("background").Background.Picture.Name = "Guage_Background.png"
var_Picture = oGauge.Layers.Add("background").Background.Picture
oGauge.TemplateDef = "dim var_Picture"
oGauge.TemplateDef = var_Picture
oGauge.Template = "var_Picture.Name = `Guage_Background.png`"

' oGauge.Layers.Add("needle").Background.Picture.Name = "Guage_Needle.png"
var_Picture1 = oGauge.Layers.Add("needle").Background.Picture
oGauge.TemplateDef = "dim var_Picture1"
oGauge.TemplateDef = var_Picture1
oGauge.Template = "var_Picture1.Name = `Guage_Needle.png`"

oGauge.EndUpdate()

Visual Objects


oDCOCX_Exontrol1:BeginUpdate()
oDCOCX_Exontrol1:PicturesPath := "C:\Program Files\Exontrol\ExGauge\Sample\Design\Circular\Guage"
oDCOCX_Exontrol1:Layers:Add("background"):Background:Picture:Name := "Guage_Background.png"
oDCOCX_Exontrol1:Layers:Add("needle"):Background:Picture:Name := "Guage_Needle.png"
oDCOCX_Exontrol1:EndUpdate()

PowerBuilder

OleObject oGauge

oGauge = ole_1.Object
oGauge.BeginUpdate()
oGauge.PicturesPath = "C:\Program Files\Exontrol\ExGauge\Sample\Design\Circular\Guage"
oGauge.Layers.Add("background").Background.Picture.Name = "Guage_Background.png"
oGauge.Layers.Add("needle").Background.Picture.Name = "Guage_Needle.png"
oGauge.EndUpdate()

Visual DataFlex

Procedure OnCreate
	Forward Send OnCreate
	Send ComBeginUpdate
	Set ComPicturesPath to "C:\Program Files\Exontrol\ExGauge\Sample\Design\Circular\Guage"
	Variant voLayers
	Get ComLayers to voLayers
	Handle hoLayers
	Get Create (RefClass(cComLayers)) to hoLayers
	Set pvComObject of hoLayers to voLayers
		Variant voLayer
		Get ComAdd of hoLayers "background" to voLayer
		Handle hoLayer
		Get Create (RefClass(cComLayer)) to hoLayer
		Set pvComObject of hoLayer to voLayer
			Variant voBackground
			Get ComBackground of hoLayer to voBackground
			Handle hoBackground
			Get Create (RefClass(cComBackground)) to hoBackground
			Set pvComObject of hoBackground to voBackground
				Variant voPicture
				Get ComPicture of hoBackground to voPicture
				Handle hoPicture
				Get Create (RefClass(cComPicture)) to hoPicture
				Set pvComObject of hoPicture to voPicture
					Set ComName of hoPicture to "Guage_Background.png"
				Send Destroy to hoPicture
			Send Destroy to hoBackground
		Send Destroy to hoLayer
	Send Destroy to hoLayers
	Variant voLayers1
	Get ComLayers to voLayers1
	Handle hoLayers1
	Get Create (RefClass(cComLayers)) to hoLayers1
	Set pvComObject of hoLayers1 to voLayers1
		Variant voLayer1
		Get ComAdd of hoLayers1 "needle" to voLayer1
		Handle hoLayer1
		Get Create (RefClass(cComLayer)) to hoLayer1
		Set pvComObject of hoLayer1 to voLayer1
			Variant voBackground1
			Get ComBackground of hoLayer1 to voBackground1
			Handle hoBackground1
			Get Create (RefClass(cComBackground)) to hoBackground1
			Set pvComObject of hoBackground1 to voBackground1
				Variant voPicture1
				Get ComPicture of hoBackground1 to voPicture1
				Handle hoPicture1
				Get Create (RefClass(cComPicture)) to hoPicture1
				Set pvComObject of hoPicture1 to voPicture1
					Set ComName of hoPicture1 to "Guage_Needle.png"
				Send Destroy to hoPicture1
			Send Destroy to hoBackground1
		Send Destroy to hoLayer1
	Send Destroy to hoLayers1
	Send ComEndUpdate
End_Procedure

XBase++

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

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

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

	oGauge := XbpActiveXControl():new( oForm:drawingArea )
	oGauge:CLSID  := "Exontrol.Gauge.1" /*{91628F12-393C-44EF-A558-83ED1790AAD3}*/
	oGauge:create(,, {10,60},{610,370} )

		oGauge:BeginUpdate()
		oGauge:PicturesPath := "C:\Program Files\Exontrol\ExGauge\Sample\Design\Circular\Guage"
		oGauge:Layers():Add("background"):Background():Picture():Name := "Guage_Background.png"
		oGauge:Layers():Add("needle"):Background():Picture():Name := "Guage_Needle.png"
		oGauge:EndUpdate()

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