ShowReadOnly: Boolean;
The ShowReadOnly property indicates whether the flag used to select mode of file opening is displayed in the dialog.
By default the property is set to False, the flag is not displayed. If the property is set to True, the Read-only flag is present in the dialog during its initialization. This checkbox controls value of the ReadOnlyChecked property, it can be further used to check the mode of file opening.
Executing the example requires a form, a button named Button1 positioned on it and the FileOpenDialog component named FileOpenDialog1.
Sub Button1OnClick(Sender: Object; Args: IEventArgs);
Var
FileStr: IFileStream;
Begin
FileOpenDialog1.MultiSelect := False;
FileOpenDialog1.ShowReadOnly := True;
FileOpenDialog1.ReadOnlyChecked := True;
If FileOpenDialog1.Execute Then
If FileOpenDialog1.ReadOnlyChecked Then
FileStr := File.Open(FileOpenDialog1.FileName, FileOpenMode.Read, FileShare.DenyNone);
...
Else
FileStr := File.Open(FileOpenDialog1.FileName, FileOpenMode.ReadWrite, FileShare.Exclusive);
...
End If;
Dispose FileStr;
End If;
End Sub Button1OnClick;
After executing the example pressing the button initializes the dialog of file opening. There is the Read-only flag during initialization of the dialog. This flag is selected. It is possible to select only one file. When the user selects a file and presses OK button, depending on the state of Read-only flag, this file is read-only or writable and without access to this file from other applications.
See also: