Unicode Controls & Classes for VB6 - Version 4

clsCommDialogs.ShowOpen Function

Creates an Open dialog box that lets the user specify the drive, directory, and the name of a file or set of files to be opened.

Syntax
Public Function ShowOpen (ByVal hwndParent As Long, _
ByVal sFilter As String, _
ByVal sTitle As String, _
ByRef lFlags As eOpenFileFlags, _
ByVal sStartDir As String, _
Optional ByVal sDefExt As String = "", _
Optional ByVal sDefaultFile As String = "") As String
Parameters
Parameter Description
ByVal hwndParent As Long A handle to the window that owns the dialog box. This member can be any valid window handle, or it can be NULL if the dialog box has no owner.
ByVal sFilter As String The first string in each pair is a display string that describes the filter (for example, "Text Files"), and the second string specifies the filter pattern (for example, "*.TXT"). To specify multiple filter patterns for a single display string, use a semicolon to separate the patterns (for example, "*.TXT;*.DOC;*.BAK"). A pattern string can be a combination of valid file name characters and the asterisk (*) wildcard character. Do not include spaces in the pattern string.
ByVal sTitle As String A string to be placed in the title bar of the dialog box. If this member is NULL, the system uses the default title (that is, Save As or Open).
ByRef lFlags As eOpenFileFlags A combination of values of the [eOpenFileFlags] enum
ByVal sStartDir As String The initial directory. The algorithm for selecting the initial directory varies on different platforms.
Optional ByVal sDefExt As String = "" The default extension. GetOpenFileName and GetSaveFileName append this extension to the file name if the user fails to type an extension. This string can be any length, but only the first three characters are appended. The string should not contain a period (.). If this member is "" and the user fails to type an extension, no extension is appended.
Optional ByVal sDefaultFile As String = "" The default Filename searched for
Remarks
Returns the chosen filename
This code will open the OpenFile dialog
Private Sub mnuOpen_Click()
Dim s As String

Dim sFilter As String
sFilter = "All Text Files" + Chr(0) + "*.txt; *.js; *.htm; *.html; *.xml; *.asp; *.php; *.cfm; *.jsp; *.inc; *.vb; *.cs; *.frm; *.bas; *.c; *.cpp; *.diz; *.ini;" + Chr(0) & _
"Text File (*.txt)" + Chr(0) + "*.txt" + Chr(0) & _
"Script File (*.js)" + Chr(0) + "*.js" + Chr(0) & _
"HTML File (*.htm; *.html)" + Chr(0) + "*.htm; *.html" + Chr(0) & _
"XML File (*.xml)" + Chr(0) + "*.xml" + Chr(0) & _
"ASP File (*.asp)" + Chr(0) + "*.asp" + Chr(0) & _
"PHP File (*.php)" + Chr(0) + "*.php" + Chr(0) & _
"Cold Fusion File (*.cfm)" + Chr(0) + "*.cfm" + Chr(0) & _
"Java Server Page File (*.jsp)" + Chr(0) + "*.jsp" + Chr(0) & _
"Include (*.inc)" + Chr(0) + "*.inc" + Chr(0) & _
"All Files (*.*)" + Chr(0) + "*.*" + Chr(0)

s = moCommonDialog.ShowOpen(Me.hWnd, sFilter, moMultiLngSupport.GGS("001", "Open File"), _
eOpenFileFlags.OFN_FILEMUSTEXIST Or eOpenFileFlags.OFN_EXPLORER, App.Path)

If Len(s) > 0 Then
moCommonWrapper.ShowMessageBoxW s, , App.Title
End If
End Sub