Update of /cvsroot/pywin32/pywin32/win32/src
In directory sc8-pr-cvs1:/tmp/cvs-serv2512
Modified Files:
win32clipboardmodule.cpp
Log Message:
CF_HDROP support, from Roger Upole.
Index: win32clipboardmodule.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/win32clipboardmodule.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** win32clipboardmodule.cpp 8 Oct 2002 12:24:52 -0000 1.10
--- win32clipboardmodule.cpp 12 Jul 2003 13:07:22 -0000 1.11
***************
*** 284,292 ****
--- 284,301 ----
}
+ if (!IsClipboardFormatAvailable(format)){
+ PyErr_SetString(PyExc_TypeError, "Specified clipboard format is not available");
+ return NULL;
+ }
HANDLE handle;
+ WCHAR *filename=NULL;
+ PyObject* obfilename = NULL;
+ UINT filecnt=0, fileind=0, filenamesize=0;
+ HDROP hdrop;
Py_BEGIN_ALLOW_THREADS;
handle = GetClipboardData((UINT)format);
Py_END_ALLOW_THREADS;
+
if (!handle) {
return ReturnAPIError("GetClipboardData");
***************
*** 296,299 ****
--- 305,311 ----
DWORD size;
switch (format) {
+ case CF_HDROP:
+ hdrop = (HDROP)GlobalLock(handle);
+ break;
case CF_ENHMETAFILE:
size = GetEnhMetaFileBits((HENHMETAFILE)handle, 0, NULL);
***************
*** 345,348 ****
--- 357,378 ----
}
switch (format) {
+ case CF_HDROP:
+ filecnt = DragQueryFileW(hdrop, 0xFFFFFFFF, NULL, NULL);
+ ret = PyTuple_New(filecnt);
+ if (!ret) return PyErr_NoMemory();
+ for (fileind=0;fileind<filecnt;fileind++){
+ filenamesize = DragQueryFileW(hdrop, fileind, NULL, NULL);
+ filename = (WCHAR *)malloc((filenamesize+1)*sizeof(WCHAR));
+ if (!filename) {
+ Py_DECREF(ret);
+ return PyErr_NoMemory();
+ }
+ filenamesize = DragQueryFileW(hdrop, fileind, filename, filenamesize+1);
+ obfilename=PyWinObject_FromWCHAR(filename);
+ PyTuple_SetItem(ret,fileind,obfilename);
+ free (filename);
+ }
+ GlobalUnlock(handle);
+ break;
case CF_UNICODETEXT:
ret = PyWinObject_FromWCHAR((wchar_t *)cData, (size / sizeof(wchar_t))-1);
***************
*** 807,810 ****
--- 837,841 ----
HANDLE handle;
int ihandle;
+
if (PyArg_ParseTuple(args, "ii:SetClipboardData",
&format, &ihandle)) {
***************
*** 819,830 ****
// to the new memory.
PyObject *obBuf;
if (!PyArg_ParseTuple(args, "iO:SetClipboardData",
&format, &obBuf))
return NULL;
! PyBufferProcs *pb = obBuf->ob_type->tp_as_buffer;
! if (pb==NULL)
RETURN_TYPE_ERR("The object must support the buffer interfaces");
- void *buf = NULL;
- int bufSize = (*pb->bf_getreadbuffer)(obBuf, 0, &buf);
// size doesnt include nulls!
if (PyString_Check(obBuf))
--- 850,861 ----
// to the new memory.
PyObject *obBuf;
+ const void * buf = NULL;
+ int bufSize = 0;
if (!PyArg_ParseTuple(args, "iO:SetClipboardData",
&format, &obBuf))
return NULL;
!
! if (PyObject_AsReadBuffer(obBuf,&buf,&bufSize)==-1)
RETURN_TYPE_ERR("The object must support the buffer interfaces");
// size doesnt include nulls!
if (PyString_Check(obBuf))
|