Multiple Selection of Files in GetOpenFileName

Multiple Selection of Files in GetOpenFileName

Hi,

when I try to make multiple selection of files in GetOpenFileName setting the OFN_ALLOWMULTISELECT flag I can select more than one file but the returned value of the buffer is the directory name only. I read the documentation of this function but I can not understand how can I get the name of EACH of the selected files.
Can somebody help me?
Thanks in advance!
Stan

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

It depends on whether you are using old interface or explorer interface, but your return value has the directory followed by all the files selected, delimited by spaces (old) or nulls (new). Simple example:

 
program test
use comdlg32
implicit none
character*1024 files
type (T_OPENFILENAME) fn
integer base /1/, length
files = "*.*"c
fn%lStructSize = SIZEOF (fn)
fn%lpstrFile = LOC (files)
fn%nMaxFile = SIZEOF (files)
fn%Flags = OFN_ALLOWMULTISELECT .or. OFN_EXPLORER
if (GetOpenFileName(fn) .ne. 0) then
length = INDEX (files, char(0))
do while (length .gt. 1)
type *, 'Filename is ', files(base:base+length-1)
base = base + length
length = INDEX (files(base:), char(0))
end do
end if
end

James

Leave a Comment

Please sign in to add a comment. Not a member? Join today