Skip to content

Commit 642d07d

Browse files
committed
Add logger to the ParentWindow subclass.
1 parent e5f460e commit 642d07d

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Rubberduck.Main/ComClientLibrary/UI/DockableWindowHost.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ private void RemoveChildControlsFromExposedControl()
146146
public int /* IOleObject:: */ Close([In] uint dwSaveOption)
147147
{
148148
_logger.Log(LogLevel.Trace, "IOleObject::Close() called");
149-
int hr = _userControl.IOleObject.Close(dwSaveOption);
149+
var hr = _userControl.IOleObject.Close(dwSaveOption);
150150

151151
// IOleObject::SetClientSite is typically called with pClientSite = null just before calling IOleObject::Close()
152152
// If it didn't, we release all host COM objects here instead,
@@ -438,6 +438,8 @@ private static void ToggleDockable(IntPtr hWndVBE)
438438
[ComVisible(false)]
439439
public class ParentWindow : SubclassingWindow
440440
{
441+
private readonly Logger _logger = LogManager.GetCurrentClassLogger();
442+
441443
private const int MF_BYPOSITION = 0x400;
442444

443445
public event SubClassingWindowEventHandler CallBackEvent;
@@ -484,20 +486,20 @@ private void DisplayUndockableContextMenu(IntPtr handle, IntPtr lParam)
484486

485487
if (_menuHandle == IntPtr.Zero)
486488
{
487-
Debug.Print("Cannot create menu handle");
489+
_logger.Warn("Cannot create menu handle");
488490
return;
489491
}
490492

491493
if (!NativeMethods.InsertMenu(_menuHandle, 0, MF_BYPOSITION, (UIntPtr)WM.RUBBERDUCK_UNDOCKABLE_CONTEXT_MENU, "Dockable" + char.MinValue))
492494
{
493-
Debug.Print("Failed to insert a menu item for dockable command");
495+
_logger.Warn("Failed to insert a menu item for dockable command");
494496
}
495497
}
496498

497499
var param = new LParam {Value = (uint)lParam};
498500
if (!NativeMethods.TrackPopupMenuEx(_menuHandle, 0x0, param.LowWord, param.HighWord, handle, IntPtr.Zero ))
499501
{
500-
Debug.Print("Failed to set the context menu for undockable tool windows");
502+
_logger.Warn("Failed to set the context menu for undockable tool windows");
501503
};
502504
}
503505

@@ -553,7 +555,7 @@ public override int SubClassProc(IntPtr hWnd, IntPtr msg, IntPtr wParam, IntPtr
553555
{
554556
if (!NativeMethods.DestroyMenu(_menuHandle))
555557
{
556-
Debug.Print($"Failed to destroy the menu handle {_menuHandle}");
558+
_logger.Fatal($"Failed to destroy the menu handle {_menuHandle}");
557559
}
558560
}
559561
break;

0 commit comments

Comments
 (0)