Announcement

Collapse
No announcement yet.

Using the OpenDialog to select multiple files

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

  • Using the OpenDialog to select multiple files

    Hi Dave, the OpenDialog is useful but I'm trying to select multiple files, I've tried to 'amend' the commctrl.inc to use the correct style but I'm having trouble passing an array to be filled. To me it seems that I can get the number of files, then I have to show the OpenDialog again to pass the array with the correct number of elements. This of course assumes the end user wants to select multiple files multiple times !!! Any pointers ?

    Regards

    Adrian Aitken
    [email protected]

  • #2
    I have not personally set this up yet, although one of these days I may have a need for it.
    So I would imagine you would need this as flags in OpenFileDialog:

    %OFN_ALLOWMULTISELECT


    And then you would have say FileSpec returned.

    Result = Tally$(St,";")

    Now you know how many strings are in your return string:

    For x = 1 to Result
    FileSpec(x) = Parse$(St,";",x)
    Next

    This is just a sample of how I might do it...
    But I would be interested in testing your code, I have one application that may work better doing multiple files at one time..


    Scott

    ------------------
    Scott Turchin


    Scott Turchin
    MCSE, MCP+I
    http://www.tngbbs.com
    ----------------------
    True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

    Comment


    • #3
      Hi Scott,
      Yes , I used the multiselect declare but (and theres always a but) although I can select multi files in the dialog the returned values was the directory name (and if I did i&=open... then i& was the length of the directory name). The actual files were never returned so I couldn't parse them. I am using Win98 SE with IE5.

      Regards

      Adrian Aitken

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

      Comment


      • #4
        Adrian --

        I'm writing this from home so I can't check, but I'm pretty sure that the multi-file option returns a string that is delimited with CHR$(0). So if you are using an ASCIIZ string, you will only see the first part, which is the path. The trick, as I remember it, is to create a "regular" PowerBASIC string variable, and fill it with spaces or nuls with STRING$ to a length that is long enough to hold a very long lsit of files, like STRING$(4096,0). Then pass that string (using BYVAL STRPTR) instead of an ASCIIZ string. The result will be a string that you can parse with PARSECOUNT and PARSE$(,,$NUL) to get everything you need.

        I'll edit this post in the morning, after I check Win32.HLP, unless somebody looks it up in the meantime.

        -- Eric


        ------------------
        Perfect Sync: Perfect Sync Development Tools
        Email: mailto:[email protected][email protected]</A>

        "Not my circus, not my monkeys."

        Comment


        • #5
          The following returns the path, plus all selected filenames,
          separated with a space, like "c:\path file1 file2 file3", etc,
          but it doesn't support long filenames, because long filenames
          can contain spaces in themselves.

          Therefore, it also changes the Open file dialog to look like the
          old Win 3.1 style, with separate File, Dir and Drive lists. Not
          very useful, in other words - you probably need to build up your
          own dialog with lists and comboboxes for files and directories,
          etc, if you want to allow the user to open several files at once.

          Code:
          LOCAL f AS STRING, Path AS STRING, Style AS DWORD 'LONG in older win32api.inc
          
          f     = "*.TXT" 
          Path  = CURDIR$
          Style = %OFN_ALLOWMULTISELECT OR %OFN_FILEMUSTEXIST OR %OFN_HIDEREADONLY OR %OFN_LONGNAMES
          IF OpenFileDialog(hWndClient, "Open File", f, Path, _
             "Word processing  (*.RTF)|*.RTF|Text files  (*.BAS, *.BAT, *.DIZ, *.TXT)|*.BAS;*.BAT;*.DIZ;*.TXT|All files  (*.*)|*.*", "TXT", Style) THEN
             MSGBOX f
          END IF
          ------------------




          [This message has been edited by Borje Hagsten (edited February 07, 2000).]

          Comment


          • #6
            ok, i have posted a slightly modified version of the openfiledialog function in the source code forum:

            http://www.powerbasic.com/support/pb...ad.php?t=23077

            it does not use the old-style dialog, and it does allow the use of long file names.

            -- eric

            ------------------
            perfect sync: perfect sync development tools
            email: mailto:[email protected][email protected]</a>



            [this message has been edited by eric pearson (edited february 08, 2000).]
            "Not my circus, not my monkeys."

            Comment


            • #7
              Thanks for the replies, I'd tried the 'old' style but didn't like the shortened filenames and after I posted the last response I remembered I'd had this problem before with registry settings, needing asciiz ptrs.

              Regards

              Adrian Aitken

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

              Comment

              Working...
              X