0

I have simple RunBase Dialog:

Dialog dialog;
DialogField fieldFilenameOpen;

dialog = super();

fieldFilenameOpen = dialog.addField(extendedTypeStr("FilenameOpen"));
dialog.filenameLookupFilter(['xml','*.xml']);

return dialog;

Is it possible to set the dialog to allow the selection of multiple files?

Best Regards

Jan B. Kjeldsen
  • 17,817
  • 5
  • 32
  • 50
Tomasz Filipek
  • 579
  • 1
  • 6
  • 17

2 Answers2

2

You can't using standard AX AFAIK.

AX calls WinAPI::getOpenFileName(...), which uses COMDLG32.dll. You could copy/modify that method according to https://learn.microsoft.com/en-us/windows/win32/api/commdlg/, but good luck!

You can use .Net pretty easily though. I just threw this job together in a few minutes, so make sure to read up on the control. For example, there are properties like CheckFileExists you might want. Error checking, etc. This should get you going though.

static void JobMultiselectDemo(Args _args)
{
    System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog();
    System.String[]     results;
    System.String       sysFilename;
    Filename            axFilename;
    int                 i;
    int                 fileCount;
    
    ofd.set_Multiselect(true);
    ofd.set_Title("Multiselect demo");
    ofd.set_DefaultExt("xml");
    ofd.set_Filter("XML Files (*.txt)|*.xml");
    ofd.ShowDialog();

    results = ofd.get_FileNames();
    
    fileCount = results.get_Count();
    for (i=0; i<fileCount; i++)
    {
        sysFilename = results.get_Item(i);
        axFilename = sysFilename;
        info(axFilename);
    }
}
Alex Kwitny
  • 11,211
  • 2
  • 49
  • 71
-1

Finally, i used button on RunBase Dialog.

protected Object dialog()
{
    dlgGroup        = dialog.addGroup('');
    buttonGroup     = dialog.formBuildDesign().control(dlgGroup.formBuildGroup().id());
    buttonControl   = buttonGroup.addControl(FormControlType::Button, 'A Button');

    buttonControl.text("Select files");
    buttonControl.registerOverrideMethod(methodStr(FormButtonControl, clicked),
                                         methodStr(MultiselectFileTest, selectFilesButtonClicked),
                                         this);

    return dialog;
}



private void selectFilesButtonClicked(FormButtonControl _formButtonControl)
{
    System.Windows.Forms.OpenFileDialog openFileDialog;
    System.String[] files;
    System.String file;
    str fileName;
    int i, filesCount;
    ;

    openFileDialog = new System.Windows.Forms.OpenFileDialog();

    openFileDialog.set_Multiselect(true);
    
    if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult::OK)
    {
        files = openFileDialog.get_FileNames();
    
        filesCount = CLRInterop::getAnyTypeForObject(files.get_Count());
        
        selectedFiles = conDel(selectedFiles, 1, conLen(selectedFiles));
        
    for(i=0; i<filesCount; i++)
        {
            file = files.get_Item(i);
            fileName = CLRInterop::getAnyTypeForObject(file);
            selectedFiles = selectedFiles + [fileName];
        }
    }
}
Tomasz Filipek
  • 579
  • 1
  • 6
  • 17
  • Great, it looks like you used my answer. If you could mark it as accepted, that would close out the question and help others. – Alex Kwitny Oct 24 '22 at 15:31