include("../include.php"); writeHeader("Save file dialog", "Programming » Visual Basic 6 » Visual Basic 6 Code » Common Dialogs » ");?>
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 Declare Function GetSaveFileName Lib "comdlg32.dll" Alias "GetSaveFileNameA" _ (pOpenfilename As OPENFILENAME) As Long Sub ShowSave(hWnd As Long) Dim ofn As OPENFILENAME ofn.lStructSize = Len(ofn) ofn.hwndOwner = hWnd ofn.hInstance = App.hInstance ofn.lpstrFilter = "Text Files (*.txt)" & Chr$(0) & "*.txt" & Chr$(0) & _ "Rich Text Files (*.rtf)" + Chr$(0) + "*.rtf" + Chr$(0) ofn.lpstrFile = Space$(254) ofn.nMaxFile = 255 ofn.lpstrFileTitle = Space$(254) ofn.nMaxFileTitle = 255 ofn.lpstrInitialDir = CurDir ofn.lpstrTitle = "Our File Save Title" ofn.flags = 0 Dim a a = GetOpenFileName(ofn) If (a) Then MsgBox "File to Save: " + Trim$(ofn.lpstrFile) Else MsgBox "Cancel was pressed" End If End Sub