1. 程式人生 > >InstallShield建立自定義對話方塊 例項2

InstallShield建立自定義對話方塊 例項2

由於http://blog.csdn.net/dragoo1/article/details/44758243裡的對話方塊比較簡單,沒有edit賦值,取值,操作,這裡多寫一點,先在對話方塊新增一個edit

#define DLG_MYDLG "MyDlg"    //MyDlg是我們的對話方塊名字

#define HELLOBTN 1302                //1302就是我們那個按鈕的Control Identifer屬性值
#define SD_EDIT_CUSTOM_NAME 1303    //1303是編輯框的Control Identifer屬性值

prototype NUMBER MyDlg(BYREF STRING, BYREF STRING);

function NUMBER MyDlg(msg, svName)
    HWND    hDlg;
    NUMBER    nId, nResult;
    NUMBER    nControl;
    BOOL    bDone;
begin
    // ensure general initialization is complete
    if (!bSdInit) then
        SdInit( );
    endif;
    
    //初始對話方塊函式
    if (EzDefineDialog( DLG_MYDLG,ISUSER , "MyDlg", 0 ) = DLG_ERR) then        
        return ISERR_GEN_FAILURE;
    endif;
      
    bDone = FALSE;
    //迴圈
    while (!bDone)
        nId = WaitOnDialog( DLG_MYDLG );//獲得對話方塊的訊息
        switch (nId)
        case DLG_INIT:
            CtrlSetText( DLG_MYDLG, SD_EDIT_CUSTOM_NAME, svName );
            hDlg = CmdGetHwndDlg( DLG_MYDLG );
            SdGeneralInit( DLG_MYDLG, hDlg, STYLE_BOLD, szSdProduct );
        case HELLOBTN:    //如果是HELLOBTN
            MessageBox(msg,WARNING);
            bDone=TRUE;                                  
        case DLG_ERR:       
            nId   = ISERR_GEN_FAILURE;
            SdError(nId, DLG_MYDLG);
            bDone = TRUE;   
           
        case DLG_CLOSE:             
            SdCloseDlg(hDlg, nId, bDone);  
           
        default:
            // check standard handling
            if (SdIsStdButton(nId) && SdDoStdButton(nId)) then
                bDone = TRUE;
            endif;
                                           
        endswitch;
    endwhile;
    
    CtrlGetText( DLG_MYDLG, SD_EDIT_CUSTOM_NAME, svName );
    
    EndDialog( DLG_MYDLG );
    ReleaseDialog( DLG_MYDLG );

    SdUnInit( );
    
    return nId;
end;


參考:D:\Program Files\InstallShield\2014\Samples\InstallScript\Serial Number Validation Sample Project\Script Files\Custom_Password.rul