كود :
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
For Each Resize As Process In Process.GetProcessesByName("HiPlayer")
If ComboBox1.SelectedItem = ("640 × 480") Then
End If
If ComboBox1.SelectedItem = ("800 × 600") Then
End If
If ComboBox1.SelectedItem = ("1024 × 768") Then
End If
If ComboBox1.SelectedItem = ("1600 × 1200") Then
End If
If ComboBox1.SelectedItem = (Screen.PrimaryScreen.Bounds.Width & " × " & Screen.PrimaryScreen.Bounds.Height) Then
End If
Next
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ComboBox1.Items.Add("640 × 480")
ComboBox1.Items.Add("800 × 600")
ComboBox1.Items.Add("1024 × 768")
ComboBox1.Items.Add("1600 × 1200")
ComboBox1.Items.Add(Screen.PrimaryScreen.Bounds.Width & " × " & Screen.PrimaryScreen.Bounds.Height)
End Sub
ما الكزد الذى يضاف لى هضا الكود لكي يغير حجم البرنامج
كود :
Private Declare Function GetForegroundWindow Lib "user32.dll" () As IntPtr
Private Declare Function GetWindowThreadProcessId Lib "user32.dll" (ByVal ByValhwnd As IntPtr, ByRef lpdwProcessID As Integer) As Integer
Dim _focusedWindow As IntPtr = GetForegroundWindow()
Dim _activeWindowName As String
Dim _processID As Integer = 0
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim _focusedWindow As IntPtr = GetForegroundWindow()
If _focusedWindow <> IntPtr.Zero Then
If GetWindowThreadProcessId(_focusedWindow, _processID) <> 0 Then
Dim proc As Process = Process.GetProcessById(_processID)
If proc Is Nothing Then Exit Sub
_activeWindowName = proc.ProcessName
'
'Get access to the window properties somehow!
'
End If
End If
End Sub
وجد هذا الكود
كود :
Imports System.Runtime.InteropServices
Public Class Form1
Dim tom As New Process
Dim tomstyle As New ProcessWindowStyle
Dim hndtom As IntPtr
Public Declare Auto Function SetWindowPos Lib "user32.dll" ( _
ByVal hWnd As IntPtr, _
ByVal hWndInsertAfter As IntPtr, _
ByVal X As Int32, _
ByVal Y As Int32, _
ByVal cx As Int32, _
ByVal cy As Int32, _
ByVal uFlags As UInt32 _
) As Boolean
Public Declare Auto Function MoveWindow Lib "user32.dll" ( _
ByVal hWnd As IntPtr, _
ByVal X As Int32, _
ByVal Y As Int32, _
ByVal nWidth As Int32, _
ByVal nHeight As Int32, _
ByVal bRepaint As Boolean _
) As Boolean
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
tomstyle = ProcessWindowStyle.Normal
tom = Process.Start("c:\program files\internet explorer\iexplore.exe")
hndtom = tom.MainWindowHandle
MsgBox(MoveWindow(hndtom, 10, 10, 300, 400, True))
End Sub
End Class