04-19-2010 02:40 PM
I have a Bitmap picture in which I call GetBitmapFromFile right after this popupfile select. So I want the user to pick one of the folowing filetypes seen below.
I have the following call
FileSelectPopup ("", "*.*", "*.tif;*.pcx;*.bmp;*.dib;*.rle;*.ico;*.jpg;*.png;*.wmf;*.emf", "Select picture file", VAL_LOAD_BUTTON, 0, 0, 1, 0,pic_file_name); //Extension Not Required
But when this is ran, it prompts the user showing all file types and all file types are allowed.
Doing the following:
FileSelectPopup ("", "*.tif;*.pcx;*.bmp;*.dib;*.rle;*.ico;*.jpg;*.png;*.wmf;*.emf", "*.tif;*.pcx;*.bmp;*.dib;*.rle;*.ico;*.jpg;*.png;*.wmf;*.emf", "Select picture file", VAL_LOAD_BUTTON, 0, 0, 1, 0,pic_file_name); //Extension not required
The prompt shows only those file-types, but the default stays on .emf and the user must select the correct file-type at the bottom they are trying to select.
If I do the following (with commas and restrict file-extension):
FileSelectPopup ("", "*.tif;*.pcx;*.bmp;*.dib;*.rle;*.ico;*.jpg;*.png;*.wmf;*.emf", "*.tif,*.pcx,*.bmp,*.dib,*.rle,*.ico,*.jpg,*.png,*.wmf,*.emf", "Select picture file", VAL_LOAD_BUTTON, 0, 1, 1, 0,pic_file_name); //using commas
It shows the correct files, but when clicking one, it says the file-type must be .emf
The only workign way I found was to do the last statement, but not restrict the file-extension. (This would give the user the option to change the file-type)
What I want is the file-type allowed list to be one of those file-types, only show files with those extensions and not require/allow the user to select which file-type they will choose.
Can this not be done?
04-20-2010 02:10 AM
I see no way of customizing FileSelectPopup the way you want: either you restrict extensions, and you are limited to "Default file spec" contents (in case you put a filetype list in this field, the last one is used, as you already noted) or you allow to change extensions, but the user must choose which one to use an "*.*" is always present.
I am afraid you will need to post-process operator's choice and prompt again in case of non-allowed extension.
As an alternative you can use the toolbox path control, which can be tailored the way you want but it isn't as easy for the operator as FileSelectPopup. It iìultimately is a string control with customized features to offer an alternative in selecting files / paths. You can tailor it by doing so:
SetCtrlVal (panelHandle, PANEL_STRING, "c:\\myDefaultPath");
errChk (NewPathCtrl (panelHandle, PANEL_STRING, 15, 1));
SetPathCtrlAttribute (panelHandle, PANEL_STRING, ATTR_PATH_CTRL_FILE_FILTER, "*.bmp;*.ico");
This control permits you a limited filetype choice but forces the user to more impactive operability to select the desired file.
There is a sample project that uses this control in <sampledir>\userint\custctrl\pathctrl.
Another alternative is the File Browser toolslib control: a customized tree control which can be restricted to multiple file types; it is relatively slow on large file systems -at least at the first execution.
The control maintains the native context menu of the original tree control: I suppose this can be tailored as in native control but I haven't tested it: if it's possibleit may help the user in finding the correct file to select.
04-20-2010 10:26 AM