Not sure where I got this, but it works.
Windows example --
New Property:
filter as String
New Property:
ParentWindow as Window
New Method:
GetMultiOpenDialog, title as String, filter() as String, parentWindow as
Window, Return Type is FolderItem()
#if TargetWin32 then
Declare Function GetOpenFileNameA lib "comdlg32" (lpofn as Ptr) as
Boolean
Declare Function CommDlgExtendedError lib "comdlg32" as Integer
Declare Function GetModuleHandleA lib "kernel32" (name as Integer) as
Integer
dim OpenFileStruct as new MemoryBlock(73)
dim FilterString as MemoryBlock
dim fileOutBuffer as new MemoryBlock(2048)
dim titleCString as MemoryBlock = title + chr(0)
dim results(-1) as Folderitem
dim pos as integer
dim s as string
dim path as String
dim error as integer, exc as RuntimeException
OpenFileStruct.long(0) = 76 // Struct Size
if ParentWindow <> nil then
OpenFileStruct.Long(4) = parentWindow.WinHWND // Owning window
end if
OpenFileStruct.long(8) = GetModuleHandleA(0)
FilterString = Join(filter,chr(0)) + chr(0)
OpenFileStruct.Ptr(12) = FilterString
OpenFileStruct.long(16) = 0 //NULL -- lpstrCustomFilter
OpenFileStruct.long(20) = 0 // Ignored because of above --
nMaxCustFilter
OpenFileStruct.long(24) = 0 // Ignored because of above -- nFilterIndex
OpenFileStruct.ptr(28) = fileOutBuffer
OpenFileStruct.long(32) = 2048
OpenFileStruct.long(36) = 0
OpenFileStruct.long(40) = 0
OpenFileStruct.long(44) = 0
OpenFileStruct.Ptr(48) = titleCString
OpenFileStruct.Long(52) = &h81200
if GetOpenFileNameA(OpenFileStruct) then
// Try to get the results
// scan the fileOutBuf
path = fileOutBuffer.CString(0)
while fileOutBuffer.byte(pos) <> 0 // scan for another null character
s = fileOutBuffer.CString(pos)
pos = pos + lenb(s) + 1
results.append GetFolderItem(path+"\"+s,
FolderItem.PathTypeAbsolute)
wend
If UBound(results) = 0 And Len(path) > 1 Then
results.Append GetFolderItem(path, FolderItem.PathTypeAbsolute)
End if
// the first file is the current directory. We can remove it
results.remove 0
return Results
else
error = CommDlgExtendedError()
if error = 0 then
// Just pressed cancel...
return Results
else
exc = new RuntimeException
exc.ErrorNumber = error
raise exc
end if
end if
#else // not win32
raise new RuntimeException
#endif
PushButton Action:
dim f() as FolderItem
dim i as integer
f = GetMultiOpenDialog("Hello World!", Array("All Files","*.*"), self)
for i = 0 to ubound(f)
msgBox "You selected " + f(i).AbsolutePath
next
ParentWindow = Window1
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>