public SubclassingWindow Subclass(IntPtr hwnd) { var windowType = hwnd.ToWindowType(); if (windowType == WindowType.Indeterminate) { // Not the droids we're looking for. return(null); } if (_subclasses.TryGetValue(hwnd, out var existing)) { return(existing); } // Any additional cases also need to be added to IsSubclassable above. switch (windowType) { case WindowType.CodePane: lock (ThreadLock) { var codePane = new CodePaneSubclass(hwnd, null); _subclasses.TryAdd(hwnd, codePane); codePane.ReleasingHandle += SubclassRemoved; codePane.CaptionChanged += AssociateCodePane; SubclassLogger.Trace($"Subclassed hWnd 0x{hwnd.ToInt64():X8} as CodePane."); return(codePane); } case WindowType.DesignerWindow: lock (ThreadLock) { var designer = new DesignerWindowSubclass(hwnd); _subclasses.TryAdd(hwnd, designer); designer.ReleasingHandle += SubclassRemoved; SubclassLogger.Trace($"Subclassed hWnd 0x{hwnd.ToInt64():X8} as DesignerWindow."); return(designer); } default: return(null); } }
private DesignerWindowSubclass TrackNewDesigner(IntPtr hwnd) { var designer = new DesignerWindowSubclass(hwnd); try { if (_subclasses.TryAdd(hwnd, designer)) { designer.ReleasingHandle += SubclassRemoved; SubclassLogger.Trace($"Subclassed hWnd 0x{hwnd.ToInt64():X8} as DesignerWindow."); return(designer); } } catch (Exception ex) { SubclassLogger.Error(ex); } designer.Dispose(); return(null); }