+inline void wxRGBToColour(wxColour& c, COLORREF rgb)
+{
+ c.Set(GetRValue(rgb), GetGValue(rgb), GetBValue(rgb));
+}
+
+// copy Windows RECT to our wxRect
+inline void wxCopyRECTToRect(const RECT& r, wxRect& rect)
+{
+ rect.y = r.top;
+ rect.x = r.left;
+ rect.width = r.right - r.left;
+ rect.height = r.bottom - r.top;
+}
+
+// translations between HIMETRIC units (which OLE likes) and pixels (which are
+// liked by all the others) - implemented in msw/utilsexc.cpp
+extern void HIMETRICToPixel(LONG *x, LONG *y);
+extern void PixelToHIMETRIC(LONG *x, LONG *y);
+
+// Windows convention of the mask is opposed to the wxWindows one, so we need
+// to invert the mask each time we pass one/get one to/from Windows
+extern HBITMAP wxInvertMask(HBITMAP hbmpMask, int w = 0, int h = 0);
+
+// get (x, y) from DWORD - notice that HI/LOWORD can *not* be used because they
+// will fail on system with multiple monitors where the coords may be negative
+//
+// these macros are standard now (Win98) but some older headers don't have them
+#ifndef GET_X_LPARAM
+ #define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp))
+ #define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp))
+#endif // GET_X_LPARAM
+
+// get the current state of SHIFT/CTRL keys
+inline bool wxIsShiftDown()
+{
+ return (::GetKeyState(VK_SHIFT) & 0x100) != 0;
+}
+
+inline bool wxIsCtrlDown()
+{
+ return (::GetKeyState(VK_CONTROL) & 0x100) != 0;
+}
+
+// wrapper around GetWindowRect() and GetClientRect() APIs doing error checking
+// for Win32
+inline RECT wxGetWindowRect(HWND hwnd)
+{
+ RECT rect;
+#ifdef __WIN16__
+ ::GetWindowRect(hwnd, &rect);
+#else // Win32
+ if ( !::GetWindowRect(hwnd, &rect) )
+ {
+ wxLogLastError(_T("GetWindowRect"));
+ }
+#endif // Win16/32
+
+ return rect;
+}
+
+inline RECT wxGetClientRect(HWND hwnd)
+{
+ RECT rect;
+#ifdef __WIN16__
+ ::GetClientRect(hwnd, &rect);
+#else // Win32
+ if ( !::GetClientRect(hwnd, &rect) )
+ {
+ wxLogLastError(_T("GetClientRect"));
+ }
+#endif // Win16/32
+
+ return rect;
+}
+
+// ---------------------------------------------------------------------------
+// small helper classes
+// ---------------------------------------------------------------------------
+
+// create an instance of this class and use it as the HDC for screen, will
+// automatically release the DC going out of scope
+class ScreenHDC
+{
+public:
+ ScreenHDC() { m_hdc = GetDC(NULL); }
+ ~ScreenHDC() { ReleaseDC(NULL, m_hdc); }
+ operator HDC() const { return m_hdc; }
+
+private:
+ HDC m_hdc;
+};