?
Solved

Two OpenDialogs forget the Inital Dir

Posted on 2002-04-30
4
Medium Priority
?
191 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
[X]
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
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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

765 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