Skip to content

Commit c343337

Browse files
committed
Improve handle getter
1 parent 907d683 commit c343337

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

Flow.Launcher.Infrastructure/QuickSwitch/Models/WindowsDialog.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,6 @@ internal class WindowsDialogTab : IQuickSwitchDialogWindowTab
109109
public WindowsDialogTab(HWND handle)
110110
{
111111
Handle = handle;
112-
GetPathControlEditor();
113-
GetFileEditor();
114-
GetOpenButton();
115112
}
116113

117114
#endregion
@@ -120,7 +117,7 @@ public WindowsDialogTab(HWND handle)
120117

121118
public string GetCurrentFolder()
122119
{
123-
if (_pathEditor.IsNull) return string.Empty;
120+
if (_pathEditor.IsNull && !GetPathControlEditor()) return string.Empty;
124121
return GetWindowText(_pathEditor);
125122
}
126123

@@ -164,7 +161,7 @@ public bool JumpFolder(string path, bool auto)
164161
return JumpFolderWithFileEditor(path, true);
165162
}
166163

167-
if (_pathEditor.IsNull && !GetPathControlEditor())
164+
if (_pathEditor.IsNull)
168165
{
169166
// Path editor cannot be found, so we can only edit file editor directly.
170167
Log.Debug(ClassName, "Path editor cannot be found, using legacy jump folder method");
@@ -207,7 +204,7 @@ public void Dispose()
207204
private bool GetPathControlEditor()
208205
{
209206
// Get the handle of the path editor
210-
// (Must use PInvoke.FindWindowEx instead of PInvoke.GetDlgItem, or ReBarWindow32 will be null)
207+
// Must use PInvoke.FindWindowEx because PInvoke.GetDlgItem(Handle, 0x0000) will get another control
211208
_pathControl = PInvoke.FindWindowEx(Handle, HWND.Null, "WorkerW", null); // 0x0000
212209
_pathControl = PInvoke.FindWindowEx(_pathControl, HWND.Null, "ReBarWindow32", null); // 0xA005
213210
_pathControl = PInvoke.FindWindowEx(_pathControl, HWND.Null, "Address Band Root", null); // 0xA205

0 commit comments

Comments
 (0)