NewImage

Description

Adds an image to a form

Syntax

[Set oCtl =] oFrm.NewImage

( Name, Left, Top, Width, Height, Picture, [Container] )

Parameters

Part

Description

Set oCtl =

(optional) Store a reference to the new control in the variable oCtl. This variable can be used to access the control's properties and methods

oFrm

A reference to a form object (see the NewForm method)

Name

The name of the control. It must be unique within the form and may not be empty or start with an asterisk (*)

Left

See the list of properties below

Top

See the list of properties below

Width

See the list of properties below

Height

See the list of properties below

Picture

The name and path of a graphic (BMP, ICO, WMF, GIF or JPG file) to be loaded. You may also specify one of four string constants ( "IconCritical", "IconQuestion", "IconExclamation" or "IconInformation" ) to show the corresponding standard Windows icon.

Container

(optional) The name of an existing frame control that will act as container for the image. If unspecified or an empty string, the Form itself will be the container. Please note that the Left and Top properties are relative to the container's left and top edges

Properties, Methods and Events

Property

Description

BorderStyle

0

None (default)

1

Fixed single

Enabled

(boolean) Determines if the control can respond to user-generated events

Height

The height of the control in twips

Left

The distance from the left edge of the specified container in twips

Parent

(read-only) Returns the parent form, object or collection. You can use the parent property to access the properties and methods of an object's parent

Picture

Returns or sets a graphic to be displayed in the control. This property can be set to any other object's DragIcon, Icon, Image, or Picture property, or you can assign it a graphic returned by the LoadPic function

Stretch

(boolean) Stretch the image to the given height and width or not (default).
If you specify a non-zero height or width when the control is added, the image will be stretched automatically

Tag

(reserved) Used internally to store the user-defined controlname

ToolTipText

Explanatory text that appears in a small rectangle below the object when you pause the mouse pointer (hover) over it for about one second

Top

The distance from the top edge of the specified container in twips

Visible

(boolean) Determines whether the control is visible or hidden

Width

The width of the control in twips

Method

Description

Move

Parameters: left [, top [, width [, height ]]]

Only the left argument is required. However, to specify any other arguments, you must specify all arguments that appear in the syntax before the argument you want to specify. For example, you can't specify width without specifying left and top. Any trailing arguments that are unspecified remain unchanged

Refresh

Forces a complete repaint of a control

Event

Description

Event raised

Click

Occurs when the user clicks the image with the left or right mouse button

Controlname

To be able to handle events you need to operate a form in callback mode.
This subject is described in the following topics:
Callback forms, ClickHandler

Example

Option Explicit

Const vbModal = 1

Dim oDlg, oFrm

'Create the WshDialog.Kit object and store a reference in oDlg
Set oDlg = Wscript.CreateObject("WshDialog.Kit", "oDlg_")

'Add a new form and store a reference to it in the variable oFrm
Set oFrm = oDlg.NewForm("Sample")

'Add the four standard Windows icons
oFrm.
NewImage "ICON1", 200, 100, 0, 0, "IconCritical"
oFrm.
NewImage "ICON2", 800, 100, 0, 0, "IconQuestion"
oFrm.
NewImage "ICON3", 1400, 100, 0, 0, "IconExclamation"
oFrm.
NewImage "ICON4", 2000, 100, 0, 0, "IconInformation"

'Add an external bitmap file
oFrm.NewImage "BMP1", 100, 750, 4000, 3000, "C:\Windows\Setup.bmp"

'Add an OK button and set it's Default property
Set oCtl = oFrm.NewButton("OK", 2900, 200, 1000, 375, "&OK")
oCtl.Default = True

'Automatically size the form and show it (modally)
oFrm.Autosize
oFrm.Show vbModal