Imports System.Runtime.InteropServices Imports System.Threading
Imports System.Runtime.InteropServices Imports System.Threading Public Class Form1 <DllImport("user32.dll")> _ Shared Function SetWindowPos(ByVal hWnd As IntPtr, ByVal hWndInsertAfter As IntPtr, ByVal X As Integer, ByVal Y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal uFlags As Integer) As Boolean End Function <DllImport("user32.dll")> _ Shared Function SetWindowText(ByVal hwnd As IntPtr, ByVal windowName As String) As Boolean End Function Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Dim process As New Process() process.StartInfo.FileName = "notepad.exe" process.Start() Thread.Sleep(100) SetWindowPos(process.MainWindowHandle, IntPtr.Zero, 0, 0, 400, 300, 0) End Sub Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click Dim process As New Process() process.StartInfo.FileName = "notepad.exe" process.Start() Thread.Sleep(100) SetWindowText(process.MainWindowHandle, "Fancy Notepad") End Sub End Class
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionPublic Class Form1 <DllImport("user32.dll")> _ Shared Function SetWindowPos(ByVal hWnd As IntPtr, ByVal hWndInsertAfter As IntPtr, ByVal X As Integer, ByVal Y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal uFlags As Integer) As Boolean End Function <DllImport("user32.dll")> _ Shared Function SetWindowText(ByVal hwnd As IntPtr, ByVal windowName As String) As Boolean End Function Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Dim process As New Process() process.StartInfo.FileName = "notepad.exe" process.Start() Thread.Sleep(100) SetWindowPos(process.MainWindowHandle, IntPtr.Zero, 0, 0, 400, 300, 0) End Sub Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click Dim process As New Process() process.StartInfo.FileName = "notepad.exe" process.Start() Thread.Sleep(100) SetWindowText(process.MainWindowHandle, "Fancy Notepad") End Sub End Class