Gl ob a l s
OverviewGlobal FunctionsBuilt In
AutoPlay Media Studio comes with some built-in global functions to make certain runtime tasks simpler.
Note: These optional functions are automatically called by your application. You do not call them in your script, only define them.
General Project Functions
General project functions are called by the application whenever something project-wide happens. These functions allow the developer to control how certain aspects of the published application behave.
g _ On S y s t em T ray M e nu ( nu m b er X , nu m b er Y )
Called whenever the user right-clicks on your application's system tray icon. Typically, you would use
Application.ShowPopupMenu in this function to create a right-click popup menu from the system tray.
X:
The X coordinate, in pixels, in relation to the top left corner of the user's screen.
Y:
The Y coordinate, in pixels, in relation to the top left corner of the user's screen.
Re t u r n s :
Nothing.
E xam pl e :
function g_OnSystemTrayMenu(X, Y) tblMenu = {};
tblMenu[1] ={}; tblMenu[1].Text = "&New Menu"; tblMenu[1].ID = 100; tblMenu[1].Checked = false; tblMenu[1].Enabled = true; tblMenu[1].SubMenu = {}; tblMenu[1].SubMenu[1] = {};
tblMenu[1].SubMenu[1].Text = "&SubItem 1"; tblMenu[1].SubMenu[1].ID = 101; tblMenu[1].SubMenu[1].Checked = false; tblMenu[1].SubMenu[1].Enabled = true; tblMenu[1].SubMenu[2] = {}; tblMenu[1].SubMenu[2].Text = "S&ubItem 2"; tblMenu[1].SubMenu[2].ID = 102; tblMenu[1].SubMenu[2].Checked = false; tblMenu[1].SubMenu[2].Enabled = true;
result = Application.ShowPopupMenu(X, Y, tblMenu, TPM_RIGHTALIGN, TPM_BOTTOMALIGN, true, false);
if(result ~= -1)then
Dialog.Message("Menu Item Selected",result);
end end
Qu eryA llow P r oj ec t C lo s e ( )
Called whenever the project is 'told' to close. Using this function, you can control how the user can close the application, such as confirming with the user that they intended to close the application.
Re t u r n s :
True if the application should close, false if it should not close.
E xam pl e :
function QueryAllowProjectClose()
result= Dialog.Message("Application Exit", "Are you sure that you want to quit?", MB_YESNO, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
--if they choose yes
if result == IDYES then
--allow the app to close return true;
else
--cancel close return false;
end
end
g _ OnG e t M in M ax I n f o ( )
Called whenever the application is resized at runtime. Using this function, you can set the minimum and maximum application window size for your project. If 'Resizable' is not checked in your application's Project Settings, this function is ignored.
Note: If this function is not defined then window size during a resize will not be restricted.
Note: The Min. height and Min. width settings on the Appearance tab of the Project Settings dialog can also be used to set a minimum page height and width, however this function will override those values.
Re t u r n s :
A table indexed by the following keys:
KEY |
TYPE DESCRIPTION |
|
MinX |
number |
The minimum window width in pixels. Note that there is an absolute minimum size allowed by Windows if you have a title bar displayed. |
MinY |
number |
The minimum window height in pixels. Note that there is an absolute minimum |
size allowed by Windows if you have a title bar displayed. |
|||
MaxX |
number |
The maximum window width in pixels. |
|
MaxY |
number |
The maximum window height in pixels. |
|
Tip: Do not set any of the values above which you do not want to restrict. For example, if you only want to set a minimum height but not restrict sizing in any other way then only define the MinY value. |
E xam pl e :
-- Restrict the window size to 200x100 minimum
-- and 800x600 maximum: function g_OnGetMinMaxInfo()
tbReturn = {}; tbReturn.MinX = 200;
tbReturn.MinY = 100;
tbReturn.MaxX = 800;
tbReturn.MaxY = 600;
end
return tbReturn;
Dialog Functions
Dialog functions are called by the application whenever dialogs are used. These functions allow the developer to control how certain aspects of the dialog behave.
Qu eryA llow D i a log C lo s e ( s t r ing D i a log Name )
Called whenever the dialog is 'told' to close. Using this function, you can control how the user can close the dialog, such as confirming with the user that they intended to close the dialog. This function will be called before the dialog's On Close event.
D i a log Name
A string containing the name of the dialog you want this function to be used on.
Re t u r n s :
True to allow the dialog to close, false to not close it.
E xam pl e :
function QueryAllowDialogClose(strDialogName)
result= Dialog.Message("Close Dialog", "Are you sure that you want to close the dialog?", MB_YESNO, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
--if they choose yes
if result == IDYES then
--allow the dialog to close return true;
else
--cancel close return false;
end
end
Menu Bar Functions
Menu Bar functions are called by the application at runtime to allow the developer to dynamically enable/disable and check/uncheck menu items. By default these functions are not defined (and therefore will do nothing). These functions will only perform tasks if they are defined by the developer at design time.
bool ea n g _ On U pd a t e M e nu E n a bl e d ( nu m b er C o mma nd I D , t a bl e I t em I n f o )
Accepts both a Command ID and a table of item information from the AutoPlay runtime. Should return true if the current item should be enabled, and false if the current item should be disabled.
C o mma nd I D :
The ID of the currently selected menu item.
I t em I n f o :
A table of information about the currently selected item, indexed by the following keys:
KEY |
TYPE DESCRIPTION |
|
ID |
number |
The numeric ID of the menu item. |
Text |
string |
The text of the menu item. Note that a separator item's Text is set to "---". |
IconID |
number |
The 0-based icon index from the Image List specified on the Menu Bar for the menu item. |
Enabled |
boolean |
Whether the menu item is enabled. |
Checked |
boolean |
Whether the menu item is checked. |
SubTable |
table |
A numerically indexed table of menu item tables if child elements exist, or nil if no child elements exist. |
Re t u r n s :
True if the current item should be enabled, false if the current item should not be enabled.
E xam pl e :
function g_OnUpdateMenuEnabled(CommandID,tblInfo)
-- Disable command 2000
if (CommandID == 2000) then return false;
else
return true;
end
end
bool ea n g _ On U pd a t e M e nu C h eck ( nu m b er C o mma nd I D , t a bl e I t em I n f o )
Accepts both a Command ID and a table of item information from the AutoPlay runtime. Should return true if the current item should be checked, and false if the current item should not be checked.
C o mma nd I D
The ID of the currently selected menu item.
I t em I n f o
A table of information about the currently selected item, indexed by the following keys:
KEY |
TYPE DESCRIPTION |
|
ID |
number |
The numeric ID of the menu item. |
Text |
string |
The text of the menu item. Note that a separator item's Text is set to "---". |
IconID |
number |
The 0-based icon index from the Image List specified on the Menu Bar for the menu item. |
Enabled |
boolean |
Whether the menu item is enabled. |
Checked |
boolean |
Whether the menu item is checked. |
SubTable |
table |
A numerically indexed table of menu item tables if child elements exist, or nil if no child elements exist. |
Re t u r n s :
True if the current item should be checked, false if the current item should not be checked.
E xam pl e :
function g_OnUpdateMenuCheck(CommandID,tblInfo)
-- Uncheck command 2000
if (CommandID == 2000) then return false;
else
return true;
end
end
G e n e r a l In f o
ContentsInput Mask
An input mask is a special pattern that controls what the user can type into a MaskedInput dialog or input object at run time. The mask can be any combination of regular text characters (literal characters) and special characters. Each special character, as outlined below, represents one "place" in the edit field where the user can type a character. Different special characters allow different kinds of characters to be typed in their "place" by the user. For example, the # character only allows a digit between 0 and 9 to be typed in its place, and the ? character only allows a letter between a and Z.
Note: The special characters you use in the input mask determine what the user will be allowed to type into the edit field.
You can use any literal characters to include "normal" characters in the edit field. The user will type "around" the literal characters as they fill in the "blanks" created by the special characters.
Here are the special characters that you can use in an input mask:
Note: Some of these special literal characters adapt to the user's system settings, so they may need to be forced on all systems using "\" before the character.
. |
Decimal. (Special literal.) This will be replaced by the character specified as the decimal in the user's international settings. To force a period on all systems, use \. instead. |
, |
Thousands separator. (Special literal.) This will be replaced by the character specified as the thousands separator in the user's international settings. To force a comma on all systems, use \, instead. |
: |
Time separator. (Special literal.) This will be replaced by the character specified as the time separator in the user's international settings. To force a colon on all systems, use \: instead. |
/ |
Date separator. (Special literal.) This will be replaced by the character specified as the date separator in the user's international settings. To force a slash on all systems, use \/ instead. |
# |
Digit character (0-9). For every # in the input mask, the user will only be able to enter a digit between 0 and 9. To display a literal number sign (#), use \# instead. |
A |
Alphanumeric character (0-9 and a-Z). For every A in the input mask, the user will be able to enter any letter from a to Z or any digit between 0 and 9. To display a literal "A", use \A instead. |
? |
Alphabetic character (a-Z). For every ? in the input mask, the user will only be able to enter a letter from a to Z. To display a literal question mark, use \? instead. |
> |
Alphabetic character, but forces any letters typed to uppercase (A-Z). For every > in the input mask, the user will only be able to enter a letter from A to Z, and whatever letter they type will be converted to uppercase. To display a literal greater-than sign, use \> instead. |
< |
Alphabetic character, but forces any letters typed to lowercase (a-z). For every < in the input mask, the user will only be able to enter a letter from a to z, and whatever letter they type will be converted to lowercase. To display a literal less-than sign, use \< instead. |
& |
ANSI Character. Allows any ANSI character in the following ranges: 32-126 and 128-255. To display a literal ampersand, use \& instead. |
\ |
Literal escape. Use this to make a special character act as a literal in the input mask. For example, you could create a mask for an IP address: IP \Address\: ###\.###\.###\.### |
...which would appear as: IP Address: . . .
(Note that we needed to use the literal escape for the 'A' in Address, the colon, and all three decimal points.)