@@ -97,6 +97,7 @@ public frmSuperPutty(string[] args)
97
97
m_hotkeys = new GlobalHotkeys ( ) ;
98
98
m_keyboard = new KeyboardListener ( this , m_hotkeys ) ;
99
99
m_titleTracker = new WindowTitleTracker ( this ) ;
100
+ registerHotkeys ( ) ;
100
101
101
102
// Check SQLite Database
102
103
openOrCreateSQLiteDatabase ( ) ;
@@ -186,7 +187,6 @@ public frmSuperPutty(string[] args)
186
187
// Set window state and size
187
188
setWindowStateAndSize ( ) ;
188
189
189
- registerHotkeys ( ) ;
190
190
191
191
focusHacks ( ) ;
192
192
}
@@ -589,7 +589,7 @@ private void selectTab(GlobalHotkeys.Purpose tabPosition)
589
589
590
590
private void selectTab ( int index )
591
591
{
592
- if ( this . children . Count > 1 )
592
+ if ( this . children . Count > 1 && this . children . Count > ( index + 1 ) )
593
593
{
594
594
this . dockPanel1 . ActiveContent . DockHandler . SetActiveTab ( index ) ;
595
595
}
@@ -895,6 +895,7 @@ private void quickConnectToolStripMenuItem_Click(object sender, EventArgs e)
895
895
private DateTime m_lastMouseDownOnTitleBar = DateTime . Now ;
896
896
private TimeSpan m_delayUntilMouseMove = new TimeSpan ( 0 , 0 , 0 , 0 , 200 ) ; // 200ms
897
897
private Point m_mouseDownLocation = new Point ( 0 , 0 ) ;
898
+ private RestoreFromMinimizedTracker m_restoreFromMinimized ;
898
899
899
900
private int GET_X_LPARAM ( int lParam )
900
901
{
@@ -911,6 +912,11 @@ private bool WndProcForFocus(ref Message m)
911
912
const int WM_NCLBUTTONDOWN = 0x00A1 ;
912
913
const int WM_NCMOUSEMOVE = 0x00A0 ;
913
914
const int WM_NCACTIVATE = 0x0086 ;
915
+ const int WM_SYSCOMMAND = 0x0112 ;
916
+
917
+ const int SC_MINIMIZE = 0xF030 ;
918
+ const int SC_RESTORE = 0xF120 ;
919
+ const int SC_DRAGMOVE = 0xF012 ;
914
920
915
921
switch ( m . Msg )
916
922
{
@@ -937,6 +943,17 @@ private bool WndProcForFocus(ref Message m)
937
943
DefWindowProc ( this . Handle , m . Msg , ( IntPtr ) 1 , m . LParam ) ;
938
944
m . Result = ( IntPtr ) 1 ;
939
945
return false ;
946
+ case WM_SYSCOMMAND :
947
+ // Removing the last 4 bits. This is necessary because
948
+ // maximizing by double click gives you 0xF032, not 0xF030.
949
+ switch ( ( int ) m . WParam & 0xFFF0 )
950
+ {
951
+ case SC_MINIMIZE :
952
+ case SC_RESTORE :
953
+ FocusCurrentTab ( ) ;
954
+ break ;
955
+ }
956
+ break ;
940
957
default :
941
958
if ( m . Msg == m_shellHookNotify )
942
959
{
@@ -973,6 +990,7 @@ private void focusHacks()
973
990
this . ResizeEnd += HandleResizeEnd ;
974
991
m_shellHookNotify = RegisterWindowMessage ( "SHELLHOOK" ) ;
975
992
RegisterShellHookWindow ( this . Handle ) ;
993
+ m_restoreFromMinimized = new RestoreFromMinimizedTracker ( this ) ;
976
994
}
977
995
978
996
// Handle various events to keep the child window focused
0 commit comments