1

When I call SWP to try and move a resize a specific window. It does not move or resize.

SetWindowPos(hWndWindow, NULL, 0, 0, 500, 500, SWP_NOZORDER);

The window handle is valid. I tried both getting the handle with FindWindow and by manually setting the handle value to the window I wanted to resize.

When I use GetWindowPlacement, it says the window is SW_NORMAL and not SW_MAXIMIZE.

The window style is

0x160b0000 (WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_SYSMENU | WS_MINMIZEBOX | WS_MAXIMIZEBOX)

and the extend style is 0x0.

I have also tried setting the window to SW_NORMAL with ShowWindow before calling SetWindowPos.

SetWindowPos and MoveWindow both return non false values saying that they didn't fail.

Why is SetWindowPos and MoveWindow unable to move or resize this window?

drescherjm
  • 10,365
  • 5
  • 44
  • 64
John
  • 5,942
  • 3
  • 42
  • 79
  • Sounds like the window belongs to another process. – Cheers and hth. - Alf Oct 23 '16 at 02:15
  • @Cheersandhth.-Alf, it didn't move until I called SWP from the exact thread inside the process that created the window. Why does this process have this limitation while I'm able to move some other windows of other processes? – John Oct 23 '16 at 02:46
  • I don't know, sorry. It was just a surface observation, hopefully pointing in the direction of some clarification or ideas. – Cheers and hth. - Alf Oct 23 '16 at 03:45
  • @John: This is one of the rules of the window manager in Windows. Windows have thread affinity, meaning, that they can only safely and reliably be modified from the thread, that owns them. Manipulating windows from threads other than the owning thread is undefined. – IInspectable Oct 23 '16 at 15:29
  • 1
    @IInspectable perhaps, but it is allowed to move windows across threads. So maybe this is a UIPI restriction across integrity levels, or maybe the window's message procedure, or even a message hook, is simply blocking the move. – Remy Lebeau Oct 23 '16 at 15:36
  • @RemyLebeau: Moving windows across threads is most certainly **not** allowed. It happens to work, frequently, but it is not part of the documented contract. Any data associated with a `HWND` must be manipulated from the owning thread, and the owning thread alone (and that includes the window rectangle). – IInspectable Oct 23 '16 at 16:35

0 Answers0