MoveWindow API doesn't work well on Vista

Posted by Dex Ilic on Stack Overflow See other posts from Stack Overflow or by Dex Ilic
Published on 2010-05-09T21:14:33Z Indexed on 2010/05/09 21:18 UTC
Read the original article Hit count: 164

Filed under:
|

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?

© Stack Overflow or respective owner

Related posts about c#

Related posts about Vista