15-02-13, 12:45 PM
كود :
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