ShowOpen / ShowSave / ShowFolder / GetSpecialFolder
(创建时间:2010年12月03日 16:39:00)
Jangogo :
用于通用对话框,取代VB自带的 CommonDialog .减少控件依赖
Public Function ShowOpen(ByVal hWnd As Long, Optional ByVal strTitle As String, Optional ByVal strInitDir As String, Optional ByVal lngFlags As Long, Optional strFilter As String) As String Public Function ShowSave(ByVal hWnd As Long, Optional ByVal strFile As String, Optional ByVal strTitle As String, Optional ByVal strInitDir As String, Optional ByVal lngFlags As Long, Optional strFilter As String) As String
'文件夹选择对话框,用于获得一个文件夹 Public Function ShowFolder(ByVal hWnd As Long, Optional ByVal strIniDir As String, Optional strPromt As String) As String
注意:1. hWnd 是调用本函数的窗口的句柄,必填。
2. strFilter 是过滤器,例如:电子表格文件(*.xls)|*.HTM|网页文件 (*.HTM)|*.HTM|文本文件 (*.TXT)|*.TXT|所有文件格式 (*.*)|*.*
3. strInitDir 是默认路径,一般不需要设置值,默认桌面,系统会记录最后一次的位置
4.如果调用成功则返回文件名称,如果失败则返回空串
5. 如果你需要其他的对话框,如:颜色选择,字体选择,打印机选择等,请告知,我会开放出来给大家
'获得系统的文件夹,默认为桌面文件夹 Public Function GetSpecialFolder(Optional ByVal CSIDL As Long = &H0) As String '文件夹的CSIDL 常数 Const CSIDL_DESKTOP = &H0 Const CSIDL_PROGRAMS = &H2 Const CSIDL_CONTROLS = &H3 Const CSIDL_PRINTERS = &H4 Const CSIDL_PERSONAL = &H5 Const CSIDL_FAVORITES = &H6 Const CSIDL_STARTUP = &H7 Const CSIDL_RECENT = &H8 Const CSIDL_SENDTO = &H9 Const CSIDL_BITBUCKET = &HA Const CSIDL_STARTMENU = &HB Const CSIDL_DESKTOPDIRECTORY = &H10 Const CSIDL_DRIVES = &H11 Const CSIDL_NETWORK = &H12 Const CSIDL_NETHOOD = &H13 Const CSIDL_FONTS = &H14 Const CSIDL_TEMPLATES = &H15
特别地,我们增加了几个常数:
CSIDL_WindowsPath = -1 CSIDL_WindowsSystemPath = -2 CSIDL_TempPath = -3
文档中心