的InstallShield自定义对话框,WaitOnDialog()总是返回-1(DLG_ERR)

问题描述 投票:1回答:1

目前,我正在做一个自定义对话框处理上的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;

我有双重检查和利用,在这两个对话框和直接编辑的ISResourceID是12345,这是传递到EzDefineDialog (szDlg, ISUSER, "", nTemplate)为nTemplate。对话框名称(szDlg)也双重检查。

我想知道我做错了。我怎样才能显示我的自定义对话框?

dialog return-value installshield customdialog installscript
1个回答
0
投票

我也有过类似的经历,我通过它的名称所引用的对话,而不是resourceID。该WaitOnDialog()函数总是返回DLG_ERR,直到我改变了对话框的resourceID0

也许这可以帮助...

© www.soinside.com 2019 - 2024. All rights reserved.