www.pudn.com > BMP2JPG.rar > Module1.bas
Attribute VB_Name = "Module1"
Option Explicit
'=== Get Open Filename ====
Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
Type OPENFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As Long
lpstrFileTitle As String
nMaxFileTitle As Long
lpstrInitialDir As String
lpstrTitle As String
flags As Long
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
Sub ShowOpenFile(ShowTitle As String, FileType As String, FileDescription As String, sFileName As String)
Dim ofn As OPENFILENAME
Dim rtn As Long
ofn.lStructSize = Len(ofn)
ofn.hwndOwner = Form1.hWnd
ofn.hInstance = App.hInstance
ofn.lpstrFilter = FileDescription & "(" & FileType & ")" & vbNullChar & FileType
ofn.lpstrFile = Space(254)
ofn.nMaxFile = 255
ofn.lpstrFileTitle = Space(254)
ofn.nMaxFileTitle = 255
ofn.lpstrInitialDir = GetSetting(App.EXEName, "Setting", "Init_Dir", App.Path)
ofn.lpstrTitle = ShowTitle
ofn.flags = 6148
rtn = GetOpenFileName(ofn)
If rtn >= 1 Then
'get filename
sFileName = Trim$(UCase$(ofn.lpstrFile))
'^--- last word is enter,Cut it
sFileName = Left$(sFileName, Len(sFileName) - 1)
Else
sFileName = ""
End If
End Sub