vb通用对话框
2个回答
展开全部
VB通用对话框函数说明:
hwnd 窗口句柄
sFilter 过滤器设置 格式为: "音频文件" & Chr(0) & "*.mp3;*.wav;*.mid"
dwFlags 对话框类型 可选值 0 - 1
0 打开对话框
1 保存对话框
具体函数代码如下:
01 PublicType OPENFILENAME '通用对话框信息
02 lStructSize AsLong '缓冲区大小
03 hwndOwner AsLong'父窗口句柄
04 hInstance AsLong'应用程序事件句柄 一般设为 App.hInstance
05 lpstrFilter AsString'文件类型过滤器
06 lpstrCustomFilter AsString'默认文件扩展名
07 nMaxCustFilter AsLong'扩展名最大长度
08 nFilterIndex AsLong
09 lpstrFile AsString'文件全路径
10 nMaxFile AsLong'文件全路径名最大长度
11 lpstrFileTitle AsString'文件标题
12 nMaxFileTitle AsLong'文件标题最大长度
13 lpstrInitialDir AsString'默认路径
14 lpstrTitle AsString'打开对话框标题
15 Flags AsLong'打开对话框类型
16 nFileOffset AsInteger
17 nFileExtension AsInteger
18 lpstrDefExt AsString
19 lCustData AsLong
20 lpfnHook AsLong
21 lpTemplateName AsString
22 EndType
23 PublicFunctionOpenDialog(ByValhWnd AsLong, ByValsFilter AsString, ByValdwFlgs AsLong) AsString
24 DimInfo AsOPENFILENAME
25 SelectCasedwFlgs
26 Case0 '打开
27 WithInfo
28 .lStructSize = Len(Info)
29 .hwndOwner = hWnd
30 .hInstance = App.hInstance
31 .lpstrFilter = sFilter
32 .lpstrFile = Space(254)
33 .nMaxFile = 255
34 .lpstrFileTitle = Space(254)
35 .nMaxFileTitle = 255
36 .lpstrInitialDir = App.Path
37 .Flags = 6148
38 EndWith
39 GetOpenFileName Info
40OpenDialog = Info.lpstrFile
41 Case1 '保存
42 WithInfo
43 .lStructSize = Len(Info)
44 .hwndOwner = hWnd
45 .hInstance = App.hInstance
46.lpstrFilter = sFilter
47 .lpstrFile = Space(254)
48nMaxFile = 255
49.lpstrFileTitle = Space(254)
50.nMaxFileTitle = 255
51.lpstrInitialDir = App.Path
52Flags = 6148
53 EndWith
54 GetSaveFileName Info
55OpenDialog = Info.lpstrFile
56EndSelect
57EndFunction
hwnd 窗口句柄
sFilter 过滤器设置 格式为: "音频文件" & Chr(0) & "*.mp3;*.wav;*.mid"
dwFlags 对话框类型 可选值 0 - 1
0 打开对话框
1 保存对话框
具体函数代码如下:
01 PublicType OPENFILENAME '通用对话框信息
02 lStructSize AsLong '缓冲区大小
03 hwndOwner AsLong'父窗口句柄
04 hInstance AsLong'应用程序事件句柄 一般设为 App.hInstance
05 lpstrFilter AsString'文件类型过滤器
06 lpstrCustomFilter AsString'默认文件扩展名
07 nMaxCustFilter AsLong'扩展名最大长度
08 nFilterIndex AsLong
09 lpstrFile AsString'文件全路径
10 nMaxFile AsLong'文件全路径名最大长度
11 lpstrFileTitle AsString'文件标题
12 nMaxFileTitle AsLong'文件标题最大长度
13 lpstrInitialDir AsString'默认路径
14 lpstrTitle AsString'打开对话框标题
15 Flags AsLong'打开对话框类型
16 nFileOffset AsInteger
17 nFileExtension AsInteger
18 lpstrDefExt AsString
19 lCustData AsLong
20 lpfnHook AsLong
21 lpTemplateName AsString
22 EndType
23 PublicFunctionOpenDialog(ByValhWnd AsLong, ByValsFilter AsString, ByValdwFlgs AsLong) AsString
24 DimInfo AsOPENFILENAME
25 SelectCasedwFlgs
26 Case0 '打开
27 WithInfo
28 .lStructSize = Len(Info)
29 .hwndOwner = hWnd
30 .hInstance = App.hInstance
31 .lpstrFilter = sFilter
32 .lpstrFile = Space(254)
33 .nMaxFile = 255
34 .lpstrFileTitle = Space(254)
35 .nMaxFileTitle = 255
36 .lpstrInitialDir = App.Path
37 .Flags = 6148
38 EndWith
39 GetOpenFileName Info
40OpenDialog = Info.lpstrFile
41 Case1 '保存
42 WithInfo
43 .lStructSize = Len(Info)
44 .hwndOwner = hWnd
45 .hInstance = App.hInstance
46.lpstrFilter = sFilter
47 .lpstrFile = Space(254)
48nMaxFile = 255
49.lpstrFileTitle = Space(254)
50.nMaxFileTitle = 255
51.lpstrInitialDir = App.Path
52Flags = 6148
53 EndWith
54 GetSaveFileName Info
55OpenDialog = Info.lpstrFile
56EndSelect
57EndFunction
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询