how do i check if there is no filename?

Posted on 1998-02-13
Last Modified: 2010-04-04
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);
 PathName := FileName;
 Editor.SelStart := 0; <- error here when the user presses the cancel button in open file dialog...

 Caption := ExtractFileName(PathName);
 Editor.Modified := False;
Question by:superboy
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

puppy earned 10 total points
ID: 1359184
hi superboy,
try this:
procedure TForm1.Button1Click(Sender: TObject);
label ok,nofile;
if opendialog1.filename = '' then goto nofile
else goto ok;

Author Comment

ID: 1359185
i solved this problem already..i set a boolean flag to true when opening a file and this affects the canel button..the boolean flag is fileopened..thanx anyway..

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how to center only a line in richedit? 4 69
Delphi Form ownership 4 125
How to debug For loops? 3 61
Tviruailstringtree sort multi columns on header click 1 85
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question