zu Punkt 1 und 2:
Richtig. Das fehlt noch.
zu Punkt 3:
Reichen die Funktionen SaveFileDialog und OpenFileDialog des NotesUIWorkspace-Objekts nicht aus?
Hintergrund: Diese Library sollte lediglich das Handling ermöglichen, Frontend-Funktionen habe ich in einer Frontend-Klasse (von Filesystem vererbt) definiert.
Aber hier zwei Beispiele (Ordner und Datei auswählen) wie es in der Klasse aussehen könnte:
' ChoiceFolder
Public Function ChoiceFolder(str_title) As Variant
Dim folder As Variant
Dim var_filepath As Variant
Dim uiws as NotesUIWorkspace
Set uiws = New NotesUIWorkspace
var_filepath = uiws.SaveFileDialog(True, str_title, "", "")
If Isempty(var_filepath) Then Exit Function
If Me.FolderExists(var_filepath(0)) Then
Set folder = Me.GetFolder(var_filepath(0))
Else
If Messagebox("Das angegebene Verzeichnis existiert nicht!" & Chr(13) & _
"Möchten Sie es jetzt erstellen?", MB_YESNO + MB_ICONQUESTION, str_title) = 6 Then
Call Me.CreateFolder(var_filepath(0))
Set folder = Me.GetFolder(var_filepath(0))
End If
End If
If Not (Isempty(folder)) Then ChoiceFolder = folder.Path
Set folder = Nothing
End Function
' DlgFile
' Shows a dialog to choice a file and returns the file path.
Public Function DlgFile(str_title as String, str_filter As String, str_initdir As String) As String
Dim uiws as NotesUIWorkspace
Set uiws = New NotesUIWorkspace
Dim var_result As Variant
var_result = uiws.OpenFileDialog(False, str_title, str_filter, str_initdir)
If Isempty(var_result) Then Exit Function
DlgFile = var_result(0)
End Function
Im Prinzip schon. Nur ich verwende gerne, wenn es nur um die Auswahl eines Verzeichnisses geht die Funktion BrowseForFolder. Ich bin eigentlich auch gerne, wenn's sich machen lässt, Windows-konform.
Unteranderem auch die Funktionen DlgNetworkComputer und DlgNetworkShare:
' ### constants ###
' DlgNetworkShare / DlgNetworkComputer
Private Const ERROR_SUCCESS = 0
Private Const MAX_PATH = 260
Private Const CSIDL_NETWORK = &H12
Private Const BIF_RETURNONLYFSDIRS = &H1
Private Const BIF_BROWSEFORCOMPUTER = &H1000
Private Const DLG_NETWORKSHARE_TITLE = "Bitte wählen Sie eine Freigabe aus!"
Private Const DLG_NETWORKCOMPUTER_TITLE = "Bitte wählen Sie einen Computer aus!"
' ### user defined types ###
' BrowseInfo
Private Type BrowseInfo
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type
' ### external functions ###
' This function converts an item identifier list to a file system path.
Declare Private Function apiSHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (Byval pidl As Long, Byval pszPath As String) As Long
' This function retrieves the location of a special folder, such as My Handheld PC, Recycle Bin, Control Panel, Desktop, Printers, Fonts, or various file system directories.
Declare Private Function apiSHGetSpecialFolderLocation Lib "shell32.dll" Alias "SHGetSpecialFolderLocation" (Byval hwndOwner As Long, Byval nFolder As Long, pidl As Long) As Long
' This function displays a dialog box that allows a user to select a folder.
Declare Private Function apiSHBrowseForFolder Lib "shell32.dll" Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long
Public Function DlgNetworkComputer As String
Dim bi As BrowseInfo
Dim lng_pidl As Long
If apiSHGetSpecialFolderLocation(0, CSIDL_NETWORK, lng_pidl) = ERROR_SUCCESS Then
bi.hOwner = 0
bi.pidlRoot = lng_pidl
bi.pszDisplayName = Space$(MAX_PATH)
bi.lpszTitle = DLG_NETWORKCOMPUTER_TITLE
bi.ulFlags = BIF_BROWSEFORCOMPUTER
If apiSHBrowseForFolder(bi) <> 0 Then
DlgNetworkComputer = "\\" & Left$(bi.pszDisplayName,Instr(bi.pszDisplayName,Chr$(0)) - 1)
End If
End If
End Function
Public Function DlgNetworkShare As String
Dim bi As BrowseInfo
Dim lng_pidl As Long
Dim str_path As String
Dim lng_return As Long
If apiSHGetSpecialFolderLocation(0, CSIDL_NETWORK, lng_pidl) = ERROR_SUCCESS Then
bi.hOwner = 0
bi.pidlRoot = lng_pidl
bi.pszDisplayName = Space$(MAX_PATH)
bi.lpszTitle = DLG_NETWORKSHARE_TITLE
bi.ulFlags = BIF_RETURNONLYFSDIRS
lng_pidl = apiSHBrowseForFolder(bi)
If lng_pidl <> 0 Then
str_path = Space$(MAX_PATH)
If apiSHGetPathFromIDList(Byval lng_pidl, Byval str_path) Then
DlgNetworkShare = Left$(str_path, Instr(str_path, Chr$(0)) - 1) ' folder on host
Else
DlgNetworkShare = "\\" & Left$(bi.pszDisplayName, Instr(bi.pszDisplayName,Chr$(0)) - 1) ' host only
End If
End If
End If
End Function
mmh, irgendwie hänge ich in einer Schleife:
Sub Initialize
Dim fs As New Filesystem
Dim foRoot As folder
Set foRoot = fs.NotesFolder
End Sub
Was mache ich falsch?