Skip to content

Commit fb35c93

Browse files
[Settings]Fix ZoomIt page changing current directory (#37052)
1 parent eeeabc8 commit fb35c93

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

.github/actions/spell-check/expect.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,7 @@ NNN
993993
NOACTIVATE
994994
NOAGGREGATION
995995
NOASYNC
996+
NOCHANGEDIR
996997
NOCLIP
997998
NOCLOSEPROCESS
998999
NOCOALESCE

src/settings-ui/Settings.UI/Helpers/OpenFileName.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,10 @@ public class OpenFileName
3333
public IntPtr Hook = IntPtr.Zero;
3434
public string Template;
3535
}
36+
37+
// https://learn.microsoft.com/en-us/windows/win32/api/commdlg/ns-commdlg-openfilenamea
38+
public enum OpenFileNameFlags
39+
{
40+
OFN_NOCHANGEDIR = 0x00000008,
41+
}
3642
}

src/settings-ui/Settings.UI/SettingsXAML/Views/ZoomItPage.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ private static string PickFileDialog(string filter, string title, string initial
3535
openFileName.Title = title;
3636
openFileName.FilterIndex = initialFilter;
3737
openFileName.DefExt = null;
38+
openFileName.Flags = (int)OpenFileNameFlags.OFN_NOCHANGEDIR; // OFN_NOCHANGEDIR flag is needed, because otherwise GetOpenFileName overwrites the process working directory.
3839
IntPtr windowHandle = WinRT.Interop.WindowNative.GetWindowHandle(App.GetSettingsWindow());
3940
openFileName.Hwnd = windowHandle;
4041

0 commit comments

Comments
 (0)