views:

120

answers:

1

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?

A: 

It seems that MoveWindow function doesn't have any effect on the minimized windows. So, before MoveWindow I used ShowWindow:

ShowWindow(handle, 3); //ShowMaximized = 3

This helped!

I used SetWindowPos function but MSDN documentation about this function says that in Vista "hwnd and window manager operations are only effective inside a session and cross-session attempts to manipulate the hwnd will fail" and that statement indicated that problem is because of Vista.

http://msdn.microsoft.com/en-us/library/ms633545%28v=VS.85%29.aspx

Dex Ilic