Forum > Other

TOpenDialog in Windows full functional?


Giuseppe RidinĂ²:
I'm getting problems using TOpenDialog in Windows XP.
I use a simple code like that:

--- Code: ---var
  openDialog : TOpenDialog;
  openDialog := TOpenDialog.Create(self);
  openDialog.InitialDir := GetCurrentDir;
  openDialog.Options := [ofFileMustExist];
  openDialog.Filter :=
    'Delphi project files|*.dpr|Delphi pascal files|*.pas';
  openDialog.FilterIndex := 2;
  if openDialog.Execute then
--- End code ---

It usually works fine, but sometimes the openDialog.Execute command doesn't popup the dialog, thus I can't choose no file, but a message error is shown:
The file "" does not exist. with title File must exist with only one button "Cancel".
Any idea?  :cry:
Is TOpenDialog in Windows full functional?

Giuseppe RidinĂ²:
The problem arise when editing a data file in my application and want to load a new one. If data has been modified and not saved, then my application should ask for "Save changes?". Depending on then answer (Yes, No, or Cancel), the OpenDialog is opened to choose the new file.
...  :evil:  ... and here comes the error I described previously!

I noted that Lazarus IDE do it in the reverse mode when loading a new file. It first open the OpenDialog and then later ask for "Save changes?" ... and every thing works fine!  :P
So this is the way I implemented it! :!:


[0] Message Index

Go to full version