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

#124 Troubleshoot IntelliSense arguments tooltip not appearing issue … #130

Merged
Show file tree
Hide file tree
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
10 changes: 8 additions & 2 deletions Source/ExcelDna.IntelliSense/UIMonitor/WinEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,9 @@ void HandleWinEvent(IntPtr hWinEventHook, WinEvent eventType, IntPtr hWnd,
if (_hWndFilterOrZero != IntPtr.Zero && hWnd != _hWndFilterOrZero)
return;

if (!IsSupportedWinEvent(eventType) || idObject == WinEventObjectId.OBJID_CURSOR || hWnd == IntPtr.Zero)
if (!IsSupportedWinEvent(eventType, idObject)
|| idObject == WinEventObjectId.OBJID_CURSOR
|| hWnd == IntPtr.Zero)
return;

// Moving the GetClassName call here where the main thread is running.
Expand All @@ -209,7 +211,7 @@ void HandleWinEvent(IntPtr hWinEventHook, WinEvent eventType, IntPtr hWnd,
}

// A quick filter that runs on the Excel main thread (or other thread handling the WinEvent)
bool IsSupportedWinEvent(WinEvent winEvent)
bool IsSupportedWinEvent(WinEvent winEvent, WinEventObjectId idObject)
{
return winEvent == WinEvent.EVENT_OBJECT_CREATE ||
// winEvent == WinEvent.EVENT_OBJECT_DESTROY || // Stopped watching for this, because we can't route using the ClassName and don't really need anymore
Expand All @@ -219,6 +221,10 @@ bool IsSupportedWinEvent(WinEvent winEvent)
winEvent == WinEvent.EVENT_SYSTEM_MOVESIZESTART || // Only for the on-demand hook
winEvent == WinEvent.EVENT_SYSTEM_MOVESIZEEND || // Only for the on-demand hook
winEvent == WinEvent.EVENT_OBJECT_SELECTION || // Only for the PopupList
// NB: Including the next event 'EVENT_OBJECT_LOCATIONCHANGE (0x800B = 32779)' without the check for 'OBJID_CARET'
// will cause the Excel main window to lag when dragging.
// This drag issue seems to have been introduced with an Office update around November 2022.
(winEvent == WinEvent.EVENT_OBJECT_LOCATIONCHANGE && idObject == WinEventObjectId.OBJID_CARET) ||
winEvent == WinEvent.EVENT_SYSTEM_CAPTURESTART;
}

Expand Down
5 changes: 2 additions & 3 deletions Source/ExcelDna.IntelliSense/UIMonitor/WindowWatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ internal WindowChangedEventArgs(IntPtr windowHandle, WinEventHook.WinEvent winEv
case WinEventHook.WinEvent.EVENT_OBJECT_FOCUS:
Type = ChangeType.Focus;
break;
case WinEventHook.WinEvent.EVENT_OBJECT_LOCATIONCHANGE:
case WinEventHook.WinEvent.EVENT_SYSTEM_MOVESIZEEND:
Type = ChangeType.LocationChange;
break;
Expand Down Expand Up @@ -151,9 +152,7 @@ public WindowWatcher(SynchronizationContext syncContextAuto, SynchronizationCont
// EVENT_OBJECT_SELECTIONREMOVE
// EVENT_OBJECT_SELECTIONWITHIN
// EVENT_OBJECT_STATECHANGE (0x800A = 32778)
// NB: Including the next event 'EVENT_OBJECT_LOCATIONCHANGE (0x800B = 32779)' will cause the Excel main window to lag when dragging.
// This drag issue seems to have been introduced with an Office update around November 2022.
_windowStateChangeHooks.Add(new WinEventHook(WinEventHook.WinEvent.EVENT_OBJECT_CREATE, WinEventHook.WinEvent.EVENT_OBJECT_STATECHANGE, syncContextAuto, syncContextMain, IntPtr.Zero));
_windowStateChangeHooks.Add(new WinEventHook(WinEventHook.WinEvent.EVENT_OBJECT_CREATE, WinEventHook.WinEvent.EVENT_OBJECT_LOCATIONCHANGE, syncContextAuto, syncContextMain, IntPtr.Zero));
_windowStateChangeHooks.Add(new WinEventHook(WinEventHook.WinEvent.EVENT_SYSTEM_CAPTURESTART, WinEventHook.WinEvent.EVENT_SYSTEM_CAPTURESTART, syncContextAuto, syncContextMain, IntPtr.Zero));

foreach (var windowStateChangeHook in _windowStateChangeHooks)
Expand Down