I'm trying to move a window, with the MoveWindow Function of API, but the problem is, it doesnt work on every window (but on the most), i found out that the windows that wont move are such windows forms that arent allowed to be maximized but when i made a form on my VS which isnt allowed to be maximized either, then it worked, so im confused and if you have any idea please reply as soon as possible, thanks in advance Begi.
PS: I used the SetWindowPos too, the same thing...here's the code below;
Imports System.Runtime.InteropServices
Imports System.Threading
Public Class Form1
Friend Structure RECT
Public left As Integer
Public top As Integer
Public right As Integer
Public bottom As Integer
End Structure
Friend Declare Auto Function GetForegroundWindow Lib "user32.dll" () As IntPtr
<DllImport("user32.dll", CharSet:=CharSet.Auto, CallingConvention:=CallingConvention.StdCall, ExactSpelling:=True, SetLastError:=True)> _
Friend Shared Function GetWindowRect(hWnd As IntPtr, ByRef rect As RECT) As Boolean
End Function
<DllImport("user32.dll", CharSet:=CharSet.Auto, CallingConvention:=CallingConvention.StdCall, ExactSpelling:=True, SetLastError:=True)> _
Friend Shared Sub MoveWindow(hwnd As IntPtr, X As Integer, Y As Integer, nWidth As Integer, nHeight As Integer, bRepaint As Boolean)
End Sub
Private Shared Sub Main()
Dim id As IntPtr
Dim Rect As New RECT()
Thread.Sleep(2000)
id = GetForegroundWindow()
GetWindowRect(id, Rect)
MoveWindow(id, 450, 100, Rect.right - Rect.left, Rect.bottom - Rect.top, True)
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Main()
End Sub
End Class