Click to See Complete Forum and Search --> : SetWindowPos not working in loop


TheIrishThug
July 9th, 2008, 04:05 PM
I had posted this in C# because that's what I'm writing in, but I think this might be able to get a few ideas here.

http://www.codeguru.com/forum/showthread.php?t=456754
I'm using SetWindowPos to bring a certain set of windows. This works fine when I just try to bring one window to the front. However, when I try to bring a group of windows to the front, only the first window is affected. This is not a problem with my foreach loop or making sure all the right windows are in the group, because the minimize and restore commands that use the same loop work fine.

Does anyone know a reason why the following would fail if called quickly in succession?
bool success = Win32.SetWindowPos(hWND, Win32.HWND_TOP,
_shape.X, _shape.Y, _shape.Width, _shape.Height,
Win32.SWP_NOMOVE | Win32.SWP_NOSIZE | Win32.SWP_SHOWWINDOW);

doy2001
July 13th, 2008, 10:46 PM
Check that your window handle is changing from window to window.
If you insert an Sleep(xxxx) does it work? I'm asking this because you said quickly in a succession.