]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/statbmp.cpp
Don't handle WM_PRINTCLIENT anymore, manually draw the static box label background...
[wxWidgets.git] / src / msw / statbmp.cpp
index ca99580ab0c7cab4839ce06034890127cd604f7e..26a32bf03b6a2ff351329f10fd539b73d8b2a7c0 100644 (file)
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
-// Name:        statbmp.cpp
+// Name:        src/msw/statbmp.cpp
 // Purpose:     wxStaticBitmap
 // Author:      Julian Smart
 // Modified by:
 
 #if wxUSE_STATBMP
 
-#include "wx/window.h"
-#include "wx/msw/private.h"
+#include "wx/statbmp.h"
 
 #ifndef WX_PRECOMP
+    #include "wx/window.h"
     #include "wx/icon.h"
-    #include "wx/statbmp.h"
 #endif
 
+#include "wx/msw/private.h"
+
 #include "wx/sysopt.h"
 
 #include <stdio.h>
@@ -269,8 +270,16 @@ void wxStaticBitmap::SetImageNoCopy( wxGDIImage* image)
     LONG style = ::GetWindowLong( (HWND)GetHWND(), GWL_STYLE ) ;
     ::SetWindowLong( (HWND)GetHWND(), GWL_STYLE, ( style & ~( SS_BITMAP|SS_ICON ) ) |
                      ( m_isIcon ? SS_ICON : SS_BITMAP ) );
-    ::SendMessage(GetHwnd(), STM_SETIMAGE,
+    HGDIOBJ oldHandle = (HGDIOBJ)::SendMessage(GetHwnd(), STM_SETIMAGE,
                   m_isIcon ? IMAGE_ICON : IMAGE_BITMAP, (LPARAM)handle);
+    // detect if this is still the handle we passed before or
+    // if the static-control made a copy of the bitmap!
+    if (m_currentHandle != 0 && oldHandle != (HGDIOBJ) m_currentHandle)
+    {
+        // the static control made a copy and we are responsible for deleting it
+        DeleteObject((HGDIOBJ) oldHandle);
+    }
+    m_currentHandle = (WXHANDLE)handle;
 #endif // Win32
 
     if ( ImageIsOk() )
@@ -295,4 +304,3 @@ void wxStaticBitmap::SetImageNoCopy( wxGDIImage* image)
 }
 
 #endif // wxUSE_STATBMP
-