Hi,

Please include your tests in the same patch, or use series notation of format-patch/send-email.

+    siz.cx = rc.right - rc.left;
+    siz.cy = rc.bottom - rc.top;
+
+    if (rc.right > mi.rcWork.right)
+    {
+        rc.right = mi.rcWork.right;
+        rc.left = rc.right - siz.cx;
+    }
+    if (rc.bottom > mi.rcWork.bottom)
+    {
+        rc.bottom = mi.rcWork.bottom;
+        rc.top = rc.bottom - siz.cy;
+    }
+
+    if (rc.left < mi.rcWork.left)
+    {
+        rc.left = mi.rcWork.left;
+        rc.right = rc.left + siz.cx;
+    }
+    if (rc.top < mi.rcWork.top)
+    {
+        rc.top = mi.rcWork.top;
+        rc.bottom = rc.top + siz.cy;
+    }
+
+    SetWindowPos(hwnd, NULL, rc.left, rc.top, 0, 0,
+                 SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSIZE |
+                 SWP_NOZORDER);
You only need (x,y) coordinates - no need to set 'bottom' or 'right', so it could be reduced to a several min/max calls. Also please change 'siz' -> 'size'.