[fpc-pascal] Difference in TOpenDFialog behavior Win10 => Win11

Bo Berglund bo.berglund at gmail.com
Tue Sep 9 11:23:38 CEST 2025


This is an issue that I believe is caused by Windows 11...

5-6 years ago I have created a FreePascal/Lazarus utility to process video files
and I have and used it daily since then. It was last built on Windows 10 using
Lazarus 3.4 in beginning of this year.

It operates on video files which the user select through an OpenFile form button
which opens a TOpenDialog selection window.
I always preset this to the last open video file (path saved in the ini file).

On Windows 10 this shows the *file content* of the directory in the right hand
pane and the directory tree view to the left selects the directory of that file
and shows the other video sub-directories in there.

This makes it very easy to navigate from one video dir to another.

But now after upgrading my PC to Windows 11 the dialog no longer focuses the
tree view to the left on the dir where the video file last  used is located.

Instead the dir pane has the focus set to "Desktop" of all things, when at the
same time the files pane shows the content of my video dir on a different device
(my NAS) as it should!!!!
So the navigation becomes rather awkward and non-intuitive..

How can I change this back (in code) such that given the full path of the target
file (from the ini file) I can set the properties of the TOpenDialog object such
that it shows the actual file (in the right pane like it is now) but *also* sets
the directory pane to the left to select the directory the file is located in?

Code snippet from the open video file function:

  lastfile := ReadIniString('videofile', 'lastfile', '');
  lastvolume := ReadIniInt('videofile', 'lastvol', trkVolume.Position);
  lastpos := ReadIniInt('videofile', 'lastpos', 0);
  if lastfile <> '' then
  begin
    dlgOpen.InitialDir := ExtractFileDir(lastfile);
    dlgOpen.FileName := ExtractFileName(lastfile);
  end;
  if dlgOpen.Execute then
  begin
    VideoURL := dlgOpen.FileName;
    FVideoFile := ExtractFileName(VideoURL);

Is there something else I need to set on the TOpenDialog object dlgOpen to force
it to set the dir pane to select the parent dir of the file?

(I wish I did not do the Windows 11 upgrade....)


-- 
Bo Berglund
Developer in Sweden



More information about the fpc-pascal mailing list