Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed some more edge cases where intellisense was not working in latest Excel. #127

Merged
merged 1 commit into from
Jan 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions Source/ExcelDna.IntelliSense/UIMonitor/WindowWatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,14 @@ void _windowStateChangeHook_WinEventReceived(object sender, WinEventHook.WinEven
}

var className = e.WindowClassName;
var windowHandle = e.WindowHandle;

if (e.EventType == WinEventHook.WinEvent.EVENT_SYSTEM_CAPTURESTART && !string.IsNullOrEmpty(_focusedWindowClassName))
if (e.EventType == WinEventHook.WinEvent.EVENT_SYSTEM_CAPTURESTART && !string.IsNullOrEmpty(_focusedWindowClassName) && _focusedWindowHandle != IntPtr.Zero)
{
// Excel seems to always send this event to the XLMAIN window. However, it relates to user actions that happens inside the currently focused window.
// Thus, we relay this event to our recollection of the currently focused window.
className = _focusedWindowClassName;
windowHandle = _focusedWindowHandle;
}

// Debug.Print("### Thread receiving WindowStateChange: " + Thread.CurrentThread.ManagedThreadId);
Expand All @@ -250,16 +252,16 @@ void _windowStateChangeHook_WinEventReceived(object sender, WinEventHook.WinEven
// }
// break;
case _popupListClass:
PopupListWindowChanged?.Invoke(this, new WindowChangedEventArgs(e.WindowHandle, e.EventType, e.ObjectId));
PopupListWindowChanged?.Invoke(this, new WindowChangedEventArgs(windowHandle, e.EventType, e.ObjectId));
break;
case _inCellEditClass:
InCellEditWindowChanged?.Invoke(this, new WindowChangedEventArgs(e.WindowHandle, e.EventType, e.ObjectId));
InCellEditWindowChanged?.Invoke(this, new WindowChangedEventArgs(windowHandle, e.EventType, e.ObjectId));
break;
case _formulaBarClass:
FormulaBarWindowChanged?.Invoke(this, new WindowChangedEventArgs(e.WindowHandle, e.EventType, e.ObjectId));
FormulaBarWindowChanged?.Invoke(this, new WindowChangedEventArgs(windowHandle, e.EventType, e.ObjectId));
break;
case _excelToolTipClass:
ExcelToolTipWindowChanged?.Invoke(this, new WindowChangedEventArgs(e.WindowHandle, e.EventType, e.ObjectId));
ExcelToolTipWindowChanged?.Invoke(this, new WindowChangedEventArgs(windowHandle, e.EventType, e.ObjectId));
break;
//case _nuiDialogClass:
// // Debug.Print($"SelectDataSource {_selectDataSourceClass} Window update: {e.WindowHandle:X}, EventType: {e.EventType}, idChild: {e.ChildId}");
Expand Down