ImageBox controls

Use an ImageBox control to display a graphic. An image box can display a graphic from a Joint Photographic Experts Group (JPEG [.jpg]), multiresolution seamless image database (Mr.SID [.sid]), or bitmap (.bmp) file.

ImageBox controls are represented by Control objects in the ArcPad object model and by IMAGEBOX elements in ArcPad Extensible Markup Language (XML).

Attributes

ImageBox control attributes are set at design time in ArcPad Studio on the Control Properties dialog box. They cannot be changed at run time (some attributes have corresponding properties that can be accessed and changed at run time). For more information, see Attributes vs. properties.

Attributes beginning with "on" (for example, onchange) are used to specify the script to run when an event occurs. These attributes are set in the Events page on the Control Properties dialog box. Attributes are written to the customization file (layer definition, applet, default configuration) in ArcPad XML format.

The following table shows the available ImageBox control attributes and descriptions:

Attributes

Descriptions

name

The name of the ImageBox control. Used to reference the ImageBox control in scripts.

width

The width of the image box.

height

The height of the image box.

x

The x-coordinate of the upper left corner of the image box.

y

The y-coordinate of the upper left corner of the image box.

clickaction

The action taken when the user taps the image box.

defaultvalue

A simple expression that specifies the default value of the image box.

required

Specifies if the user must select an image in the image box.

readonly

Specifies if the image box's value can be modified by the user.

tabstop

Specifies if the TAB key can be used to move the focus to the image box.

group

Specifies if the image box starts a new group of controls.

border

Specifies if the image box has a border.

field

The field of the shapefile's database file format (DBF) table that is linked to the image box.

onchange

The script to run when an OnChange event occurs.

onclick

The script to run when an OnClick event occurs.

Events

ImageBox controls generate a range of events as they are operating. You can specify a script to run when any of these events occur in the Events page on the Control Properties dialog box.

The following table shows the available ImageBox control events and descriptions:

Events

Descriptions

OnClick

Occurs when the image box is clicked.

OnChange

Occurs when a new image is placed in an ImageBox control (via selecting a file or using the camera).

Properties

ImageBox control properties can be read and set at run time via scripts.

The following table shows the available ImageBox control properties and descriptions:

Properties

Descriptions

DefaultValue

Returns or sets the default value expression for the image box.

Enabled

Returns or sets a value that determines if the image box is enabled.

Field

Returns a reference to the feature attribute field to which the image box is bound.

hWnd

Returns the window handle of the image box.

Index

Returns the index of the image box.

Name

Returns the name of the image box.

Parent

Returns a reference to the page that contains the image box.

Type

Returns the control type (IMAGEBOX for an image box).

Value

Returns or sets the complete file path of the image that displays in the image box.

Visible

Returns or sets a value that determines if the image box is visible.

Methods

ImageBox controls do not support any methods.

Referencing an ImageBox control

You can only reference an ImageBox control in a form that is currently displayed. Attempting to reference an ImageBox control in a form that is not currently displayed results in a run time error. The following discusses the approaches (Direct and Event) to referencing an ImageBox control:

Direct reference

This involves referencing an ImageBox control via its name, page's name, form's name, and form's parent object. For example, use the following code to reference an ImageBox control with the name "imgLogo" on a page with the name "pgPage2" in a form with the name "frmSettings" that is present in an applet with the name "Custom Settings":

VBScript

Dim objForm 
Set objForm = Applet.Forms("frmSettings")
Dim objPage
Set objPage = objForm.Pages("pgPage2")
Dim objLabel
Set objLabel = objPage.Controls("imgLogo")

JScript

var objForm = Applet.Forms("frmSettings");
var objPage = objForm.Pages("pgPage2");
var objLabel = objPage.Controls("imgLogo");

Python

objForm = Applet.Forms("frmSettings")
objPage = objForm.Pages("pgPage2")
objLabel = objPage.Controls("imgLogo")

The previous code assumes that it is present in the applet (that is, in the .apa file or its associated script file). If you need to reference the same ImageBox control from a different applet or other customization file, explicitly reference the applet. See the following code:

VBScript

Dim objApplet
Set objApplet = Application.Applets("Custom Settings")
Dim objForm 
Set objForm = objApplet.Forms("frmSettings")
Dim objPage
Set objPage = objForm.Pages("pgPage2")
Dim objLabel
Set objLabel = objPage.Controls("imgLogo")

JScript

var objApplet = Application.Applets("Custom Settings");
var objForm = objApplet.Forms("frmSettings");
var objPage = objForm.Pages("pgPage2");
var objLabel = objPage.Controls("imgLogo");

Python

objApplet = Application.Applets("Custom Settings")
objForm = objApplet.Forms("frmSettings")
objPage = objForm.Pages("pgPage2")
objLabel = objPage.Controls("imgLogo")

Event reference

This involves referencing an ImageBox control in an event handling script. For example, use the following code to reference an ImageBox control with the name "imgLogo" on a page with the name "pgPage2" in the OnLoad event handler of its form:

VBScript

Dim objPage
Set objPage = ThisEvent.Object.Pages("pgPage2")
Dim objListBox
Set objListBox = objPage.Controls("imgLogo")

JScript

var objPage = ThisEvent.Object.Pages("pgPage2");
var objListBox = objPage.Controls("imgLogo");

Python

objPage = ThisEvent.Object.Pages("pgPage2")
objListBox = objPage.Controls("imgLogo")

Initializing an ImageBox control

Image box initialization involves setting particular image box properties when the image box firsts displays. Generally, the OnLoad event handler of the page or form is the most appropriate place to do this. For example, the following code hides an image box with the name "imgLogo" when called in the page's OnLoad event handler:

VBScript

Dim objControls
Set objControls = ThisEvent.Object.Controls 
objControls("imgLogo").Visible = False

JScript

var objControls = ThisEvent.Object.Controls;
objControls("imgLogo").Visible = false

Python

objControls = ThisEvent.Object.Controls
objControls("imgLogo").Visible = false

Specifying the image displayed in an ImageBox control

To set the image displayed in an image box at run time, set its Value property to the applicable image file's file path. For example, use the following code to display the bitmap image "c:\images\logo.bmp" in an image box referenced by the variable objImageBox:

VBScript

objImageBox.Value = "c:\images\logo.bmp"

JScript

objImageBox.Value = "c:\images\logo.bmp";

Python

objImageBox.Value = "c:\\images\\logo.bmp"

2/7/2013