Pages

Tuesday, March 22, 2005

Multiple file types in GetFileOpenName

Ever notice how the File Open dialog in some applications (including the PowerBuilder IDE) show multiple file types in a single line in the drop-down list box? Ever wonder how you could do it from PowerBuilder? Well, if you look at the documenation for the OpenFileName structure that is the argument for the native GetOpenFileName function in the Windows API, you'll notice the following statement about it's lpstrFilter attribute:

"To specify multiple filter patterns for a single display string, use a semicolon to separate the patterns (for example, "*.TXT;*.DOC;*.BAK")."

Well, it's not documented, but that works for the filter argument for the PowerScript GetFileOpenName function as well. Try setting the filter to something like:

"Graphic Files (*.bmp;*.gif;*.jpg;*.jpeg),*.bmp;*.gif;*.jpg;*.jpeg"

And you'll see that not only does the dialog show that line in the DDLB, but it also shows all the files that match any of those file types.

GetOpenFileName

5 comments:

  1. Terry Dykstra5:18 AM

    Cool! Exactly what I was looking for.

    ReplyDelete
  2. Terry Dykstra8:36 AM

    "Graphic Files (*.bmp;*.gif;*.jpg,*.jpeg),*.bmp;*.gif;*.jpg,*.jpeg" should read:
    "Graphic Files (*.bmp;*.gif;*.jpg;*.jpeg),*.bmp;*.gif;*.jpg;*.jpeg"

    ReplyDelete
  3. Ram Chandra Samal8:58 PM

    Need More Informations!!!

    ReplyDelete
  4. bruce.armstrong1:28 AM

    Ram,

    I'm not quite sure what you're asking for.

    ReplyDelete
  5. bruce.armstrong1:29 AM

    Terry,

    Good point. A typo when I wrote the entry, as you can see the image displays the semi-colon rather the comma which results from the correct syntax.

    ReplyDelete