我想在我设计中的Visual FoxPro6.0程序中的 菜单栏设置一个子菜单来打开一个D盘文件夹,应该怎样实行? 35
1个回答
展开全部
二十年以前我也想搞过,结果没弄成!看到你的提问后网上查了查,实现如WINXP的“资源管理器”现在有办法了,可参考一下:
先用vb建立一个dll工程,添加一个模块,包含以下代码:
Public Type BrowPath
lpWner As Long '窗体句柄
lpRoot As Long '起始目录
lpName As String
lpTite As String '标题
lpFlag As Long
lpFn As Long
lParam As Long
lpiImag As Long
End Type
'浏览文件夹函数
Public Declare Function SHBrowseForFolder Lib "shell32.dll " Alias "SHBrowseForFolderA " (lpBrowPath As BrowPath) As Long
'获得文件夹路径函数
Public Declare Function SHGetPathFromIDList Lib "shell32.dll " Alias "SHGetPathFromIDListA " (ByVal i As Long, ByVal pszPath As String) As Long
再添加一个类模块,命名如myclss
在类模块中建立一个函数,包含以下代码:
Public Function MyBrowpathG As String
On Error Resume Next
Dim lBpath As BrowPath
Dim i As Long
Dim m0 As String
Dim m1 As String * 500
m0 = " "
With lBpath
.lpTite = "请选择文件夹 "
.lpFlag = &H1
End With
i = SHBrowseForFolder(lBpath)
If i = 0 Then
m1 = " "
Exit Function
Else
SHGetPathFromIDList i, m1
m0 = BqTrim(m1)
m0 = Left$(m1, InStr(m1, Chr$(0)) - 1)
End If
MyBrowpathG = m0
End Function
然后,将这个dll工程编译成.dll文件,(文件名假设为aaa.dll)
这些准备做好后,就可以在VFP中调用了。方法是这样的:在vfp表单中,添加命令按钮,加入如下代码:
o=CREATEOBJECT( "aaa.myclss ")
m=o.MyBrowpathG()
运行表单,即可出现浏览对话框,并得到选择的文件夹赋给变量 m 。
先用vb建立一个dll工程,添加一个模块,包含以下代码:
Public Type BrowPath
lpWner As Long '窗体句柄
lpRoot As Long '起始目录
lpName As String
lpTite As String '标题
lpFlag As Long
lpFn As Long
lParam As Long
lpiImag As Long
End Type
'浏览文件夹函数
Public Declare Function SHBrowseForFolder Lib "shell32.dll " Alias "SHBrowseForFolderA " (lpBrowPath As BrowPath) As Long
'获得文件夹路径函数
Public Declare Function SHGetPathFromIDList Lib "shell32.dll " Alias "SHGetPathFromIDListA " (ByVal i As Long, ByVal pszPath As String) As Long
再添加一个类模块,命名如myclss
在类模块中建立一个函数,包含以下代码:
Public Function MyBrowpathG As String
On Error Resume Next
Dim lBpath As BrowPath
Dim i As Long
Dim m0 As String
Dim m1 As String * 500
m0 = " "
With lBpath
.lpTite = "请选择文件夹 "
.lpFlag = &H1
End With
i = SHBrowseForFolder(lBpath)
If i = 0 Then
m1 = " "
Exit Function
Else
SHGetPathFromIDList i, m1
m0 = BqTrim(m1)
m0 = Left$(m1, InStr(m1, Chr$(0)) - 1)
End If
MyBrowpathG = m0
End Function
然后,将这个dll工程编译成.dll文件,(文件名假设为aaa.dll)
这些准备做好后,就可以在VFP中调用了。方法是这样的:在vfp表单中,添加命令按钮,加入如下代码:
o=CREATEOBJECT( "aaa.myclss ")
m=o.MyBrowpathG()
运行表单,即可出现浏览对话框,并得到选择的文件夹赋给变量 m 。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询