Solved

Two OpenDialogs forget the Inital Dir

Posted on 2002-04-30
4
186 Views
Last Modified: 2012-05-04
Greetings -

I have two OpenDialogs on a TabControl form. I have included my code below:

//global values
var
  videopath : widestring;
  reportpath : widestring;

procedure TfrmMDIMain.FormShow(Sender: TObject);
var
 Reg: TRegistry;
 MyPicts : string;
begin
 Reg := TRegistry.Create;
    Reg.RootKey := HKEY_CURRENT_USER;
    if Reg.OpenKey('Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders', false) then begin
      MyPicts := Reg.ReadString('My Pictures');
      Reg.CloseKey;
    end; // if
    Reg.Free;
videopath := ExtractFileDir(Application.ExeName) + '\video';
reportpath := ExtractFileDir(Application.ExeName) + '\report';
MainMovie1.StoragePath := MyPicts;
OpenVideoDialog.InitialDir := videopath;
OpenWordDialog.InitialDir := reportPath;
end;


The problem is when my app loads USUALLY one path is remember (InitialDir) while the other fails to load. For example -

Click on the tab 'video' and you open to the folder where videopath is, but go to the reports tab next, and the app goes to the same folder where video is.

Any ideas?

Jim
0
Comment
Question by:JPersinger
4 Comments
 
LVL 7

Expert Comment

by:Motaz
ID: 6982638
Make sure that Report directory is exists inside your application directory or you can create it if not exists:

videopath := ExtractFileDir(Application.ExeName) + '\video';
reportpath := ExtractFileDir(Application.ExeName) + '\report';

  if not DirectoryExists(ReportPath) then
    CreateDir(ReportPath);

Motaz
0
 
LVL 1

Expert Comment

by:SchweizerD
ID: 6982752
Well, the most obvious answer is 'cut and paste error', are you sure you are calling the right OpenDialog ?

HTH
David
0
 

Author Comment

by:JPersinger
ID: 6983943
Motaz -

This application exists on a CD-ROM so I can't really use the CreateDir. I have made sure the CD contains the folders prior to the burn, so that its available on the CD-ROM.

David -

I'm sure. Here is the copy of code for the reports:

procedure TfrmMDIMain.CustomItem2Click(Sender: TObject);
begin
 TabControlForm.Visible := false;
 if OpenWordDialog.Execute then
  begin  
   OpenWordDialog.InitialDir := reportpath;
    CreateMDIChild(OpenWordDialog.FileName);
  end;
end;

and for the video I have:

procedure TfrmMDIMain.loadbuttonClick(Sender: TObject);
begin
   if OpenVideoDialog.Execute then
     begin
      OpenVideoDialog.InitialDir := videopath;
      Edit1.Text := OpenVideoDialog.FileName;
      ActiveMovie1.FileName := Edit1.Text;
      ActiveMovie1.Open;
     end;
end;

Jim
0
 

Accepted Solution

by:
ComTech earned 0 total points
ID: 7229743
This question will be placed in PAQ.

Regards,

ComTech
Community Support
Administrator @ EE
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi: how to send PJL commands to printer 3 89
Delphi IDE crash without error message ... 7 76
Delphi inherited method 6 63
RESTRequest Parameter 4 12
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

920 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now