PDA

View Full Version : OpenFileDialog.Filter for multiple extentions at once?


Gravey
07-01-2008, 02:42 AM
I'd like to be able to create an OpenFileDialog that I can assign a filter to for multiple extentions at once.
eg. so i can display .jpg and .tga files at the same time.

This would be similar to photoshop where it filters 'All Formats' that will open with photoshop. I'm guessing that the filter string is the key but all the examples i've seen only show a single format or all formats (*.*)

Gravey
07-01-2008, 03:17 AM
i did some more digging and found a solution not long after i posted... I knew that would happend!

Anyway the solution is to use a semicolon as a separator so a filter string for tga and jpg would be:
"tga and jpg|*.tga;*.jpg"

ZeBoxx2
07-01-2008, 10:33 AM
*bump* for the powers that be at maxscript documentation - this has been reported before as missing in the help :)

*digs through logs to find the conversation*


[22@19:47:09] <guy> anyone know how to specify multiple extensions for a single type with getOpenFileName()?
[22@19:48:21] <dude> i think you just put comma's between them but I don't think i've ever done that
[22@19:48:28] <dude> you could always do multiple entries
[22@19:48:31] <guy> doesn't seem to like it
[22@19:49:19] <guy> scriptfile = getOpenFileName types:"Script Files(*.ms,*.mcr)|#(*.ms,*.mcr)|All|*.*|"
[22@19:49:50] <guy> the array there doesn't work
[22@19:50:05] <me> ahhh I see what you mean
[22@19:51:07] <guy> ah well, I'll just force .ms
[22@19:51:17] <guy> we're unlikely to want a macroscript there anyway
[22@19:55:24] <me> aha
[22@19:55:26] <me> semicolon
[22@19:55:44] <me> scriptfile = getOpenFileName types:"Script Files(*.ms,*.mcr)|*.ms;*.mcr|All|*.*"
[22@19:55:56] <guy> sweet, thanks


MSDN has changed considerably since then, but this was probably where I finally spotted the info -_-
http://msdn.microsoft.com/en-us/library/ms646839(VS.85).aspx - OPENFILENAME Structure
lpstrFilter ... To specify multiple filter patterns for a single display string, use a semicolon to separate the patterns (for example, "*.TXT;*.DOC;*.BAK").

CGTalk Moderation
07-01-2008, 10:33 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.