]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/dcmemory.cpp
added support for right aligned labels (wxALIGN_RIGT maps to BS_LEFTTEXT)
[wxWidgets.git] / src / msw / dcmemory.cpp
index a89b217bcb3fedf925aa0cc50ae72300fd62a8a3..243861faccdde23dcc5285dce3dbb6b02ffd209a 100644 (file)
@@ -84,8 +84,19 @@ void wxMemoryDC::SelectObject(const wxBitmap& bitmap)
     wxFatalError("Error in wxMemoryDC::SelectObject\nBitmap is selected in another wxMemoryDC.\nDelete the first wxMemoryDC or use SelectObject(NULL)");
     return;
   }
-  
-  m_selectedBitmap = bitmap;
+
+  // Check if the bitmap has the correct depth for this device context
+  if (bitmap.Ok() && (bitmap.GetDepth() != GetDepth()))
+  {
+      // Make a new bitmap that has the correct depth.
+      wxBitmap newBitmap = bitmap.GetBitmapForDC(* this);
+
+      m_selectedBitmap = newBitmap ;
+  }
+  else
+  {
+      m_selectedBitmap = bitmap;
+  }
 
   if (!m_selectedBitmap.Ok())
     return;