Good time of day.

To display the contents of directories I use the ShellListView component.
For the reaction of the program only on the selected files using the code:

procedure TForm1.ShellListViewClick(Sender: TObject); begin if not(ShellListView.SelectedFolder.IsFolder) then begin {перенос наименования выделенного файла в StrinGrid} end; end; 

The code is working fine.
But if in this component you accidentally press a lion. mouse button on an empty area, pops up:

“Project Project1.exe raised exception class EAccessViolation with message 'Access violation at address 0046FDCF in module' Project1.exe '. Read of address 0000000C '. Process stopped. Use Step or Run to continue. ”

Has anyone encountered this?

Thank.

    1 answer 1

    If there is no selection, then the SelectedFolder will be nil. Correctly:

     if (ShellListView.SelectedFolder<>nil) and not(ShellListView.SelectedFolder.IsFolder) then begin {перенос наименования выделенного файла в StrinGrid} end; 
    • Thanks again :-) - Konstantin78