Skip to content

Commit 69dd6f1

Browse files
committed
#124 Update comments
1 parent 78aa148 commit 69dd6f1

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

Source/ExcelDna.IntelliSense/UIMonitor/WindowLocationWatcher.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,16 @@ public class WindowLocationWatcher : IDisposable
1515
public event EventHandler LocationChanged;
1616

1717
// NOTE: An earlier attempt was to monitor LOCATIONCHANGE only between EVENT_SYSTEM_MOVESIZESTART and EVENT_SYSTEM_MOVESIZEEND
18+
// (for the purpose of moving the tooltip to the correct position when the user moves the Excel main window)
1819
// This nearly worked, and meant we were watching many fewer events ...
1920
// ...but we missed some of the resizing events for the window, leaving our tooltip stranded.
20-
// So until we can find a workaround for that (perhaps a timer would work fine for this), we watch all the LOCATIONCHANGE events.
21+
// We then started to watch all the LOCATIONCHANGE events, but it caused the Excel main window to lag when dragging.
22+
// (This drag issue seems to have been introduced with an Office update around November 2022)
23+
// So until we can find a workaround for that (perhaps a timer would work fine for this), we decided not to bother
24+
// with tracking the tooltip position (we still update it as soon as the Excel main window moving ends).
25+
// We still need to watch the LOCATIONCHANGE events, otherwise the tooltip is not shown at all in some cases.
26+
// To workaround the Excel main window lagging, we unhook from LOCATIONCHANGE upon encountering EVENT_SYSTEM_MOVESIZESTART
27+
// and then hook again upon encountering EVENT_SYSTEM_MOVESIZEEND (see UnhookFromLocationChangeUponDraggingExcelMainWindow).
2128
public WindowLocationWatcher(IntPtr hWnd, SynchronizationContext syncContextAuto, SynchronizationContext syncContextMain)
2229
{
2330
_hWnd = hWnd;
@@ -31,10 +38,7 @@ public WindowLocationWatcher(IntPtr hWnd, SynchronizationContext syncContextAuto
3138

3239
void SetUpLocationChangeEventListener()
3340
{
34-
// NB: Including the next event 'EVENT_OBJECT_LOCATIONCHANGE (0x800B = 32779)' will cause the Excel main window to lag when dragging.
35-
// This drag issue seems to have been introduced with an Office update around November 2022.
36-
// To workaround this, we unhook from this event upon encountering EVENT_SYSTEM_MOVESIZESTART and then hook again upon encountering
37-
// EVENT_SYSTEM_MOVESIZEEND (see UnhookFromLocationChangeUponDraggingExcelMainWindow).
41+
3842
_locationChangeEventHook = new WinEventHook(WinEventHook.WinEvent.EVENT_OBJECT_LOCATIONCHANGE, WinEventHook.WinEvent.EVENT_OBJECT_LOCATIONCHANGE, _syncContextAuto, _syncContextMain, IntPtr.Zero);
3943
_locationChangeEventHook.WinEventReceived += _windowMoveSizeHook_WinEventReceived;
4044
}

0 commit comments

Comments
 (0)