Solved

Two OpenDialogs forget the Inital Dir

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

730 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