Problème de focus ...
Panel1.Focus()
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionOption Explicit On ' putty Imports System.Runtime.InteropServices Public Class Form1 <DllImport("user32.dll")> _ Public Shared Function GetForegroundWindow() As IntPtr End Function <DllImport("user32.dll", SetLastError:=True)> _ Public Shared Function SetParent(ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As Long End Function <DllImport("user32")> _ Public Shared Function ShowWindow(ByVal hWnd As IntPtr, ByVal nCmdShow As Integer) As Integer End Function <DllImport("user32.dll", SetLastError:=True)> _ Public Shared Function MoveWindow(ByVal hWnd As IntPtr, ByVal x As Integer, ByVal y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal repaint As Boolean) As Boolean End Function Public Const SWP_NOOWNERZORDER As Integer = 512 Public Const SWP_NOREDRAW As Integer = 8 Public Const SWP_NOZORDER As Integer = 4 Public Const SWP_SHOWWINDOW As Integer = 64 Public Const WS_EX_MDICHILD As Integer = 64 Public Const SWP_FRAMECHANGED As Integer = 32 Public Const SWP_NOACTIVATE As Integer = 16 Public Const SWP_ASYNCWINDOWPOS As Integer = 16384 Public Const SWP_NOMOVE As Integer = 2 Public Const SWP_NOSIZE As Integer = 1 Public Const GWL_STYLE As Integer = (-16) Public Const WS_VISIBLE As Integer = 268435456 Public Const WM_CLOSE As Integer = 16 Public Const WS_CHILD As Integer = 1073741824 Public Const WS_MAXIMIZE As Integer = 16777216 Public Const SW_SHOWMAXIMIZED As Integer = 3 Public Const SW_RESTORE As Integer = 9 Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click ' lance putty Dim PuttyProcess As New Process PuttyProcess.StartInfo.FileName = "C:\Program Files (x86)\PuTTY\PuTTY.exe" ' Localisation de l'exécutable de PUTTY PuttyProcess.StartInfo.Arguments = "-ssh -P 22 ""nom_ou_ip_du_serveur_ssh"" -l ""root""" ' ARGV PuttyProcess.EnableRaisingEvents = True PuttyProcess.Start() ' go PuttyProcess.WaitForInputIdle() SetParent(PuttyProcess.MainWindowHandle, Me.Panel1.Handle) ' Ratachement fenetre au Handle Form ShowWindow(PuttyProcess.MainWindowHandle, SW_SHOWMAXIMIZED) End Sub End Class
j'ai l'impression que Putty perd son focus à partir du moment ou l'on clique ailleurs dans la fenêtre
ucfoutu : Non, c'est pas qu'une impression... Il perd bien le focus, ce que j'aimerai éviter.
' putty form 1 Option Explicit On Imports System.Runtime.InteropServices Imports System.Security.Permissions Public Class Form1 #Region "Dll Imports" <DllImport("user32.dll")> _ Public Shared Function GetForegroundWindow() As IntPtr End Function <DllImport("user32.dll", SetLastError:=True)> _ Public Shared Function SetParent(ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As Long End Function <DllImport("user32")> _ Public Shared Function ShowWindow(ByVal hWnd As IntPtr, ByVal nCmdShow As Integer) As Integer End Function <DllImport("user32.dll", SetLastError:=True)> _ Public Shared Function MoveWindow(ByVal hWnd As IntPtr, ByVal x As Integer, ByVal y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal repaint As Boolean) As Boolean End Function #End Region #Region "Constants" Public Const SWP_NOOWNERZORDER As Integer = 512 Public Const SWP_NOREDRAW As Integer = 8 Public Const SWP_NOZORDER As Integer = 4 Public Const SWP_SHOWWINDOW As Integer = 64 Public Const WS_EX_MDICHILD As Integer = 64 Public Const SWP_FRAMECHANGED As Integer = 32 Public Const SWP_NOACTIVATE As Integer = 16 Public Const SWP_ASYNCWINDOWPOS As Integer = 16384 Public Const SWP_NOMOVE As Integer = 2 Public Const SWP_NOSIZE As Integer = 1 Public Const GWL_STYLE As Integer = (-16) Public Const WS_VISIBLE As Integer = 268435456 Public Const WM_CLOSE As Integer = 16 Public Const WS_CHILD As Integer = 1073741824 Public Const WS_MAXIMIZE As Integer = 16777216 Public Const SW_SHOWMAXIMIZED As Integer = 3 Public Const SW_RESTORE As Integer = 9 #End Region Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Dim PuttyProcess As New Process PuttyProcess.StartInfo.FileName = My.Application.Info.DirectoryPath & "\PuTTY.exe" ' ...\bin\... PuttyProcess.StartInfo.Arguments = "-ssh -P 22 ""ftp.premium.ovh.net""" PuttyProcess.EnableRaisingEvents = True PuttyProcess.Start() PuttyProcess.WaitForInputIdle() SetParent(PuttyProcess.MainWindowHandle, Me.Panel1.Handle) ShowWindow(PuttyProcess.MainWindowHandle, SW_SHOWMAXIMIZED) End Sub End Class