Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

GETOPENFILENAME & multiselection

ksalamon
Beginner
595 Views

Hi

I have one question.

Namely, I write application which uses function/procedure GETOPENFILENAME. Under structure type Flags I put"ofn_explorer .or. ofn_allowmultiselect" which means that I want Explorer-style dialog box and multiple selections of files.

But when I want to read or get information about selected files and directory in string structure type lpstrFile, I get only directory without files. How can I get full path and all files which I selected? When I exclude ofn_explorer flag (old style dialog box) everything is OK, but I want new style dialog box.

Thank You.

Kreso.

0 Kudos
2 Replies
Jugoslav_Dujic
Valued Contributor II
595 Views
Rehi Kreso,
The information is (supposed to be) there, but it's a bit hidden. In case of multi-select dialog box, the directory name is followed by char(0), followed by char(0)-separated list of file names, terminated by double char(0). Thus, you have to parse the string to retrieve the list of file names:
Code:
!Assuming "szFiles" is the string to parse (OFN%lpstrFile)
nBegin=1   !Index of 1st character in next filename 
nFiles=0   !Number of files retrieved
DO
   nNextZero = nBegin + INDEX(szFiles(nBegin:), CHAR(0))-1
   IF (nNextZero-nBegin .LE. 1) EXIT  !Terminal double zero
   IF (nBegin.EQ.1) THEN
      !Directory name
      sDir = szFiles(nBegin:nNextZero-1)
   ELSE
      !File names
      nFiles = nFiles+1
      sFile = szFiles(nBegin:nNextZero-1)
      !Do something with sFile (or, better, TRIM(sDir)//""//sFile)
   END IF
   nBegin = nNextZero + 1
END DO

Jugoslav
0 Kudos
ksalamon
Beginner
595 Views

Thanks Jugoslav! That is solution for my problem.

Best regards.

Kreso.

0 Kudos
Reply