Board index » delphi » Open/Save Dialog Boxes

Open/Save Dialog Boxes

When I access the Open Dialog and select a filename, I immediately access
the Save Dialog and need to insert the filename selected in the Open Dialog
as the default filename for the Save Dialog. The following code does not
work. Can anyone provide me some guidance?

OnShow Event
SaveDialog.FileName:= OpenDialog.FileName;

 

Re:Open/Save Dialog Boxes


"George Kwascha" <kas...@mindspring.com> skrev i en meddelelse
news:398c3fdd_1@dnews...

Quote
> When I access the Open Dialog and select a filename, I immediately access
> the Save Dialog and need to insert the filename selected in the Open
Dialog
> as the default filename for the Save Dialog. The following code does not
> work. Can anyone provide me some guidance?
> OnShow Event
> SaveDialog.FileName:= OpenDialog.FileName;

Try this:
  if OpenDialog.Execute then
    begin
      SaveDialog.FileName:= OpenDialog.FileName;
      SaveDialog.Execute;
    end;

Finn Tolderlund

Re:Open/Save Dialog Boxes


On Sat, 5 Aug 2000 12:35:13 -0400, "George Kwascha"

Quote
<kas...@mindspring.com> wrote:
>Can anyone provide me some guidance?

I'm having an awfully hard time understanding what you are doing from
your description (and it also seems highly unorthodox) but I assure
you the assignment  --

  SaveDialog.FileName:= OpenDialog.FileName;
does "work" in that the value of the OpenDialog.FileName property is
assigned to the SaveDialog.FileName property. The problem is that it
probably occurs at a time you aren't expecting.

You said you did it in "OnShow", by which I assume you mean you've
done it in the OpenDialog's OnShow event. This is too early, as the
event fires immediately when the dialog is shown, not much later after
the user uses the dialog to select a file name.

Here's a code snippet which does what I think you want:

procedure TForm1.Button1Click(Sender: TObject);
begin
  if OpenDialog.Execute then
  begin
    SaveDialog.FileName := OpenDialog.FileName;
    SaveDialog.Execute;
  end;
end;
--
Rick Rogers (TeamB)
www.fenestra.com and www.componentfactory.com

Other Threads