+/*
+ All this code is used for adjusting the message box layout when we mess
+ with its contents. It's rather complicated because we try hard to avoid
+ assuming much about the standard layout details and so, instead of just
+ laying out everything ourselves (which would have been so much simpler!)
+ we try to only modify the existing controls positions by offsetting them
+ from their default ones in the hope that this will continue to work with
+ the future Windows versions.
+ */
+
+// convert the given RECT from screen to client coordinates in place
+void ScreenRectToClient(HWND hwnd, RECT& rc)
+{
+ // map from desktop (i.e. screen) coordinates to ones of this window
+ //
+ // notice that a RECT is laid out as 2 consecutive POINTs so the cast is
+ // valid
+ ::MapWindowPoints(HWND_DESKTOP, hwnd, reinterpret_cast<POINT *>(&rc), 2);
+}
+
+// set window position to the given rect
+inline void SetWindowRect(HWND hwnd, const RECT& rc)
+{
+ ::MoveWindow(hwnd,
+ rc.left, rc.top,
+ rc.right - rc.left, rc.bottom - rc.top,
+ FALSE);
+}
+
+// set window position expressed in screen coordinates, whether the window is
+// child or top level
+void MoveWindowToScreenRect(HWND hwnd, RECT rc)
+{
+ ScreenRectToClient(::GetParent(hwnd), rc);
+
+ SetWindowRect(hwnd, rc);
+}
+
+// helper of AdjustButtonLabels(): move the given window by dx
+//
+// works for both child and top level windows
+void OffsetWindow(HWND hwnd, int dx)
+{
+ RECT rc = wxGetWindowRect(hwnd);
+
+ rc.left += dx;
+ rc.right += dx;
+
+ MoveWindowToScreenRect(hwnd, rc);
+}
+