IFileOpenDialog.ReadOnlyChecked

Syntax

ReadOnlyChecked: Boolean;

Description

The ReadOnlyChecked property determines the state of the Read-only checkbox of the dialog.

Comments

It is relevant, if the ShowReadOnly property is set to True. By default the ReadOnlyChecked property is set to False, and the checkbox is not selected. If the property is set to True, the checkbox is selected. This property can be used to check the mode of opening the files selected in the dialog.

Example

Executing the example requires a form with the Button1 button 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 checkbox during initialization of the dialog. This checkbox is selected. It is possible to select only one file. On selecting a file and on pressing the OK button, depending on the state of Read-only checkbox, this file is read-only or writable and without access to this file from other applications.

See also:

IFileOpenDialog