- 积分
- 11502
- 明经币
- 个
- 注册时间
- 2002-10-2
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2005-3-28 07:14:00
|
显示全部楼层
本帖最后由 作者 于 2005-3-28 7:45:45 编辑
Joe Sutphin 写过下面这个用comdlg32.dll的SaveAs对话框替代
Option Explicit
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 lpstrCustomerFilter 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 Function ShowSave(Filter As String, _ InitialDir As String, _ DialogTitle As String) As String Dim OFName As OPENFILENAME 'Set the structure size OFName.lStructSize = Len(OFName) 'set the owner window OFName.hwndOwner = 0 'set the filter OFName.lpstrFilter = Filter 'set the maximum number of chars OFName.nMaxFile = 255 'create a buffer OFName.lpstrFile = Space(254) 'create a buffer OFName.lpstrFileTitle = Space$(254) 'set the maximum number of chars OFName.nMaxFileTitle = 255 'set the initial directory OFName.lpstrInitialDir = InitialDir 'set the dialog title OFName.lpstrTitle = DialogTitle 'no extra flags OFName.flags = 0 'Show 'SaveAs File' dialog If GetSaveFileName(OFName) Then ShowSave = Trim(OFName.lpstrFile) Else ShowSave = "" End If End Function
Sub Test_SaveAs() Dim Filter As String Dim InitialDir As String Dim DialogTitle As String Dim FileSelected As String
Filter = "Drawing Files (*.dwg)" + Chr$(0) + "*.dwg" + Chr$(0) + _ "All File(*.*)" + Chr$(0) & "*.*" + Chr$(0) InitialDir = "C:\Program Files\AutoCAD 2004\Sample" DialogTitle = "Save DWG as file"
FileSelected = ShowSave(Filter, InitialDir, DialogTitle) If FileSelected <> "" Then MsgBox "You just selected a file: " & FileSelected Else MsgBox "You didn't select a file." End If End Sub
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册
x
|