InstallShield 2019 » 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 CmdGetHwndDlg function.
*
* This example displays a custom dialog. On initialization
* of the dialog, the script calls CmdGetHwndDlg to retrieve
* the dialog's window handle so that it can perform the
* following operations:
*
* -- Change the text of the window's title bar.
* -- Disable and enable buttons in the dialog.
* -- Send messages to maximize and restore the dialog window.
*
* The "custom" dialog used in this script is actually the
* InstallShield Sd dialog that is displayed by the
* built-in function SdBitmap. 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.
* Note that the script changes the static text of the dialog's
* Back and Next buttons to fit the requirements of the example.
*
\*-----------------------------------------------------------*/
// Dialog controls
#define RES_DIALOG_ID 12027 // ID of the custom dialog
#define RES_PBUT_RESTORE 1 // ID of dialog's Next button
#define RES_PBUT_CANCEL 9 // ID of dialog's Cancel button
#define RES_PBUT_MAXIMIZE 12 // ID of dialog's Back button
// Include Ifx.h for built-in InstallScript function prototypes.
#include "Ifx.h"
export prototype ExFn_CmdGetHwndDlg(HWND);
function ExFn_CmdGetHwndDlg(hMSI)
STRING szDialogName;
NUMBER nResult, nCmdValue, hwndDlg;
BOOL bDone;
HWND hwndDlg;
begin
// 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 the indicator used to control the 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 static text of the buttons.
CtrlSetText (szDialogName, RES_PBUT_MAXIMIZE, "&Maximize");
CtrlSetText (szDialogName, RES_PBUT_RESTORE, "&Restore");
// Disable the Restore button using a call from Winsub.
_WinSubEnableControl (hwndDlg, RES_PBUT_RESTORE, 0);
case RES_PBUT_RESTORE:
// Restore the window to its normal size.
SendMessage (hwndDlg, WM_SYSCOMMAND, SC_RESTORE, 0);
// Disable the Restore button using a call from Winsub.
_WinSubEnableControl (hwndDlg, RES_PBUT_RESTORE, 0);
// Enable the Maximize button using a call from Winsub.
_WinSubEnableControl (hwndDlg, RES_PBUT_MAXIMIZE, 1);
case RES_PBUT_MAXIMIZE:
// Maximize the dialog's window.
SendMessage (hwndDlg, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
// Disable the Maximize button using a call from Winsub.
_WinSubEnableControl (hwndDlg, RES_PBUT_MAXIMIZE, 0);
// Enable the Restore button using a call from Winsub.
_WinSubEnableControl (hwndDlg, RES_PBUT_RESTORE, 1);
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 2019 Help LibraryApril 2019 |
Copyright Information | Flexera |