Announcement

Collapse
No announcement yet.

Selecting multiple files with "openfiledialog" of "Comdlg32.inc"?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Selecting multiple files with "openfiledialog" of "Comdlg32.inc"?

    Hi all,

    In my program I want to open a file dialog to ask the name(s) of 1 or more files.
    I managed to open a file dialog using the "OpenFileDialog" function of "Comdlg32.inc".
    When using the %OFN_ALLOWMULTISELECT style, you can select 1 or more files.
    The trouble is that I haven't succeeded in retrieving the filenames.
    The Win32API help file gives following info:
    "If the OFN_ALLOWMULTISELECT flag is set and the user selects multiple files, the buffer
    contains the current directory followed by the filenames of the selected files. For
    Explorer-style dialog boxes, the directory and filename strings are NULL separated, with
    an extra NULL character after the last filename. For old-style dialog boxes, the strings
    are space separated and the function uses short filenames for filenames with spaces.
    You can use the FindFirstFile function to convert between long and short filenames."
    I have used the "explorer-style" dialog box. The returned filename gives only the
    directory of the filenames.
    How can I retrieve the separate filenames?
    Code:
    CALLBACK FUNCTION CBF_OPT_ADDINCLFILEBUTT
        LOCAL IncFilename   AS STRING
        LOCAL Path          AS STRING
        LOCAL Style         AS DWORD
        LOCAL hFile         AS LONG
        LOCAL Buffer        AS STRING
        LOCAL f             AS STRING
        LOCAL zText         AS ASCIIZ * 255
        LOCAL Flag          AS LONG
        DIM s AS STRING PTR, a AS STRING, b AS STRING, teller AS LONG
        Path = CURDIR$
        IF CBCTLMSG=%BN_CLICKED THEN
            Style = %OFN_FILEMUSTEXIST OR %OFN_LONGNAMES OR %OFN_ALLOWMULTISELECT OR %OFN_EXPLORER
            IncFilename = "*.inc"
            Flag = OpenFileDialog(hOpt&, "Select File", IncFilename, Path, _
            "*.inc|*.inc|*.bas|*.bas|All Files|*.*", "*.inc", Style)
            IF Flag THEN LISTBOX ADD hOpt&,  %OPT_IgnoreInc, IncFilename   ' <-- returns only directory!!
        END IF
    END FUNCTION
    Any advice?
    Kind regards
    Eddy


    ------------------
    [email protected]



    [This message has been edited by Eddy Van Esch (edited April 23, 2001).]
    Eddy

  • #2
    see one way of doing it at: http://www.powerbasic.com/support/pb...ad.php?t=22903

    ------------------

    Comment


    • #3
      Once again thanks Borje!
      Your routine is exactly what i need!
      I tried something similar, but instead of "parsecount" I used "tally"
      to check for null-characters and that's were it didn't work.
      Kind regards
      Eddy




      ------------------
      [email protected]
      Eddy

      Comment

      Working...
      X