Recent

Author Topic: Is there a TOpenDialog alternative that works on Windows11?  (Read 1279 times)

BosseB

  • Sr. Member
  • ****
  • Posts: 484
Is there a TOpenDialog alternative that works on Windows11?
« on: September 21, 2025, 08:12:43 am »
Using Lazarus I created a video editing tool back in 2018 or so and I have updated it with new functionality ever since. I use it several times daily. When I created it I was running on Windows 10 Pro.
About 2 weeks ago I had to bite the bullet and upgrade my PC to Windows 11, which was a hurdle by itself. And now I have discovered an issue in my program that slows me down using it and which I have to solve somehow:

Every time I open a video file for editing I use the TOpenDialog like this in code:

Code: Pascal  [Select][+][-]
  1. dlgOpen: TOpenDialog; //Dropped on the form when creating the application

And its customized propertis (in the lfm file) are:

Code: Pascal  [Select][+][-]
  1.   object dlgOpen: TOpenDialog
  2.     DefaultExt = '.mp4'
  3.     Filter = 'MP4 Video|*.mp4|MP3 Audio|*.mp3|Other media|*.*'
  4.     Left = 24
  5.     Top = 280
  6.   end
  7.  

Everything else are defaults.

The dialog is called like this:

Code: Pascal  [Select][+][-]
  1. procedure TfrmMain.btnOpenClick(Sender: TObject);
  2. var
  3.   VideoURL: Widestring;
  4.   lastfile: string;
  5.   lastvolume, lastpos: integer;
  6. begin
  7.   lastfile := ReadIniString('videofile', 'lastfile', '');
  8.   lastvolume := ReadIniInt('videofile', 'lastvol', trkVolume.Position);
  9.   lastpos := ReadIniInt('videofile', 'lastpos', 0);
  10.   if lastfile <> '' then
  11.   begin
  12.     dlgOpen.InitialDir := ExtractFileDir(lastfile);
  13.     dlgOpen.FileName := ExtractFileName(lastfile);
  14.   end;
  15.   if dlgOpen.Execute then
  16.   //Stuff that is done after the user selects the mp4 file still works normally..
  17.  
  18.  

At this point the dialog is shown to the user with the lastfile selected in the
right hand pane as expected.

The left hand pane is supposed to show the *parent directory* of the selected
file in a list of same level directories so it is easy to navigate to another directory in the same video library's main dir.
And this has always happened without me having to code anything else...

Not so after the switch to Windows 11!

(I have not modified the exe file of the application after the Windows upgrade.)

PROBLEM
Now on Windows 11 the right hand pane shows the defined file selected in its directory with
the other files listed too. So that is still OK.

But the left hand pane shows the ** User's Desktop content **, which is totally
irrelevant for the operation to select the next file to edit...
It *should* show the folder content of the parent directory of the selected file's dir.

QUESTIONS:
1) Is there some additional property of TOpenDialog I can set to return it to work like before?
2) Is this behavior due to the fact the application was compiled in Windows10 and it can be solved by recompiling it from Windows 11?
3) Is there some other dialog I can use to open the target file, which operates like I want?

Grateful for any help on this since it bugs me every time I use the application now.
--
Bo Berglund
Sweden

jamie

  • Hero Member
  • *****
  • Posts: 7493
Re: Is there a TOpenDialog alternative that works on Windows11?
« Reply #1 on: September 21, 2025, 08:59:13 am »
There is an alt on the Misc tab i believe that uses a listtree and listview.
The only true wisdom is knowing you know nothing

BosseB

  • Sr. Member
  • ****
  • Posts: 484
Re: Is there a TOpenDialog alternative that works on Windows11?
« Reply #2 on: September 21, 2025, 10:34:26 am »
I have installed Lazarus 4.2 on Windows 11 (after the upgrade) using fpcupdeluxe and configured it according to my notes, but in the Misc tab I don't see anything like a file_open_dialog component.
Do I have to enable something for it to be put on the Misc tab?
I cannot find anything when I look at the packages that are not installed in Package/Install-Uninstall

If there only was a way to set the target folder for the left hand pane I could easily do that before calling the execute method on the dialog.

In fact I thought that dlgOpen.InitialDir:= xxx would do that, but apparently it does not.

What somewhat works but is not so convenient is to find the up button in the dialog top bar and click that, then the right hand pane changes to the folder view of the level above and I can select the new source folder there, but the left hand pane is still unusable.
In Windows10 it was so much simpler to navigate folders at the left for the wanted file to the right....
--
Bo Berglund
Sweden

wp

  • Hero Member
  • *****
  • Posts: 13334
Re: Is there a TOpenDialog alternative that works on Windows11?
« Reply #3 on: September 21, 2025, 12:24:31 pm »
If I understand correctly, this is a setting of the Windows Explorer: Open the Explorer options ('...' > 'Options'), tab "View", scroll down to the node named like "Navigation pane" ("Navigationsbereich" in German) and "Expand to opened folder" (2nd item, "Auf geöffneten Ordner erweitern" in German).

jamie

  • Hero Member
  • *****
  • Posts: 7493
Re: Is there a TOpenDialog alternative that works on Windows11?
« Reply #4 on: September 21, 2025, 03:53:13 pm »
Maybe the TShellTreeView and TShellListView will work better in this case?

Located on the Misc TAB near the end.
Jamie
The only true wisdom is knowing you know nothing

jcmontherock

  • Sr. Member
  • ****
  • Posts: 336
Re: Is there a TOpenDialog alternative that works on Windows11?
« Reply #5 on: September 21, 2025, 05:01:04 pm »
Maybe "openDialog1.InitialDir := GetCurrentDir;" could help you if you set the current dir before.
« Last Edit: September 21, 2025, 05:10:57 pm by jcmontherock »
Windows 11 UTF8-64 - Lazarus 4.4-64 - FPC 3.2.2

