Mark Di Val
Mark Di Val

Reputation: 81

C++Builder Change TOpenDialog->Options While Dialog is Open

The C++Builder App can open a number of file types and for one of these it makes sense to allow the user to open multiple files so that they can be processed as a batch.

The file types are set in the Filter property before the dialog is open. What is required, is to enable multiple file selection when the user selects the second file type - i.e. when FilterIndex is set to 2. Multiple selection should be disabled when Filter Index is set to any other value.

In the OpenDialogTypeChange event handler the TOpenDialog->Options are set like so:

void __fastcall TMainForm::OpenDialog1TypeChange(TObject *Sender)
{
  if (OpenDialog1->FilterIndex == 2)
    OpenDialog1->Options =
        TOpenOptions() << ofHideReadOnly << ofEnableSizing << ofAllowMultiSelect;
  else
    OpenDialog1->Options = TOpenOptions() << ofHideReadOnly << ofEnableSizing;
}

This works, however, after selecting file type 2 the OpenDialog must be closed and reopened (i.e. Cancel the File | Open) for the changes to take effect.

Is there a way to refresh these options into the currently open dialog without needing to close and reopen?

Upvotes: 0

Views: 31

Answers (0)

Related Questions