Contact Us
Contact our corporate or local offices directly.
This reference outlines the supported graphical components for scripting and their main properties and methods.
The visual form components available for use in Altium Designer scripts are mostly derived from Embarcadero's Visual Component Library (VCL), which is a collection of defined visual components for developing Windows applications using Delphi and C++ languages.
Developed as a visual class library, the VCL classes descend from the TComponent
object (itself a descendant from the TObject
root object) in a linear object hierarchy. Therefore a common script component, such as the TButton
object, inherits the properties, methods and events from its ascending objects. In this case the class hierarchy is: TObject → TPersistent → TComponent → TControl → TWinControl → TButtonControl → TButton
.
Note that the components that descend from the TControl
object are generally visual components (controls), and common components that descend from TWinControl
are mostly wrappers around the Windows API.
► See Embarcadero RAD Studio VCL for an overview of the VCL architecture and components.
When creating a Form in the Altium Designer Script Editor, the components are accessed from the Tool Palette panel. Script Forms have an associated *.DFM
file that includes details of the form's configuration, its component locations and other attributes – the file can be found in the script project's host folder. Altium Designer allows the components to be used by either DelphiScript or VBScript when designing Script Forms.
The Tool Palette Panel contains categorized visual controls that can be dropped onto a script Form.
The Tool Palette panel (accessed from the button in the bottom status bar, or the View » Panels » Tool Palette menu option) contains categorized selections of components that can be placed on a Script Form. The available components are assembled in expandable sections in the Tool Palette panel, categorized as Standard, Additional, Win32, System, Dialogs, Altium Standard and Instrument Controls.
The components (or 'controls') available in the Palette are visual components when used on a script form, meaning that a user can see a control and possibly interact with it at runtime. All controls have properties, methods, and events that describe aspects of their appearance, such as the position property of the control, methods to paint or move the control, and events that respond to user actions.
The properties and events are available in the Object Inspector panel for the currently selected form component, including the form itself. The methods are procedures and functions supported by that component.
A Script Form is the primary user interface in scripts, although there are other forms such as dialog boxes, secondary windows and so on. To create a new Script Form, with a project open in Altium Designer, select File » New » Script » Script Form or right-click on the Script project name and choose Add New to Project » Script Form. If the VBScript langauge is enabled, the command is avaiable for both VB Script and Delphi Script.
A new Script Form appears with the Form1
form name as the default, which can be changed through the Name property (under Misc) in the Object Inspector panel. Script form names should be unique in a project.
When designing a script Form, open the Object Inspector Panel from the Script button in the lower status bar.
A blank form is basically a visual window that controls can be added to. A dialog and a panel are different types of forms, and by default, a form includes standard window functionality such as:
These features, along with any other available form property, can be changed at design time using the Object Inspector panel. Since a Script Form is a VCL component it has the three following items:
Visible
property determines whether an object can be seen on a script form.► See Writing Scripts for a basic guide to developing a form-based script.
The Tool Palette panel's controls are based on the Embarcadero Visual Component Library (VCL). For full details on the methods, properties and events for the Form component (TForm
), refer to the Embarcadero VCL documentation.
► See the Embarcadero TForm reference
The available Properties for the TForm
component object, the base script form, can be viewed in the following ways:
Note that only visual component objects will appear in the panel. Non-visual objects, that act as behind the scenes controls, are not displayed on the form.
For the Form object, enter TForm.
(note the period) to activate the window. Narrow the search by typing the first few letters of a desired property – note that both properties and methods are shown.
The available Methods for the TForm
component object can be viewed in the following ways:
The available Events for the TForm
component object can be viewed in the following ways:
The Tool Palette panel's controls are based on the Embarcadero Visual Component Library (VCL). For full details on the methods, properties and events for the majority of components, refer to the component categories in the Embarcadero VCL documentation. Some Component types in the Tool Palette, in particular the Altium Instrument Controls, are exclusive to Altium Designer and not included in the Embarcadero reference documentation.
► See the Embarcadero VCL Components Categories Index
To see a list of Properties for a component:
TForm
component object.TButton
control for example, select the Standard Component category, the TButton page and then the Properties view.To see a list of Events that a component can react on:
TForm
component object.To create an event handling procedure, choose the event that the component should react to in the Object Inspector Events tab and double click in the Event entry field. The event handler procedure, named from the component and the event action, is then generated automatically in the script. If the event is renamed in the Object Inspector panel, then the corresponding code procedure is renamed accordingly.
Refer to the Component Categories documentation for information on the available Methods for a Tool Palette component.
This includes references for the following control object categories.
In the most part, these categories collect together types of visual form controls based on standard Delphi-type VCL components. The Altium Standard and Instrument Controls categories are the exception, since they offer components that are exclusive to Altium Designer's scripting system.
► See the Tool Palette Component Categories.
FormStyle
property to fsStayOnTop
.FormKind
to one of the following values; fkNone, fkNormal, fkServerPanel
or fkModal
.
fkModal
is selected then the form will be a modal form. That is, a form waiting for user input before proceeding with actions such as closing the form.fkServerPanel
is selected then the form will be shown as a Server panel.fkNormal
is selected then the form acts as a normal non-modal form.HorzScrollBar
and VertScrollBar
properties.FormStyle
property.BorderIcons
and BorderStyle
properties. (The results are visible at runtime.)Icon
property.Position
property.WindowState
property.ClientHeight
and ClientWidth
properties. Note that ClientHeight
and ClientWidth
represent the area within the form's border, whereas Height
and Width
represent the entire area of the form.ActiveControl
property to choose from the available components.KeyPreview
property.Menu
property.In some instances the visual aspect of a script form can become out of date, for example if intensive background processing from a script causes the controls to be not updated or repainted, and appear frozen or corrupted.
The Update
method of the script form provides a programmatic way to refresh the graphical contents of a form or specific control(s). In the below code example, the Update
method code lines are highlighted in gray.
Using the Update method to refresh the Status Bar:
Procedure TConverterForm.loadbuttonClick(Sender: TObject);
Var
I, J : Integer;
Begin
If OpenPictureDialog1.Execute then
Begin
XPProgressBar1.Position := 0;
XStatusBar1.SimpleText := ' Loading...';
XStatusBar1.Update;
// loading a monochrome bitmap only
Image1.Picture.LoadFromFile(OpenPictureDialog1.FileName);
// Check if image is monochrome, otherwise prompt a warning
If Image1.Picture.Bitmap.PixelFormat <> pf1bit Then
Begin
For J := 0 to Image1.Picture.Height – 1 Do
For I := 0 to Image1.Picture.Height – 1 Do
Begin
If Image1.Canvas.Pixels[I,J] <> clWhite Then
Image1.Canvas.Pixels[I,J] := clBlack;
End;
End;
ScalingFactorChange(Nil);
convertbutton.Enabled := True;
LoadButton.Enabled := False;
XStatusBar1.SimpleText := ' Ready...';
XStatusBar1.Update;
End;
End;
Refer to the PCB Logo Creator
script project located in the Scripts\Delphiscript Scripts\PCB\PCB Logo Creator
folder of the downloadable scripts collection.
Contact our corporate or local offices directly.