+// call AlphaBlend() to blit contents of hdcSrc to hdcDst using alpha
+//
+// NB: bmpSrc is the bitmap selected in hdcSrc, it is not really needed
+// to pass it to this function but as we already have it at the point
+// of call anyhow we do
+//
+// return true if we could draw the bitmap in one way or the other, false
+// otherwise
+static bool AlphaBlt(HDC hdcDst,
+ int x, int y, int w, int h,
+ int srcX, int srcY, HDC hdcSrc,
+ const wxBitmap& bmpSrc);
+
+#ifdef wxHAVE_RAW_BITMAP
+
+// our (limited) AlphaBlend() replacement for Windows versions not providing it
+static void
+wxAlphaBlend(HDC hdcDst, int x, int y, int w, int h,
+ int srcX, int srcY, const wxBitmap& bmp);
+
+#endif // wxHAVE_RAW_BITMAP
+
+// ----------------------------------------------------------------------------
+// private classes
+// ----------------------------------------------------------------------------
+
+// instead of duplicating the same code which sets and then restores text
+// colours in each wxDC method working with wxSTIPPLE_MASK_OPAQUE brushes,
+// encapsulate this in a small helper class
+
+// wxColourChanger: changes the text colours in the ctor if required and
+// restores them in the dtor
+class wxColourChanger
+{
+public:
+ wxColourChanger(wxDC& dc);
+ ~wxColourChanger();
+
+private:
+ wxDC& m_dc;
+
+ COLORREF m_colFgOld, m_colBgOld;
+
+ bool m_changed;
+
+ DECLARE_NO_COPY_CLASS(wxColourChanger)
+};
+
+// this class saves the old stretch blit mode during its life time
+class StretchBltModeChanger
+{
+public:
+ StretchBltModeChanger(HDC hdc,
+ int WXUNUSED_IN_WINCE(mode))
+ : m_hdc(hdc)
+ {
+#ifndef __WXWINCE__
+ m_modeOld = ::SetStretchBltMode(m_hdc, mode);
+ if ( !m_modeOld )
+ wxLogLastError(_T("SetStretchBltMode"));
+#endif
+ }
+
+ ~StretchBltModeChanger()
+ {
+#ifndef __WXWINCE__
+ if ( !::SetStretchBltMode(m_hdc, m_modeOld) )
+ wxLogLastError(_T("SetStretchBltMode"));
+#endif
+ }
+
+private:
+ const HDC m_hdc;
+
+ int m_modeOld;
+
+ DECLARE_NO_COPY_CLASS(StretchBltModeChanger)
+};
+
+// support for dynamic loading of msimg32.dll which we use for some functions
+class wxMSImg32DLL
+{
+public:
+ // return the symbol with the given name if the DLL not loaded or symbol
+ // not present
+ static void *GetSymbol(const wxChar *name)
+ {
+ wxLogNull noLog;
+
+ if ( !ms_triedToLoad )
+ {
+ ms_triedToLoad = true;
+ ms_dll.Load(_T("msimg32"));
+ }
+
+ return ms_dll.IsLoaded() ? ms_dll.GetSymbol(name) : NULL;
+ }
+
+private:
+ static wxDynamicLibrary ms_dll;
+ static bool ms_triedToLoad;
+};
+
+wxDynamicLibrary wxMSImg32DLL::ms_dll;
+bool wxMSImg32DLL::ms_triedToLoad = false;
+
+// helper macro for getting the symbols from msimg32.dll: it supposes that a
+// type "name_t" is defined and casts the returned symbol to it automatically
+#define wxMSIMG32_SYMBOL(name) (name ## _t)wxMSImg32DLL::GetSymbol(_T(#name))
+