MoveWindow API doesn't work well on Vista
- by Dex Ilic
Hello! I have an application on Vista which loops through all processes and finds associated main windows in order to move and resize them.
The problem is that some windows get moved and resized and some don't. Also it even seems that moved and resized windows aren't moved and resized according to the MoveWindow function call because they are resized to title bar and all of them are on the same line (same y coordinate).
Here's the sample code:
IntPtr handle;
Process[] processList = Process.GetProcesses();
int i = 0;
foreach (Process process in processList)
{
handle = process.MainWindowHandle;
if (handle != IntPtr.Zero) //If the process has window then move and resize it.
{
bool moveResult = MoveWindow(handle, i * 50, i * 50, 500, 500, true);
i++;
}
}
Is this because of Vista? What alternative should I use?