1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
Imports System
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.Runtime.InteropServices
Imports System.Diagnostics
Imports System.Threading
Partial Public Class Form1
Inherits Form
<DllImport("user32.dll", CharSet:=CharSet.Auto)>
Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal Msg As UInt32, ByVal wParam As Integer, ByVal lParam As Integer) As IntPtr
End Function
<DllImport("user32.dll", SetLastError:=True)>
Shared Function SetParent(ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As IntPtr
End Function
Public Sub New()
InitializeComponent()
End Sub
Private Sub Button1_Click_1(sender As Object, e As EventArgs)
Const WM_SYSCOMMAND As Integer = &H112
Const SC_MINIMIZE As Integer = &HF020
Const SC_MAXIMIZE As Integer = &HF030
Dim p As Process = Process.Start(New ProcessStartInfo() With {.FileName = "cmd.exe", .WindowStyle = ProcessWindowStyle.Minimized})
Thread.Sleep(500)
Dim value As IntPtr = SetParent(p.MainWindowHandle, Panel1.Handle)
SendMessage(p.MainWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0)
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Const WM_SYSCOMMAND As Integer = &H112
Const SC_MINIMIZE As Integer = &HF020
Const SC_MAXIMIZE As Integer = &HF030
Dim p As Process = Process.Start(New ProcessStartInfo() With {.FileName = "cmd.exe", .WindowStyle = ProcessWindowStyle.Minimized})
Thread.Sleep(500)
Dim value As IntPtr = SetParent(p.MainWindowHandle, Panel1.Handle)
SendMessage(p.MainWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0)
End Sub
Private Sub Form1_SizeChanged(sender As Object, e As EventArgs) Handles MyBase.SizeChanged
Timer1.Start()
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Const WM_SYSCOMMAND As Integer = &H112
Const SC_MINIMIZE As Integer = &HF020
Const SC_MAXIMIZE As Integer = &HF030
Dim p As Process = Process.Start(New ProcessStartInfo() With {.FileName = "cmd.exe", .WindowStyle = ProcessWindowStyle.Minimized})
Thread.Sleep(500)
Dim value As IntPtr = SetParent(p.MainWindowHandle, Panel1.Handle)
SendMessage(p.MainWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0)
Timer1.Stop()
End Sub
End Class |
Partager