Announcement

Collapse
No announcement yet.

%OFN question

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

  • %OFN question

    On the Open File Dialog box, there are several options you can specify.

    I re-wrote the function to my own tastes, very very close to what the Commdlg32.inc has anyway.

    One of the things I want is to be able to select MULTIPLE files.
    So I add
    %OFN_ALLOWMULTISELECT = &H00000200???


    And I get the old 16 bit dialog box, where all files are on the left, folder on the right, drives on the bottom...


    How do I get a "Normal" open file dialog box with the ability to select multipel files???

    Paint Shop Pro uses it, so I know it can be done, question is how???

    Currently here's my call, and consider it the same as the .INC file's call, because there's only one minor difference..

    Code:
                            g_Result = MyOpenFileDialog(ByVal hDLg,_
                                                        ByVal Caption,_
                                                        FileSpec,_
                                                        g_CurrWorkingDir,_
                                                        ByVal Filter,_
                                                        ByVal DefExtension,_
                                                        %OFN_FILEMUSTEXIST Or %OFN_HIDEREADONLY Or %OFN_LONGNAMES)
    If I add that %OFN_ALLOWMULTISELECT THEN it goes to the Old style dialog box


    Scott

    ------------------
    Scott
    mailto:[email protected][email protected]</A>
    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

  • #2
    Combine your flags with OFN_EXPLORER.


    ------------------
    Dominic Mitchell
    Dominic Mitchell
    Phoenix Visual Designer
    http://www.phnxthunder.com

    Comment


    • #3
      Thanks!
      That did the trick!

      Scott

      ------------------
      Scott
      mailto:[email protected][email protected]</A>
      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


      • #4
        Whoa..
        This works, but now the file is only coming back as a directory.

        Microsoft states:

        Specifies that the File Name list box allows multiple selections. If you also set the OFN_EXPLORER flag, the dialog box uses the Explorer-style user interface; otherwise, it uses the old-style user interface.
        If the user selects more than one file, the lpstrFile buffer returns the path to the current directory followed by the file names of the selected files. The nFileOffset member is the offset, in bytes or characters, to the first file name, and the nFileExtension member is not used. For Explorer-style dialog boxes, the directory and file name strings are NULL separated, with an extra NULL character after the last file name. This format enables the Explorer-style dialog boxes to return long file names that include spaces. For old-style dialog boxes, the directory and file name strings are separated by spaces and the function uses short file names for file names with spaces. You can use the FindFirstFile function to convert between long and short file names.

        If you specify a custom template for an old-style dialog box, the definition of the File Name list box must contain the LBS_EXTENDEDSEL value.

        But I don't get filenames in that string, could it be that because it's an asciiz ptr and the Asciiz stops at the first null??


        Scott


        ------------------
        Scott
        mailto:[email protected][email protected]</A>
        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


        • #5
          What you are seeing is correct. The strings are built as follows
          Single file - directory\file\0\0
          Multiple files - directory\0file1\0file2\0\0

          \0 = NULL

          You need to write custom parsing routines to get the filenames.


          ------------------
          Dominic Mitchell
          Dominic Mitchell
          Phoenix Visual Designer
          http://www.phnxthunder.com

          Comment


          • #6
            OK Cool but here's the issue:

            The function has this in it while building the OFN

            Code:
            zFile = FileSpec 'FileSpec is string, zFile is asciiz * 255
              Local Ofn           As OPENFILENAME
              ofn.lpstrFile         = VarPtr(zFile)
            
            
            Now, the function inside the function is called:
              Function = GetOpenFilename(ofn)
            
            Then 
            Filespec = zFile because zFile has the data.
            
            But it gets the FOldername, and as you know Asciiz is NULL terminated, so it terminates at the first NULL>
            
            
            Not good  
            
            Any workaround to this?
            
            Scott
            ------------------
            Scott
            mailto:[email protected][email protected]</A>
            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


            • #7
              First your buffer size, 255, is way too small. Try 1024 or larger.

              Filespec = zFile is not going to work. Because of the way zFile is
              formulated you will always get the directory if you use simple assignment.
              Treat zFile as a compound string containing NULL delimited data where
              the double NULL marks the end of the data.
              "directory\0file1\0file2\0\0"

              The nFileOffset member of the OPENFILENAME struct is also important for
              parsing the string. Its the zero based offset of the first file in the string.
              ------------------
              Dominic Mitchell

              [This message has been edited by Dominic Mitchell (edited January 30, 2001).]
              Dominic Mitchell
              Phoenix Visual Designer
              http://www.phnxthunder.com

              Comment


              • #8
                use a fixed-length string...

                [This message has been edited by Ron Pierce (edited January 30, 2001).]

                Comment


                • #9
                  Posted small sample how to do it to source code. This is one of
                  those things that sounds easy, until you start messing with it.
                  Buffer must be increased to contain all file names and returned
                  string can look two ways. For one file selected, full path and
                  file name is returned. For multiple files, Path comes first,
                  then File names. Sample should explain..


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

                  Comment


                  • #10
                    Very cool, Thank you.
                    I'll dig into it deeper, I prefer using Strings when I can...

                    It works great, I just use Tally to search for Chr$(0), if it is NOT zero then I have multiple files...
                    So far so good...



                    Thanks!

                    Scott


                    ------------------
                    Scott
                    mailto:[email protected][email protected]</A>
                    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

                    Working...
                    X