InstallShield 2016 » InstallScript Language Reference
Note • To call this function in a Basic MSI setup, you must first create a custom action for the entry-point function, execute the custom action in a sequence or as the result of a dialog's control event, and then build the release.
/*--------------------------------------------------------------*\
*
* InstallShield Example Script
*
* Demonstrates the GetFont and CtrlSetFont functions.
*
* This example script calls GetFont to retrieve the handles
* of four fonts. These handles are then passed to CtrlSetFont
* to set the font of the static text fields in a custom dialog
* box.
*
* The "custom" dialog used in this script is actually the
* InstallShield dialog that is displayed by the built-in
* function SetupType. Because this dialog is stored in
* the file _isres.dll, which is already compressed in
* the installation, it can be used in a script as a custom
* dialog.
*
\*--------------------------------------------------------------*/
// Dialog and control IDs.
#define RES_DIALOG_ID 10203 // ID of the custom dialog
#define RES_PBUT_NEXT 1 // ID of Next button
#define RES_PBUT_CANCEL 9 // ID of Cancel button
#define RES_TEXT_1 202 // ID of first static text box
#define RES_TEXT_2 210 // ID of second static text box
#define RES_TEXT_3 220 // ID of third static text box
#define RES_TEXT_4 230 // ID of fourth static text box
// Include Ifx.h for built-in InstallScript function prototypes.
#include "Ifx.h"
export prototype ExFn_CtrlSetFont(HWND);
function ExFn_CtrlSetFont(hMSI)
STRING szDialogName;
NUMBER nResult, nCmdValue;
HWND hFont1, hFont2, hFont3, hFont4, hwndDldg;
BOOL bDone;
begin
// Get the handle of the fonts to use for the static text
// that is displayed by the custom dialog.
hFont1 = GetFont("Arial", 14, STYLE_BOLD);
hFont2 = GetFont("Times New Roman", 11, STYLE_ITALIC);
hFont3 = GetFont("Arial", 10, STYLE_BOLD);
hFont4 = GetFont("Courier New", 9, STYLE_NORMAL);
if (hFont1 = 0 || hFont2 = 0 || hFont3 = 0 || hFont4 = 0) then
// Report an error; then terminate.
MessageBox ("Unable to get all fonts. ", SEVERE);
abort;
endif;
// Specify a name to identify the custom dialog in this installation.
szDialogName = "CustomDialog";
// Define the dialog. Pass a null string in the second parameter
// to get the dialog from _isuser.dll or _isres.dll. Pass a null
// string in the third parameter because the dialog is identified
// by its ID in the fourth parameter.
nResult = EzDefineDialog (szDialogName, "", "", RES_DIALOG_ID);
if (nResult < 0) then
// Report an error; then terminate.
MessageBox ("Error in defining dialog.", SEVERE);
abort;
endif;
// Initialize indicator used to control the while loop.
bDone = FALSE;
// Loop until done.
repeat
// Display the dialog and return the next dialog event.
nCmdValue = WaitOnDialog (szDialogName);
// Respond to the event.
switch (nCmdValue)
case DLG_CLOSE:
// The user clicked the window's Close button.
Do (EXIT);
case DLG_ERR:
MessageBox ("Unable to display dialog. Setup canceled.", SEVERE);
abort;
case DLG_INIT:
// Initialize the back, next, and cancel button enable/disable states
// for this dialog and replace %P, %VS, %VI with
// IFX_PRODUCT_DISPLAY_NAME, IFX_PRODUCT_DISPLAY_VERSION, and
// IFX_INSTALLED_DISPLAY_VERSION, respectively, on control IDs 700-724 and 202.
hwndDlg = CmdGetHwndDlg(szDialogName);
SdGeneralInit(szDialogName, hwndDlg, 0, "");
// Set the font and text for static text box 1.
if (CtrlSetFont (szDialogName, hFont1, RES_TEXT_1) = 0) then
CtrlSetText (szDialogName, RES_TEXT_1,
"This text is set in 14-point Arial bold.");
else
CtrlSetText (szDialogName, RES_TEXT_1,
"Unable to set font for first static text box.");
endif;
// Set font and text for static text box 2.
if (CtrlSetFont (szDialogName, hFont2, RES_TEXT_2) = 0) then
CtrlSetText (szDialogName, RES_TEXT_2,
"This text is set in 11-point Times New Roman italic.");
else
CtrlSetText (szDialogName, RES_TEXT_2,
"Unable to set font for second static text box.");
endif;
// Set font and text for static text box 3.
if (CtrlSetFont (szDialogName, hFont3, RES_TEXT_3) = 0) then
CtrlSetText (szDialogName, RES_TEXT_3,
"This text is set in 10-point Arial bold.");
else
CtrlSetText (szDialogName, RES_TEXT_3,
"Unable to set font for third static text box.");
endif;
// Set font and text for static text box 4.
if (CtrlSetFont (szDialogName, hFont4, RES_TEXT_4) = 0) then
CtrlSetText (szDialogName, RES_TEXT_4,
"This text is set in 9-point Courier New.");
else
CtrlSetText (szDialogName, RES_TEXT_4,
"Unable to set font for fourth static text box.");
endif;
case RES_PBUT_NEXT:
bDone = TRUE;
case RES_PBUT_CANCEL:
// The user clicked the Cancel button.
Do (EXIT);
endswitch;
until bDone;
// Close the dialog
EndDialog (szDialogName);
// Free the dialog from memory
ReleaseDialog (szDialogName);
end;
InstallShield 2016 Help LibraryMay 2017 |
Copyright Information | Flexera Software |