[pywin32-checkins] pywin32/com/win32com/src/extensions PySTGMEDIUM.cpp, 1.7, 1.8
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Roger U. <ru...@us...> - 2007-06-03 09:40:56
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src/extensions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10018/com/win32com/src/extensions Modified Files: PySTGMEDIUM.cpp Log Message: Fix some 64-bit HANDLE issues Index: PySTGMEDIUM.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/extensions/PySTGMEDIUM.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PySTGMEDIUM.cpp 24 May 2007 06:01:04 -0000 1.7 --- PySTGMEDIUM.cpp 3 Jun 2007 09:40:56 -0000 1.8 *************** *** 31,49 **** ps->Close(); // ensure any old data clean switch (tymed) { ! case TYMED_GDI: ! if (!PyInt_Check(ob) || !PyLong_Check(ob)) ! return PyErr_Format(PyExc_TypeError, "tymed value of %d requires an integer handle", tymed); ! ps->medium.hBitmap = (HBITMAP)PyInt_AsLong(ob); break; ! case TYMED_MFPICT: ! if (!PyInt_Check(ob) || !PyLong_Check(ob)) ! return PyErr_Format(PyExc_TypeError, "tymed value of %d requires an integer handle", tymed); ! ps->medium.hMetaFilePict = (HMETAFILEPICT)PyInt_AsLong(ob); break; ! case TYMED_ENHMF: ! if (!PyInt_Check(ob) || !PyLong_Check(ob)) ! return PyErr_Format(PyExc_TypeError, "tymed value of %d requires an integer handle", tymed); ! ps->medium.hEnhMetaFile = (HENHMETAFILE)PyInt_AsLong(ob); break; case TYMED_HGLOBAL: { const void * buf = NULL; --- 31,55 ---- ps->Close(); // ensure any old data clean switch (tymed) { ! case TYMED_GDI:{ ! HBITMAP htmp; ! if (!PyWinObject_AsHANDLE(ob, (HANDLE *)&htmp)) ! return NULL; ! ps->medium.hBitmap = htmp; break; ! } ! case TYMED_MFPICT:{ ! HMETAFILEPICT htmp; ! if (!PyWinObject_AsHANDLE(ob, (HANDLE *)&htmp)) ! return NULL; ! ps->medium.hMetaFilePict = htmp; break; ! } ! case TYMED_ENHMF:{ ! HENHMETAFILE htmp; ! if (!PyWinObject_AsHANDLE(ob, (HANDLE *)&htmp)) ! return NULL; ! ps->medium.hEnhMetaFile = htmp; break; + } case TYMED_HGLOBAL: { const void * buf = NULL; *************** *** 141,151 **** assert(pDest->tymed==0 && pDest->pUnkForRelease==0 && pDest->hGlobal == 0); switch (medium.tymed) { - // we can't just copy these handles, and there is no easy way I see - // to generically duplicate them. There is a CopyStgMedium function, - // but is part of IE, not of OLE. case TYMED_GDI: ! PyErr_SetString(PyExc_ValueError, "don't know how to copy these objects"); ! return FALSE; ! // is it ok to just copy these handles? pDest->hBitmap = medium.hBitmap; break; --- 147,153 ---- assert(pDest->tymed==0 && pDest->pUnkForRelease==0 && pDest->hGlobal == 0); switch (medium.tymed) { case TYMED_GDI: ! // Receiving app that is performing Paste operation takes ownership of the handle and ! // is responsible for freeing it (usually by calling ReleaseStgMedium) pDest->hBitmap = medium.hBitmap; break; |