Skip to content

Commit

Permalink
[Settings]Fix ZoomIt page changing current directory (#37052)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaimecbernardo authored Jan 24, 2025
1 parent eeeabc8 commit fb35c93
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/actions/spell-check/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,7 @@ NNN
NOACTIVATE
NOAGGREGATION
NOASYNC
NOCHANGEDIR
NOCLIP
NOCLOSEPROCESS
NOCOALESCE
Expand Down
6 changes: 6 additions & 0 deletions src/settings-ui/Settings.UI/Helpers/OpenFileName.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,10 @@ public class OpenFileName
public IntPtr Hook = IntPtr.Zero;
public string Template;
}

// https://learn.microsoft.com/en-us/windows/win32/api/commdlg/ns-commdlg-openfilenamea
public enum OpenFileNameFlags
{
OFN_NOCHANGEDIR = 0x00000008,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ private static string PickFileDialog(string filter, string title, string initial
openFileName.Title = title;
openFileName.FilterIndex = initialFilter;
openFileName.DefExt = null;
openFileName.Flags = (int)OpenFileNameFlags.OFN_NOCHANGEDIR; // OFN_NOCHANGEDIR flag is needed, because otherwise GetOpenFileName overwrites the process working directory.
IntPtr windowHandle = WinRT.Interop.WindowNative.GetWindowHandle(App.GetSettingsWindow());
openFileName.Hwnd = windowHandle;

Expand Down

0 comments on commit fb35c93

Please sign in to comment.