diff --git a/SuperPutty/frmSuperPutty.cs b/SuperPutty/frmSuperPutty.cs index 14f43de..866c44f 100755 --- a/SuperPutty/frmSuperPutty.cs +++ b/SuperPutty/frmSuperPutty.cs @@ -277,9 +277,16 @@ public bool IsActiveDocument(ctlPuttyPanel panel) /// private void dockPanel1_ActiveDocumentChanged(object sender, EventArgs e) { - FocusCurrentTab(); - dockPanel1.ActiveDocument.TabTextColor = null; - dockPanel1.ActiveDocument.DockHandler.RefreshPaneChanges(); + if (dockPanel1.ActiveDocument != null) + { + FocusCurrentTab(); + dockPanel1.ActiveDocument.TabTextColor = null; + dockPanel1.ActiveDocument.DockHandler.RefreshPaneChanges(); + } + else + { + this.Focus(); + } } private void frmSuperPutty_Activated(object sender, EventArgs e) @@ -447,7 +454,7 @@ public void CreatePuttyPanel(SessionData sessionData, bool isPutty) this.BeginInvoke((MethodInvoker)delegate() { sessionPanel.Close(); - }); + }); } else { @@ -458,6 +465,7 @@ public void CreatePuttyPanel(SessionData sessionData, bool isPutty) sessionPanel = new ctlPuttyPanel(this, sessionData, callback, isPutty); sessionPanel.Show(dockPanel1, sessionData.LastDockstate); + FocusCurrentTab(); } private void newMintty_Click(object sender, EventArgs e)