[pywin32-checkins] pywin32/win32/src win32gui.i,1.48,1.49
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Roger U. <ru...@us...> - 2004-09-12 22:42:37
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25925/win32/src Modified Files: win32gui.i Log Message: Add non-MFC version of CreateDC, rewrite parsing of SCROLLINFO tuple to eliminate stale errors Index: win32gui.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32gui.i,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** win32gui.i 7 Sep 2004 08:38:15 -0000 1.48 --- win32gui.i 12 Sep 2004 22:42:25 -0000 1.49 *************** *** 2772,2823 **** BOOL ParseSCROLLINFOTuple( PyObject *args, SCROLLINFO *pInfo) { ! PyObject *ob; int len = PyTuple_Size(args); ! if (len<1 || len > 5) { ! PyErr_SetString(PyExc_TypeError, "SCROLLINFO tuple has invalid size"); return FALSE; } ! PyErr_Clear(); // clear any errors, so I can detect my own. ! // 0 - mask. ! if ((ob=PyTuple_GetItem(args, 0))==NULL) return FALSE; ! pInfo->fMask = (UINT)PyInt_AsLong(ob); // 1/2 - nMin/nMax ! if (len==2) { PyErr_SetString(PyExc_TypeError, "SCROLLINFO - Both min and max, or neither, must be provided."); return FALSE; } ! if (len<3) return TRUE; ! if ((ob=PyTuple_GetItem(args, 1))==NULL) ! return FALSE; ! if (ob != Py_None) { ! pInfo->fMask |= SIF_RANGE; ! pInfo->nMin = PyInt_AsLong(ob); ! if ((ob=PyTuple_GetItem(args, 2))==NULL) return FALSE; ! pInfo->nMax = PyInt_AsLong(ob); } ! // 3 == nPage. ! if (len<4) return TRUE; ! if ((ob=PyTuple_GetItem(args, 3))==NULL) ! return FALSE; ! if (ob != Py_None) { ! pInfo->fMask |=SIF_PAGE; ! pInfo->nPage = PyInt_AsLong(ob); } ! // 4 == nPos ! if (len<5) return TRUE; ! if ((ob=PyTuple_GetItem(args, 4))==NULL) ! return FALSE; ! if (ob != Py_None) { ! pInfo->fMask |=SIF_POS; ! pInfo->nPos = PyInt_AsLong(ob); } ! // 5 == trackpos ! if (len<6) return TRUE; ! if ((ob=PyTuple_GetItem(args, 5))==NULL) ! return FALSE; ! if (ob != Py_None) { ! pInfo->nTrackPos = PyInt_AsLong(ob); } return TRUE; --- 2772,2813 ---- BOOL ParseSCROLLINFOTuple( PyObject *args, SCROLLINFO *pInfo) { ! static char *err_msg="SCROLLINFO must be a tuple of 1-6 ints"; ! PyObject *obMin=Py_None, *obMax=Py_None, *obPage=Py_None, *obPos=Py_None, *obTrackPos=Py_None; int len = PyTuple_Size(args); ! if (len<1 || len > 6) { ! PyErr_SetString(PyExc_TypeError, err_msg); return FALSE; } ! if (!PyArg_ParseTuple(args, "l|OOOOO", &pInfo->fMask, &obMin, &obMax, &obPage, &obPos, &obTrackPos)){ ! PyErr_SetString(PyExc_TypeError, err_msg); return FALSE; ! } ! PyErr_Clear(); // clear any errors, so I can detect my own. // 1/2 - nMin/nMax ! if ((obMin==Py_None && obMax!=Py_None) || (obMin!=Py_None && obMax==Py_None)){ PyErr_SetString(PyExc_TypeError, "SCROLLINFO - Both min and max, or neither, must be provided."); return FALSE; } ! if (obMin!=Py_None){ ! if (((pInfo->nMin=PyInt_AsLong(obMin))==-1)&&PyErr_Occurred()) return FALSE; ! if (((pInfo->nMax=PyInt_AsLong(obMax))==-1)&&PyErr_Occurred()) ! return FALSE; ! pInfo->fMask |= SIF_RANGE; } ! if (obPage!=Py_None){ ! if (((pInfo->nPage=PyInt_AsLong(obPage))==-1)&&PyErr_Occurred()) ! return FALSE; ! pInfo->fMask |= SIF_PAGE; } ! if (obPos!=Py_None){ ! if (((pInfo->nPos=PyInt_AsLong(obPos))==-1)&&PyErr_Occurred()) ! return FALSE; ! pInfo->fMask |= SIF_POS; } ! if (obTrackPos!=Py_None){ ! if (((pInfo->nTrackPos=PyInt_AsLong(obTrackPos))==-1)&&PyErr_Occurred()) ! return FALSE; ! pInfo->fMask |= SIF_TRACKPOS; } return TRUE; *************** *** 2873,2880 **** SCROLLINFO info; info.cbSize = sizeof(SCROLLINFO); ! if (ParseSCROLLINFOTuple(obInfo, &info) == 0) { ! PyWin_SetAPIError("SetScrollInfo"); return NULL; ! } GUI_BGN_SAVE; int rc = SetScrollInfo(hwnd, nBar, &info, bRedraw); --- 2863,2869 ---- SCROLLINFO info; info.cbSize = sizeof(SCROLLINFO); ! if (ParseSCROLLINFOTuple(obInfo, &info) == 0) return NULL; ! GUI_BGN_SAVE; int rc = SetScrollInfo(hwnd, nBar, &info, bRedraw); *************** *** 3070,3071 **** --- 3059,3084 ---- %native (ListView_SortItems) PyListView_SortItems; %native (ListView_SortItemsEx) PyListView_SortItemsEx; + + // @pyswig int|CreateDC|Creates a device context for a printer or display device + %native (CreateDC) PyCreateDC; + %{ + static PyObject *PyCreateDC(PyObject *self, PyObject *args) + { + PDEVMODE pdevmode; + PyObject *obdevmode=NULL; + char *driver, *device, *dummyoutput=NULL; + HDC hdc; + // @pyparm string|Driver||Name of display or print provider, usually DISPLAY or WINSPOOL + // @pyparm string|Device||Name of specific device, eg printer name returned from GetDefaultPrinter + // @pyparm <o PyDEVMODE>|InitData||A PyDEVMODE that specifies printing parameters, use None for printer defaults + if (!PyArg_ParseTuple(args, "szO", &driver, &device, &obdevmode)) + return NULL; + if (!PyWinObject_AsDEVMODE(obdevmode, &pdevmode, TRUE)) + return NULL; + hdc=CreateDC(driver, device, dummyoutput, pdevmode); + if (hdc!=NULL) + return Py_BuildValue("l",hdc); + PyWin_SetAPIError("CreateDC",GetLastError()); + return NULL; + } + %} |