' ----------------------------------------------------------------------------
' New QOpenDialog         March 3rd, 2006      by Jacques        Version  002
'
' This is based on RQDIALOG.INC  by  BILL K  1-2003
' ----------------------------------------------------------------------------
'
' Version 002 is compatible with Version 001 except that it dont replace
' QOPENDIALOG anymore.
'
' The QOPENDIALOGNEW OBJECT IS ALWAYS SET TO EXPLORER MODE (OLD MODE IS OBSOLETE)
'
' EXAMPLE:
' -------
'
'    $Include "QOpenDialogNew.Inc"
'
'    Dim dlgSave as QOpenDialogNew     ' ALWAYS GLOBAL. WILL BUG IN A SUB/FUNCTION
'
'    dlgOpen.Filter = "All Files(*.*)|*.*;Picture(*.jpg)|*.jpg"
'    dlgOpen.InitialDir = "c:\\windows\\Temp\\"
'    dlgOpen.Caption = "SAVE : Nice Caption"
'    dlgOpen.FilterIndex = 1
'    dlgOpen.FileName = "Open.Jpg"
'    ' New Properties   vs QSAVEDIALOG
'    ' --------------
'    dlgOpen.DefaultExtension = "xyz"
'    dlgOpen.OpenReadOnly = 1
'    dlgOpen.MultiSelect = 1
'    dlgOpen.HideReadOnly = 0
'    dlgOpen.OverWritePrompt = 0
'
'    If dlgOpen.Execute = 0 Then     ' Opens the dialogbox
'        ' .SelectedDir : the directory in which files were selected no BackSlash terminal
'        rchWin.AddString ("SAVE: SelectedDir = " & dlgOpen.SelectedDir)
'
'        DefInt I
'        ' .SelectedFile: the filename of a selected file without its path
'        For I = 0 To dlgOpen.SelectedFile.ItemCount - 1
'            rchWin.AddString "    SelectedFile(" & Str$(I) & ") = " & dlgOpen.SelectedFile.Item(I)
'        Next I
'
'        ' .SelectedPathFile: the filename of a selected file with its full path
'        For I = 0 To dlgOpen.SelectedPathFile.ItemCount - 1
'            rchWin.AddString "SelectedPathFile(" & Str$(I) & ") = " & dlgOpen.SelectedPathFile.Item(I)
'        Next I
'    Else
'        ShowMessage "  *** USER CANCELLED SAVEDIALOGBOX, NOTHING DONE"
'    End If
' -----------------------------------------------------------------------------
'
' See documentation at : "http://msdn.microsoft.com"  for  MSDN COMDIALOG STRUCTURE
' AND CommonDialogBoxMSDN API GetOpenFileName
'
' The SAVEDLG_OPENFILENAME structure is Public, so you have access to all the
' Open Dialog Features implemented in the API GetOpenFileName (See URLs above)
'
' -----------------------------------------------------------------------------
' QOpenDialog
' -----------------------------------------------------------------------------
' Property Name                 Type           R/W              Default
' -----------------------------------------------------------------------------
' Caption                       STRING         RW               "SAVE FILE"
' FileName                      STRING         RW               ""
' Filter                        STRING         RW               "All Files(*.*)|*.*"
' FilterIndex                   INTEGER        RW               1
' InitialDir                    STRING         RW               "C:\"
' -----------------------------------------------------------------------------
' Extended Properties
'       !!!! Using them will loose compatibility with Old QOpenDialog !!!!
' -----------------------------------------------------------------------------
' CreatePrompt                  INTEGER        RW               FALSE
' ExtensionDifferent            INTEGER        RW               It's a return value
' FileMustExist                 INTEGER        RW               FALSE
' DefaultExtension              STRING         RW               ""   ie "bas" no dot
' HideReadOnly                  INTEGER        RW               TRUE
' Multiselect                   INTEGER        RW               FALSE
' OverWritePrompt               INTEGER        RW               FALSE
' PathMustExist                 INTEGER        RW               FALSE
' RestoreCurrentDirectory       INTEGER        RW               FALSE
' OpenReadOnly                  INTEGER        RW               FALSE
' -----------------------------------------------------------------------------
' RESULT PROPERTIES
' -----------------------------------------------------------------------------
' SelectedDir                   String         RW               ""
'       returns the directory in which files have been selected (no terminal \)
' SelectedFile                  QStringList    RW               Cleared
'                       the list of selected files without path
' SelectedPathFile              QStringList    RW               Cleared
'                       the list of selected files with their full path
' -----------------------------------------------------------------------------
' Method Name                   Type        Description                 Params
' -----------------------------------------------------------------------------
' Execute                       FUNCTION    Returns TRUE or FALSE       0
' -----------------------------------------------------------------------------
'   ... and many more possible, see Documentation.
' -----------------------------------------------------------------------------
' OPENFILENAME Structure
' ----------------------
' TYPE SAVEDLG_OPENFILENAME
'    lStructSize AS LONG
'    hwndOwner AS LONG
'    hInstance AS LONG
'    lpstrFilter AS LONG
'    lpstrCustomFilter AS LONG
'    nMaxCustFilter AS LONG
'    nFilterIndex AS LONG
'    lpstrFile AS LONG
'    nMaxFile AS LONG
'    lpstrFileTitle AS LONG
'    nMaxFileTitle AS LONG
'    lpstrInitialDir AS LONG
'    lpstrTitle AS LONG
'    flags AS LONG
'    nFileOffset AS SHORT
'    nFileExtension AS SHORT
'    lpstrDefExt AS LONG
'    lCustData AS LONG
'    lpfnHook AS LONG
'    lpTemplateName AS LONG
' END TYPE
' -----------------------------------------------------------------------------
' CONSTANTE DECLARE IN QSAVEDIALOGEX
' ----------------------------------
' Const SAVEDLG_OFN_ALLOWMULTISELECT = 512
' Const SAVEDLG_OFN_CREATEPROMPT = &H2000
' Const SAVEDLG_OFN_ENABLEHOOK = 32
' Const SAVEDLG_OFN_ENABLETEMPLATE = 64
' Const SAVEDLG_OFN_ENABLETEMPLATEHANDLE = 128
' Const SAVEDLG_OFN_EXPLORER = &H80000
' Const SAVEDLG_OFN_EXTENSIONDIFFERENT = &H400
' Const SAVEDLG_OFN_FILEMUSTEXIST = &H1000
' Const SAVEDLG_OFN_HIDEREADONLY = 4
' Const SAVEDLG_OFN_LONGNAMES = &H200000
' Const SAVEDLG_OFN_NOCHANGEDIR = 8
' Const SAVEDLG_OFN_NODEREFERENCELINKS = &H100000
' Const SAVEDLG_OFN_NOLONGNAMES = &H40000
' Const SAVEDLG_OFN_NONETWORKBUTTON = &H20000
' Const SAVEDLG_OFN_NOREADONLYRETURN = &H8000
' Const SAVEDLG_OFN_NOTESTFILECREATE = &H10000
' Const SAVEDLG_OFN_NOVALIDATE = 256
' Const SAVEDLG_OFN_OVERWRITEPROMPT = 2
' Const SAVEDLG_OFN_PATHMUSTEXIST = &H800
' Const SAVEDLG_OFN_READONLY = 1
' Const SAVEDLG_OFN_SHAREAWARE = &H4000
' Const SAVEDLG_OFN_SHOWHELP = 16
' Const SAVEDLG_OFN_SHAREFALLTHROUGH = 2
' Const SAVEDLG_OFN_SHARENOWARN = 1
' Const SAVEDLG_OFN_SHAREWARN = 0
'
' DECLARE FUNCTION RQSAVEDLG_GetOpenFileName LIB "COMDLG32" ALIAS "GetOpenFileNameA" _
'                                                (pOpenfilename AS SAVEDLG_OPENFILENAME) AS LONG
' -----------------------------------------------------------------------------
'