1、MultiSel=True
2、CommonDialogControl不支持,自己编写

解决方案 »

  1.   


    设置Flag就可以完成,稍后有例子
      

  2.   


    CommonDialog.Flag=cdlOFNAllowMultiselect
    File Open/Save Dialog Box Flags
    Constant Value Description 
    cdlOFNAllowMultiselect &H200 Specifies that the File Namelist box allows multiple selections.
    The user can select more than one file atrun time by pressing the SHIFT key and using the UP ARROW and DOWN ARROW keys to select the desired files. When this is done, the FileName property returns a string containing the names of all selected files. The names in the string are delimited by spaces.
     
    cdlOFNCreatePrompt &H2000 Specifies that the dialog box prompts the user to create a file that doesn't currently exist. This flag automatically sets the cdlOFNPathMustExist and cdlOFNFileMustExist flags. 
    cdlOFNExplorer &H80000 Use the Explorer-like Open A File dialog box template. Common dialogs that use this flag do not work under Windows NT using the Windows 95 shell. 
    CdlOFNExtensionDifferent &H400 Indicates that the extension of the returned filename is different from the extension specified by the DefaultExt property. This flag isn't set if the DefaultExt property is Null, if the extensions match, or if the file has no extension. This flag value can be checked upon closing the dialog box. 
    cdlOFNFileMustExist &H1000 Specifies that the user can enter only names of existing files in the File Name text box. If this flag is set and the user enters an invalid filename, a warning is displayed. This flag automatically sets the cdlOFNPathMustExist flag. 
    cdlOFNHelpButton &H10 Causes the dialog box to display the Help button. 
    cdlOFNHideReadOnly &H4 Hides the Read Onlycheck box. 
    cdlOFNLongNames &H200000 Use long filenames. 
    cdlOFNNoChangeDir &H8 Forces the dialog box to set the current directory to what it was when the dialog box was opened. 
    CdlOFNNoDereferenceLinks &H100000 Do not dereference shell links (also known as shortcuts). By default, choosing a shell link causes it to be dereferenced by the shell. 
    cdlOFNNoLongNames &H40000 Do not use long file names. 
    CdlOFNNoReadOnlyReturn &H8000  Specifies that the returned file won't have the Read Only attribute set and won't be in a write-protected directory. 
    cdlOFNNoValidate &H100 Specifies that the common dialog box allows invalid characters in the returned filename. 
    cdlOFNOverwritePrompt &H2 Causes the Save As dialog box to generate a message box if the selected file already exists. The user must confirm whether to overwrite the file. 
    cdlOFNPathMustExist &H800 Specifies that the user can enter only validpaths. If this flag is set and the user enters an invalid path, a warning message is displayed. 
    cdlOFNReadOnly &H1 Causes the Read Only check box to be initially checked when the dialog box is created. This flag also indicates the state of the Read Only check box when the dialog box is closed. 
    CdlOFNShareAware &H4000 Specifies that sharing violation errors will be ignored. 
    Color Dialog Box Flags
    Constant Value Description 
    cdlCCFullOpen &H2 Entire dialog box is displayed, including the Define Custom Colors section 
    cdlCCShowHelp &H8 Causes the dialog box to display a Help button 
    cdlCCPreventFullOpen &H4 Disables the Define Custom Colors command button and prevents the user from defining custom colors 
    cdlCCRGBInit &H1 Sets the initial color value for the dialog box 
    Fonts Dialog Box Flags
    Constant Value Description 
    cdlCFANSIOnly &H400 Specifies that the dialog box allows only a selection of the fonts that use the Windows character set. If this flag is set, the user won't be able to select a font that contains only symbols. 
    cdlCFApply &H200 Enables the Apply button on the dialog box. 
    cdlCFBoth &H3 Causes the dialog box to list the available printer and screen fonts. The hDC property identifies thedevice context associated with the printer. 
    cdlCFEffects &H100 Specifies that the dialog box enables strikethrough, underline, and color effects. 
    cdlCFFixedPitchOnly &H4000 Specifies that the dialog box selects only fixed-pitch fonts. 
    cdlCFForceFontExist &H10000 Specifies that an error message box is displayed if the user attempts to select a font or style that doesn't exist. 
    cdlCFHelpButton &H4 Causes the dialog box to display a Help button. 
    cdlCFLimitSize &H2000 Specifies that the dialog box selects only font sizes within the range specified by the Min and Max properties. 
    cdlCFNoFaceSel &H80000 No font name selected. 
    cdlCFNoSimulations &H1000 Specifies that the dialog box doesn't allow graphic device interface (GDI) font simulations. 
    cdlCFNoSizeSel &H200000 No font size selected. 
    cdlCFNoStyleSel &H100000 No style was selected. 
    cdlCFNoVectorFonts &H800 Specifies that the dialog box doesn't allow vector-font selections. 
    cdlCFPrinterFonts &H2 Causes the dialog box to list only the fonts supported by the printer, specified by the hDC property. 
    cdlCFScalableOnly &H20000 Specifies that the dialog box allows only the selection of fonts that can be scaled.  
    cdlCFScreenFonts &H1 Causes the dialog box to list only the screen fonts supported by the system. 
    cdlCFTTOnly &H40000 Specifies that the dialog box allows only the selection of TrueType fonts. 
    cdlCFWYSIWYG &H8000 Specifies that the dialog box allows only the selection of fonts that are available on both the printer and on screen. If this flag is set, the cdlCFBoth and cdlCFScalableOnly flags should also be set. 
    Printer Dialog Box Flags
    Constant Value Description 
    cdlPDAllPages &H0 Returns or sets the state of the All Pagesoption button. 
    cdlPDCollate &H10 Returns or sets the state of the Collatecheck box. 
    cdlPDDisablePrintToFile &H80000 Disables the Print To File check box. 
    cdlPDHelpButton &H800 Causes the dialog box to display the Help button. 
    cdlPDHidePrintToFile &H100000 Hides the Print To File check box. 
    cdlPDNoPageNums &H8 Disables the Pages option button and the associated edit control. 
    cdlPDNoSelection &H4 Disables the Selection option button. 
    cdlPDNoWarning &H80 Prevents a warning message from being displayed when there is no default printer. 
    cdlPDPageNums &H2 Returns or sets the state of the Pages option button. 
    cdlPDPrintSetup &H40 Causes the system to display the Print Setup dialog box rather than the Print dialog box. 
    cdlPDPrintToFile &H20 Returns or sets the state of the Print To File check box. 
    cdlPDReturnDC &H100 Returns adevice context for the printer selection made in the dialog box. The device context is returned in the dialog box's hDC property. 
    cdlPDReturnDefault &H400 Returns default printer name. 
    cdlPDReturnIC &H200 Returns an information context for the printer selection made in the dialog box. An information context provides a fast way to get information about the device without creating a device context. The information context is returned in the dialog box's hDC property. 
    cdlPDSelection &H1 Returns or sets the state of the Selection option button. If neither cdlPDPageNums nor cdlPDSelection is specified, the All option button is in the selected state. 
    cdlPDUseDevModeCopies &H40000 If a printer driver doesn't support multiple copies, setting this flag disables the copies edit control. If a driver does support multiple copies, setting this flag indicates that the dialog box stores the requested number of copies in the Copies property. 
      

  3.   

    2.SHBrowseForFolder
    WINSHELLAPI LPITEMIDLIST WINAPI SHBrowseForFolder(
        LPBROWSEINFO lpbi
    ); Displays a dialog box that enables the user to select a shell folder. Returns the address of an item identifier list that specifies the location of the selected folder relative to the root of the namespace. If the user chooses the Cancel button in the dialog box, the return value is NULL. 
    lpbi 
    Address of a BROWSEINFO structure that contains information used to display the dialog box. 
    The calling application is responsible for freeing the returned item identifier list by using the shell's task allocator. 
    BROWSEINFO
    typedef struct _browseinfo { 
        HWND hwndOwner; 
        LPCITEMIDLIST pidlRoot; 
        LPSTR pszDisplayName; 
        LPCSTR lpszTitle; 
        UINT ulFlags; 
        BFFCALLBACK lpfn; 
        LPARAM lParam; 
        int iImage; 
    } BROWSEINFO, *PBROWSEINFO, *LPBROWSEINFO; Contains parameters for the SHBrowseForFolder function and receives information about the folder selected by the user. hwndOwner 
    Handle to the owner window for the dialog box. 
    pidlRoot 
    Address of an ITEMIDLIST structure specifying the location of the root folder from which to browse. Only the specified folder and its subfolders appear in the dialog box. This member can be NULL; in that case, the namespace root (the desktop folder) is used. 
    pszDisplayName 
    Address of a buffer to receive the display name of the folder selected by the user. The size of this buffer is assumed to be MAX_PATH bytes. 
    lpszTitle 
    Address of a null-terminated string that is displayed above the tree view control in the dialog box. This string can be used to specify instructions to the user. 
    ulFlags 
    Flags specifying the options for the dialog box. This member can include zero or a combination of the following values: BIF_BROWSEFORCOMPUTER  Only return computers. If the user selects anything other than a computer, the OK button is grayed.  
    BIF_BROWSEFORPRINTER  Only return printers. If the user selects anything other than a printer, the OK button is grayed.  
    BIF_BROWSEINCLUDEFILES  The browse dialog will display files as well as folders.  
    BIF_DONTGOBELOWDOMAIN  Do not include network folders below the domain level in the tree view control.  
    BIF_EDITBOX  Version 4.71. The browse dialog includes an edit control in which the user can type the name of an item.  
    BIF_RETURNFSANCESTORS  Only return file system ancestors. If the user selects anything other than a file system ancestor, the OK button is grayed.  
    BIF_RETURNONLYFSDIRS  Only return file system directories. If the user selects folders that are not part of the file system, the OK button is grayed.  
    BIF_STATUSTEXT  Include a status area in the dialog box. The callback function can set the status text by sending messages to the dialog box.  
    BIF_VALIDATE  Version 4.71. If the user types an invalid name into the edit box, the browse dialog will call the application's BrowseCallbackProc with the BFFM_VALIDATEFAILED message. This flag is ignored if BIF_EDITBOX is not specified.  lpfn 
    Address of an application-defined function that the dialog box calls when an event occurs. For more information, see the BrowseCallbackProc function. This member can be NULL. 
    lParam 
    Application-defined value that the dialog box passes to the callback function, if one is specified. 
    iImage 
    Variable to receive the image associated with the selected folder. The image is specified as an index to the system image list. 
      

  4.   

    '设置打开文件对话框的显示风格。
        FileDailog.Flags = cdlOFNExplorer + cdlOFNLongNames _
            + cdlOFNAllowMultiselect + cdlOFNHideReadOnly _
            + cdlOFNFileMustExist
        Call FileDailog.ShowOpen
      

  5.   

    MultiSel=True有这个东西?我还不知道呢:)
    CommonDialogControl不支持,很多软件都有啊,是一个类似Treeview的东西..
      

  6.   

    Public Declare Function SHBrowseForFolder _
            Lib "shell32.dll" Alias "SHBrowseForFolderA" _
            (lpBrowseInfo As BROWSEINFO) As LongPublic Type BROWSEINFO
        hOwner As Long
        pidlRoot As Long
        pszDisplayName As String
        lpszTitle As String
        ulFlage As Long
        lpfn As Long
        lparam As Long
        iImage As Long
    End Type
    Public Function ShowDir(MehWnd As Long, _
            DirPath As String, _
            Optional Title As String = "请选择文件夹:", _
            Optional flage As Long = &H1, _
            Optional DirID As Long) As Long
        Dim BI As BROWSEINFO
        Dim TempID As Long
        Dim TempStr As String
        
        TempStr = String$(255, Chr$(0))
        With BI
            .hOwner = MehWnd
            .pidlRoot = 0
            .lpszTitle = Title + Chr$(0)
            .ulFlage = flage
            
        End With
        
        TempID = SHBrowseForFolder(BI)
        DirID = TempID
        
        If SHGetPathFromIDList(ByVal TempID, ByVal TempStr) Then
            DirPath = Left$(TempStr, InStr(TempStr, Chr$(0)) - 1)
            ShowDir = -1
            
        Else
            ShowDir = 0
            
        End If
        
    End Function
      

  7.   

    Private Type BrowseInfo
       hwndOwner      As Long
       pIDLRoot       As Long
       pszDisplayName As Long
       lpszTitle      As Long
       ulFlags        As Long
       lpfnCallback   As Long
       lParam         As Long
       iImage         As Long
    End TypePrivate Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
    Private Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
    Private Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As LongFunction OpenDirectory(RhWnd As Long, odtvTitle As String) As String   '浏览文件夹,类似Open Dialog
      Dim lpIDList As Long
      Dim sBuffer As String
      Dim szTitle As String
      Dim tBrowseInfo As BrowseInfo
      szTitle = odtvTitle
      With tBrowseInfo
       .hwndOwner = RhWnd
       .lpszTitle = lstrcat(szTitle, "")
       .ulFlags = BIF_RETURNONLYFSDIRS + BIF_DONTGOBELOWDOMAIN
      End With
      lpIDList = SHBrowseForFolder(tBrowseInfo)
      If (lpIDList) Then
       sBuffer = Space(MAX_PATH)
       SHGetPathFromIDList lpIDList, sBuffer
       sBuffer = Left(sBuffer, InStr(sBuffer, vbNullChar) - 1)
       OpenDirectory = sBuffer
      End If
    End FunctionPrivate Sub Command1_Click()
      OpenDirectory Me.hWnd, "My Folder"
    End Sub
      

  8.   

    哈,好多码呀,看花眼了
    还是 Azi03(微风轻扬) 干脆复制那么多做什么?我不信写个打开文件对话框,要写那么多代码,哈哈~~~
    (SkywolfY等着苹果打过来~~)