InstallShield自定义对话框,WaitOnDialog()始终返回-1(DLG_ERR)

我正在做一个自定义对话框来处理InstallScript项目上的锁定文件情况 . 我知道有像SdException()这样的内置函数来处理这种情况,但这是一个要求,以避免用户意外选择忽略这种情况 .

总之,我初始化EzDefineDialog()然后调用WaitOnDialog()来显示对话框,但它总是返回-1 .

以下是我的代码:

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;

我已经仔细检查并使用了Dialogs和Direct Editor中的ISResourceID为12345,它作为nTemplate被传递到 EzDefineDialog (szDlg, ISUSER, "", nTemplate) . 对话框名称(szDlg)也经过双重检查 .

我想知道我做错了什么 . 如何显示自定义对话框?

回答(0)