Subversion Repositories DevTools

Rev

Rev 1530 | Blame | Compare with Previous | Last modification | View Log | RSS feed

/////////////////////////////////////////////////////////////////////////////
//                                                                            
//  File Name:    AskFilePath.rul                                                   
//                                                                            
//  Description:  InstallShield script                                          
//                                                                            
//  Comments:     This contains the script to drive the AskFilePath Dialog.
//                The dialog is defined in the AskFilePath.isd file and must
//                be imported into the project for use.
//                It uses the FileBrowseDlg.rul file to display the standard
//                windows file open dialog when browse is selected.
//              
//                The AskFilePath is an exact copy of the standard IS askPath
//                dialog and functions like a std dialog.  The AskFilePath
//                function simply accepts a title & message to change the 
//                standard ones on the dialog and a FileName field that is used
//                initially to set the default value and returns the path selected.
//                Return values are standard BACK, NEXT values.
//
//  Usage:        On the dialogs section right click on the All Dialogs Folder
//                and select import dialog from the pop up menu.  Navigate to the
//                installshield source dir for the package being built and select
//                the AskFilePath.isd file.  The dialog can then be included in 
//                your install script as per normal.
//      
/////////////////////////////////////////////////////////////////////////////
#include "FileBrowseDlg.rul"

#define ASKFILEPATH_NEXT    1
#define ASKFILEPATH_EDIT    4
#define ASKFILEPATH_CANCEL  9
#define ASKFILEPATH_BACK    12
#define ASKFILEPATH_BROWSE  31
#define ASKFILEPATH_TITLE   51
#define ASKFILEPATH_MSG     901

prototype NUMBER AskFilePath( STRING, STRING, BYREF STRING );


function NUMBER AskFilePath( Title, Msg, FileName)
    BOOL    bDone;
    NUMBER  nReturn, nControl, nResult;
    LIST    dummyList;
    STRING  tmpFileName, tmpDir;
begin

    EzDefineDialog("AskFilePath", ISUSER, "AskFilePath", 0);
    
    dummyList = ListCreate( STRINGLIST );

    bDone = FALSE;
    
    while (!bDone)

        nControl = WaitOnDialog("AskFilePath");

        switch (nControl)
            case DLG_INIT:
                // Initialise dialog defaults
                if ( Title != "" ) then
                    CtrlSetText("AskFilePath", ASKFILEPATH_TITLE, Title);
                endif;
                if ( Msg != "" ) then
                    CtrlSetText("AskFilePath", ASKFILEPATH_MSG, Msg);
                endif;
                CtrlSetText("AskFilePath", ASKFILEPATH_EDIT, FileName);

            case ASKFILEPATH_BACK:
                // user clicked Back
                nReturn = ASKFILEPATH_BACK;
                bDone = TRUE;
        
            case ASKFILEPATH_NEXT:
                // user clicked Next
                nReturn = ASKFILEPATH_NEXT;
                bDone = TRUE;
        
            case ASKFILEPATH_CANCEL:
                // user clicked Cancel; ask user to verify cancellation
                Do(EXIT);
    
            case ASKFILEPATH_BROWSE:
                CtrlGetText("AskFilePath", ASKFILEPATH_EDIT, tmpFileName);
                ParsePath(tmpDir, tmpFileName, PATH);
                nResult = FileBrowseDlg(tmpFileName, 
                                        "All Files (*.*)|*.*||",
                                        "Select the required file",
                                        tmpDir,
                                        FALSE,
                                        dummyList,
                                        FALSE);
                if ( nResult == 0 ) then
                    CtrlSetText("AskFilePath", ASKFILEPATH_EDIT, tmpFileName);
                endif;                  
                
        endswitch;
    
    endwhile;

    CtrlGetText("AskFilePath", ASKFILEPATH_EDIT, FileName);

    EndDialog("AskFilePath");
    ReleaseDialog("AskFilePath");
    
    ListDestroy(dummyList);
    
    return nReturn;
end;