Bonjour,
Ouvrir une appli (Ex. : NotePad) à partir d'une Form et en Maximized est simple, et ouvrir une appli dans le Panel d'une Form est évoqué ici :
http://www.developpez.net/forums/d83...terne-winform/
et ici :
http://www.developpez.net/forums/d93...ulaire-vb-net/
Donc séparément on peut faire l'un ou l'autre, ouvrir une Appli en mode Maximized, et ouvrir et contenir une Appli dans le Panel d'une Form.
Mais comment combiner les deux, autant être propre, non ?
Mon code, en premier :
1 2
| Imports System.Diagnostics
Imports System.Runtime.InteropServices |
Pour l'utilisation de la méthode "SetParent" :
Public Declare Function SetParent Lib "user32.dll" (ByVal hWndChild As Int32, ByVal hWndNewParent As Int32) As Boolean
Dans le Click d'un bouton :
1 2 3 4 5 6 7 8 9 10 11 12 13
| Dim runProcess As New System.Diagnostics.Process
Dim info As New System.Diagnostics.ProcessStartInfo
info.FileName = "NotePad.exe"
' La ligne suivante devrait mettre NotePad en Maxi dans la Form mais n'a aucun effet ici :
info.WindowStyle = ProcessWindowStyle.Maximized
runProcess = Process.Start(info)
runProcess.WaitForInputIdle()
While runProcess.MainWindowHandle = IntPtr.Zero OrElse String.IsNullOrEmpty(runProcess.MainWindowTitle)
Thread.Sleep(100)
runProcess.Refresh()
End While
'Ici Notepad est incorporé au Panel2 :
SetParent(runProcess.MainWindowHandle, Panel2.Handle) |
Merci d'avance pour votre aide.
VS 2008 Express – VB.Net – Framework 3,5
Partager