]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/enhmeta.cpp
fix for potention crash when conversion fails
[wxWidgets.git] / src / msw / enhmeta.cpp
index 037b749003b3458ea9797daf81f111754848d052..ce2ecc0ae846dc57f852c23bcdfbeb2171536c7a 100644 (file)
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////////
-// Name:        msw/enhmeta.cpp
+// Name:        src/msw/enhmeta.cpp
 // Purpose:     implementation of wxEnhMetaFileXXX classes
 // Author:      Vadim Zeitlin
 // Modified by:
@@ -75,7 +75,7 @@ void wxEnhMetaFile::Init()
     }
     else // have valid file name, load metafile from it
     {
-        m_hMF = GetEnhMetaFile(m_filename);
+        m_hMF = (WXHANDLE)::GetEnhMetaFile(m_filename);
         if ( !m_hMF )
             wxLogSysError(_("Failed to load metafile from file \"%s\"."),
                           m_filename.c_str());
@@ -194,7 +194,9 @@ wxEnhMetaFileDC::wxEnhMetaFileDC(const wxString& filename,
                                  int width, int height,
                                  const wxString& description)
 {
-    ScreenHDC hdcRef;
+    m_width = width;
+    m_height = height;
+
     RECT rect;
     RECT *pRect;
     if ( width && height )
@@ -215,6 +217,7 @@ wxEnhMetaFileDC::wxEnhMetaFileDC(const wxString& filename,
         pRect = (LPRECT)NULL;
     }
 
+    ScreenHDC hdcRef;
     m_hDC = (WXHDC)::CreateEnhMetaFile(hdcRef, GetMetaFileName(filename),
                                        pRect, description);
     if ( !m_hDC )
@@ -223,6 +226,14 @@ wxEnhMetaFileDC::wxEnhMetaFileDC(const wxString& filename,
     }
 }
 
+void wxEnhMetaFileDC::DoGetSize(int *width, int *height) const
+{
+    if ( width )
+        *width = m_width;
+    if ( height )
+        *height = m_height;
+}
+
 wxEnhMetaFile *wxEnhMetaFileDC::Close()
 {
     wxCHECK_MSG( Ok(), NULL, _T("invalid wxEnhMetaFileDC") );