[pywin32-checkins] pywin32/win32/src win32clipboardmodule.cpp,1.11,1.12
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: <mha...@us...> - 2003-11-29 05:50:21
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1:/tmp/cvs-serv17188 Modified Files: win32clipboardmodule.cpp Log Message: Prevent crash when using CF_DIB, and add new GetClipboardDataHandle() method to return the raw handle. Index: win32clipboardmodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32clipboardmodule.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** win32clipboardmodule.cpp 12 Jul 2003 13:07:22 -0000 1.11 --- win32clipboardmodule.cpp 29 Nov 2003 05:50:18 -0000 1.12 *************** *** 265,271 **** //***************************************************************************** // // @pymethod string/unicode|win32clipboard|GetClipboardData|The GetClipboardData function // retrieves data from the clipboard in a specified format. The clipboard ! // must have been opened previously. static PyObject * --- 265,300 ---- //***************************************************************************** // + // @pymethod int|win32clipboard|GetClipboardDataHandle|Retrieves data from the + // clipboard in a specified format, and returns an integer handle to the data. + // To get the data bytes, use the <om win32clipboard.GetClipboardData> function. + static PyObject * + py_get_clipboard_data_handle(PyObject* self, PyObject* args) + { + // @pyparm int|format|CF_TEXT|Specifies a clipboard format. For a description of + // the standard clipboard formats, see Standard Clipboard Formats. + int format = CF_TEXT; + if (!PyArg_ParseTuple(args, "|i:GetClipboardDataHandle:", &format)) + return NULL; + + if (!IsClipboardFormatAvailable(format)) + return PyErr_Format(PyExc_TypeError, + "The clipboard format %d is not available", format); + HANDLE handle; + Py_BEGIN_ALLOW_THREADS; + handle = GetClipboardData((UINT)format); + Py_END_ALLOW_THREADS; + if (!handle) + return ReturnAPIError("GetClipboardData"); + return PyLong_FromVoidPtr(handle); + } + + + //***************************************************************************** + // // @pymethod string/unicode|win32clipboard|GetClipboardData|The GetClipboardData function // retrieves data from the clipboard in a specified format. The clipboard ! // must have been opened previously. Note that not all data formats are supported, ! // and that the underlying handle can be retrieved with ! // <om win32clipboard.GetClipboardDataHandle> static PyObject * *************** *** 342,345 **** --- 371,375 ---- case CF_DIB: PyErr_SetString(PyExc_NotImplementedError, "GetClipboardData(CF_DIB) unimplemented"); + return NULL; break; default: *************** *** 1030,1033 **** --- 1060,1067 ---- // specified format. {"GetClipboardData", py_get_clipboard_data, 1}, + + // @pymeth GetClipboardDataHandle|Retrieves data from the clipboard in a + // specified format, returning the underlying integer handle. + {"GetClipboardDataHandle", py_get_clipboard_data_handle, 1}, // @pymeth GetClipboardFormatName|Retrieves from the clipboard the name |