Skip to content

Commit d24ed82

Browse files
committed
Only subclass code windows and designers.
1 parent ed27dce commit d24ed82

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Rubberduck.VBEEditor/Events/VBENativeServices.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,13 @@ public static void VbeEventCallback(IntPtr hWinEventHook, uint eventType, IntPtr
7373
{
7474
OnSelectionChanged(hwnd);
7575
}
76-
else if (idObject == (int)ObjId.Window &&
77-
(eventType == (uint)WinEvent.ObjectCreate || eventType == (uint)WinEvent.ObjectDestroy) &&
78-
hwnd.ToWindowType() != WindowType.Indeterminate)
76+
else if (idObject == (int)ObjId.Window && (eventType == (uint)WinEvent.ObjectCreate || eventType == (uint)WinEvent.ObjectDestroy))
7977
{
78+
var type = hwnd.ToWindowType();
79+
if (type != WindowType.DesignerWindow && type != WindowType.VbaWindow)
80+
{
81+
return;
82+
}
8083
if (eventType == (uint) WinEvent.ObjectCreate)
8184
{
8285
AttachWindow(hwnd);
@@ -90,6 +93,7 @@ public static void VbeEventCallback(IntPtr hWinEventHook, uint eventType, IntPtr
9093
{
9194
//Test to see if it was a selection change in the project window.
9295
var parent = User32.GetParent(hwnd);
96+
//TODO: Need to test to see if the Project window is active before raising this.
9397
if (parent != IntPtr.Zero && parent.ToWindowType() == WindowType.Project)
9498
{
9599
FocusDispatcher(_vbe, new WindowChangedEventArgs(parent, null, null, FocusType.ChildFocus));

0 commit comments

Comments
 (0)