Solved

Two OpenDialogs forget the Inital Dir

Posted on 2002-04-30
4
184 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
This question will be placed in PAQ.

Regards,

ComTech
Community Support
Administrator @ EE
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

772 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

15 Experts available now in Live!

Get 1:1 Help Now