OpenSaveDlg.cls
资源名称:IE_VB.rar [点击查看]
上传用户:davilee3
上传日期:2015-04-22
资源大小:986k
文件大小:5k
源码类别:
浏览器
开发平台:
Visual Basic
- VERSION 1.0 CLASS
- BEGIN
- MultiUse = -1 'True
- Persistable = 0 'NotPersistable
- DataBindingBehavior = 0 'vbNone
- DataSourceBehavior = 0 'vbNone
- MTSTransactionMode = 0 'NotAnMTSObject
- END
- Attribute VB_Name = "OpenSaveDlg"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = True
- Attribute VB_PredeclaredId = False
- Attribute VB_Exposed = False
- Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
- Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
- Option Explicit
- Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
- Private Declare Function GetSaveFileName Lib "comdlg32.dll" Alias "GetSaveFileNameA" (pOpenfilename As OPENFILENAME) As Long
- Private 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
- Public Enum enuDlgFlgs
- OFN_ALLOWMULTISELECT = &H200&
- OFN_CREATEPROMPT = &H2000&
- OFN_DONTADDTORECENT = &H2000000
- OFN_ENABLEHOOK = &H20&
- OFN_ENABLEINCLUDENOTIFY = &H400000
- OFN_ENABLESIZING = &H800000
- OFN_ENABLETEMPLATE = &H40&
- OFN_ENABLETEMPLATEHANDLE = &H80&
- OFN_EX_NOPLACESBAR = &H1&
- OFN_EXPLORER = &H80000
- OFN_EXTENSIONDIFFERENT = &H400&
- OFN_FILEMUSTEXIST = &H1000&
- OFN_FORCESHOWHIDDEN = &H10000000
- OFN_HIDEREADONLY = &H4&
- OFN_LONGNAMES = &H200000
- OFN_NOCHANGEDIR = &H8&
- OFN_NODEREFERENCELINKS = &H100000
- OFN_NOLONGNAMES = &H40000
- OFN_NONETWORKBUTTON = &H20000
- OFN_NOREADONLYRETURN = &H8000
- OFN_NOTESTFILECREATE = &H10000
- OFN_NOVALIDATE = &H100&
- OFN_OVERWRITEPROMPT = &H2&
- OFN_PATHMUSTEXIST = &H800&
- OFN_READONLY = &H1&
- OFN_SHAREAWARE = &H4000&
- OFN_SHAREFALLTHROUGH = 2&
- OFN_SHARENOWARN = 1&
- OFN_SHAREWARN = 0&
- OFN_SHOWHELP = &H10&
- OFN_USEMONIKERS = &H1000000
- End Enum
- Public Filter As String
- Public Flags As enuDlgFlgs
- Public InitDir As String
- Public DialogTitle As String
- Public FileTitle As String
- Public FileName As String
- Public Function ShowSave(hOwner As Long) As Boolean
- Dim ofn As OPENFILENAME
- Dim rtn As Long
- With ofn
- .lStructSize = Len(ofn)
- .hwndOwner = hOwner
- .hInstance = App.hInstance
- .lpstrFilter = Replace(Filter, "|", Chr(0))
- .lpstrFile = Left(FileName & Chr(0) & Space(254), 254)
- .nMaxFile = 255
- .lpstrFileTitle = Space(254)
- .nMaxFileTitle = 255
- .lpstrInitialDir = InitDir
- 'If InitDir <> "" Then .lpstrInitialDir = InitDir Else .lpstrInitialDir = "" 'vbNullString ' App.Path
- If DialogTitle <> "" Then
- .lpstrTitle = DialogTitle
- Else
- .lpstrTitle = "保存"
- End If
- .Flags = Flags
- End With
- rtn = GetSaveFileName(ofn)
- If rtn >= 1 Then
- ShowSave = True
- FileName = Trim$(ofn.lpstrFile)
- FileName = Left$(FileName, Len(FileName) - 1)
- FileTitle = Trim$(ofn.lpstrFileTitle)
- If FileTitle <> "" Then FileTitle = Left$(FileTitle, Len(FileTitle) - 1)
- InitDir = ofn.lpstrInitialDir
- Else
- ShowSave = False
- End If
- DialogTitle = ""
- End Function
- Public Function ShowOpen(hOwner As Long) As Boolean
- Dim ofn As OPENFILENAME
- Dim rtn As Long
- With ofn
- .lStructSize = Len(ofn)
- .hwndOwner = hOwner
- .hInstance = App.hInstance
- .lpstrFilter = Replace(Filter, "|", Chr(0))
- .lpstrFile = Left(FileName & Chr(0) & Space(254), 254)
- .nMaxFile = 255
- .lpstrFileTitle = Space(254)
- .nMaxFileTitle = 255
- .lpstrInitialDir = InitDir
- 'If InitDir <> "" Then .lpstrInitialDir = InitDir Else .lpstrInitialDir = "" 'vbNullString ' App.Path
- If DialogTitle <> "" Then
- .lpstrTitle = DialogTitle
- Else
- .lpstrTitle = "打开"
- End If
- .Flags = Flags
- End With
- rtn = GetOpenFileName(ofn)
- If rtn >= 1 Then
- ShowOpen = True
- FileName = Trim$(ofn.lpstrFile)
- FileName = Left$(FileName, Len(FileName) - 1)
- FileTitle = Trim$(ofn.lpstrFileTitle)
- If FileTitle <> "" Then FileTitle = Left$(FileTitle, Len(FileTitle) - 1)
- InitDir = ofn.lpstrInitialDir
- Else
- ShowOpen = False
- End If
- 'Debug.Print ofn.nFileOffset
- DialogTitle = ""
- End Function
- 'Private Sub Class_Initialize()
- 'Flags = OFN_ALLOWMULTISELECT Or OFN_EXPLORER
- 'End Sub
- '