Permalink
Browse files

Clean up code and fix possible NullReferenceException in UI.Window.Co…

…nnection.WndProc().
  • Loading branch information...
1 parent c9ca613 commit eb435bc6b0189bd558583ecce6a6586fbc9eebd3 @rmcardle rmcardle committed Nov 20, 2013
Showing with 14 additions and 13 deletions.
  1. +14 −13 mRemoteV1/UI/UI.Window.Connection.vb
@@ -954,27 +954,28 @@ Namespace UI
#End Region
#Region "Window Overrides"
- Protected Overloads Overrides Sub WndProc(ByRef WndMsg As Message)
+ Protected Overloads Overrides Sub WndProc(ByRef m As Message)
Try
- If WndMsg.Msg = Native.WM_MOUSEACTIVATE Then
- Dim curTab As Magic.Controls.TabPage = Me.TabController.SelectedTab
- Dim curRect As Rectangle = curTab.RectangleToScreen(curTab.ClientRectangle)
-
- If curRect.Contains(Form.MousePosition) Then
- If curTab IsNot Nothing Then
- Dim IC As mRemoteNG.Connection.InterfaceControl = Me.TabController.SelectedTab.Tag
-
- If IC.Info.Protocol = mRemoteNG.Connection.Protocol.Protocols.RDP Then
- IC.Protocol.Focus()
+ If m.Msg = Native.WM_MOUSEACTIVATE Then
+ Dim selectedTab As Magic.Controls.TabPage = TabController.SelectedTab
+ If selectedTab IsNot Nothing Then
+ Dim tabClientRectangle As Rectangle = selectedTab.RectangleToScreen(selectedTab.ClientRectangle)
+ If tabClientRectangle.Contains(MousePosition) Then
+ Dim interfaceControl As InterfaceControl = TryCast(TabController.SelectedTab.Tag, InterfaceControl)
+ If interfaceControl IsNot Nothing AndAlso interfaceControl.Info IsNot Nothing Then
+ If interfaceControl.Info.Protocol = Protocol.Protocols.RDP Then
+ interfaceControl.Protocol.Focus()
+ Return ' Do not pass to base class
+ End If
End If
End If
End If
- Return ' Do not pass to base class
End If
Catch ex As Exception
+ MessageCollector.AddExceptionMessage("UI.Window.Connection.WndProc() failed.", ex, , True)
End Try
- MyBase.WndProc(WndMsg)
+ MyBase.WndProc(m)
End Sub
#End Region

0 comments on commit eb435bc

Please sign in to comment.