Save As dialog box with multiple file choice
Luigi Castelli
Aug 24 2017 | 2:55 pm
Hello there,
I am using the function saveasdialog_extended() to give the user the choice to save two different types of image files. (PNG or JPEG)
Here is the relevant code snippet:
void myobj_do_image_save(t_myobj *x, t_symbol *msg, long argc, t_atom *argv) { t_symbol *sym; char name[MAX_FILENAME_CHARS]; t_filepath path = 0; t_fourcc type = 0; t_fourcc typelist[2] = { FOUR_CHAR_CODE('PNG '), FOUR_CHAR_CODE('JPEG') }; short typecount = 2; t_max_err err; if (argc && argv) { if (atom_gettype(argv) == A_SYM) { sym = atom_getsym(argv); strncpy_zero(name, sym->s_name, MAX_FILENAME_CHARS); } else { strncpy_zero(name, “untitled.png”, MAX_FILENAME_CHARS); } } else { strncpy_zero(name, “untitled.png”, MAX_FILENAME_CHARS); } err = saveasdialog_extended(name, &path, &type, typelist, typecount); if (err == MAX_ERR_NONE) { post("name: %s, path: %d, type: %d”, name, path, type); } else { post(“user cancelled…”); } }
I am using the latest Max SDK 7.3.3 and I am noticing some unexpected behavior in the function saveasdialog_extended() as prototyped in ext_proto.h.
In my code the ‘type’ argument doesn’t seem to return the type of file chosen by the user.
I get the file name and the path ID correctly, but - no matter what I try - the function always returns a zero for the type argument.
Can someone double check that?
How is it possible to distinguish what file type has the user selected in the dialog box?
Any help is highly appreciated.
Thank you.
- Luigi