how do i check if there is no filename entered in the
open file dialog and the user just press the cancel button
in the open file dialog?
procedure TEditForm.Open(const FileName: string);
begin
PathName := FileName;
Editor.Lines.LoadFromFile(PathName);
Editor.SelStart := 0; <- error here when the user presses the cancel button in open file dialog...
Caption := ExtractFileName(PathName);
Editor.Modified := False;
end;
try this:
procedure TForm1.Button1Click(Sender
label ok,nofile;
begin
OpenDialog1.execute;
if opendialog1.filename = '' then goto nofile
else goto ok;
ok:
editor.lines.loadfromfile(
...
nofile:
end;