BosseB

  • Sr. Member
  • ****
  • Posts: 484
Re: Is there a TOpenDialog alternative that works on Windows11?
« Reply #6 on: September 21, 2025, 05:30:53 pm »
Maybe "openDialog1.InitialDir := GetCurrentDir;" could help you.
Well that is in essence what I already am doing:

Code: Pascal  [Select][+][-]
  1. dlgOpen.InitialDir := ExtractFileDir(lastfile);

But I have seen something I did not see before when trying different tricks:

1) Use the "OpenFile" button in my application to bring up the file select dialog
2) It now shows the content of the last used file directory in the right hand pane so another file can easily be selected from that dir.
3) The left pane now shows some list of various Windows selected "folders" like Home, Videos,  Gallery etc, not as before the content of the directory parent of the last used file. Unusable!
4) If I now click the up-arrow button on the top ribbon of the dialog then:
    The right hand pane changes to show the content of the parent folder (what I wanted to see on the left from the start).
5) Now double-click the folder in the right hand pane where the last file resides.
    This brings back the original file list to the right which I had at the start.
    But now the left hand pane has switched to show the list of folders one level up from the folder with the last used file!
6) From now on the dialog works like it did originally on Windows10!

So now the problem becomes:
How can I display the dialog and perform the above click steps (in code) when the user clicks the OpenFile button?
I think that if these steps are automatically performed then the dialog when shown to the user will look as I want it to.

Any suggestions?
--
Bo Berglund
Sweden

jamie

  • Hero Member
  • *****
  • Posts: 7493
Re: Is there a TOpenDialog alternative that works on Windows11?
« Reply #7 on: September 21, 2025, 10:07:24 pm »
What does the start of an example path look like ?

you may need to include UNC naming.

Jamie
The only true wisdom is knowing you know nothing

BosseB

  • Sr. Member
  • ****
  • Posts: 484
Re: Is there a TOpenDialog alternative that works on Windows11?
« Reply #8 on: September 21, 2025, 11:08:32 pm »
What does the start of an example path look like ?
I don't really understand your question but to answer for the current setup and where the files are located:
The videos are on a Linux server device, which is mounted through samba as T:\ on Windows.
So a typical video path might be:
T:\science\stanford\Cosmology\Cosmology_Lecture_1.mp4
(this example is from 10 years back and is not subject to editing but shows the path you asked about).

I have many such video dirs below T:\ and the videos I usually operate on are in directories where the server drops them off during scheduled downloads and I go in and edit them using my app.
Quote
you may need to include UNC naming.

There is no problem with the file naming and paths, they have worked fine with the editor application since the conception of it back in 2018 or so (on Windows 10).
The issue is that a smooth work flow using the application to edit the files is now more cumbersome after migration to Windows11 because Microsoft has altered the way the Explorer works which affects standard packages/components in Lazarus/Fpc (and hence the Lazarus TOpenDialog component).
--
Bo Berglund
Sweden

jamie

  • Hero Member
  • *****
  • Posts: 7493
Re: Is there a TOpenDialog alternative that works on Windows11?
« Reply #9 on: September 21, 2025, 11:38:36 pm »
I wonder what would happen if you inserted "\\" at the start of the line?

Jamie
The only true wisdom is knowing you know nothing

BosseB

  • Sr. Member
  • ****
  • Posts: 484
Re: Is there a TOpenDialog alternative that works on Windows11?
« Reply #10 on: September 22, 2025, 08:59:39 pm »
I have had a session with ChatGPT now and tested various suggestions, none of which solved the problem.
However I have found out how to get really close without code changes, just by using the application a bit differently:

When a new file is to be opened I can do this:
- Click the OpenFile button to show the dialog
- It now displays the previously loaded file selected in the right hand pane and the other files in the same directory are also shown. But the left hand pane does not show the directory list as it did on Win10.
- Now if I click the Up-Arrow button on the explorer top ribbon the display changes on the right hand pane where it shows the directory list I wanted on the left side.
. Next I go back into the directory that I was in a moment ago by double clicking its name in the right hand pane. It now shows the files again.
- But now the left hand pane changed and is showing the directory list I have been after the whole time...

So with this Up-arrow click  followed by a double-click of the directory name the two panes are showing what I am used to from before.
A bit awkward but not very much so. It is a workaround I can live with.
--
Bo Berglund
Sweden

dseligo

  • Hero Member
  • *****
  • Posts: 1651
Re: Is there a TOpenDialog alternative that works on Windows11?
« Reply #11 on: September 23, 2025, 10:37:02 am »
I tried this and noticed something interesting. When I first executed your code in already existing directory (C:\temp\\temp) it showed directory structure on the left side. But then I created new directory (C:\temp\temp2) and now Onedrive directory is highlighted. And then is consistent, Windows somehow "knows" what is new directory and what is old - it happens the same every time. It looks like that this has something to do with Windows.

So with this Up-arrow click  followed by a double-click of the directory name the two panes are showing what I am used to from before.
A bit awkward but not very much so. It is a workaround I can live with.

You can just click on the directory name in the address field (see attachment).
« Last Edit: September 23, 2025, 10:41:23 am by dseligo »

BosseB

  • Sr. Member
  • ****
  • Posts: 484
Re: Is there a TOpenDialog alternative that works on Windows11?
« Reply #12 on: September 24, 2025, 12:26:39 am »
You can just click on the directory name in the address field (see attachment).

Even better!!!  :D 8)
Thank you for this 1-click solution!
--
Bo Berglund
Sweden

 

TinyPortal © 2005-2018