Skip to content

Commit

Permalink
Merge remote branch 'remotes/thrilleratplay/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Riley McArdle committed Mar 31, 2011
2 parents 07ea389 + 2f60379 commit a798785
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 24 deletions.
16 changes: 16 additions & 0 deletions mRemoteV1/App/App.Native.vb
Expand Up @@ -90,6 +90,22 @@ Namespace App
<DllImport("user32")> _
Public Shared Function PostMessage(ByVal hWnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Long
End Function

<DllImport("user32")> _
Public Shared Function RegisterHotKey(ByVal Handle As IntPtr, ByVal ID As Integer, ByVal Modifier As Integer, ByVal Key As Integer) As Integer
End Function

<DllImport("user32")> _
Public Shared Function UnregisterHotKey(ByVal Handle As IntPtr, ByVal ID As Integer) As Integer
End Function

<DllImport("kernel32")> _
Public Shared Function GlobalAddAtom(ByVal lpString As String) As Integer
End Function

<DllImport("kernel32")> _
Public Shared Function GlobalDeleteAtom(ByVal nAtom As Integer) As Integer
End Function
#End Region

#Region "Constants"
Expand Down
84 changes: 84 additions & 0 deletions mRemoteV1/App/App.Runtime.vb
Expand Up @@ -3,9 +3,11 @@ Imports System.IO
Imports Crownwood
Imports System.Threading
Imports System.Xml
Imports mRemoteNG.App.Native

Namespace App
Public Class Runtime

#Region "Public Declarations"
Public Shared sL As Config.Settings.Load
Public Shared sS As Config.Settings.Save
Expand Down Expand Up @@ -38,8 +40,43 @@ Namespace App
Public Shared DefaultInheritance As mRemoteNG.Connection.Info.Inheritance

Public Shared ExtApps As New ArrayList()

'HotKeys
Public Shared HotKey_CtrlTab As clsHotKeyRegister
#End Region

Public NotInheritable Class clsHotKeyRegister : Inherits NativeWindow
Private atomID As Integer

Event Pressed(ByVal ID As Integer)

Sub New(ByVal Modifier As ModifierKey, ByVal Key As Keys)
CreateHandle(New CreateParams)
atomID = GlobalAddAtom(GetHashCode())
RegisterHotKey(Handle, atomID, Modifier, Key)
End Sub

Sub Unregister()
UnregisterHotKey(Handle, atomID)
End Sub

Protected Overrides Sub WndProc(ByRef M As Message)
If M.Msg = 786 Then 'W_HOTKEY
If ForegroundWindowRealtedToAppInstance() Then
RaiseEvent Pressed(M.WParam.ToInt32)
End If
End If
MyBase.WndProc(M)
End Sub

Public Enum ModifierKey
'None = 0 'Not a good idea to use, commenting out
Alt = 1
Ctrl = 2
Shift = 4
End Enum
End Class

Public Class Windows
Public Shared treeForm As UI.Window.Tree
Public Shared treePanel As New DockContent
Expand Down Expand Up @@ -250,6 +287,11 @@ Namespace App
log = log4net.LogManager.GetLogger("mRemoteNG.Log")
End Sub

Public Shared Sub RegisterHotKeys()
'Register HotKey
HotKey_CtrlTab = New clsHotKeyRegister(clsHotKeyRegister.ModifierKey.Ctrl, Keys.Tab)
End Sub

Public Shared Sub UpdateCheck()
If My.Settings.CheckForUpdatesAsked And My.Settings.CheckForUpdatesOnStartup Then
If My.Settings.UpdatePending Or My.Settings.CheckForUpdatesLastCheck < Date.Now.Subtract(TimeSpan.FromDays(My.Settings.CheckForUpdatesFrequencyDays)) Then
Expand Down Expand Up @@ -413,7 +455,10 @@ Namespace App
' ToDo: Change Report.log location
File.Delete(My.Application.Info.DirectoryPath & "\Report.log")
End If

End If
'Unregister Hotkey
HotKey_CtrlTab.Unregister()

sS.Save()
Catch ex As Exception
Expand Down Expand Up @@ -1658,6 +1703,45 @@ Namespace App
End If
Next
End Sub

'Determine if the Foreground window is current instance of mRemoteNG, Contained Putty instance or Contained External App instance
Public Shared Function ForegroundWindowRealtedToAppInstance() As Boolean
If GetForegroundWindow() = frmMain.Handle Then
Return True
End If

For Each conns As Connection.Info In cL
For Each openCon As Connection.Protocol.Base In conns.OpenConnections
Select Case openCon.InterfaceControl.Info.Protocol
Case Connection.Protocol.Protocols.SSH1
If TryCast(openCon.InterfaceControl.Protocol, Connection.Protocol.PuttyBase).PuttyHandle = GetForegroundWindow() Then
Return True
End If
Case Connection.Protocol.Protocols.SSH2
If TryCast(openCon.InterfaceControl.Protocol, Connection.Protocol.PuttyBase).PuttyHandle = GetForegroundWindow() Then
Return True
End If
Case Connection.Protocol.Protocols.RAW
If TryCast(openCon.InterfaceControl.Protocol, Connection.Protocol.PuttyBase).PuttyHandle = GetForegroundWindow() Then
Return True
End If
Case Connection.Protocol.Protocols.Rlogin
If TryCast(openCon.InterfaceControl.Protocol, Connection.Protocol.PuttyBase).PuttyHandle = GetForegroundWindow() Then
Return True
End If
Case Connection.Protocol.Protocols.Telnet
If TryCast(openCon.InterfaceControl.Protocol, Connection.Protocol.PuttyBase).PuttyHandle = GetForegroundWindow() Then
Return True
End If
Case Connection.Protocol.Protocols.IntApp
If TryCast(openCon.InterfaceControl.Protocol, Connection.Protocol.IntApp).IntAppHandle = GetForegroundWindow() Then
Return True
End If
End Select
Next
Next
Return False
End Function
#End Region

#Region "SQL Watcher"
Expand Down
2 changes: 2 additions & 0 deletions mRemoteV1/Forms/frmMain.vb
Expand Up @@ -24,6 +24,8 @@ Public Class frmMain

Startup.CreateLogger()

Startup.RegisterHotKeys()

' Load GUI Configuration
sL.Load()

Expand Down
Binary file modified mRemoteV1/References/VncSharpNG.dll
Binary file not shown.
15 changes: 15 additions & 0 deletions mRemoteV1/UI/UI.Window.Connection.vb
Expand Up @@ -226,8 +226,23 @@ Namespace UI
Me.InitializeComponent()
Me.Text = FormText
Me.TabText = FormText

AddHandler mRemoteNG.App.Runtime.HotKey_CtrlTab.Pressed, AddressOf CtrlTabHK_Press
End Sub

Protected Sub CtrlTabHK_Press(ByVal sender As Integer)
With Me.TabController
If .TabPages.Count > 1 And Me.Visible Then
If .TabPages.Count = .SelectedIndex + 1 Then
.SelectedIndex = 0
Else
.SelectedIndex = .SelectedIndex + 1
End If
FocusIC()
RefreshIC()
End If
End With
End Sub
Public Function AddConnectionTab(ByVal conI As mRemoteNG.Connection.Info) As Magic.Controls.TabPage
Try
Dim nTab As New Magic.Controls.TabPage
Expand Down
36 changes: 12 additions & 24 deletions mRemoteV1/mRemoteV1.vbproj
Expand Up @@ -92,6 +92,10 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>References\ADTree.dll</HintPath>
</Reference>
<Reference Include="AxInterop.WFICALib, Version=2.5.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>do not check in\AxInterop.WFICALib.dll</HintPath>
</Reference>
<Reference Include="DiffieHellman, Version=0.0.0.0, Culture=neutral">
<SpecificVersion>False</SpecificVersion>
<HintPath>References\DiffieHellman.dll</HintPath>
Expand All @@ -100,6 +104,14 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>References\FilteredPropertyGrid.dll</HintPath>
</Reference>
<Reference Include="Interop.EOLWTSCOM, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>do not check in\Interop.EOLWTSCOM.dll</HintPath>
</Reference>
<Reference Include="Interop.WFICALib, Version=2.5.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>do not check in\Interop.WFICALib.dll</HintPath>
</Reference>
<Reference Include="IPTextBox, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>References\IPTextBox.dll</HintPath>
Expand Down Expand Up @@ -894,22 +906,6 @@
<WrapperTool>aximp</WrapperTool>
<Isolated>False</Isolated>
</COMReference>
<COMReference Include="AxWFICALib">
<Guid>{238F6F80-B8B4-11CF-8771-00A024541EE3}</Guid>
<VersionMajor>2</VersionMajor>
<VersionMinor>7</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>aximp</WrapperTool>
<Isolated>False</Isolated>
</COMReference>
<COMReference Include="EOLWTSCOM">
<Guid>{96C3FA7A-3211-4D93-BFEA-4589DA4ABDE2}</Guid>
<VersionMajor>1</VersionMajor>
<VersionMinor>0</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>tlbimp</WrapperTool>
<Isolated>False</Isolated>
</COMReference>
<COMReference Include="MSTSCLib">
<Guid>{8C11EFA1-92C3-11D1-BC1E-00C04FA31489}</Guid>
<VersionMajor>1</VersionMajor>
Expand All @@ -934,14 +930,6 @@
<WrapperTool>primary</WrapperTool>
<Isolated>False</Isolated>
</COMReference>
<COMReference Include="WFICALib">
<Guid>{238F6F80-B8B4-11CF-8771-00A024541EE3}</Guid>
<VersionMajor>2</VersionMajor>
<VersionMinor>7</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>tlbimp</WrapperTool>
<Isolated>False</Isolated>
</COMReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.VisualBasic.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down

0 comments on commit a798785

Please sign in to comment.