程式碼
//===========================================================================
//
// File Name: MyCustomDialog.rul
//
// Description: Custom Dialog Template
//
// Comments: Written by Kevin Wan. Written August 2010.
// This is freeware as long as you keep mention my name in your code
// Send questions to kevin.wan@msn.com or QQ:17842153
//
//===========================================================================
//Include Ifx.h for built-in InstallScript function prototypes.
#include "Ifx.h"
#define RES_DIALOG_ID 13699 // ID of dialog itself
export prototype MyCustomDialog(string, string);
function MyCustomDialog(szTitle, szMsg)
string szDlg, szDialogName, szDLLName, szDialog;
number nId, nSdDialog, hInstance, hwndParent, nResult;
HWND hwndDlg;
BOOL bDone;
begin
// Specify a name to identify the custom dialog in this installation.
szDlg = "NewDialog";
nSdDialog = RES_DIALOG_ID;
// record data produced by this dialog
if( MODE = SILENTMODE ) then
return nId;
endif;
// ensure general initialization is complete
if( !bSdInit ) then
SdInit();
endif;
szDialogName = "NewDialog";
hInstance = 0;
szDLLName = "";
szDialog = "";
hwndParent = 0;
nResult = DefineDialog (szDialogName, hInstance, szDLLName, nSdDialog, szDialog,
hwndParent, HWND_INSTALL,
DLG_MSG_STANDARD|DLG_CENTERED);
if ( nResult = DLG_ERR ) then
bDone = TRUE;
return -1;
endif;
// Initialize the indicator used to control the while loop.
bDone = FALSE;
// Loop until done.
while (!bDone)
// Display the dialog and return the next dialog event.
nId = WaitOnDialog( szDlg );
// Respond to the event.
switch(nId)
case DLG_INIT:
// No initialization is required for this example.
case NEXT:
nId = NEXT;
bDone = TRUE;
case BACK:
nId = BACK;
bDone = TRUE;
case DLG_ERR:
SdError( -1, "MyDefineDialog" );
nId = -1;
bDone = TRUE;
case DLG_CLOSE:
SdCloseDlg( hwndDlg, nId, bDone );
default:
// check standard handling
if(SdIsStdButton( nId ) && SdDoStdButton( nId )) then
bDone = TRUE;
endif;
endswitch;
endwhile;
// Cleanup Dialog
EndDialog( szDlg );
ReleaseDialog( szDlg );
SdUnInit();
// record data produced by this dialog
if( MODE = RECORDMODE ) then
//
endif;
return nId;
end;
//
// File Name: MyCustomDialog.rul
//
// Description: Custom Dialog Template
//
// Comments: Written by Kevin Wan. Written August 2010.
// This is freeware as long as you keep mention my name in your code
// Send questions to kevin.wan@msn.com or QQ:17842153
//
//===========================================================================
//Include Ifx.h for built-in InstallScript function prototypes.
#include "Ifx.h"
#define RES_DIALOG_ID 13699 // ID of dialog itself
export prototype MyCustomDialog(string, string);
function MyCustomDialog(szTitle, szMsg)
string szDlg, szDialogName, szDLLName, szDialog;
number nId, nSdDialog, hInstance, hwndParent, nResult;
HWND hwndDlg;
BOOL bDone;
begin
// Specify a name to identify the custom dialog in this installation.
szDlg = "NewDialog";
nSdDialog = RES_DIALOG_ID;
// record data produced by this dialog
if( MODE = SILENTMODE ) then
return nId;
endif;
// ensure general initialization is complete
if( !bSdInit ) then
SdInit();
endif;
szDialogName = "NewDialog";
hInstance = 0;
szDLLName = "";
szDialog = "";
hwndParent = 0;
nResult = DefineDialog (szDialogName, hInstance, szDLLName, nSdDialog, szDialog,
hwndParent, HWND_INSTALL,
DLG_MSG_STANDARD|DLG_CENTERED);
if ( nResult = DLG_ERR ) then
bDone = TRUE;
return -1;
endif;
// Initialize the indicator used to control the while loop.
bDone = FALSE;
// Loop until done.
while (!bDone)
// Display the dialog and return the next dialog event.
nId = WaitOnDialog( szDlg );
// Respond to the event.
switch(nId)
case DLG_INIT:
// No initialization is required for this example.
case NEXT:
nId = NEXT;
bDone = TRUE;
case BACK:
nId = BACK;
bDone = TRUE;
case DLG_ERR:
SdError( -1, "MyDefineDialog" );
nId = -1;
bDone = TRUE;
case DLG_CLOSE:
SdCloseDlg( hwndDlg, nId, bDone );
default:
// check standard handling
if(SdIsStdButton( nId ) && SdDoStdButton( nId )) then
bDone = TRUE;
endif;
endswitch;
endwhile;
// Cleanup Dialog
EndDialog( szDlg );
ReleaseDialog( szDlg );
SdUnInit();
// record data produced by this dialog
if( MODE = RECORDMODE ) then
//
endif;
return nId;
end;
另InstallShield幫助檔案中程式碼模板:
// Dialog and control IDs.
#define RES_DIALOG_ID 12027 // ID of dialog itself
#define RES_PBUT_NEXT 1 // ID of Next button
#define RES_PBUT_CANCEL 9 // ID of Cancel button
#define RES_PBUT_BACK 12 // ID of Back button
// Include Ifx.h for built-in InstallScript function prototypes.
#include "Ifx.h"
export prototype ExFn_DefineDialog(HWND);
function ExFn_DefineDialog(hMSI)
STRING szDialogName, szDLLName, szDialog;
NUMBER nDialog, nResult, nCmdValue;
BOOL bDone;
HWND hInstance, hwndParent;
begin
// Define the name of a dialog to pass as first
// parameter to DefineDialog.
szDialogName = "ExampleDialog";
// DefineDialog's second parameter will be 0 because the
// .dll file is in _isres.dll.
hInstance = 0;
// DefineDialog's third parameter will be null; installation will
// search for the dialog in _isuser.dll and _isres.dll.
szDLLName = "";
// DefineDialog's fifth parameter will be null because the
// dialog is identified by its ID in the fourth parameter.
szDialog = "";
// This value is reserved and must be 0.
hwndParent = 0;
// Define the dialog. The installation's main window will own the
// dialog (indicated by HWND_INSTALL in parameter 7).
nResult = DefineDialog (szDialogName, hInstance, szDLLName,
RES_DIALOG_ID, szDialog, hwndParent,
HWND_INSTALL, DLG_MSG_STANDARD|DLG_CENTERED);
// Check for an error.
if (nResult < 0) then
MessageBox ("An error occurred while defining the dialog.", SEVERE);
bDone = TRUE;
abort;
endif;
// Initialize the 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: ;
// No initialization is required for this example.
case RES_PBUT_CANCEL:
// The user clicked the Cancel button.
Do (EXIT);
case RES_PBUT_NEXT:
bDone = TRUE;
case RES_PBUT_BACK:
bDone = TRUE;
// check standard handling
if (SdIsStdButton( nCmdValue ) && SdDoStdButton( nCmdValue )) then
bDone = TRUE;
endif;
endswitch;
until bDone;
// Close the dialog.
EndDialog (szDialogName);
// Free the dialog from memory.
ReleaseDialog (szDialogName);
end;
#define RES_DIALOG_ID 12027 // ID of dialog itself
#define RES_PBUT_NEXT 1 // ID of Next button
#define RES_PBUT_CANCEL 9 // ID of Cancel button
#define RES_PBUT_BACK 12 // ID of Back button
// Include Ifx.h for built-in InstallScript function prototypes.
#include "Ifx.h"
export prototype ExFn_DefineDialog(HWND);
function ExFn_DefineDialog(hMSI)
STRING szDialogName, szDLLName, szDialog;
NUMBER nDialog, nResult, nCmdValue;
BOOL bDone;
HWND hInstance, hwndParent;
begin
// Define the name of a dialog to pass as first
// parameter to DefineDialog.
szDialogName = "ExampleDialog";
// DefineDialog's second parameter will be 0 because the
// .dll file is in _isres.dll.
hInstance = 0;
// DefineDialog's third parameter will be null; installation will
// search for the dialog in _isuser.dll and _isres.dll.
szDLLName = "";
// DefineDialog's fifth parameter will be null because the
// dialog is identified by its ID in the fourth parameter.
szDialog = "";
// This value is reserved and must be 0.
hwndParent = 0;
// Define the dialog. The installation's main window will own the
// dialog (indicated by HWND_INSTALL in parameter 7).
nResult = DefineDialog (szDialogName, hInstance, szDLLName,
RES_DIALOG_ID, szDialog, hwndParent,
HWND_INSTALL, DLG_MSG_STANDARD|DLG_CENTERED);
// Check for an error.
if (nResult < 0) then
MessageBox ("An error occurred while defining the dialog.", SEVERE);
bDone = TRUE;
abort;
endif;
// Initialize the 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: ;
// No initialization is required for this example.
case RES_PBUT_CANCEL:
// The user clicked the Cancel button.
Do (EXIT);
case RES_PBUT_NEXT:
bDone = TRUE;
case RES_PBUT_BACK:
bDone = TRUE;
// check standard handling
if (SdIsStdButton( nCmdValue ) && SdDoStdButton( nCmdValue )) then
bDone = TRUE;
endif;
endswitch;
until bDone;
// Close the dialog.
EndDialog (szDialogName);
// Free the dialog from memory.
ReleaseDialog (szDialogName);
end;
參考網址:http://www.cnblogs.com/installshield/archive/2010/09/13/1824981.html