1

I'm currently doing a Custom Dialog to handle locked file situation on an InstallScript project. I know there are built-in functions like SdException() to handle this case but this is a requirement to avoid the case where user accidentally chose to ignore the situation.

In summary, I initialize the EzDefineDialog() and then call WaitOnDialog() to display the dialog but it always returns -1.

The following is my code:

prototype NUMBER LockedFile(string /*FilePath*/);

//[[ ID_DATA
#define IDD_VER 300
#define ID_NAME_LOCKED_FILE "LockedFile"
#define ID_TITLE_LOCKED_FILE "Default Dialog Title\nDefault Title message"
#define ID_TEMPLATE_LOCKED_FILE 12345
//]]

//[[ ID_SYMBOLS
#define BT_PostPone 1303 
#define BT_Retry    1304 
#define BT_Abort    1305

#define IDC_TEXT1_LOCKED_FILE   1301

//]]

function NUMBER LockedFile(szFile /*FilePath*/)

NUMBER  nId;        // contains the return code of WaitOnDialog 
NUMBER  nResult;    // contains the return code of LockedFile
BOOL    bDone;      // tells if the dialog is to be closed
INT     hwndDlg;    // the handle of the dialog itself
STRING  szTitle;    // dialog's title
STRING  szDlg;      // the name of the dialog
STRING  szMessage;  // message to display on dialog
NUMBER  nTemplate;  // variable to store the template to be used for this dialog

begin

// Specify a name to identify the custom dialog in this installation.
szDlg = ID_NAME_LOCKED_FILE;
nTemplate = ID_TEMPLATE_LOCKED_FILE;



if (EzDefineDialog (szDlg, ISUSER, "", nTemplate) = DLG_ERR) then
    MessageBox("Fail to initialize the Locked Dialog for "+szFile, SEVERE);
    abort;
endif;

bDone = FALSE;
while (!bDone)
    nId = WaitOnDialog(szDlg);

    switch (nId)
        case DLG_INIT:
            // first internal InstallShield intitialise
            hwndDlg = CmdGetHwndDlg( szDlg );
            SdGeneralInit(szDlg, hwndDlg, 0, "");
        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 BT_PostPone:
            // user clicked PostPone button, the operation will be carried out after reboot
            bDone = TRUE;
            nResult =  1;
        case BT_Retry:
            // user clicked retry button, retry the operation immediately
            bDone = TRUE;
            nResult = 2;
        case BT_Abort:
            // user clicked abort button, abort the installation
            bDone = TRUE;
            nResult = 3;
        default:    
            // user do something else
            bDone = TRUE;
            nResult = -1;
     endswitch;
endwhile;

EndDialog(szDlg); // Close the dialog box. 

ReleaseDialog(szDlg);   // Free the dialog box from memory.

return nResult;

end;

I have double checked and make use that the ISResourceID in both Dialogs and Direct Editor to be 12345, which was passed into EzDefineDialog (szDlg, ISUSER, "", nTemplate) as nTemplate. The Dialog name (szDlg) is also double checked.

I want to know where I did wrong. How can I display my Custom Dialog ?

1 Answers1

0

I had a similar experience, I referenced the dialog by its name, not resourceID. The WaitOnDialog() function always returned DLG_ERR until I changed the dialog's resourceID to 0.

Perhaps this helps...