-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathclsCdlg.cls
86 lines (84 loc) · 2.33 KB
/
clsCdlg.cls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "clsCdlg"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
Private Declare Function GetSaveFileName Lib "comdlg32.dll" Alias "GetSaveFileNameA" (pSavefilename 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 FileName As String
Public rtnFilter As Long
Public Function ShowOpen(hwnd As Long, Filter As String, Title As String) As String
Dim OFName As OPENFILENAME
With OFName
.lStructSize = Len(OFName)
.hwndOwner = hwnd
.hInstance = App.hInstance
.lpstrFilter = Filter
.lpstrFile = Space$(259)
.nMaxFile = 260
.lpstrFileTitle = Space$(259)
.nMaxFileTitle = 260
.lpstrInitialDir = MyPath
.lpstrTitle = Title
.flags = 0
End With
If GetOpenFileName(OFName) Then
ShowOpen = Trim(OFName.lpstrFile)
Else
ShowOpen = ""
End If
FileName = Replace(ShowOpen, Chr(0), "")
End Function
Public Function ShowSave(hwnd As Long, Filter As String, Title As String) As String
Dim OFName As OPENFILENAME
With OFName
.lStructSize = Len(OFName)
.hwndOwner = hwnd
.hInstance = App.hInstance
.lpstrFilter = Filter
.lpstrFile = FileName & String(255 - Len(FileName), vbNullChar)
.nMaxFile = 260
.lpstrFileTitle = Space$(259)
.nMaxFileTitle = 260
.lpstrInitialDir = MyPath
.lpstrTitle = Title
.flags = 0
End With
If GetSaveFileName(OFName) Then
ShowSave = Trim(OFName.lpstrFile)
Else
ShowSave = ""
End If
FileName = Replace(ShowSave, Chr(0), "")
rtnFilter = OFName.nFilterIndex
End Function