IDialogsComponentCopy link to this sectionLink to this section copied!

Interface for Dialog Editor.

OverviewCopy link to this sectionLink to this section copied!

IDialogsComponent exposes the Dialogs editor of a project to the Advanced Installer COM automation surface, the same way dialogs, their controls, and the install UI sequence are configured in the GUI. It lets a script enumerate dialogs, create and delete them, edit their controls, and wire dialogs into (or out of) an install chain. It is reached through the project object:

$advinst = New-Object -ComObject "AdvancedInstaller"
$proj    = $advinst.CreateProject($advinst.ProjectTypes.Architect)
$dialogs = $proj.DialogsComponent

The component returns two kinds of objects:

  • IDialog - a single dialog, with its geometry and its controls.
  • IControl - a single control hosted by a dialog.

Install types (chains)Copy link to this sectionLink to this section copied!

Several members target an install type, the predefined dialog chain a dialog belongs to. The values returned by SupportedInstallTypes are:

  • Install - the first-time install sequence.
  • Maintenance - the maintenance (change/repair/remove) sequence.
  • Patch - the patch sequence.
  • Resume - the resume sequence
  • Bootstrapper - the prerequisites/bootstrapper UI sequence.

Control typesCopy link to this sectionLink to this section copied!

NewControl accepts a control type, validated against SupportedControlTypes. The accepted values are: Text, Edit, PushButton, CheckBox, RadioButtonGroup, GroupBox, PathEdit, MaskedEdit, ScrollableText, Bitmap, Icon, Line, ComboBox, ListBox, ListView, DirectoryList, VolumeCostList, DirectoryCombo, VolumeSelectCombo, SelectionTree, ProgressBar and Hyperlink.

PropertiesCopy link to this sectionLink to this section copied!

Dialogs
- Returns an array of IDialog objects for every dialog in the project. Transient dialogs (display-only rows such as Trial / Aero variants that are never persisted) are not included. (Read-only).

SupportedControlTypes
- Returns the array of control type names accepted by IDialog.NewControl. Useful for validating a type before creating a control. (Read-only)

SupportedInstallTypes
- Returns the array of install-type names accepted by the chain methods: Install, Maintenance, Patch, Resume and Bootstrapper. (Read-only)

GetChainDialogs
- Returns the names of the dialogs that are actually wired into the chain of the given install type, in the order they are displayed. The result is computed by walking the chain's Back / Next links, so a dialog appears only when it is genuinely linked into the sequence. This is the easiest way to verify that NewDialog / AddDialogToChain placed a dialog in the chain and where it sits relative to its neighbors. The install type must be one of ,, otherwise an error is raised. (Read-only)

MethodsCopy link to this sectionLink to this section copied!

FindDialog
- Looks up a dialog by name and returns the matching IDialog, or $null when no dialog with that name exists or when the match is a transient dialog.

NewDialog
- Creates a new dialog from the built-in template and returns it as an IDialog. An empty name raises an error. A name that is already used by another dialog raises an error. The second argument is an optional install type: when omitted the dialog is only created and appears under Unused Dialogs; when supplied it must be one of SupportedInstallTypes (otherwise an error is raised) and the dialog is also linked into that chain at the default insertion point (before VerifyReadyDlg, or after the bootstrapper welcome dialog for the Bootstrapper chain), with its neighbors' Back / Next links rewired to it.

AddDialogToChain
- Links an existing dialog into the chain of the given install type. The install type must be one of SupportedInstallTypes, otherwise an error is raised. The third argument is an optional "insert after" anchor: when supplied it must be the name of an existing dialog (otherwise an error is raised). The anchor is honored only when it is a real member of the chain that allows inserting a dialog after it; for anchors that cannot be followed (for example startup dialogs such as PrepareDlg, which have no usable Next link) and when the anchor is omitted, the dialog falls back to the default insertion point (before VerifyReadyDlg). This keeps the dialog spliced between two real neighbors instead of producing a dead-end dialog.

RemoveDialogFromChain
- Removes a dialog from the chain of the given install type. The install type must be one of SupportedInstallTypes, otherwise an error is raised. When the dialog is not part of the requested chain an error is raised.

DeleteDialog
- Permanently deletes a dialog. The dialog can only be removed when nothing else references it; if it is still used in an install sequence or by a control event, an error is raised and the dialog is kept.

ExamplesCopy link to this sectionLink to this section copied!

Example 1: Create a dialog and add it to the Install chain

$advinst = New-Object -ComObject "AdvancedInstaller"
$proj    = $advinst.CreateProject($advinst.ProjectTypes.Architect)
$dialogs = $proj.DialogsComponent

# create the dialog, then splice it into the Install chain after WelcomeDlg
$dlg = $dialogs.NewDialog("MyCustomDlg")
$dialogs.AddDialogToChain($dlg, "Install", "WelcomeDlg")

# verify it really landed in the chain, and where
$dialogs.GetChainDialogs("Install")     # -> ... WelcomeDlg, MyCustomDlg, FolderDlg ...

Example 2: Add controls to a dialog

$dlg = $proj.DialogsComponent.FindDialog("MyCustomDlg")

$label = $dlg.NewControl("Text", "Caption")
$label.Text = "Choose an option:"
$label.X = 20; $label.Y = 60

$ok = $dlg.NewControl("PushButton", "OkButton")
$ok.Text = "OK"

# inspect the dialog's controls
$dlg.Controls | ForEach-Object { "{0} ({1})" -f $_.Name, $_.Type }

Example 3: Remove a dialog from a chain and verify

$dialogs = $proj.DialogsComponent
$dlg     = $dialogs.FindDialog("MyCustomDlg")

$dialogs.RemoveDialogFromChain($dlg, "Install")

if ($dialogs.GetChainDialogs("Install") -notcontains "MyCustomDlg") {
  "MyCustomDlg is no longer in the Install chain"
}

Topics

  • IDialog
    Interface for a dialog, with its geometry and its controls.
  • IControl
    Interface for a control element hosted by a dialog.