Solved

Two OpenDialogs forget the Inital Dir

Posted on 2002-04-30
4
187 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

776 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