pywin32-checkins Mailing List for Python for Windows Extensions (Page 97)
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
(1) |
Jun
(6) |
Jul
(50) |
Aug
(11) |
Sep
(24) |
Oct
(184) |
Nov
(118) |
Dec
(22) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(31) |
Feb
(25) |
Mar
(34) |
Apr
(105) |
May
(49) |
Jun
(38) |
Jul
(39) |
Aug
(7) |
Sep
(98) |
Oct
(79) |
Nov
(20) |
Dec
(17) |
2005 |
Jan
(66) |
Feb
(32) |
Mar
(43) |
Apr
(30) |
May
(58) |
Jun
(30) |
Jul
(16) |
Aug
(4) |
Sep
(21) |
Oct
(42) |
Nov
(11) |
Dec
(14) |
2006 |
Jan
(42) |
Feb
(30) |
Mar
(22) |
Apr
(1) |
May
(9) |
Jun
(15) |
Jul
(20) |
Aug
(9) |
Sep
(8) |
Oct
(1) |
Nov
(9) |
Dec
(43) |
2007 |
Jan
(52) |
Feb
(45) |
Mar
(20) |
Apr
(12) |
May
(59) |
Jun
(39) |
Jul
(35) |
Aug
(31) |
Sep
(17) |
Oct
(20) |
Nov
(4) |
Dec
(4) |
2008 |
Jan
(28) |
Feb
(111) |
Mar
(4) |
Apr
(27) |
May
(40) |
Jun
(27) |
Jul
(32) |
Aug
(94) |
Sep
(87) |
Oct
(153) |
Nov
(336) |
Dec
(331) |
2009 |
Jan
(298) |
Feb
(127) |
Mar
(20) |
Apr
(8) |
May
|
Jun
(10) |
Jul
(6) |
Aug
|
Sep
(2) |
Oct
(2) |
Nov
|
Dec
(1) |
2010 |
Jan
(7) |
Feb
(1) |
Mar
|
Apr
|
May
(15) |
Jun
(4) |
Jul
(3) |
Aug
(28) |
Sep
(1) |
Oct
(19) |
Nov
(16) |
Dec
(6) |
2011 |
Jan
(2) |
Feb
(18) |
Mar
(17) |
Apr
(12) |
May
(5) |
Jun
(11) |
Jul
(7) |
Aug
(2) |
Sep
(2) |
Oct
(4) |
Nov
(4) |
Dec
|
2012 |
Jan
(6) |
Feb
(2) |
Mar
|
Apr
(8) |
May
(4) |
Jun
(3) |
Jul
(13) |
Aug
(27) |
Sep
(8) |
Oct
(9) |
Nov
(3) |
Dec
(2) |
2013 |
Jan
|
Feb
(1) |
Mar
(5) |
Apr
(10) |
May
|
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
(9) |
2014 |
Jan
(2) |
Feb
(4) |
Mar
(4) |
Apr
(1) |
May
(4) |
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
(1) |
2015 |
Jan
(1) |
Feb
|
Mar
|
Apr
(6) |
May
(2) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2016 |
Jan
(3) |
Feb
(2) |
Mar
|
Apr
(3) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2017 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
From: Roger U. <ru...@us...> - 2007-01-13 09:35:19
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10830/win32/src Modified Files: win32apimodule.cpp Log Message: Stop parsing handles as longs, return int handles using PyWinLong_FromHANDLE Index: win32apimodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32apimodule.cpp,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -d -r1.68 -r1.69 *** win32apimodule.cpp 10 Dec 2006 08:58:37 -0000 1.68 --- win32apimodule.cpp 13 Jan 2007 09:35:16 -0000 1.69 *************** *** 106,110 **** &nStdHandle)) // @pyparm int|handle||input, output, or error device return NULL; ! return Py_BuildValue("i", ::GetStdHandle (nStdHandle)); } --- 106,110 ---- &nStdHandle)) // @pyparm int|handle||input, output, or error device return NULL; ! return PyWinLong_FromHANDLE(GetStdHandle (nStdHandle)); } [...1094 lines suppressed...] if(!PyWinObject_AsResourceID(obtypname,(long *)&typname)) --- 4671,4675 ---- if (!PyArg_ParseTuple(args, "OOO:EnumResourceLanguages", &pyhandle, &obtypname, &obresname)) return NULL; ! if (!PyWinObject_AsHANDLE(pyhandle, (HANDLE *)&hmodule)) return NULL; if(!PyWinObject_AsResourceID(obtypname,(long *)&typname)) *************** *** 4784,4788 **** FILETIME ft; BOOL success; ! if (!PyArg_ParseTuple(args,"OO", &obfile_name, // @pyparm string/unicode|Filename||File to query for version info &obinfo)) // @pyparm string/unicode|SubBlock||Information to return: \ for VS_FIXEDFILEINFO, \VarFileInfo\Translation for languages/codepages available --- 4882,4886 ---- FILETIME ft; BOOL success; ! if (!PyArg_ParseTuple(args,"OO:GetFileVersionInfo", &obfile_name, // @pyparm string/unicode|Filename||File to query for version info &obinfo)) // @pyparm string/unicode|SubBlock||Information to return: \ for VS_FIXEDFILEINFO, \VarFileInfo\Translation for languages/codepages available |
From: Roger U. <ru...@us...> - 2007-01-12 05:54:39
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28214/win32/src Modified Files: win32gui.i Log Message: Return plain int handles via PyWinLong_FromHANDLE Index: win32gui.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32gui.i,v retrieving revision 1.99 retrieving revision 1.100 diff -C2 -d -r1.99 -r1.100 *** win32gui.i 11 Jan 2007 04:42:26 -0000 1.99 --- win32gui.i 12 Jan 2007 05:54:38 -0000 1.100 *************** *** 292,321 **** } ! %apply HCURSOR {long}; ! typedef long HCURSOR; ! ! %apply HINSTANCE {long}; ! typedef long HINSTANCE; ! ! %apply HMENU {long}; ! typedef long HMENU ! ! %apply HICON {long}; ! typedef long HICON ! ! %apply HGDIOBJ {long}; ! typedef long HGDIOBJ ! ! %apply HWND {long}; ! typedef long HWND ! ! %apply HDC {long}; ! typedef long HDC ! ! %apply HIMAGELIST {long}; ! typedef long HIMAGELIST ! ! %apply HACCEL {long}; ! typedef long HACCEL %apply COLORREF {long}; --- 292,304 ---- } ! // Handles types with no specific PyHANDLE subclass, returned to Python as plain ints or longs ! typedef float HDC, HWND, HCURSOR, HINSTANCE, HMENU, HICON, HGDIOBJ, HIMAGELIST, HACCEL; ! %typemap(python, in) HDC, HWND, HCURSOR, HINSTANCE, HMENU, HICON, HGDIOBJ, HIMAGELIST, HACCEL{ ! if (!PyWinObject_AsHANDLE($source, (HANDLE *)&$target, FALSE)) ! return NULL; ! } ! %typemap(python, out) HDC, HWND, HCURSOR, HINSTANCE, HMENU, HICON, HGDIOBJ, HIMAGELIST, HACCEL{ ! $target=PyWinLong_FromHANDLE($source); ! } %apply COLORREF {long}; *************** *** 345,350 **** %typemap(python,argout) MSG *OUTPUT{ PyObject *o; ! o = Py_BuildValue("iiiii(ii)", ! $source->hwnd, $source->message, $source->wParam, --- 328,333 ---- %typemap(python,argout) MSG *OUTPUT{ PyObject *o; ! o = Py_BuildValue("Niiii(ii)", ! PyWinLong_FromHANDLE($source->hwnd), $source->message, $source->wParam, *************** *** 541,546 **** %typemap(python,argout) PAINTSTRUCT *OUTPUT { PyObject *o; ! o = Py_BuildValue("(ll(iiii)lls#)", ! $source->hdc, $source->fErase, $source->rcPaint.left, $source->rcPaint.top, $source->rcPaint.right, $source->rcPaint.bottom, --- 524,529 ---- %typemap(python,argout) PAINTSTRUCT *OUTPUT { PyObject *o; ! o = Py_BuildValue("(Nl(iiii)lls#)", ! PyWinLong_FromHANDLE($source->hdc), $source->fErase, $source->rcPaint.left, $source->rcPaint.top, $source->rcPaint.right, $source->rcPaint.bottom, *************** *** 662,665 **** --- 645,652 ---- if (PyDict_Check(obFuncOrMap)) { PyObject *key = PyInt_FromLong(uMsg); + if (key==NULL){ + HandleError("Internal error converting Msg param of window procedure"); + return FALSE; + } obFunc = PyDict_GetItem(obFuncOrMap, key); Py_DECREF(key); *************** *** 668,677 **** } } ! if (obFunc==NULL) { ! PyErr_Clear(); return FALSE; ! } // We are dispatching to Python... ! PyObject *args = Py_BuildValue("llll", hWnd, uMsg, wParam, lParam); PyObject *ret = PyObject_CallObject(obFunc, args); Py_DECREF(args); --- 655,667 ---- } } ! if (obFunc==NULL) return FALSE; ! // We are dispatching to Python... ! PyObject *args = Py_BuildValue("Nlll", PyWinLong_FromHANDLE(hWnd), uMsg, wParam, lParam); ! if (args==NULL){ ! HandleError("Error building argument tuple for python callback"); ! return FALSE; ! } PyObject *ret = PyObject_CallObject(obFunc, args); Py_DECREF(args); *************** *** 690,694 **** LRESULT CALLBACK PyWndProcClass(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { ! PyObject *obFunc = (PyObject *)GetClassLong( hWnd, 0); LRESULT rc = 0; CEnterLeavePython _celp; --- 680,684 ---- LRESULT CALLBACK PyWndProcClass(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { ! PyObject *obFunc = (PyObject *)GetClassLongPtr( hWnd, 0); LRESULT rc = 0; CEnterLeavePython _celp; *************** *** 702,706 **** LRESULT CALLBACK PyDlgProcClass(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { ! PyObject *obFunc = (PyObject *)GetClassLong( hWnd, 0); LRESULT rc = 0; CEnterLeavePython _celp; --- 692,696 ---- LRESULT CALLBACK PyDlgProcClass(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { ! PyObject *obFunc = (PyObject *)GetClassLongPtr( hWnd, 0); LRESULT rc = 0; CEnterLeavePython _celp; *************** *** 715,719 **** { CEnterLeavePython _celp; ! PyObject *key = PyInt_FromLong((long)hWnd); PyObject *obInfo = PyDict_GetItem(g_HWNDMap, key); Py_DECREF(key); --- 705,709 ---- { CEnterLeavePython _celp; ! PyObject *key = PyWinLong_FromHANDLE(hWnd); PyObject *obInfo = PyDict_GetItem(g_HWNDMap, key); Py_DECREF(key); *************** *** 738,742 **** #endif _celp.acquire(); // in case we released above - safe if already acquired. ! PyObject *key = PyInt_FromLong((long)hWnd); if (PyDict_DelItem(g_HWNDMap, key) != 0) PyErr_Clear(); --- 728,732 ---- #endif _celp.acquire(); // in case we released above - safe if already acquired. ! PyObject *key = PyWinLong_FromHANDLE(hWnd); if (PyDict_DelItem(g_HWNDMap, key) != 0) PyErr_Clear(); *************** *** 757,761 **** // Replace the lParam with the one the user specified. lParam = PyInt_AsLong( PyTuple_GET_ITEM(obTuple, 1) ); ! PyObject *key = PyInt_FromLong((long)hWnd); if (g_DLGMap==NULL) g_DLGMap = PyDict_New(); --- 747,751 ---- // Replace the lParam with the one the user specified. lParam = PyInt_AsLong( PyTuple_GET_ITEM(obTuple, 1) ); ! PyObject *key = PyWinLong_FromHANDLE(hWnd); if (g_DLGMap==NULL) g_DLGMap = PyDict_New(); *************** *** 774,778 **** PyObject *obFunc = NULL; if (g_DLGMap) { ! PyObject *key = PyInt_FromLong((long)hWnd); obFunc = PyDict_GetItem(g_DLGMap, key); Py_XDECREF(key); --- 764,768 ---- PyObject *obFunc = NULL; if (g_DLGMap) { ! PyObject *key = PyWinLong_FromHANDLE(hWnd); obFunc = PyDict_GetItem(g_DLGMap, key); Py_XDECREF(key); *************** *** 791,795 **** if (uMsg==WM_DESTROY) { #endif ! PyObject *key = PyInt_FromLong((long)hWnd); if (g_DLGMap != NULL) --- 781,785 ---- if (uMsg==WM_DESTROY) { #endif ! PyObject *key = PyWinLong_FromHANDLE(hWnd); if (g_DLGMap != NULL) *************** *** 1578,1582 **** return NULL; } ! return Py_BuildValue("ll",(long) addr, len); } %} --- 1568,1572 ---- return NULL; } ! return Py_BuildValue("Nl", PyLong_FromVoidPtr(addr), len); } %} *************** *** 1929,1933 **** PyEnumWindowsCallback *cb = (PyEnumWindowsCallback *)lParam; CEnterLeavePython _celp; ! PyObject *args = Py_BuildValue("(iO)", hwnd, cb->extra); PyObject *ret = PyEval_CallObject(cb->func, args); Py_XDECREF(args); --- 1919,1923 ---- PyEnumWindowsCallback *cb = (PyEnumWindowsCallback *)lParam; CEnterLeavePython _celp; ! PyObject *args = Py_BuildValue("(NO)", PyWinLong_FromHANDLE(hwnd), cb->extra); PyObject *ret = PyEval_CallObject(cb->func, args); Py_XDECREF(args); *************** *** 2068,2072 **** int rc; Py_BEGIN_ALLOW_THREADS ! rc = DialogBoxParam((HINSTANCE)hinst, resid, (HWND)hwnd, PyDlgProcHDLG, (LPARAM)obExtra); Py_END_ALLOW_THREADS Py_DECREF(obExtra); --- 2058,2062 ---- int rc; Py_BEGIN_ALLOW_THREADS ! rc = DialogBoxParam(hinst, resid, hwnd, PyDlgProcHDLG, (LPARAM)obExtra); Py_END_ALLOW_THREADS Py_DECREF(obExtra); *************** *** 2117,2121 **** Py_BEGIN_ALLOW_THREADS HGLOBAL templ = (HGLOBAL) GlobalLock(h); ! rc = DialogBoxIndirectParam((HINSTANCE)hinst, (const DLGTEMPLATE *) templ, (HWND)hwnd, PyDlgProcHDLG, (LPARAM)obExtra); GlobalUnlock(h); GlobalFree(h); --- 2107,2111 ---- Py_BEGIN_ALLOW_THREADS HGLOBAL templ = (HGLOBAL) GlobalLock(h); ! rc = DialogBoxIndirectParam(hinst, (const DLGTEMPLATE *) templ, hwnd, PyDlgProcHDLG, (LPARAM)obExtra); GlobalUnlock(h); GlobalFree(h); *************** *** 2164,2168 **** Py_BEGIN_ALLOW_THREADS HGLOBAL templ = (HGLOBAL) GlobalLock(h); ! rc = CreateDialogIndirectParam((HINSTANCE)hinst, (const DLGTEMPLATE *) templ, (HWND)hwnd, PyDlgProcHDLG, (LPARAM)obExtra); GlobalUnlock(h); GlobalFree(h); --- 2154,2158 ---- Py_BEGIN_ALLOW_THREADS HGLOBAL templ = (HGLOBAL) GlobalLock(h); ! rc = CreateDialogIndirectParam(hinst, (const DLGTEMPLATE *) templ, hwnd, PyDlgProcHDLG, (LPARAM)obExtra); GlobalUnlock(h); GlobalFree(h); *************** *** 2370,2378 **** CURSORINFO ci; ci.cbSize = sizeof(ci); ! if (!PyArg_NoArgs(args)) return NULL; if (!::GetCursorInfo(&ci)) return PyWin_SetAPIError("GetCursorInfo"); ! return Py_BuildValue("ii(ii)", ci.flags, ci.hCursor, ci.ptScreenPos.x, ci.ptScreenPos.y); } %} --- 2360,2368 ---- CURSORINFO ci; ci.cbSize = sizeof(ci); ! if (!PyArg_ParseTuple(args,":GetCursorInfo")) return NULL; if (!::GetCursorInfo(&ci)) return PyWin_SetAPIError("GetCursorInfo"); ! return Py_BuildValue("iN(ii)", ci.flags, PyWinLong_FromHANDLE(ci.hCursor), ci.ptScreenPos.x, ci.ptScreenPos.y); } %} *************** *** 2418,2422 **** ha = ::CreateAcceleratorTable(accels, num); if (ha) ! ret = PyLong_FromVoidPtr((void *)ha); else PyWin_SetAPIError("CreateAcceleratorTable"); --- 2408,2412 ---- ha = ::CreateAcceleratorTable(accels, num); if (ha) ! ret = PyWinLong_FromHANDLE(ha); else PyWin_SetAPIError("CreateAcceleratorTable"); *************** *** 2490,2494 **** %{ ! // @pyswig int|CreateIconFromResource|Creates an icon or cursor from resource bits describing the icon. static PyObject *PyCreateIconFromResource(PyObject *self, PyObject *args) { --- 2480,2484 ---- %{ ! // @pyswig <o PyHANDLE>|CreateIconFromResource|Creates an icon or cursor from resource bits describing the icon. static PyObject *PyCreateIconFromResource(PyObject *self, PyObject *args) { *************** *** 2507,2511 **** if (!ret) return PyWin_SetAPIError("CreateIconFromResource"); ! return PyLong_FromVoidPtr(ret); } %} --- 2497,2501 ---- if (!ret) return PyWin_SetAPIError("CreateIconFromResource"); ! return PyWinLong_FromHANDLE(ret); } %} *************** *** 3085,3089 **** BOOL rc; Py_BEGIN_ALLOW_THREADS ! rc = SetWindowPlacement( (HWND)hwnd, &pment ); Py_END_ALLOW_THREADS if (!rc) --- 3075,3079 ---- BOOL rc; Py_BEGIN_ALLOW_THREADS ! rc = SetWindowPlacement(hwnd, &pment ); Py_END_ALLOW_THREADS if (!rc) *************** *** 3146,3150 **** return NULL; atom=(LPTSTR)PyLong_AsVoidPtr(obatom); ! if (atom==NULL) return NULL; // Only low word can be set when using an atom --- 3136,3140 ---- return NULL; atom=(LPTSTR)PyLong_AsVoidPtr(obatom); ! if (atom==NULL && PyErr_Occurred()) return NULL; // Only low word can be set when using an atom *************** *** 3670,3675 **** if (!objects_small) goto done; for (i=0;i<nicons;i++) { ! PyList_SET_ITEM(objects_large, i, PyInt_FromLong((long)rgLarge[i])); ! PyList_SET_ITEM(objects_small, i, PyInt_FromLong((long)rgSmall[i])); } ret = Py_BuildValue("OO", objects_large, objects_small); --- 3660,3665 ---- if (!objects_small) goto done; for (i=0;i<nicons;i++) { ! PyList_SET_ITEM(objects_large, i, PyWinLong_FromHANDLE(rgLarge[i])); ! PyList_SET_ITEM(objects_small, i, PyWinLong_FromHANDLE(rgSmall[i])); } ret = Py_BuildValue("OO", objects_large, objects_small); *************** *** 5981,5985 **** hdc=CreateDC(driver, device, dummyoutput, pdevmode); if (hdc!=NULL) ! ret = Py_BuildValue("l",hdc); else { PyWin_SetAPIError("CreateDC",GetLastError()); --- 5971,5975 ---- hdc=CreateDC(driver, device, dummyoutput, pdevmode); if (hdc!=NULL) ! ret = PyWinLong_FromHANDLE(hdc); else { PyWin_SetAPIError("CreateDC",GetLastError()); |
From: Roger U. <ru...@us...> - 2007-01-12 03:35:10
|
Update of /cvsroot/pywin32/pywin32/SWIG/swig_lib/python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7877/SWIG/swig_lib/python Modified Files: pywintypes.i Log Message: Use PyWinLong_FromHANDLE to return int handles Index: pywintypes.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/SWIG/swig_lib/python/pywintypes.i,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** pywintypes.i 28 Jan 2005 02:12:23 -0000 1.4 --- pywintypes.i 12 Jan 2007 03:35:09 -0000 1.5 *************** *** 294,300 **** } } - %apply long {HANDLE}; - typedef long HANDLE; typedef HANDLE PyHANDLE; %{ --- 294,299 ---- } } + typedef long HANDLE; typedef HANDLE PyHANDLE; %{ *************** *** 326,336 **** } ! %typemap(python,ignore) PyHANDLE *OUTPUT(HANDLE temp) { ! $target = &temp; } ! %typemap(python,ignore) PyHKEY *OUTPUT(HKEY temp) { ! $target = &temp; } --- 325,335 ---- } ! %typemap(python,ignore) PyHANDLE *OUTPUT(HANDLE handle_output) { ! $target = &handle_output; } ! %typemap(python,ignore) PyHKEY *OUTPUT(HKEY hkey_output) { ! $target = &hkey_output; } *************** *** 341,344 **** --- 340,346 ---- $target = PyWinObject_FromHKEY($source); } + %typemap(python,out) HANDLE { + $target = PyWinLong_FromHANDLE($source); + } %typemap(python,argout) PyHANDLE *OUTPUT { |
From: Roger U. <ru...@us...> - 2007-01-11 13:13:54
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4788/win32/src Modified Files: PyHANDLE.cpp PyWinObjects.h PyWinTypes.h Log Message: Add PyWinLong_FromHANDLE to act as a unified way to return integer handles Index: PyWinObjects.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWinObjects.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** PyWinObjects.h 22 Sep 2006 14:31:32 -0000 1.10 --- PyWinObjects.h 11 Jan 2007 13:13:48 -0000 1.11 *************** *** 183,187 **** int print(FILE *fp, int flags); PyObject *asStr(void); - long asLong(void); long hash(void); --- 183,186 ---- *************** *** 193,196 **** --- 192,196 ---- static PyObject * strFunc(PyObject *ob); static PyObject * intFunc(PyObject *ob); + static PyObject * longFunc(PyObject *ob); static PyObject * unaryFailureFunc(PyObject *ob); static PyObject * binaryFailureFunc(PyObject *ob1, PyObject *ob2); Index: PyHANDLE.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyHANDLE.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** PyHANDLE.cpp 22 Sep 2006 14:32:33 -0000 1.12 --- PyHANDLE.cpp 11 Jan 2007 13:13:48 -0000 1.13 *************** *** 10,14 **** { HANDLE hInit; ! if (!PyArg_ParseTuple(args, "|i:HANDLE", &hInit)) return NULL; return new PyHANDLE(hInit); --- 10,17 ---- { HANDLE hInit; ! PyObject *obhInit=Py_None; ! if (!PyArg_ParseTuple(args, "|O:HANDLE", &obhInit)) ! return NULL; ! if (!PyWinObject_AsHANDLE(obhInit, &hInit, TRUE)) return NULL; return new PyHANDLE(hInit); *************** *** 27,31 **** --- 30,40 ---- *pHANDLE = (HANDLE)(*pH); } else{ // Support integer objects for b/w compat. + // Can't use PyLong_AsVoidPtr here, since it calls PyLong_AsLong. See + // http://sourceforge.net/tracker/?func=detail&atid=105470&aid=1630863&group_id=5470 + #ifdef _WIN64 + *pHANDLE = (HANDLE)PyLong_AsLongLong(ob); + #else *pHANDLE = (HANDLE)PyInt_AsLong(ob); + #endif if ((*pHANDLE==(HANDLE)-1)&&PyErr_Occurred()){ PyErr_SetString(PyExc_TypeError, "The object is not a PyHANDLE object"); *************** *** 41,44 **** --- 50,65 ---- } + // For handles that aren't returned as PyHANDLE or a subclass thereof (HDC, HWND, etc). + // Return as python ints or longs + // ??? Maybe make this a macro to avoid extra function call ??? + PyObject *PyWinLong_FromHANDLE(HANDLE h) + { + #ifdef _WIN64 + return PyLong_FromLongLong((long long)h); + #else + return PyInt_FromLong((long)h); + #endif + } + BOOL PyWinObject_CloseHANDLE(PyObject *obHandle) { *************** *** 81,87 **** return NULL; PyHANDLE *pThis = (PyHANDLE *)self; ! long ret = (long)pThis->m_handle; ! pThis->m_handle = 0; ! return PyInt_FromLong(ret); } --- 102,109 ---- return NULL; PyHANDLE *pThis = (PyHANDLE *)self; ! PyObject *ret = PyWinLong_FromHANDLE(pThis->m_handle); ! if (ret!=NULL) ! pThis->m_handle = 0; ! return ret; } *************** *** 122,126 **** 0, /* nb_coerce (allowed to be zero) */ PyHANDLE::intFunc, /* nb_int */ ! PyHANDLE::unaryFailureFunc, /* nb_long */ PyHANDLE::unaryFailureFunc, /* nb_float */ PyHANDLE::unaryFailureFunc, /* nb_oct */ --- 144,148 ---- 0, /* nb_coerce (allowed to be zero) */ PyHANDLE::intFunc, /* nb_int */ ! PyHANDLE::longFunc, /* nb_long */ PyHANDLE::unaryFailureFunc, /* nb_float */ PyHANDLE::unaryFailureFunc, /* nb_oct */ *************** *** 233,251 **** } - long PyHANDLE::asLong(void) - { - return (long)m_handle; - } - // @pymethod |PyHANDLE|__int__|Used when the handle as an integer is required. // @comm To get the underling win32 handle from a PyHANDLE object, use int(handleObject) PyObject * PyHANDLE::intFunc(PyObject *ob) { ! long result = ((PyHANDLE *)ob)->asLong(); ! /* PyHANDLE::asLong sets no errors ! if ( result == -1 ) ! return NULL; ! */ ! return PyInt_FromLong(result); } --- 255,270 ---- } // @pymethod |PyHANDLE|__int__|Used when the handle as an integer is required. // @comm To get the underling win32 handle from a PyHANDLE object, use int(handleObject) PyObject * PyHANDLE::intFunc(PyObject *ob) { ! return PyWinLong_FromHANDLE(((PyHANDLE *)ob)->m_handle); ! } ! ! // @pymethod |PyHANDLE|__long__|Used when the handle as an integer is required. ! // @comm To get the underling win32 handle from a PyHANDLE object, use long(handleObject) ! PyObject * PyHANDLE::longFunc(PyObject *ob) ! { ! return PyWinLong_FromHANDLE(((PyHANDLE *)ob)->m_handle); } *************** *** 285,289 **** { TCHAR resBuf[160]; ! wsprintf(resBuf, _T("<%hs at %ld (%ld)>"), GetTypeName(), (long)this, (long)m_handle); // ### ACK! Python uses a non-debug runtime. We can't use stream // ### functions when in DEBUG mode!! (we link against a different --- 304,308 ---- { TCHAR resBuf[160]; ! wsprintf(resBuf, _T("<%hs at %Id (%Id)>"), GetTypeName(), this, m_handle); // ### ACK! Python uses a non-debug runtime. We can't use stream // ### functions when in DEBUG mode!! (we link against a different *************** *** 306,310 **** { TCHAR resBuf[160]; ! wsprintf(resBuf, _T("<%s:%ld>"), GetTypeName(), (long)m_handle); return PyString_FromTCHAR(resBuf); } --- 325,329 ---- { TCHAR resBuf[160]; ! wsprintf(resBuf, _T("<%s:%Id>"), GetTypeName(), m_handle); return PyString_FromTCHAR(resBuf); } *************** *** 319,323 **** PyErr_Clear(); if (strcmp(name, "handle")==0) ! return PyInt_FromLong((long)((PyHANDLE *)self)->m_handle); return PyMember_Get((char *)self, memberlist, name); } --- 338,342 ---- PyErr_Clear(); if (strcmp(name, "handle")==0) ! return PyWinLong_FromHANDLE(((PyHANDLE *)self)->m_handle); return PyMember_Get((char *)self, memberlist, name); } *************** *** 367,371 **** // A Registry handle. ! // @object PyHKEY|A Python object, representing a win32 HKEY (a HANDLE> to a registry key). // See the <o PyHANDLE> object for more details BOOL PyWinObject_AsHKEY(PyObject *ob, HKEY *pRes, BOOL bNoneOK) --- 386,390 ---- // A Registry handle. ! // @object PyHKEY|A Python object, representing a win32 HKEY (a HANDLE to a registry key). // See the <o PyHANDLE> object for more details BOOL PyWinObject_AsHKEY(PyObject *ob, HKEY *pRes, BOOL bNoneOK) *************** *** 381,385 **** { HANDLE hInit; ! if (!PyArg_ParseTuple(args, "|i:HANDLERegistry", &hInit)) return NULL; return new PyHKEY(hInit); --- 400,407 ---- { HANDLE hInit; ! PyObject *obhInit=Py_None; // ??? hInit previously not initialized but treated as optional ??? ! if (!PyArg_ParseTuple(args, "|O:HANDLERegistry", &obhInit)) ! return NULL; ! if (!PyWinObject_AsHANDLE(obhInit, &hInit, TRUE)) return NULL; return new PyHKEY(hInit); *************** *** 388,404 **** BOOL PyWinObject_CloseHKEY(PyObject *obHandle) { ! BOOL ok; ! if (PyHANDLE_Check(obHandle)) // Python error already set. ! ok = ((PyHKEY *)obHandle)->Close(); ! else if PyInt_Check(obHandle) { ! long rc = ::RegCloseKey((HKEY)PyInt_AsLong(obHandle)); ! ok = (rc==ERROR_SUCCESS); ! if (!ok) ! PyWin_SetAPIError("RegCloseKey", rc); ! } else { ! PyErr_SetString(PyExc_TypeError, "A handle must be a HKEY object or an integer"); return FALSE; ! } return ok; } --- 410,429 ---- BOOL PyWinObject_CloseHKEY(PyObject *obHandle) { ! if (PyHANDLE_Check(obHandle)){ ! // Make sure we don't call Close() for any other type of PyHANDLE ! if (strcmp(((PyHANDLE *)obHandle)->GetTypeName(),"PyHKEY")!=0){ ! PyErr_SetString(PyExc_TypeError,"HANDLE must be a PyHKEY"); ! return FALSE; ! } // Python error already set. ! return ((PyHKEY *)obHandle)->Close(); ! } ! HKEY hkey; ! if (!PyWinObject_AsHANDLE(obHandle, (HANDLE *)&hkey, FALSE)) return FALSE; ! long rc = ::RegCloseKey(hkey); ! BOOL ok = (rc==ERROR_SUCCESS); ! if (!ok) ! PyWin_SetAPIError("RegCloseKey", rc); return ok; } Index: PyWinTypes.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWinTypes.h,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** PyWinTypes.h 27 Dec 2006 04:41:14 -0000 1.31 --- PyWinTypes.h 11 Jan 2007 13:13:48 -0000 1.32 *************** *** 394,397 **** --- 394,398 ---- PYWINTYPES_EXPORT BOOL PyWinObject_AsHANDLE(PyObject *ob, HANDLE *pRes, BOOL bNoneOK = FALSE); PYWINTYPES_EXPORT PyObject *PyWinObject_FromHANDLE(HANDLE h); + PYWINTYPES_EXPORT PyObject *PyWinLong_FromHANDLE(HANDLE h); // A global function that can work as a module method for making a HANDLE object. |
From: Roger U. <ru...@us...> - 2007-01-11 04:42:27
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1946/win32/src Modified Files: win32gui.i Log Message: Call handle's Close() method in DeleteObject Index: win32gui.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32gui.i,v retrieving revision 1.98 retrieving revision 1.99 diff -C2 -d -r1.98 -r1.99 *** win32gui.i 5 Jan 2007 20:06:53 -0000 1.98 --- win32gui.i 11 Jan 2007 04:42:26 -0000 1.99 *************** *** 2536,2541 **** #endif /* not MS_WINCE */ // @pyswig |DeleteObject|Deletes a logical pen, brush, font, bitmap, region, or palette, freeing all system resources associated with the object. After the object is deleted, the specified handle is no longer valid. ! BOOLAPI DeleteObject(HANDLE h); // @pyparm int|handle||handle to the object to delete. // @pyswig |BitBlt|Performs a bit-block transfer of the color data corresponding --- 2536,2568 ---- #endif /* not MS_WINCE */ + %{ // @pyswig |DeleteObject|Deletes a logical pen, brush, font, bitmap, region, or palette, freeing all system resources associated with the object. After the object is deleted, the specified handle is no longer valid. ! static PyObject *PyDeleteObject(PyObject *self, PyObject *args) ! { ! PyObject *obhgdiobj; ! if (!PyArg_ParseTuple(args, "O:DeleteObject", ! &obhgdiobj)) // @pyparm <o PyGdiHANDLE>|handle||handle to the object to delete. ! return NULL; ! if (PyHANDLE_Check(obhgdiobj)){ ! // Make sure we don't call Close() for any other type of PyHANDLE ! if (strcmp(((PyHANDLE *)obhgdiobj)->GetTypeName(),"PyGdiHANDLE")!=0){ ! PyErr_SetString(PyExc_TypeError,"DeleteObject requires a PyGdiHANDLE"); ! return NULL; ! } ! if (!((PyHANDLE *)obhgdiobj)->Close()) ! return NULL; ! Py_INCREF(Py_None); ! return Py_None; ! } ! HGDIOBJ hgdiobj; ! if (!PyWinObject_AsHANDLE(obhgdiobj, &hgdiobj, FALSE)) ! return NULL; ! if (!DeleteObject(hgdiobj)) ! return PyWin_SetAPIError("DeleteObject"); ! Py_INCREF(Py_None); ! return Py_None; ! } ! %} ! %native (DeleteObject) PyDeleteObject; // @pyswig |BitBlt|Performs a bit-block transfer of the color data corresponding |
From: Roger U. <ru...@us...> - 2007-01-07 03:52:20
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30752/win32/src Modified Files: win32security.i Log Message: In LsaDeregisterLogonProcess, call PyLsaLogon_HANDLE's Close() method Check handle type in LsaDeregisterLogonProcess and LsaClose Remove places where HANDLEs parsed as longs Add method names to PyArg_ParseTuple formats Index: win32security.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32security.i,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** win32security.i 2 Dec 2006 15:24:11 -0000 1.35 --- win32security.i 7 Jan 2007 03:52:18 -0000 1.36 *************** *** 209,229 **** BOOL PyWinObject_CloseLSA_HANDLE(PyObject *obHandle) { ! BOOL ok; ! if (PyHANDLE_Check(obHandle)) ! // Python error already set. ! ok = ((PyLSA_HANDLE *)obHandle)->Close(); ! else if PyInt_Check(obHandle) { ! NTSTATUS err; ! err=LsaClose((HKEY)PyInt_AsLong(obHandle)); ! ok = err == STATUS_SUCCESS; ! if (!ok) ! PyWin_SetAPIError("LsaClose",LsaNtStatusToWinError(err)); ! } else { ! PyErr_SetString(PyExc_TypeError, "A handle must be a LSA_HANDLE object or an integer"); ! ok = FALSE; ! } ! return ok; } // And re-define, so PyHANDLE in function sigs gets the PyHANDLE treatment. #define PyHANDLE HANDLE --- 209,255 ---- BOOL PyWinObject_CloseLSA_HANDLE(PyObject *obHandle) { ! if (PyHANDLE_Check(obHandle)){ ! // If it's a PyHANDLE, make sure it's the right type, since any other handle's Close method could be called successfully ! if (strcmp(((PyHANDLE *)obHandle)->GetTypeName(),"PyLSA_HANDLE")!=0){ ! PyErr_SetString(PyExc_TypeError,"PyHANDLE passed to LsaClose must be a PyLSA_HANDLE"); ! return FALSE; ! } ! return ((PyHANDLE *)obHandle)->Close(); ! } ! ! HANDLE lsahandle; ! NTSTATUS err; ! if (!PyWinObject_AsHANDLE(obHandle, &lsahandle, FALSE)) ! return FALSE; ! err=LsaClose(lsahandle); ! if (err==STATUS_SUCCESS) ! return TRUE; ! PyWin_SetAPIError("LsaClose",LsaNtStatusToWinError(err)); ! return FALSE; } + BOOL PyWinObject_CloseLsaLogon_HANDLE(PyObject *obHandle) + { + if (PyHANDLE_Check(obHandle)){ + // If it's a PyHANDLE, make sure it's the right type, since any other handle's Close method could be called successfully + if (strcmp(((PyHANDLE *)obHandle)->GetTypeName(),"PyLsaLogon_HANDLE")!=0){ + PyErr_SetString(PyExc_TypeError,"PyHANDLE passed to LsaDeregisterLogonProcess must be a PyLsaLogon_HANDLE"); + return FALSE; + } + return ((PyHANDLE *)obHandle)->Close(); + } + + HANDLE lsahandle; + NTSTATUS err; + if (!PyWinObject_AsHANDLE(obHandle, &lsahandle, FALSE)) + return FALSE; + // function pointer checked in PyLsaDeregisterLogonProcess + err=(*pfnLsaDeregisterLogonProcess)(lsahandle); + if (err==STATUS_SUCCESS) + return TRUE; + PyWin_SetAPIError("LsaDeregisterLogonProcess",LsaNtStatusToWinError(err)); + return FALSE; + } + // And re-define, so PyHANDLE in function sigs gets the PyHANDLE treatment. #define PyHANDLE HANDLE *************** *** 1467,1471 **** DWORD reqdbufsize=0, origgroupcnt=1, origbufsize, err; ! if (!PyArg_ParseTuple(args, "OiO", &obHandle, // @pyparm <o PyHANDLE>|obHandle||The handle to access token to be modified &reset, // @pyparm boolean|ResetToDefault||Sets groups to default enabled/disabled states, --- 1493,1497 ---- DWORD reqdbufsize=0, origgroupcnt=1, origbufsize, err; ! if (!PyArg_ParseTuple(args, "OiO:AdjustTokenGroups", &obHandle, // @pyparm <o PyHANDLE>|obHandle||The handle to access token to be modified &reset, // @pyparm boolean|ResetToDefault||Sets groups to default enabled/disabled states, *************** *** 1526,1530 **** void *buf = NULL; TOKEN_INFORMATION_CLASS typ; ! if (!PyArg_ParseTuple(args, "Ol", &obHandle, // @pyparm <o PyHANDLE>|handle||The handle to query the information for. (long *)&typ)) // @pyparm int|TokenInformationClass||Specifies a value from the TOKEN_INFORMATION_CLASS enumerated type identifying the type of information the function retrieves. --- 1552,1556 ---- void *buf = NULL; TOKEN_INFORMATION_CLASS typ; ! if (!PyArg_ParseTuple(args, "Ol:GetTokenInformation", &obHandle, // @pyparm <o PyHANDLE>|handle||The handle to query the information for. (long *)&typ)) // @pyparm int|TokenInformationClass||Specifies a value from the TOKEN_INFORMATION_CLASS enumerated type identifying the type of information the function retrieves. *************** *** 1689,1693 **** { PyObject *obThread, *obToken; ! if (!PyArg_ParseTuple(args, "OO", &obThread, // @pyparm <o PyHANDLE>|Thread||Handle to a thread. Use None to indicate calling thread. &obToken)) // @pyparm <o PyHANDLE>|Token||Handle to an impersonation token. Use None to end impersonation. --- 1715,1719 ---- { PyObject *obThread, *obToken; ! if (!PyArg_ParseTuple(args, "OO:SetThreadToken", &obThread, // @pyparm <o PyHANDLE>|Thread||Handle to a thread. Use None to indicate calling thread. &obToken)) // @pyparm <o PyHANDLE>|Token||Handle to an impersonation token. Use None to end impersonation. *************** *** 1728,1732 **** // @pyparm string|filename||The name of the file // @pyparm int|info|OWNER_SECURITY_INFORMATION \| GROUP_SECURITY_INFORMATION \| DACL_SECURITY_INFORMATION \| SACL_SECURITY_INFORMATION|Flags that specify the information requested. ! if (!PyArg_ParseTuple(args, "O|l", &obFname, &info)) return NULL; --- 1754,1758 ---- // @pyparm string|filename||The name of the file // @pyparm int|info|OWNER_SECURITY_INFORMATION \| GROUP_SECURITY_INFORMATION \| DACL_SECURITY_INFORMATION \| SACL_SECURITY_INFORMATION|Flags that specify the information requested. ! if (!PyArg_ParseTuple(args, "O|l:GetFileSecurity", &obFname, &info)) return NULL; *************** *** 1772,1776 **** // @pyparm int|info||The type of information to set. // @pyparm <o PySECURITY_DESCRIPTOR>|security||The security information ! if (!PyArg_ParseTuple(args, "OlO", &obFname, &info, &obsd)) return NULL; --- 1798,1802 ---- // @pyparm int|info||The type of information to set. // @pyparm <o PySECURITY_DESCRIPTOR>|security||The security information ! if (!PyArg_ParseTuple(args, "OlO:SetFileSecurity", &obFname, &info, &obsd)) return NULL; *************** *** 1805,1809 **** // @pyparm <o PyHANDLE>|handle||The handle to the object // @pyparm int|info|OWNER_SECURITY_INFORMATION \| GROUP_SECURITY_INFORMATION \| DACL_SECURITY_INFORMATION \| SACL_SECURITY_INFORMATION|Flags that specify the information requested. ! if (!PyArg_ParseTuple(args, "O|l", &obHandle, &info)) return NULL; --- 1831,1835 ---- // @pyparm <o PyHANDLE>|handle||The handle to the object // @pyparm int|info|OWNER_SECURITY_INFORMATION \| GROUP_SECURITY_INFORMATION \| DACL_SECURITY_INFORMATION \| SACL_SECURITY_INFORMATION|Flags that specify the information requested. ! if (!PyArg_ParseTuple(args, "O|l:GetUserObjectSecurity", &obHandle, &info)) return NULL; *************** *** 1848,1852 **** // @pyparm int|info||The type of information to set - combination of SECURITY_INFORMATION values // @pyparm <o PySECURITY_DESCRIPTOR>|security||The security information ! if (!PyArg_ParseTuple(args, "OlO", &obHandle, &info, &obsd)) return NULL; --- 1874,1878 ---- // @pyparm int|info||The type of information to set - combination of SECURITY_INFORMATION values // @pyparm <o PySECURITY_DESCRIPTOR>|security||The security information ! if (!PyArg_ParseTuple(args, "OlO:SetUserObjectSecurity", &obHandle, &info, &obsd)) return NULL; *************** *** 1880,1884 **** // @pyparm <o PyHANDLE>|handle||The handle to the object // @pyparm int|info|OWNER_SECURITY_INFORMATION \| GROUP_SECURITY_INFORMATION \| DACL_SECURITY_INFORMATION \| SACL_SECURITY_INFORMATION|Flags that specify the information requested. ! if (!PyArg_ParseTuple(args, "O|l", &obHandle, &info)) return NULL; --- 1906,1910 ---- // @pyparm <o PyHANDLE>|handle||The handle to the object // @pyparm int|info|OWNER_SECURITY_INFORMATION \| GROUP_SECURITY_INFORMATION \| DACL_SECURITY_INFORMATION \| SACL_SECURITY_INFORMATION|Flags that specify the information requested. ! if (!PyArg_ParseTuple(args, "O|l:GetKernelObjectSecurity", &obHandle, &info)) return NULL; *************** *** 1923,1927 **** // @pyparm int|info||The type of information to set - combination of SECURITY_INFORMATION values // @pyparm <o PySECURITY_DESCRIPTOR>|security||The security information ! if (!PyArg_ParseTuple(args, "OlO", &obHandle, &info, &obsd)) return NULL; --- 1949,1953 ---- // @pyparm int|info||The type of information to set - combination of SECURITY_INFORMATION values // @pyparm <o PySECURITY_DESCRIPTOR>|security||The security information ! if (!PyArg_ParseTuple(args, "OlO:SetKernelObjectSecurity", &obHandle, &info, &obsd)) return NULL; *************** *** 1960,1964 **** TOKEN_INFORMATION_CLASS typ; ! if (!PyArg_ParseTuple(args, "OiO", &obth, // @pyparm <o PyHANDLE>|handle||Handle to an access token to be modified (long *)&typ, // @pyparm int|TokenInformationClass||Specifies a value from the TOKEN_INFORMATION_CLASS enumerated type identifying the type of information the function retrieves. --- 1986,1990 ---- TOKEN_INFORMATION_CLASS typ; ! if (!PyArg_ParseTuple(args, "OiO:SetTokenInformation", &obth, // @pyparm <o PyHANDLE>|handle||Handle to an access token to be modified (long *)&typ, // @pyparm int|TokenInformationClass||Specifies a value from the TOKEN_INFORMATION_CLASS enumerated type identifying the type of information the function retrieves. *************** *** 2050,2054 **** %} ! // @pyswig |LsaClose|Closes a policy handle created by GetPolicyHandle %native(LsaClose) PyLsaClose; %{ --- 2076,2080 ---- %} ! // @pyswig |LsaClose|Closes a policy handle created by <om win32security.LsaOpenPolicy> %native(LsaClose) PyLsaClose; %{ *************** *** 2078,2082 **** void* buf = NULL; POLICY_INFORMATION_CLASS info_class; ! // @pyparm <o PyHANDLE>|PolicyHandle||An LSA policy handle as returned by <om win32security.LsaOpenPolicy> // @pyparm int|InformationClass||POLICY_INFORMATION_CLASS value if (!PyArg_ParseTuple(args, "Oi:LsaQueryInformationPolicy", &obhandle, (long *)&info_class)) --- 2104,2108 ---- void* buf = NULL; POLICY_INFORMATION_CLASS info_class; ! // @pyparm <o PyLSA_HANDLE>|PolicyHandle||An LSA policy handle as returned by <om win32security.LsaOpenPolicy> // @pyparm int|InformationClass||POLICY_INFORMATION_CLASS value if (!PyArg_ParseTuple(args, "Oi:LsaQueryInformationPolicy", &obhandle, (long *)&info_class)) *************** *** 2194,2198 **** void* buf = NULL; POLICY_INFORMATION_CLASS info_class; ! // @pyparm <o PyHANDLE>|PolicyHandle||An LSA policy handle as returned by <om win32security.LsaOpenPolicy> // @pyparm int|InformationClass||POLICY_INFORMATION_CLASS value // @pyparm object|Information||Type is dependent on InformationClass --- 2220,2224 ---- void* buf = NULL; POLICY_INFORMATION_CLASS info_class; ! // @pyparm <o PyLSA_HANDLE>|PolicyHandle||An LSA policy handle as returned by <om win32security.LsaOpenPolicy> // @pyparm int|InformationClass||POLICY_INFORMATION_CLASS value // @pyparm object|Information||Type is dependent on InformationClass *************** *** 2260,2264 **** %} ! // @pyswig |LsaAddAccountRights|Adds a list of privliges to an account - account is created if it doesn't already exist %native(LsaAddAccountRights) PyLsaAddAccountRights; %{ --- 2286,2290 ---- %} ! // @pyswig |LsaAddAccountRights|Adds a list of privileges to an account - account is created if it doesn't already exist %native(LsaAddAccountRights) PyLsaAddAccountRights; %{ *************** *** 2272,2276 **** HANDLE hpolicy; NTSTATUS err; ! // @pyparm <o PyHANDLE>|PolicyHandle||An LSA policy handle as returned by <om win32security.LsaOpenPolicy> // @pyparm <o PySID>|AccountSid||Account to which privs will be added // @pyparm (str/unicode,...)|UserRights||List of privilege names (SE_*_NAME unicode constants) --- 2298,2302 ---- HANDLE hpolicy; NTSTATUS err; ! // @pyparm <o PyLSA_HANDLE>|PolicyHandle||An LSA policy handle as returned by <om win32security.LsaOpenPolicy> // @pyparm <o PySID>|AccountSid||Account to which privs will be added // @pyparm (str/unicode,...)|UserRights||List of privilege names (SE_*_NAME unicode constants) *************** *** 2337,2341 **** HANDLE hpolicy; NTSTATUS err; ! // @pyparm <o PyHANDLE>|PolicyHandle||An LSA policy handle as returned by <om win32security.LsaOpenPolicy> // @pyparm <o PySID>|AccountSid||Account whose privileges will be removed // @pyparm int|AllRights||Boolean value indicating if all privs should be removed from account --- 2363,2367 ---- HANDLE hpolicy; NTSTATUS err; ! // @pyparm <o PyLSA_HANDLE>|PolicyHandle||An LSA policy handle as returned by <om win32security.LsaOpenPolicy> // @pyparm <o PySID>|AccountSid||Account whose privileges will be removed // @pyparm int|AllRights||Boolean value indicating if all privs should be removed from account *************** *** 2402,2406 **** HANDLE hpolicy; NTSTATUS err; ! // @pyparm <o PyHANDLE>|PolicyHandle||An LSA policy handle as returned by <om win32security.LsaOpenPolicy> // @pyparm <o PySID>|AccountSid||Security identifier of account for which to list privs if (!PyArg_ParseTuple(args, "OO:LsaEnumerateAccountRights", &policy_handle, &obsid)) --- 2428,2432 ---- HANDLE hpolicy; NTSTATUS err; ! // @pyparm <o PyLSA_HANDLE>|PolicyHandle||An LSA policy handle as returned by <om win32security.LsaOpenPolicy> // @pyparm <o PySID>|AccountSid||Security identifier of account for which to list privs if (!PyArg_ParseTuple(args, "OO:LsaEnumerateAccountRights", &policy_handle, &obsid)) *************** *** 2444,2448 **** NTSTATUS err; DWORD win32err; ! // @pyparm <o PyHANDLE>|PolicyHandle||An LSA policy handle as returned by <om win32security.LsaOpenPolicy> // @pyparm str/unicode|UserRight||Name of privilege (SE_*_NAME unicode constant) if (!PyArg_ParseTuple(args, "OO:LsaEnumerateAccountsWithUserRight", &policy_handle, &obpriv)) --- 2470,2474 ---- NTSTATUS err; DWORD win32err; ! // @pyparm <o PyLSA_HANDLE>|PolicyHandle||An LSA policy handle as returned by <om win32security.LsaOpenPolicy> // @pyparm str/unicode|UserRight||Name of privilege (SE_*_NAME unicode constant) if (!PyArg_ParseTuple(args, "OO:LsaEnumerateAccountsWithUserRight", &policy_handle, &obpriv)) *************** *** 2591,2595 **** static PyObject *PyLsaStorePrivateData(PyObject *self, PyObject *args) { ! // @pyparm <o PyHANDLE>|PolicyHandle||An LSA policy handle as returned by <om win32security.LsaOpenPolicy> // @pyparm string|KeyName||Registry key in which to store data // @pyparm <o PyUNICODE>|PrivateData||Unicode string to be encrypted and stored --- 2617,2621 ---- static PyObject *PyLsaStorePrivateData(PyObject *self, PyObject *args) { ! // @pyparm <o PyLSA_HANDLE>|PolicyHandle||An LSA policy handle as returned by <om win32security.LsaOpenPolicy> // @pyparm string|KeyName||Registry key in which to store data // @pyparm <o PyUNICODE>|PrivateData||Unicode string to be encrypted and stored *************** *** 2636,2640 **** static PyObject *PyLsaRetrievePrivateData(PyObject *self, PyObject *args) { ! // @pyparm <o PyHANDLE>|PolicyHandle||An LSA policy handle as returned by <om win32security.LsaOpenPolicy> // @pyparm string|KeyName||Registry key to read PyObject *obpolicyhandle=NULL, *obkeyname=NULL, *obprivatedata=NULL; --- 2662,2666 ---- static PyObject *PyLsaRetrievePrivateData(PyObject *self, PyObject *args) { ! // @pyparm <o PyLSA_HANDLE>|PolicyHandle||An LSA policy handle as returned by <om win32security.LsaOpenPolicy> // @pyparm string|KeyName||Registry key to read PyObject *obpolicyhandle=NULL, *obkeyname=NULL, *obprivatedata=NULL; *************** *** 2906,2910 **** CHECK_PFN(CreateRestrictedToken); ! if (!PyArg_ParseTuple(args,"OlOOO", &obExistingTokenHandle, // @pyparm <o PyHANDLE>|ExistingTokenHandle||Handle to an access token (see <om win32security.LogonUser>,<om win32security.OpenProcessToken> &Flags, // @pyparm int|Flags||Valid values are zero or a combination of DISABLE_MAX_PRIVILEGE and SANDBOX_INERT --- 2932,2936 ---- CHECK_PFN(CreateRestrictedToken); ! if (!PyArg_ParseTuple(args,"OlOOO:CreateRestrictedToken", &obExistingTokenHandle, // @pyparm <o PyHANDLE>|ExistingTokenHandle||Handle to an access token (see <om win32security.LogonUser>,<om win32security.OpenProcessToken> &Flags, // @pyparm int|Flags||Valid values are zero or a combination of DISABLE_MAX_PRIVILEGE and SANDBOX_INERT *************** *** 2982,2997 **** { CHECK_PFN(LsaDeregisterLogonProcess); ! HANDLE lsahandle; ! NTSTATUS err; ! // @pyparm int|LsaHandle||An Lsa handle as returned by LsaConnectUntrusted or LsaRegisterLogonProcess ! if (!PyArg_ParseTuple(args, "l:LsaDeregisterLogonProcess",&lsahandle)) return NULL; ! err=(*pfnLsaDeregisterLogonProcess)(lsahandle); ! if (err==STATUS_SUCCESS){ ! Py_INCREF(Py_None); ! return Py_None; ! } ! PyWin_SetAPIError("LsaDeregisterLogonProcess",LsaNtStatusToWinError(err)); ! return NULL; } %} --- 3008,3019 ---- { CHECK_PFN(LsaDeregisterLogonProcess); ! PyObject *obhandle; ! // @pyparm <o PyLsaLogon_HANDLE>|LsaHandle||An Lsa handle as returned by <om win32security.LsaConnectUntrusted> or <om win32security.LsaRegisterLogonProcess> ! if (!PyArg_ParseTuple(args, "O:LsaDeregisterLogonProcess",&obhandle)) return NULL; ! if (!PyWinObject_CloseLsaLogon_HANDLE(obhandle)) ! return NULL; ! Py_INCREF(Py_None); ! return Py_None; } %} *************** *** 3006,3016 **** NTSTATUS err; HANDLE lsahandle; LSA_STRING packagename; ULONG packageid; ! // @pyparm int|<o PyLsaLogon_HANDLE>||An Lsa handle as returned by <om win32security.LsaConnectUntrusted> or <om win32security.LsaRegisterLogonProcess> // @pyparm string|PackageName||Name of security package to be identified ! ! if (!PyArg_ParseTuple(args,"ls#:LsaLookupAuthenticationPackage", &lsahandle, &packagename.Buffer, &packagename.Length)) return NULL; packagename.MaximumLength=packagename.Length+1; err=(*pfnLsaLookupAuthenticationPackage)(lsahandle, &packagename, &packageid); --- 3028,3041 ---- NTSTATUS err; HANDLE lsahandle; + PyObject *obhandle; LSA_STRING packagename; ULONG packageid; ! // @pyparm <o PyLsaLogon_HANDLE>|LsaHandle||An Lsa handle as returned by <om win32security.LsaConnectUntrusted> or <om win32security.LsaRegisterLogonProcess> // @pyparm string|PackageName||Name of security package to be identified ! if (!PyArg_ParseTuple(args,"Os#:LsaLookupAuthenticationPackage", &obhandle, &packagename.Buffer, &packagename.Length)) return NULL; + if (!PyWinObject_AsHANDLE(obhandle, &lsahandle, FALSE)) + return NULL; + packagename.MaximumLength=packagename.Length+1; err=(*pfnLsaLookupAuthenticationPackage)(lsahandle, &packagename, &packageid); *************** *** 3186,3190 **** SECURITY_STATUS err; ! if (!PyArg_ParseTuple(args,"OOlOO|OO", &obPrincipal, // @pyparm str/unicode|Principal||Use None for current security context &obPackage, // @pyparm str/unicode|Package||Name of security package that credentials will be used with --- 3211,3215 ---- SECURITY_STATUS err; ! if (!PyArg_ParseTuple(args,"OOlOO|OO:AcquireCredentialsHandle", &obPrincipal, // @pyparm str/unicode|Principal||Use None for current security context &obPackage, // @pyparm str/unicode|Package||Name of security package that credentials will be used with *************** *** 3245,3249 **** SECURITY_STATUS err; PyObject *ret=NULL; ! if (!PyArg_ParseTuple(args,"OOOllOOO", &obcredhandle, // @pyparm <o PyCredHandle>|Credential||A credentials handle as returned by <om win32security.AcquireCredentialsHandle> &obctxt, // @pyparm <o PyCtxtHandle>|Context||Use None on initial call, then handle returned in NewContext thereafter --- 3270,3274 ---- SECURITY_STATUS err; PyObject *ret=NULL; ! if (!PyArg_ParseTuple(args,"OOOllOOO:InitializeSecurityContext", &obcredhandle, // @pyparm <o PyCredHandle>|Credential||A credentials handle as returned by <om win32security.AcquireCredentialsHandle> &obctxt, // @pyparm <o PyCtxtHandle>|Context||Use None on initial call, then handle returned in NewContext thereafter *************** *** 3297,3301 **** PyObject *ret=NULL; ! if (!PyArg_ParseTuple(args,"OOOllOO", &obcredhandle, // @pyparm <o PyCredHandle>|Credential||Handle to server's credentials (see AcquireCredentialsHandle) &obctxt, // @pyparm <o PyCtxtHandle>|Context||Use None on initial call, then handle returned in NewContext thereafter --- 3322,3326 ---- PyObject *ret=NULL; ! if (!PyArg_ParseTuple(args,"OOOllOO:AcceptSecurityContext", &obcredhandle, // @pyparm <o PyCredHandle>|Credential||Handle to server's credentials (see AcquireCredentialsHandle) &obctxt, // @pyparm <o PyCtxtHandle>|Context||Use None on initial call, then handle returned in NewContext thereafter *************** *** 3374,3384 **** CHECK_PFN(LsaFreeReturnBuffer); HANDLE lsahandle; NTSTATUS err, protocol_status; ULONG pkgid, inputbuflen, outputbuflen, msgtype; PVOID inputbuf=NULL, outputbuf=NULL; PyObject *ret=NULL, *obinputbuf; ! if (!PyArg_ParseTuple(args, "lllO:LsaCallAuthenticationPackage", &lsahandle, &pkgid, &msgtype, &obinputbuf)) return NULL; ! // Message-specific input // @flagh MessageType|Input type --- 3399,3412 ---- CHECK_PFN(LsaFreeReturnBuffer); HANDLE lsahandle; + PyObject *obhandle; NTSTATUS err, protocol_status; ULONG pkgid, inputbuflen, outputbuflen, msgtype; PVOID inputbuf=NULL, outputbuf=NULL; PyObject *ret=NULL, *obinputbuf; ! if (!PyArg_ParseTuple(args, "OllO:LsaCallAuthenticationPackage", &obhandle, &pkgid, &msgtype, &obinputbuf)) return NULL; ! if (!PyWinObject_AsHANDLE(obhandle, &lsahandle, FALSE)) ! return NULL; ! // Message-specific input // @flagh MessageType|Input type *************** *** 3514,3518 **** WCHAR *buf = NULL; BOOL ok; ! if (!PyArg_ParseTuple(args, "Oii|l", &obAcctName, // @pyparm <o PyUnicode>|accountName||object name &format, // @pyparm int|accountNameFormat||A value from the EXTENDED_NAME_FORMAT enumeration type indicating the format of the accountName name. --- 3542,3546 ---- WCHAR *buf = NULL; BOOL ok; ! if (!PyArg_ParseTuple(args, "Oii|l:TranslateName", &obAcctName, // @pyparm <o PyUnicode>|accountName||object name &format, // @pyparm int|accountNameFormat||A value from the EXTENDED_NAME_FORMAT enumeration type indicating the format of the accountName name. *************** *** 3557,3561 **** return PyErr_Format(PyExc_MemoryError, "CreateWellKnownSid: Unable to allocate %d bytes", bufsize); ! if (!PyArg_ParseTuple(args, "k|O", &sidtype, // @pyparm int|WellKnownSidType||One of the Win*Sid constants &obDomainSid)) // @pyparm <o PySID>|DomainSid|None|Domain for the new SID, or None for local machine --- 3585,3589 ---- return PyErr_Format(PyExc_MemoryError, "CreateWellKnownSid: Unable to allocate %d bytes", bufsize); ! if (!PyArg_ParseTuple(args, "k|O:CreateWellKnownSid", &sidtype, // @pyparm int|WellKnownSidType||One of the Win*Sid constants &obDomainSid)) // @pyparm <o PySID>|DomainSid|None|Domain for the new SID, or None for local machine *************** *** 3583,3587 **** // @pyparm (int,int,int,int)|GenericMapping||A tuple of 4 bitmasks (GenericRead, GenericWrite, GenericExecute, GenericAll) // containing the standard and specific rights that correspond to the generic rights. ! if (!PyArg_ParseTuple(args,"k(kkkk)", &mask, &mapping.GenericRead, &mapping.GenericWrite, &mapping.GenericExecute, &mapping.GenericAll)) return NULL; --- 3611,3615 ---- // @pyparm (int,int,int,int)|GenericMapping||A tuple of 4 bitmasks (GenericRead, GenericWrite, GenericExecute, GenericAll) // containing the standard and specific rights that correspond to the generic rights. ! if (!PyArg_ParseTuple(args,"k(kkkk):MapGenericMask", &mask, &mapping.GenericRead, &mapping.GenericWrite, &mapping.GenericExecute, &mapping.GenericAll)) return NULL; |
From: Roger U. <ru...@us...> - 2007-01-06 19:30:54
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4372/win32/src Modified Files: win32file.i Log Message: Use PyLong_FromVoidPtr for backup context pointers Index: win32file.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32file.i,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -d -r1.67 -r1.68 *** win32file.i 6 Jan 2007 08:16:40 -0000 1.67 --- win32file.i 6 Jan 2007 19:30:53 -0000 1.68 *************** *** 3570,3574 **** return NULL; } ! return Py_BuildValue("lNl", bytes_read, obbufout, ctxt); } --- 3570,3574 ---- return NULL; } ! return Py_BuildValue("lNN", bytes_read, obbufout, PyLong_FromVoidPtr(ctxt)); } *************** *** 3648,3652 **** return NULL; } ! return Py_BuildValue("ll", bytes_written, ctxt); } --- 3648,3652 ---- return NULL; } ! return Py_BuildValue("lN", bytes_written, PyLong_FromVoidPtr(ctxt)); } |
From: Roger U. <ru...@us...> - 2007-01-06 08:16:41
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14042/win32/src Modified Files: win32file.i Log Message: Remove places where handles parsed with 'l' format Index: win32file.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32file.i,v retrieving revision 1.66 retrieving revision 1.67 diff -C2 -d -r1.66 -r1.67 *** win32file.i 20 Nov 2006 22:21:48 -0000 1.66 --- win32file.i 6 Jan 2007 08:16:40 -0000 1.67 *************** *** 1595,1604 **** DWORD filter; DWORD bytes_returned; ! PyObject *obBuffer; PyObject *ret = NULL; PyObject *obOverlapped = Py_None; PyObject *obOverlappedRoutine = Py_None; ! if (!PyArg_ParseTuple(args, "iOii|OO", ! &handle, // @pyparm int|handle||Handle to the directory to be monitored. This directory must be opened with the FILE_LIST_DIRECTORY access right. &obBuffer, // @pyparm int|size||Size of the buffer to allocate for the results. &bWatchSubtree, // @pyparm int|bWatchSubtree||Specifies whether the ReadDirectoryChangesW function will monitor the directory or the directory tree. If TRUE is specified, the function monitors the directory tree rooted at the specified directory. If FALSE is specified, the function monitors only the directory specified by the hDirectory parameter. --- 1595,1604 ---- DWORD filter; DWORD bytes_returned; ! PyObject *obBuffer, *obhandle; PyObject *ret = NULL; PyObject *obOverlapped = Py_None; PyObject *obOverlappedRoutine = Py_None; ! if (!PyArg_ParseTuple(args, "OOii|OO:ReadDirectoryChangesW", ! &obhandle, // @pyparm <o PyHANDLE>|handle||Handle to the directory to be monitored. This directory must be opened with the FILE_LIST_DIRECTORY access right. &obBuffer, // @pyparm int|size||Size of the buffer to allocate for the results. &bWatchSubtree, // @pyparm int|bWatchSubtree||Specifies whether the ReadDirectoryChangesW function will monitor the directory or the directory tree. If TRUE is specified, the function monitors the directory tree rooted at the specified directory. If FALSE is specified, the function monitors only the directory specified by the hDirectory parameter. *************** *** 1616,1620 **** if (!PyWinObject_AsOVERLAPPED(obOverlapped, &pOverlapped)) return NULL; ! // Todo: overlappedRoutine support. if (obOverlappedRoutine != Py_None) --- 1616,1621 ---- if (!PyWinObject_AsOVERLAPPED(obOverlapped, &pOverlapped)) return NULL; ! if (!PyWinObject_AsHANDLE(obhandle, &handle, FALSE)) ! return NULL; // Todo: overlappedRoutine support. if (obOverlappedRoutine != Py_None) *************** *** 1744,1748 **** DWORD iMethod; HANDLE handle; ! if (!PyArg_ParseTuple(args, "OOl", &obHandle, // @pyparm <o PyHANDLE>|handle||The file to perform the operation on. &obOffset, // @pyparm <o Py_LARGEINTEGER>|offset||Offset to move the file pointer. --- 1745,1749 ---- DWORD iMethod; HANDLE handle; ! if (!PyArg_ParseTuple(args, "OOl:SetFilePointer", &obHandle, // @pyparm <o PyHANDLE>|handle||The file to perform the operation on. &obOffset, // @pyparm <o Py_LARGEINTEGER>|offset||Offset to move the file pointer. *************** *** 2824,2828 **** return PyErr_Format(PyExc_NotImplementedError,"SetVolumeMountPoint not supported by this version of Windows"); ! if (!PyArg_ParseTuple(args,"OO", &mount_point_obj, &volume_obj)) return NULL; --- 2825,2829 ---- return PyErr_Format(PyExc_NotImplementedError,"SetVolumeMountPoint not supported by this version of Windows"); ! if (!PyArg_ParseTuple(args,"OO:SetVolumeMountPoint", &mount_point_obj, &volume_obj)) return NULL; *************** *** 2873,2877 **** return PyErr_Format(PyExc_NotImplementedError,"DeleteVolumeMountPoint not supported by this version of Windows"); ! if (!PyArg_ParseTuple(args,"O", &mount_point_obj)) return NULL; --- 2874,2878 ---- return PyErr_Format(PyExc_NotImplementedError,"DeleteVolumeMountPoint not supported by this version of Windows"); ! if (!PyArg_ParseTuple(args,"O:DeleteVolumeMountPoint", &mount_point_obj)) return NULL; *************** *** 2921,2925 **** if (pfnCreateHardLinkW==NULL) return PyErr_Format(PyExc_NotImplementedError,"CreateHardLink not supported by this version of Windows"); ! if (!PyArg_ParseTuple(args,"OO|O", &new_file_obj, &existing_file_obj, &sa_obj)) return NULL; --- 2922,2926 ---- if (pfnCreateHardLinkW==NULL) return PyErr_Format(PyExc_NotImplementedError,"CreateHardLink not supported by this version of Windows"); ! if (!PyArg_ParseTuple(args,"OO|O:CreateHardLink", &new_file_obj, &existing_file_obj, &sa_obj)) return NULL; *************** *** 3033,3037 **** if (pfnEncryptFile==NULL) return PyErr_Format(PyExc_NotImplementedError,"EncryptFile not supported by this version of Windows"); ! if (!PyArg_ParseTuple(args,"O", &obfname)) return NULL; if (!PyWinObject_AsWCHAR(obfname, &fname, FALSE)) --- 3034,3038 ---- if (pfnEncryptFile==NULL) return PyErr_Format(PyExc_NotImplementedError,"EncryptFile not supported by this version of Windows"); ! if (!PyArg_ParseTuple(args,"O:EncryptFile", &obfname)) return NULL; if (!PyWinObject_AsWCHAR(obfname, &fname, FALSE)) *************** *** 3080,3084 **** if (pfnEncryptionDisable==NULL) return PyErr_Format(PyExc_NotImplementedError,"EncryptionDisable not supported by this version of Windows"); ! if (!PyArg_ParseTuple(args,"Oi", &obfname, &Disable)) return NULL; if (!PyWinObject_AsWCHAR(obfname, &fname, FALSE)) --- 3081,3085 ---- if (pfnEncryptionDisable==NULL) return PyErr_Format(PyExc_NotImplementedError,"EncryptionDisable not supported by this version of Windows"); ! if (!PyArg_ParseTuple(args,"Oi:EncryptionDisable", &obfname, &Disable)) return NULL; if (!PyWinObject_AsWCHAR(obfname, &fname, FALSE)) *************** *** 3108,3112 **** if (pfnFileEncryptionStatus==NULL) return PyErr_Format(PyExc_NotImplementedError,"FileEncryptionStatus not supported by this version of Windows"); ! if (!PyArg_ParseTuple(args,"O", &obfname)) return NULL; if (!PyWinObject_AsWCHAR(obfname, &fname, FALSE)) --- 3109,3113 ---- if (pfnFileEncryptionStatus==NULL) return PyErr_Format(PyExc_NotImplementedError,"FileEncryptionStatus not supported by this version of Windows"); ! if (!PyArg_ParseTuple(args,"O:FileEncryptionStatus", &obfname)) return NULL; if (!PyWinObject_AsWCHAR(obfname, &fname, FALSE)) *************** *** 3538,3544 **** BOOL bAbort,bProcessSecurity; LPVOID ctxt; ! PyObject *obbuf=NULL, *obbufout=NULL; ! if (!PyArg_ParseTuple(args, "llOlll", &h, &bytes_requested, &obbuf, &bAbort, &bProcessSecurity, &ctxt)) return NULL; if (obbuf==Py_None){ --- 3539,3550 ---- BOOL bAbort,bProcessSecurity; LPVOID ctxt; ! PyObject *obbuf=NULL, *obbufout=NULL, *obh, *obctxt; ! if (!PyArg_ParseTuple(args, "OlOllO:BackupRead", &obh, &bytes_requested, &obbuf, &bAbort, &bProcessSecurity, &obctxt)) ! return NULL; ! if (!PyWinObject_AsHANDLE(obh, &h, FALSE)) ! return NULL; ! ctxt=PyLong_AsVoidPtr(obctxt); ! if ((ctxt==NULL) && PyErr_Occurred()) return NULL; if (obbuf==Py_None){ *************** *** 3582,3587 **** ULARGE_INTEGER bytes_moved; LPVOID ctxt; ! PyObject *obbytes_to_seek; ! if (!PyArg_ParseTuple(args,"lOl", &h, &obbytes_to_seek, &ctxt)) return NULL; if (!PyWinObject_AsULARGE_INTEGER(obbytes_to_seek, &bytes_to_seek)) --- 3588,3598 ---- ULARGE_INTEGER bytes_moved; LPVOID ctxt; ! PyObject *obbytes_to_seek, *obh, *obctxt; ! if (!PyArg_ParseTuple(args,"OOO:BackupSeek", &obh, &obbytes_to_seek, &obctxt)) ! return NULL; ! if (!PyWinObject_AsHANDLE(obh, &h, FALSE)) ! return NULL; ! ctxt=PyLong_AsVoidPtr(obctxt); ! if ((ctxt==NULL) && PyErr_Occurred()) return NULL; if (!PyWinObject_AsULARGE_INTEGER(obbytes_to_seek, &bytes_to_seek)) *************** *** 3619,3625 **** BOOL bAbort, bProcessSecurity; LPVOID ctxt; ! PyObject *obbuf; ! if (!PyArg_ParseTuple(args, "llOlll", &h, &bytes_to_write, &obbuf, &bAbort, &bProcessSecurity, &ctxt)) return NULL; if (PyObject_AsReadBuffer(obbuf, (const void **)&buf, &buflen)==-1) --- 3630,3641 ---- BOOL bAbort, bProcessSecurity; LPVOID ctxt; ! PyObject *obbuf, *obh, *obctxt; ! if (!PyArg_ParseTuple(args, "OlOllO:BackupWrite", &obh, &bytes_to_write, &obbuf, &bAbort, &bProcessSecurity, &obctxt)) ! return NULL; ! if (!PyWinObject_AsHANDLE(obh, &h, FALSE)) ! return NULL; ! ctxt=PyLong_AsVoidPtr(obctxt); ! if ((ctxt==NULL) && PyErr_Occurred()) return NULL; if (PyObject_AsReadBuffer(obbuf, (const void **)&buf, &buflen)==-1) |
From: Roger U. <ru...@us...> - 2007-01-05 20:44:36
|
Update of /cvsroot/pywin32/pywin32/Pythonwin/pywin/framework/editor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17268/Pythonwin/pywin/framework/editor Modified Files: document.py Log Message: shutil.copy2 can throw an IOError when saving new document Index: document.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/framework/editor/document.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** document.py 20 Nov 2006 12:35:01 -0000 1.9 --- document.py 5 Jan 2007 20:44:33 -0000 1.10 *************** *** 73,77 **** # to follow the backup. shutil.copy2(fileName, bakFileName) ! except (os.error, NameError): pass try: --- 73,77 ---- # to follow the backup. shutil.copy2(fileName, bakFileName) ! except (os.error, NameError, IOError): pass try: |
From: Roger U. <ru...@us...> - 2007-01-05 20:36:43
|
Update of /cvsroot/pywin32/pywin32/win32/Demos In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14391/win32/Demos Modified Files: win32gui_demo.py Log Message: Add demo for GradientFill Index: win32gui_demo.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Demos/win32gui_demo.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** win32gui_demo.py 2 Jan 2007 08:06:26 -0000 1.4 --- win32gui_demo.py 5 Jan 2007 20:36:41 -0000 1.5 *************** *** 3,7 **** import win32gui, win32con, win32api ! import time, math def _MyCallback( hwnd, extra ): --- 3,7 ---- import win32gui, win32con, win32api ! import time, math, random def _MyCallback( hwnd, extra ): *************** *** 19,23 **** ! def OnPaint(hwnd, msg, wp, lp): dc, ps=win32gui.BeginPaint(hwnd) win32gui.SetGraphicsMode(dc, win32con.GM_ADVANCED) --- 19,23 ---- ! def OnPaint_1(hwnd, msg, wp, lp): dc, ps=win32gui.BeginPaint(hwnd) win32gui.SetGraphicsMode(dc, win32con.GM_ADVANCED) *************** *** 42,57 **** win32gui.EndPaint(hwnd, ps) return 0 ! def wndproc(hwnd, msg, wp, lp): ! if msg==win32con.WM_PAINT: ! return OnPaint(hwnd, msg, wp, lp) ! return win32gui.DefWindowProc(hwnd, msg, wp, lp) def TestSetWorldTransform(): wc = win32gui.WNDCLASS() ! wc.lpszClassName = 'test_win32gui' wc.style = win32con.CS_GLOBALCLASS|win32con.CS_VREDRAW | win32con.CS_HREDRAW wc.hbrBackground = win32con.COLOR_WINDOW+1 ! wc.lpfnWndProc=wndproc class_atom=win32gui.RegisterClass(wc) hwnd = win32gui.CreateWindow(class_atom,'Spin the Lobster!', --- 42,70 ---- win32gui.EndPaint(hwnd, ps) return 0 + wndproc_1={win32con.WM_PAINT:OnPaint_1} + + def OnPaint_2(hwnd, msg, wp, lp): + dc, ps=win32gui.BeginPaint(hwnd) + win32gui.SetGraphicsMode(dc, win32con.GM_ADVANCED) + l,t,r,b=win32gui.GetClientRect(hwnd) ! for x in xrange(25): ! vertices=( ! {'x':int(random.random()*r), 'y':int(random.random()*b), 'Red':int(random.random()*0xff00), 'Green':0, 'Blue':0, 'Alpha':0}, ! {'x':int(random.random()*r), 'y':int(random.random()*b), 'Red':0, 'Green':int(random.random()*0xff00), 'Blue':0, 'Alpha':0}, ! {'x':int(random.random()*r), 'y':int(random.random()*b), 'Red':0, 'Green':0, 'Blue':int(random.random()*0xff00), 'Alpha':0}, ! ) ! mesh=((0,1,2),) ! win32gui.GradientFill(dc,vertices, mesh, win32con.GRADIENT_FILL_TRIANGLE) ! win32gui.EndPaint(hwnd, ps) ! return 0 ! wndproc_2={win32con.WM_PAINT:OnPaint_2} def TestSetWorldTransform(): wc = win32gui.WNDCLASS() ! wc.lpszClassName = 'test_win32gui_1' wc.style = win32con.CS_GLOBALCLASS|win32con.CS_VREDRAW | win32con.CS_HREDRAW wc.hbrBackground = win32con.COLOR_WINDOW+1 ! wc.lpfnWndProc=wndproc_1 class_atom=win32gui.RegisterClass(wc) hwnd = win32gui.CreateWindow(class_atom,'Spin the Lobster!', *************** *** 65,71 **** --- 78,105 ---- win32gui.UnregisterClass(class_atom,None) + def TestGradientFill(): + wc = win32gui.WNDCLASS() + wc.lpszClassName = 'test_win32gui_2' + wc.style = win32con.CS_GLOBALCLASS|win32con.CS_VREDRAW | win32con.CS_HREDRAW + wc.hbrBackground = win32con.COLOR_WINDOW+1 + wc.lpfnWndProc=wndproc_2 + class_atom=win32gui.RegisterClass(wc) + hwnd = win32gui.CreateWindowEx(0, class_atom,'Kaleidoscope', + win32con.WS_CAPTION|win32con.WS_VISIBLE|win32con.WS_THICKFRAME|win32con.WS_SYSMENU, + 100,100,900,900, 0, 0, 0, None) + s=win32gui.GetWindowLong(hwnd,win32con.GWL_EXSTYLE) + win32gui.SetWindowLong(hwnd, win32con.GWL_EXSTYLE, s|win32con.WS_EX_LAYERED) + win32gui.SetLayeredWindowAttributes(hwnd, 0, 175, win32con.LWA_ALPHA) + for x in xrange(30): + win32gui.InvalidateRect(hwnd,None,True) + win32gui.PumpWaitingMessages() + time.sleep(0.3) + win32gui.DestroyWindow(hwnd) + win32gui.UnregisterClass(class_atom,None) + print "Enumerating all windows..." TestEnumWindows() print "Testing drawing functions ..." TestSetWorldTransform() + TestGradientFill() print "All tests done!" |
From: Roger U. <ru...@us...> - 2007-01-05 20:06:55
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3465/win32/src Modified Files: win32gui.i Log Message: Remove last few places where HANDLEs parsed as longs Index: win32gui.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32gui.i,v retrieving revision 1.97 retrieving revision 1.98 diff -C2 -d -r1.97 -r1.98 *** win32gui.i 5 Jan 2007 05:33:13 -0000 1.97 --- win32gui.i 5 Jan 2007 20:06:53 -0000 1.98 *************** *** 484,496 **** } %typemap(python,in) ICONINFO *INPUT(ICONINFO iconinfo_input) { if (PyTuple_Check($source)) { ! if (PyArg_ParseTuple($source, "lllll", &iconinfo_input.fIcon, &iconinfo_input.xHotspot, &iconinfo_input.yHotspot, ! &iconinfo_input.hbmMask, &iconinfo_input.hbmColor) == 0) { ! return PyErr_Format(PyExc_TypeError, "%s: a ICONINFO must be a tuple of integers", "$name"); ! } $target = &iconinfo_input; } else { ! return PyErr_Format(PyExc_TypeError, "%s: a ICONINFO must be a tuple of integers", "$name"); } } --- 484,507 ---- } + // @object PyICONINFO|Tuple describing an icon or cursor + // @pyseeapi ICONINFO %typemap(python,in) ICONINFO *INPUT(ICONINFO iconinfo_input) { + PyObject *obmask, *obcolor; if (PyTuple_Check($source)) { ! if (!PyArg_ParseTuple($source, "lllOO", ! &iconinfo_input.fIcon, // @tupleitem 0|boolean|Icon|True indicates an icon, False for a cursor ! &iconinfo_input.xHotspot, // @tupleitem 1|int|xHotSpot|For a cursor, X coord of hotspot. Ignored for icons ! &iconinfo_input.yHotspot, // @tupleitem 2|int|yHotSpot|For a cursor, Y coord of hotspot. Ignored for icons ! &obmask, // @tupleitem 3|<o PyGdiHANDLE>|hbmMask|Monochrome mask bitmap ! &obcolor)) // @tupleitem 4|<o PyGdiHANDLE>|hbmColor|Color bitmap, may be None for black and white icon ! return PyErr_Format(PyExc_TypeError, "%s: an ICONINFO must be a tuple of (int,int,int,HANDLE,HANDLE)", "$name"); ! ! if (!PyWinObject_AsHANDLE(obmask, (HANDLE *)&iconinfo_input.hbmMask, FALSE)) ! return NULL; ! if (!PyWinObject_AsHANDLE(obcolor, (HANDLE *)&iconinfo_input.hbmColor, TRUE)) ! return NULL; $target = &iconinfo_input; } else { ! return PyErr_Format(PyExc_TypeError, "%s: an ICONINFO must be a tuple of (int,int,int,HANDLE,HANDLE)", "$name"); } } *************** *** 498,503 **** %typemap(python,argout) ICONINFO *OUTPUT { PyObject *o; ! o = Py_BuildValue("lllll", $source->fIcon, $source->xHotspot, ! $source->yHotspot, $source->hbmMask, $source->hbmColor); if (!$target) { $target = o; --- 509,514 ---- %typemap(python,argout) ICONINFO *OUTPUT { PyObject *o; ! o = Py_BuildValue("lllNN", $source->fIcon, $source->xHotspot, $source->yHotspot, ! PyWinObject_FromGdiHANDLE($source->hbmMask), PyWinObject_FromGdiHANDLE($source->hbmColor)); if (!$target) { $target = o; *************** *** 590,598 **** // @object TRACKMOUSEEVENT|A tuple of (dwFlags, hwndTrack, dwHoverTime) %typemap(python,in) TRACKMOUSEEVENT *INPUT(TRACKMOUSEEVENT e){ e.cbSize = sizeof e; if (PyTuple_Check($source)) { ! if (PyArg_ParseTuple($source, "lll", &e.dwFlags, &e.hwndTrack, &e.dwHoverTime) == 0) { return PyErr_Format(PyExc_TypeError, "%s: a TRACKMOUSEEVENT must be a tuple of 3 integers", "$name"); } $target = &e; } else { --- 601,612 ---- // @object TRACKMOUSEEVENT|A tuple of (dwFlags, hwndTrack, dwHoverTime) %typemap(python,in) TRACKMOUSEEVENT *INPUT(TRACKMOUSEEVENT e){ + PyObject *obhwnd; e.cbSize = sizeof e; if (PyTuple_Check($source)) { ! if (PyArg_ParseTuple($source, "lOl", &e.dwFlags, &obhwnd, &e.dwHoverTime) == 0) { return PyErr_Format(PyExc_TypeError, "%s: a TRACKMOUSEEVENT must be a tuple of 3 integers", "$name"); } + if (!PyWinObject_AsHANDLE(obhwnd, (HANDLE *)&e.hwndTrack, FALSE)) + return NULL; $target = &e; } else { *************** *** 1739,1743 **** static PyObject *PyCallWindowProc(PyObject *self, PyObject *args) { ! long wndproc, hwnd, wparam, lparam; UINT msg; // @pyparm int|wndproc||The wndproc to call - this is generally the return --- 1753,1759 ---- static PyObject *PyCallWindowProc(PyObject *self, PyObject *args) { ! long wndproc, wparam, lparam; ! HWND hwnd; ! PyObject *obhwnd; UINT msg; // @pyparm int|wndproc||The wndproc to call - this is generally the return *************** *** 1747,1755 **** // @pyparm int|wparam|| // @pyparm int|lparam|| ! if (!PyArg_ParseTuple(args, "llill", &wndproc, &hwnd, &msg, &wparam, &lparam)) return NULL; LRESULT rc; Py_BEGIN_ALLOW_THREADS ! rc = CallWindowProc((MYWNDPROC)wndproc, (HWND)hwnd, msg, wparam, lparam); Py_END_ALLOW_THREADS return PyInt_FromLong(rc); --- 1763,1773 ---- // @pyparm int|wparam|| // @pyparm int|lparam|| ! if (!PyArg_ParseTuple(args, "lOill", &wndproc, &obhwnd, &msg, &wparam, &lparam)) ! return NULL; ! if (!PyWinObject_AsHANDLE(obhwnd, (HANDLE *)&hwnd, FALSE)) return NULL; LRESULT rc; Py_BEGIN_ALLOW_THREADS ! rc = CallWindowProc((MYWNDPROC)wndproc, hwnd, msg, wparam, lparam); Py_END_ALLOW_THREADS return PyInt_FromLong(rc); *************** *** 2469,2473 **** // @pyswig int|CreateIconIndirect|Creates an icon or cursor from an ICONINFO structure. ! HICON CreateIconIndirect(ICONINFO *INPUT); %{ --- 2487,2491 ---- // @pyswig int|CreateIconIndirect|Creates an icon or cursor from an ICONINFO structure. ! HICON CreateIconIndirect(ICONINFO *INPUT); // @pyparm <o PyICONINFO>|iconinfo||Tuple defining the icon parameters %{ *************** *** 3411,3417 **** static PyObject *PyEdit_GetLine(PyObject *self, PyObject *args) { ! long hwnd; int line, size=0; ! if (!PyArg_ParseTuple(args, "li|i", &hwnd, &line, &size)) return NULL; int numChars; --- 3429,3438 ---- static PyObject *PyEdit_GetLine(PyObject *self, PyObject *args) { ! HWND hwnd; ! PyObject *obhwnd; int line, size=0; ! if (!PyArg_ParseTuple(args, "Oi|i", &obhwnd, &line, &size)) ! return NULL; ! if (!PyWinObject_AsHANDLE(obhwnd, (HANDLE *)&hwnd, FALSE)) return NULL; int numChars; *************** *** 3419,3425 **** Py_BEGIN_ALLOW_THREADS if (size==0) ! size = Edit_LineLength((HWND)hwnd, line)+1; buf = (TCHAR *)malloc(size * sizeof(TCHAR)); ! numChars = Edit_GetLine((HWND)hwnd, line, buf, size); Py_END_ALLOW_THREADS PyObject *ret; --- 3440,3446 ---- Py_BEGIN_ALLOW_THREADS if (size==0) ! size = Edit_LineLength(hwnd, line)+1; buf = (TCHAR *)malloc(size * sizeof(TCHAR)); ! numChars = Edit_GetLine(hwnd, line, buf, size); Py_END_ALLOW_THREADS PyObject *ret; *************** *** 3642,3647 **** #ifndef MS_WINCE ! // @pyswig tuple|GetIconInfo| ! // @pyparm int|hicon||The icon to query // @rdesc The result is a tuple of (fIcon, xHotspot, yHotspot, hbmMask, hbmColor) // The hbmMask and hbmColor items are bitmaps created for the caller, so must be freed. --- 3663,3668 ---- #ifndef MS_WINCE ! // @pyswig <o PyICONINFO>|GetIconInfo|Returns parameters for an icon or cursor ! // @pyparm <o PyHANDLE>|hicon||The icon to query // @rdesc The result is a tuple of (fIcon, xHotspot, yHotspot, hbmMask, hbmColor) // The hbmMask and hbmColor items are bitmaps created for the caller, so must be freed. *************** *** 4616,4620 **** FLOAT startangle, sweepangle; PyObject *obdc; ! if (!PyArg_ParseTuple(args, "Oiikff", &obdc, // @pyparm <o PyHANDLE>|hdc||Handle to a device context &x, // @pyparm int|Y||x pos of circle --- 4637,4641 ---- FLOAT startangle, sweepangle; PyObject *obdc; ! if (!PyArg_ParseTuple(args, "Oiikff:AngleArc", &obdc, // @pyparm <o PyHANDLE>|hdc||Handle to a device context &x, // @pyparm int|Y||x pos of circle *************** *** 5025,5029 **** int *widths = NULL; HDC hdc; ! if (!PyArg_ParseTuple (args, "OiiiOs#|O", &obdc, &x, // @pyparm x|int||The x coordinate to write the text to. --- 5046,5050 ---- int *widths = NULL; HDC hdc; ! if (!PyArg_ParseTuple (args, "OiiiOs#|O:ExtTextOut", &obdc, &x, // @pyparm x|int||The x coordinate to write the text to. *************** *** 5665,5669 **** HWND hwnd; BOOL bRedraw = TRUE; ! PyObject *obInfo; // @pyparm int|hwnd||The handle to the window. --- 5686,5690 ---- HWND hwnd; BOOL bRedraw = TRUE; ! PyObject *obhwnd, *obInfo; // @pyparm int|hwnd||The handle to the window. *************** *** 5671,5679 **** // @pyparm <o PySCROLLINFO>|scollInfo||Scollbar info. // @pyparm int|bRedraw|1|Should the bar be redrawn? ! if (!PyArg_ParseTuple(args, "liO|i:SetScrollInfo", ! &hwnd, &nBar, &obInfo, &bRedraw)) { ! PyWin_SetAPIError("SetScrollInfo"); return NULL; - } SCROLLINFO info; info.cbSize = sizeof(SCROLLINFO); --- 5692,5700 ---- // @pyparm <o PySCROLLINFO>|scollInfo||Scollbar info. // @pyparm int|bRedraw|1|Should the bar be redrawn? ! if (!PyArg_ParseTuple(args, "OiO|i:SetScrollInfo", ! &obhwnd, &nBar, &obInfo, &bRedraw)) ! return NULL; ! if (!PyWinObject_AsHANDLE(obhwnd, (HANDLE *)&hwnd, FALSE)) return NULL; SCROLLINFO info; info.cbSize = sizeof(SCROLLINFO); *************** *** 5695,5698 **** --- 5716,5720 ---- { HWND hwnd; + PyObject *obhwnd; int nBar; UINT fMask = SIF_ALL; *************** *** 5700,5704 **** // @pyparm int|nBar||The scroll bar to examine. Can be one of win32con.SB_CTL, win32con.SB_VERT or win32con.SB_HORZ // @pyparm int|mask|SIF_ALL|The mask for attributes to retrieve. ! if (!PyArg_ParseTuple(args, "li|i:GetScrollInfo", &hwnd, &nBar, &fMask)) return NULL; SCROLLINFO info; --- 5722,5728 ---- // @pyparm int|nBar||The scroll bar to examine. Can be one of win32con.SB_CTL, win32con.SB_VERT or win32con.SB_HORZ // @pyparm int|mask|SIF_ALL|The mask for attributes to retrieve. ! if (!PyArg_ParseTuple(args, "Oi|i:GetScrollInfo", &obhwnd, &nBar, &fMask)) ! return NULL; ! if (!PyWinObject_AsHANDLE(obhwnd, (HANDLE *)&hwnd, FALSE)) return NULL; SCROLLINFO info; *************** *** 5812,5821 **** { HWND hwnd; ! PyObject *ob; PyObject *obParam = Py_None; // @pyparm int|hwnd||The handle to the window // @pyparm object|callback||A callback object, taking 3 params. // @pyparm object|param|None|The third param to the callback function. ! if (!PyArg_ParseTuple(args, "iO|O:ListView_SortItems", &hwnd, &ob, &obParam)) return NULL; if (!PyCallable_Check(ob)) --- 5836,5847 ---- { HWND hwnd; ! PyObject *ob, *obhwnd; PyObject *obParam = Py_None; // @pyparm int|hwnd||The handle to the window // @pyparm object|callback||A callback object, taking 3 params. // @pyparm object|param|None|The third param to the callback function. ! if (!PyArg_ParseTuple(args, "OO|O:ListView_SortItems", &obhwnd, &ob, &obParam)) ! return NULL; ! if (!PyWinObject_AsHANDLE(obhwnd, (HANDLE *)&hwnd, FALSE)) return NULL; if (!PyCallable_Check(ob)) *************** *** 5854,5863 **** { HWND hwnd; ! PyObject *ob; PyObject *obParam = Py_None; // @pyparm int|hwnd||The handle to the window // @pyparm object|callback||A callback object, taking 3 params. // @pyparm object|param|None|The third param to the callback function. ! if (!PyArg_ParseTuple(args, "iO|O:ListView_SortItemsEx", &hwnd, &ob, &obParam)) return NULL; if (!PyCallable_Check(ob)) --- 5880,5891 ---- { HWND hwnd; ! PyObject *ob, *obhwnd; PyObject *obParam = Py_None; // @pyparm int|hwnd||The handle to the window // @pyparm object|callback||A callback object, taking 3 params. // @pyparm object|param|None|The third param to the callback function. ! if (!PyArg_ParseTuple(args, "OO|O:ListView_SortItemsEx", &obhwnd, &ob, &obParam)) ! return NULL; ! if (!PyWinObject_AsHANDLE(obhwnd, (HANDLE *)&hwnd, FALSE)) return NULL; if (!PyCallable_Check(ob)) |
From: Roger U. <ru...@us...> - 2007-01-05 05:33:16
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32594/win32/src Modified Files: win32gui.i Log Message: Return HBITMAPs as PyGdiHandles Fix stack allocation for NOTIFYICONDATA Remove a few more places where HANDLEs parsed as longs Various autoduck Index: win32gui.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32gui.i,v retrieving revision 1.96 retrieving revision 1.97 diff -C2 -d -r1.96 -r1.97 *** win32gui.i 3 Jan 2007 04:20:41 -0000 1.96 --- win32gui.i 5 Jan 2007 05:33:13 -0000 1.97 *************** *** 142,146 **** } ! // @object PyGdiHANDLE|Gdi objects such as brush (HBRUSH), pen (HPEN), font (HFONT), region (HRGN) // On destruction, the handle is closed using DeleteObject. The object's Close() method also calls DeleteObject. // The gdi object should be deselected from any DC that it is selected into before it's closed. --- 142,146 ---- } ! // @object PyGdiHANDLE|Gdi objects such as brush (HBRUSH), pen (HPEN), font (HFONT), region (HRGN), bitmap (HBITMAP) // On destruction, the handle is closed using DeleteObject. The object's Close() method also calls DeleteObject. // The gdi object should be deselected from any DC that it is selected into before it's closed. *************** *** 172,176 **** // SWIG support for GDI handles. ! %typemap(python,except) HPEN, HBRUSH, HFONT, HRGN { Py_BEGIN_ALLOW_THREADS $function --- 172,176 ---- // SWIG support for GDI handles. ! %typemap(python,except) HPEN, HBRUSH, HFONT, HRGN, HBITMAP { Py_BEGIN_ALLOW_THREADS $function *************** *** 183,195 **** /* ??? If you don't map these to a known type, swig obstinately ignores the input and output typemaps and tries to treat them as pointers. However, it doesn't seem to matter what you typedef them to as long as they have in and out typemaps. ??? */ ! typedef float HPEN, HBRUSH, HFONT, HRGN; ! %typemap(python,out) HPEN, HBRUSH, HFONT, HRGN{ $target = PyWinObject_FromGdiHANDLE($source); } ! %typemap(python,in) HPEN, HBRUSH, HFONT, HRGN{ if (!PyWinObject_AsHANDLE($source, (HANDLE *)&$target, FALSE)) return NULL; } ! %typemap(python,in) HRGN INPUT_NULLOK, HBRUSH INPUT_NULLOK{ if (!PyWinObject_AsHANDLE($source, (HANDLE *)&$target, TRUE)) return NULL; --- 183,195 ---- /* ??? If you don't map these to a known type, swig obstinately ignores the input and output typemaps and tries to treat them as pointers. However, it doesn't seem to matter what you typedef them to as long as they have in and out typemaps. ??? */ ! typedef float HPEN, HBRUSH, HFONT, HRGN, HBITMAP; ! %typemap(python,out) HPEN, HBRUSH, HFONT, HRGN, HBITMAP{ $target = PyWinObject_FromGdiHANDLE($source); } ! %typemap(python,in) HPEN, HBRUSH, HFONT, HRGN, HBITMAP{ if (!PyWinObject_AsHANDLE($source, (HANDLE *)&$target, FALSE)) return NULL; } ! %typemap(python,in) HRGN INPUT_NULLOK, HBRUSH INPUT_NULLOK, HBITMAP INPUT_NULLOK{ if (!PyWinObject_AsHANDLE($source, (HANDLE *)&$target, TRUE)) return NULL; *************** *** 304,310 **** typedef long HICON - %apply HBITMAP {long}; - typedef long HBITMAP - %apply HGDIOBJ {long}; typedef long HGDIOBJ --- 304,307 ---- *************** *** 374,380 **** %typemap(python,in) MSG *INPUT { $target = (MSG *)_alloca(sizeof(MSG)); ! if (!PyArg_ParseTuple($source, "iiiii(ii):MSG param for $name", ! &$target->hwnd, &$target->message, &$target->wParam, --- 371,378 ---- %typemap(python,in) MSG *INPUT { + PyObject *obhwnd; $target = (MSG *)_alloca(sizeof(MSG)); ! if (!PyArg_ParseTuple($source, "Oiiii(ii):MSG param for $name", ! &obhwnd, &$target->message, &$target->wParam, *************** *** 382,388 **** &$target->time, &$target->pt.x, ! &$target->pt.y)) { return NULL; ! } } %typemap(python,ignore) RECT *OUTPUT(RECT rect_output) --- 380,387 ---- &$target->time, &$target->pt.x, ! &$target->pt.y)) return NULL; ! if (!PyWinObject_AsHANDLE(obhwnd, (HANDLE *)&$target->hwnd, FALSE)) ! return NULL; } %typemap(python,ignore) RECT *OUTPUT(RECT rect_output) *************** *** 564,571 **** char *szReserved; int lenReserved; if (PyTuple_Check($source)) { if (!PyArg_ParseTuple($source, ! "ll(iiii)lls#", ! &ps_input.hdc, &ps_input.fErase, &ps_input.rcPaint.left, &ps_input.rcPaint.top, &ps_input.rcPaint.right, &ps_input.rcPaint.bottom, --- 563,571 ---- char *szReserved; int lenReserved; + PyObject *obdc; if (PyTuple_Check($source)) { if (!PyArg_ParseTuple($source, ! "Ol(iiii)lls#", ! &obdc, &ps_input.fErase, &ps_input.rcPaint.left, &ps_input.rcPaint.top, &ps_input.rcPaint.right, &ps_input.rcPaint.bottom, *************** *** 576,579 **** --- 576,581 ---- return NULL; } + if (!PyWinObject_AsHANDLE(obdc, (HANDLE *)&ps_input.hdc, FALSE)) + return NULL; if (lenReserved != sizeof(ps_input.rgbReserved)) return PyErr_Format(PyExc_ValueError, "%s: last element must be string of %d bytes", *************** *** 1299,1303 **** logger = NULL; // @pyparm object|logger||A logger object, generally from the standard logger package. ! if (!PyArg_ParseTuple(args, "O|set_logger", &logger)) return NULL; if (logger==Py_None) --- 1301,1305 ---- logger = NULL; // @pyparm object|logger||A logger object, generally from the standard logger package. ! if (!PyArg_ParseTuple(args, "O:set_logger", &logger)) return NULL; if (logger==Py_None) *************** *** 2014,2033 **** { /// XXX - todo - add support for a dialogproc! ! long hinst, hwnd, param=0; ! PyObject *obResId, *obDlgProc; ! BOOL bFreeString = FALSE; ! if (!PyArg_ParseTuple(args, "lOlO|l", &hinst, &obResId, &hwnd, &obDlgProc, ¶m)) return NULL; LPTSTR resid; ! if (PyInt_Check(obResId)) ! resid = (LPTSTR)MAKEINTRESOURCE(PyInt_AsLong(obResId)); ! else { if (!PyWinObject_AsTCHAR(obResId, &resid)) { PyErr_Clear(); ! PyErr_SetString(PyExc_TypeError, "Resource ID must be a string or int"); return NULL; } ! bFreeString = TRUE; ! } PyObject *obExtra = Py_BuildValue("Ol", obDlgProc, param); --- 2016,2049 ---- { /// XXX - todo - add support for a dialogproc! ! HINSTANCE hinst; ! HWND hwnd; ! LPARAM param=0; ! PyObject *obResId, *obDlgProc, *obhinst, *obhwnd; ! if (!PyArg_ParseTuple(args, "OOOO|l", ! &obhinst, // @pyparm <o PyHANDLE>|hInstance||Handle to module that contains the dialog template ! &obResId, // @pyparm str/int|TemplateName||Name or resource id of the dialog resource ! &obhwnd, // @pyparm <o PyHANDLE>|hWndParent||Handle to dialog's parent window ! &obDlgProc, // @pyparm function|DialogFunc||Dialog box procedure to process messages ! ¶m)) // @pyparm int|InitParam|0|Initialization data to be passed to above procedure during WM_INITDIALOG processing ! return NULL; ! if (!PyWinObject_AsHANDLE(obhinst, (HANDLE *)&hinst, FALSE)) ! return NULL; ! if (!PyWinObject_AsHANDLE(obhwnd, (HANDLE *)&hwnd, TRUE)) return NULL; LPTSTR resid; ! resid = (LPTSTR)PyLong_AsVoidPtr(obResId); ! if ((resid==NULL) && PyErr_Occurred()){ ! PyErr_Clear(); if (!PyWinObject_AsTCHAR(obResId, &resid)) { PyErr_Clear(); ! PyErr_SetString(PyExc_TypeError, "Resource ID must be a string or int in the range 0-65535"); return NULL; + } } ! else ! if (!IS_INTRESOURCE(resid)){ ! PyErr_SetString(PyExc_ValueError,"Int resource id must be in the range 0-65535"); ! return NULL; ! } PyObject *obExtra = Py_BuildValue("Ol", obDlgProc, param); *************** *** 2037,2041 **** Py_END_ALLOW_THREADS Py_DECREF(obExtra); ! if (bFreeString) PyWinObject_FreeTCHAR(resid); if (rc==-1) --- 2053,2057 ---- Py_END_ALLOW_THREADS Py_DECREF(obExtra); ! if (!IS_INTRESOURCE(resid)) PyWinObject_FreeTCHAR(resid); if (rc==-1) *************** *** 2056,2070 **** { /// XXX - todo - add support for a dialogproc! ! long hinst, hwnd, param=0; ! PyObject *obList, *obDlgProc; BOOL bFreeString = FALSE; - // @pyparm int|hinst|| - // @pyparm object|controlList|| - // @pyparm int|hwnd|| - // @pyparm object|dlgproc|| - // @pyparm int|param|0| - if (!PyArg_ParseTuple(args, "lOlO|l", &hinst, &obList, &hwnd, &obDlgProc, ¶m)) - return NULL; HGLOBAL h = MakeResourceFromDlgList(obList); if (h == NULL) --- 2072,2093 ---- { /// XXX - todo - add support for a dialogproc! ! HINSTANCE hinst; ! HWND hwnd; ! LPARAM param=0; ! PyObject *obhinst, *obhwnd, *obList, *obDlgProc; BOOL bFreeString = FALSE; + if (!PyArg_ParseTuple(args, "OOOO|l", + &obhinst, // @pyparm <o PyHANDLE>|hInstance||Handle to module creating the dialog box + &obList, // @pyparm list|controlList||List containing a <o Dialog Header Tuple>, followed by variable number of <o Dialog Item Tuple>s + &obhwnd, // @pyparm <o PyHANDLE>|hWndParent||Handle to dialog's parent window + &obDlgProc, // @pyparm function|DialogFunc||Dialog box procedure to process messages + ¶m)) // @pyparm int|InitParam|0|Initialization data to be passed to above procedure during WM_INITDIALOG processing + return NULL; + if (!PyWinObject_AsHANDLE(obhinst, (HANDLE *)&hinst, FALSE)) + return NULL; + if (!PyWinObject_AsHANDLE(obhwnd, (HANDLE *)&hwnd, TRUE)) + return NULL; + HGLOBAL h = MakeResourceFromDlgList(obList); if (h == NULL) *************** *** 2097,2111 **** { /// XXX - todo - add support for a dialogproc! ! long hinst, hwnd, param=0; ! PyObject *obList, *obDlgProc; BOOL bFreeString = FALSE; ! // @pyparm int|hinst|| ! // @pyparm object|controlList|| ! // @pyparm int|hwnd|| ! // @pyparm object|dlgproc|| ! // @pyparm int|param|0| ! if (!PyArg_ParseTuple(args, "lOlO|l", &hinst, &obList, &hwnd, &obDlgProc, ¶m)) return NULL; ! HGLOBAL h = MakeResourceFromDlgList(obList); if (h == NULL) --- 2120,2140 ---- { /// XXX - todo - add support for a dialogproc! ! HINSTANCE hinst; ! HWND hwnd; ! LPARAM param=0; ! PyObject *obhinst, *obhwnd, *obList, *obDlgProc; BOOL bFreeString = FALSE; ! if (!PyArg_ParseTuple(args, "OOOO|l", ! &obhinst, // @pyparm <o PyHANDLE>|hInstance||Handle to module creating the dialog box ! &obList, // @pyparm list|controlList||List containing a <o Dialog Header Tuple>, followed by variable number of <o Dialog Item Tuple>s ! &obhwnd, // @pyparm <o PyHANDLE>|hWndParent||Handle to dialog's parent window ! &obDlgProc, // @pyparm function|DialogFunc||Dialog box procedure to process messages ! ¶m)) // @pyparm int|InitParam|0|Initialization data to be passed to above procedure during WM_INITDIALOG processing return NULL; ! if (!PyWinObject_AsHANDLE(obhinst, (HANDLE *)&hinst, FALSE)) ! return NULL; ! if (!PyWinObject_AsHANDLE(obhwnd, (HANDLE *)&hwnd, TRUE)) ! return NULL; ! HGLOBAL h = MakeResourceFromDlgList(obList); if (h == NULL) *************** *** 2609,2613 **** &src_x, // @pyparm int|XSrc||X pos of src rect &src_y, // @pyparm int|YSrc||Y pos of src rect ! &obmask, // @pyparm <o PyHANDLE>|Mask||Handle to monochrome bitmap used to mask color &mask_x, // @pyparm int|xMask||X pos in mask &mask_y, // @pyparm int|yMask||Y pos in mask --- 2638,2642 ---- &src_x, // @pyparm int|XSrc||X pos of src rect &src_y, // @pyparm int|YSrc||Y pos of src rect ! &obmask, // @pyparm <o PyGdiHANDLE>|Mask||Handle to monochrome bitmap used to mask color &mask_x, // @pyparm int|xMask||X pos in mask &mask_y, // @pyparm int|yMask||Y pos in mask *************** *** 2673,2678 **** // @rdesc Returns the index of the first new image if successful, or -1 otherwise. int ImageList_Add(HIMAGELIST himl, // @pyparm int|himl||Handle to the image list. ! HBITMAP hbmImage, // @pyparm int|hbmImage||Handle to the bitmap that contains the image or images. The number of images is inferred from the width of the bitmap. ! HBITMAP hbmMask); // @pyparm int|hbmMask||Handle to the bitmap that contains the mask. If no mask is used with the image list, this parameter is ignored --- 2702,2707 ---- // @rdesc Returns the index of the first new image if successful, or -1 otherwise. int ImageList_Add(HIMAGELIST himl, // @pyparm int|himl||Handle to the image list. ! HBITMAP hbmImage, // @pyparm <o PyGdiHANDLE>|hbmImage||Handle to the bitmap that contains the image or images. The number of images is inferred from the width of the bitmap. ! HBITMAP hbmMask); // @pyparm <o PyGdiHANDLE>|hbmMask||Handle to the bitmap that contains the mask. If no mask is used with the image list, this parameter is ignored *************** *** 2900,2904 **** ); ! // @pyswig HBITMAP|CreateCompatibleBitmap|Creates a bitmap compatible with the device that is associated with the specified device context. HBITMAP CreateCompatibleBitmap( HDC hdc, // @pyparm int|hdc||handle to DC --- 2929,2933 ---- ); ! // @pyswig <o PyGdiHANDLE>|CreateCompatibleBitmap|Creates a bitmap compatible with the device that is associated with the specified device context. HBITMAP CreateCompatibleBitmap( HDC hdc, // @pyparm int|hdc||handle to DC *************** *** 2907,2911 **** ); ! // @pyswig HBITMAP|CreateBitmap|Creates a bitmap HBITMAP CreateBitmap( int nWidth, // @pyparm int|width||bitmap width, in pixels --- 2936,2940 ---- ); ! // @pyswig <o PyGdiHANDLE>|CreateBitmap|Creates a bitmap HBITMAP CreateBitmap( int nWidth, // @pyparm int|width||bitmap width, in pixels *************** *** 3234,3241 **** { PyObject *obTip=NULL; memset(pnid, 0, sizeof(*pnid)); pnid->cbSize = sizeof(*pnid); ! if (!PyArg_ParseTuple(ob, "l|iiilO:NOTIFYICONDATA tuple", &pnid->hWnd, &pnid->uID, &pnid->uFlags, &pnid->uCallbackMessage, &pnid->hIcon, &obTip)) return FALSE; if (obTip) { TCHAR *szTip; --- 3263,3275 ---- { PyObject *obTip=NULL; + PyObject *obhwnd, *obhicon=Py_None; memset(pnid, 0, sizeof(*pnid)); pnid->cbSize = sizeof(*pnid); ! if (!PyArg_ParseTuple(ob, "O|iiiOO:NOTIFYICONDATA tuple", &obhwnd, &pnid->uID, &pnid->uFlags, &pnid->uCallbackMessage, &obhicon, &obTip)) return FALSE; + if (!PyWinObject_AsHANDLE(obhwnd, (HANDLE *)&pnid->hWnd, FALSE)) + return NULL; + if (!PyWinObject_AsHANDLE(obhicon, (HANDLE *)&pnid->hIcon, TRUE)) + return NULL; if (obTip) { TCHAR *szTip; *************** *** 3251,3262 **** { PyObject *obTip=NULL, *obInfo=NULL, *obInfoTitle=NULL; memset(pnid, 0, sizeof(*pnid)); pnid->cbSize = sizeof(*pnid); ! if (!PyArg_ParseTuple(ob, "l|iiilOOiOi:NOTIFYICONDATA tuple", ! &pnid->hWnd, &pnid->uID, &pnid->uFlags, ! &pnid->uCallbackMessage, &pnid->hIcon, &obTip, ! &obInfo, &pnid->uTimeout, &obInfoTitle, ! &pnid->dwInfoFlags)) return FALSE; if (obTip) { TCHAR *szTip; --- 3285,3309 ---- { PyObject *obTip=NULL, *obInfo=NULL, *obInfoTitle=NULL; + PyObject *obhwnd, *obhicon=Py_None; memset(pnid, 0, sizeof(*pnid)); pnid->cbSize = sizeof(*pnid); ! // @object PyNOTIFYICONDATA|Tuple used to fill a NOTIFYICONDATA struct as used with <om win32gui.Shell_NotifyIcon> ! // @pyseeapi NOTIFYICONDATA ! if (!PyArg_ParseTuple(ob, "O|iiiOOOiOi:NOTIFYICONDATA tuple", ! &obhwnd, // @tupleitem 0|<o PyHANDLE>|hWnd|Handle to window that will process icon's messages ! &pnid->uID, // @tupleitem 1|int|ID|Unique id used when hWnd processes messages from more than one icon ! &pnid->uFlags, // @tupleitem 2|int|Flags|Combination of win32gui.NIF_* flags ! &pnid->uCallbackMessage, // @tupleitem 3|int|CallbackMessage|Message id to be pass to hWnd when processing messages ! &obhicon, // @tupleitem 4|<o PyHANDLE>|hIcon|Handle to the icon to be displayed ! &obTip, // @tupleitem 5|str|Tip|Tooltip text (optional) ! &obInfo, // @tupleitem 6|str|Info|Balloon tooltip text (optional) ! &pnid->uTimeout, // @tupleitem 7|int|Timeout|Timeout for balloon tooltip, in milliseconds (optional) ! &obInfoTitle, // @tupleitem 8|str|InfoTitle|Title for balloon tooltip (optional) ! &pnid->dwInfoFlags)) // @tupleitem 9|int|InfoFlags|Combination of win32gui.NIIF_* flags (optional) return FALSE; + if (!PyWinObject_AsHANDLE(obhwnd, (HANDLE *)&pnid->hWnd, FALSE)) + return NULL; + if (!PyWinObject_AsHANDLE(obhicon, (HANDLE *)&pnid->hIcon, TRUE)) + return NULL; if (obTip) { TCHAR *szTip; *************** *** 3290,3302 **** #ifndef MS_WINCE #define NIF_INFO NIF_INFO #define NIIF_WARNING NIIF_WARNING #define NIIF_ERROR NIIF_ERROR #define NIIF_NONE NIIF_NONE #define NIIF_INFO NIIF_INFO #endif #define NIM_ADD NIM_ADD // Adds an icon to the status area. #define NIM_DELETE NIM_DELETE // Deletes an icon from the status area. ! #define NIM_MODIFY NIM_MODIFY // Modifies an icon in the status area. #ifdef NIM_SETFOCUS #define NIM_SETFOCUS NIM_SETFOCUS // Give the icon focus. --- 3337,3355 ---- #ifndef MS_WINCE #define NIF_INFO NIF_INFO + #define NIF_STATE NIF_STATE + // #define NIF_GUID NIF_GUID #define NIIF_WARNING NIIF_WARNING #define NIIF_ERROR NIIF_ERROR #define NIIF_NONE NIIF_NONE #define NIIF_INFO NIIF_INFO + // #define NIIF_USER NIIF_USER + #define NIIF_ICON_MASK NIIF_ICON_MASK + #define NIIF_NOSOUND NIIF_NOSOUND #endif #define NIM_ADD NIM_ADD // Adds an icon to the status area. #define NIM_DELETE NIM_DELETE // Deletes an icon from the status area. ! #define NIM_MODIFY NIM_MODIFY // Modifies an icon in the status area. ! #define NIM_SETVERSION NIM_SETVERSION #ifdef NIM_SETFOCUS #define NIM_SETFOCUS NIM_SETFOCUS // Give the icon focus. *************** *** 3307,3316 **** return NULL; } ! %typemap(python,arginit) NOTIFYICONDATA *{ ! NOTIFYICONDATA nid; $target = &nid; } ! // @pyswig |Shell_NotifyIcon|Adds, removes or modifies a taskbar icon, ! BOOLAPI Shell_NotifyIcon(DWORD dwMessage, NOTIFYICONDATA *pnid); #ifdef MS_WINCE --- 3360,3372 ---- return NULL; } ! %typemap(python,arginit) NOTIFYICONDATA *(NOTIFYICONDATA nid){ ! ZeroMemory(&nid, sizeof(nid)); $target = &nid; } ! ! // @pyswig |Shell_NotifyIcon|Adds, removes or modifies a taskbar icon. ! BOOLAPI Shell_NotifyIcon( ! DWORD dwMessage, // @pyparm int|Message||One of win32gui.NIM_* flags ! NOTIFYICONDATA *pnid); // @pyparm <o PyNOTIFYICONDATA>|nid||Tuple containing NOTIFYICONDATA info #ifdef MS_WINCE *************** *** 4451,4456 **** UINT uPosition, // @pyparm int|uPosition||menu item UINT uFlags, // @pyparm int|uFlags||options ! HBITMAP hBitmapUnchecked, // @pyparm int|hBitmapUnchecked||handle to unchecked bitmap ! HBITMAP hBitmapChecked // @pyparm int|hBitmapChecked||handle to checked bitmap ); #endif /* not MS_WINCE */ --- 4507,4512 ---- UINT uPosition, // @pyparm int|uPosition||menu item UINT uFlags, // @pyparm int|uFlags||options ! HBITMAP INPUT_NULLOK, // @pyparm <o PyGdiHANDLE>|hBitmapUnchecked||handle to unchecked bitmap, can be None ! HBITMAP INPUT_NULLOK // @pyparm <o PyGdiHANDLE>|hBitmapChecked||handle to checked bitmap, can be None ); #endif /* not MS_WINCE */ *************** *** 4902,4906 **** &width, // @pyparm int|Width||Width of source rectangle &height, // @pyparm int|Height||Height of source rectangle ! &obmask, // @pyparm <o PyHANDLE>|Mask|None|Handle to monochrome bitmap to mask source &xmask, // @pyparm int|xMask|0|x pos in mask &ymask)) // @pyparm int|yMask|0|y pos in mask --- 4958,4962 ---- &width, // @pyparm int|Width||Width of source rectangle &height, // @pyparm int|Height||Height of source rectangle ! &obmask, // @pyparm <o PyGdiHANDLE>|Mask|None|Handle to monochrome bitmap to mask source, can be None &xmask, // @pyparm int|xMask|0|x pos in mask &ymask)) // @pyparm int|yMask|0|y pos in mask *************** *** 5150,5154 **** // @pyswig <o PyGdiHANDLE>|CreatePatternBrush|Creates a brush using a bitmap as a pattern HBRUSH CreatePatternBrush( ! HBITMAP hbmp); // @pyparm <o PyHANDLE>|hbmp||Handle to a bitmap // @pyswig <o PyGdiHANDLE>|CreateHatchBrush|Creates a hatch brush with specified style and color --- 5206,5210 ---- // @pyswig <o PyGdiHANDLE>|CreatePatternBrush|Creates a brush using a bitmap as a pattern HBRUSH CreatePatternBrush( ! HBITMAP hbmp); // @pyparm <o PyGdiHANDLE>|hbmp||Handle to a bitmap // @pyswig <o PyGdiHANDLE>|CreateHatchBrush|Creates a hatch brush with specified style and color *************** *** 5478,5482 **** BOOLAPI CreateCaret( HWND hWnd, // @pyparm int|hWnd||handle to owner window ! HBITMAP hBitmap, // @pyparm int|hBitmap||handle to bitmap for caret shape int nWidth, // @pyparm int|nWidth||caret width int nHeight // @pyparm int|nHeight||caret height --- 5534,5538 ---- BOOLAPI CreateCaret( HWND hWnd, // @pyparm int|hWnd||handle to owner window ! HBITMAP hBitmap, // @pyparm <o PyGdiHANDLE>|hBitmap||handle to bitmap for caret shape int nWidth, // @pyparm int|nWidth||caret width int nHeight // @pyparm int|nHeight||caret height |
From: Roger U. <ru...@us...> - 2007-01-04 08:30:35
|
Update of /cvsroot/pywin32/pywin32/win32/Demos In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9499/win32/Demos Modified Files: win32gui_dialog.py Log Message: Load icon from executable since py.ico went away in 2.5 Catch error if class already registered Index: win32gui_dialog.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Demos/win32gui_dialog.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** win32gui_dialog.py 12 Apr 2005 03:33:46 -0000 1.6 --- win32gui_dialog.py 4 Jan 2007 08:30:33 -0000 1.7 *************** *** 21,25 **** import winxpgui as win32gui import win32api ! import win32con import struct, array import commctrl --- 21,25 ---- import winxpgui as win32gui import win32api ! import win32con, winerror import struct, array import commctrl *************** *** 35,48 **** WM_SEARCH_FINISHED = win32con.WM_USER + 513 - g_registeredClass = 0 - - g_iconPathName = os.path.abspath(os.path.join( os.path.split(sys.executable)[0], "pyc.ico" )) - if not os.path.isfile(g_iconPathName): - # Look in the source tree. - g_iconPathName = os.path.abspath(os.path.join( os.path.split(sys.executable)[0], "..\\PC\\pyc.ico" )) - if not os.path.isfile(g_iconPathName): - print "Can't find the icon file" - g_iconPathName = None - class _WIN32MASKEDSTRUCT: def __init__(self, **kw): --- 35,38 ---- *************** *** 128,148 **** def _RegisterWndClass(self): className = "PythonDocSearch" ! global g_registeredClass ! if not g_registeredClass: ! message_map = {} ! wc = win32gui.WNDCLASS() ! wc.SetDialogProc() # Make it a dialog class. ! wc.hInstance = self.hinst ! wc.lpszClassName = className ! wc.style = win32con.CS_VREDRAW | win32con.CS_HREDRAW ! wc.hCursor = win32gui.LoadCursor( 0, win32con.IDC_ARROW ) ! wc.hbrBackground = win32con.COLOR_WINDOW + 1 ! wc.lpfnWndProc = message_map # could also specify a wndproc. ! # C code: wc.cbWndExtra = DLGWINDOWEXTRA + sizeof(HBRUSH) + (sizeof(COLORREF)); ! wc.cbWndExtra = win32con.DLGWINDOWEXTRA + struct.calcsize("Pi") ! icon_flags = win32con.LR_LOADFROMFILE | win32con.LR_DEFAULTSIZE ! wc.hIcon = win32gui.LoadImage(self.hinst, g_iconPathName, win32con.IMAGE_ICON, 0, 0, icon_flags) classAtom = win32gui.RegisterClass(wc) ! g_registeredClass = 1 return className --- 118,145 ---- def _RegisterWndClass(self): className = "PythonDocSearch" ! message_map = {} ! wc = win32gui.WNDCLASS() ! wc.SetDialogProc() # Make it a dialog class. ! wc.hInstance = self.hinst ! wc.lpszClassName = className ! wc.style = win32con.CS_VREDRAW | win32con.CS_HREDRAW ! wc.hCursor = win32gui.LoadCursor( 0, win32con.IDC_ARROW ) ! wc.hbrBackground = win32con.COLOR_WINDOW + 1 ! wc.lpfnWndProc = message_map # could also specify a wndproc. ! # C code: wc.cbWndExtra = DLGWINDOWEXTRA + sizeof(HBRUSH) + (sizeof(COLORREF)); ! wc.cbWndExtra = win32con.DLGWINDOWEXTRA + struct.calcsize("Pi") ! icon_flags = win32con.LR_LOADFROMFILE | win32con.LR_DEFAULTSIZE ! ! ## py.ico went away in python 2.5, load from executable instead ! this_app=win32api.GetModuleHandle(None) ! try: ! wc.hIcon=win32gui.LoadIcon(this_app, 1) ## python.exe and pythonw.exe ! except win32gui.error: ! wc.hIcon=win32gui.LoadIcon(this_app, 135) ## pythonwin's icon ! try: classAtom = win32gui.RegisterClass(wc) ! except win32gui.error, err_info: ! if err_info[0]!=winerror.ERROR_CLASS_ALREADY_EXISTS: ! raise return className |
From: Mark H. <mha...@us...> - 2007-01-04 08:20:02
|
Update of /cvsroot/pywin32/pywin32/isapi/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5446 Modified Files: ControlBlock.h PyExtensionObjects.cpp PyExtensionObjects.h Log Message: Add EXTENSION_CONTROL_BLOCK.IsKeepConn() and autoduck corrections. Index: ControlBlock.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/isapi/src/ControlBlock.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ControlBlock.h 12 Oct 2006 07:00:37 -0000 1.3 --- ControlBlock.h 4 Jan 2007 08:19:59 -0000 1.4 *************** *** 132,135 **** --- 132,143 ---- } + BOOL IsKeepConn(LPBOOL bIs) + { + BOOL bOK = (m_pECB->ServerSupportFunction)(m_pECB->ConnID, + HSE_REQ_IS_KEEP_CONN, + (void *)bIs, 0,0); + return bOK; + } + bool IsKeepAlive(void) { Index: PyExtensionObjects.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/isapi/src/PyExtensionObjects.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PyExtensionObjects.h 12 Oct 2006 07:00:37 -0000 1.2 --- PyExtensionObjects.h 4 Jan 2007 08:19:59 -0000 1.3 *************** *** 95,98 **** --- 95,99 ---- static PyObject * TransmitFile(PyObject *self, PyObject * args); // HSE_REQ_TRANSMIT_FILE static PyObject * MapURLToPath(PyObject *self, PyObject * args); // HSE_REQ_MAP_URL_TO_PATH + static PyObject * IsKeepConn(PyObject *self, PyObject * args); // HSE_REQ_IS_KEEP_CONN static PyObject * IsSessionActive(PyObject *self, PyObject * args); Index: PyExtensionObjects.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/isapi/src/PyExtensionObjects.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PyExtensionObjects.cpp 14 Dec 2006 08:35:34 -0000 1.5 --- PyExtensionObjects.cpp 4 Jan 2007 08:19:59 -0000 1.6 *************** *** 157,160 **** --- 157,161 ---- {"IsKeepAlive", PyECB::IsKeepAlive,1}, // @pymeth IsKeepAlive| {"GetImpersonationToken", PyECB::GetImpersonationToken, 1}, // @pymeth GetImpersonationToken| + {"IsKeepConn", PyECB::IsKeepConn, 1}, // @pymeth IsKeepConn|Calls ServerSupportFunction with HSE_REQ_IS_KEEP_CONN {NULL} }; *************** *** 522,525 **** --- 523,543 ---- } + // @pymethod int|EXTENSION_CONTROL_BLOCK|IsKeepConn|Calls ServerSupportFunction with HSE_REQ_IS_KEEP_CONN + PyObject * PyECB::IsKeepConn(PyObject *self, PyObject *args) + { + if (!PyArg_ParseTuple(args, ":IsKeepConn")) + return NULL; + + PyECB * pecb = (PyECB *) self; + BOOL bRes, bIs; + Py_BEGIN_ALLOW_THREADS + bRes = pecb->m_pcb->IsKeepConn(&bIs); + Py_END_ALLOW_THREADS + if (!bRes) + return SetPyECBError("IsKeepCon"); + return PyBool_FromLong(bIs); + } + + class PyTFD { public: *************** *** 578,582 **** &obCallbackParam, // @pyparm object|param||Any object - passed as 2nd arg to callback. &hFile, // @pyparm int|hFile|| ! &info.pszStatusCode, // @pyparm string|statusCode| &info.BytesToWrite, // @pyparm int|BytesToWrite|| &info.Offset, // @pyparm int|Offset|| --- 596,600 ---- &obCallbackParam, // @pyparm object|param||Any object - passed as 2nd arg to callback. &hFile, // @pyparm int|hFile|| ! &info.pszStatusCode, // @pyparm string|statusCode|| &info.BytesToWrite, // @pyparm int|BytesToWrite|| &info.Offset, // @pyparm int|Offset|| *************** *** 589,593 **** return NULL; info.hFile = (HANDLE)hFile; ! // @desc The callback is called with 4 args - (<o PyECB>, param, cbIO, dwErrCode) if (!PyCallable_Check(obCallback)) --- 607,611 ---- return NULL; info.hFile = (HANDLE)hFile; ! // @comm The callback is called with 4 args - (<o PyECB>, param, cbIO, dwErrCode) if (!PyCallable_Check(obCallback)) *************** *** 617,620 **** --- 635,640 ---- // @pymethod |EXTENSION_CONTROL_BLOCK|IsKeepAlive| + // @comm This method simply checks a HTTP_CONNECTION header for 'keep-alive', + // making it fairly useless. See <om EXTENSION_CONTROL_BLOCK.IsKeepCon> PyObject * PyECB::IsKeepAlive(PyObject *self, PyObject * args) { |
From: Mark H. <mha...@us...> - 2007-01-03 04:20:43
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11202 Modified Files: win32gui.i Log Message: GetWindowRgnBox not in win2k or earlier Index: win32gui.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32gui.i,v retrieving revision 1.95 retrieving revision 1.96 diff -C2 -d -r1.95 -r1.96 *** win32gui.i 2 Jan 2007 07:30:50 -0000 1.95 --- win32gui.i 3 Jan 2007 04:20:41 -0000 1.96 *************** *** 5216,5219 **** --- 5216,5220 ---- BOOL Redraw); // @pyparm boolean|Redraw||Indicates if window should be completely redrawn + #ifdef WINXPGUI // @pyswig int, <o PyRECT>|GetWindowRgnBox|Returns the bounding box for a window's region // @rdesc Returns type of region and rectangle coordinates in device units *************** *** 5221,5225 **** HWND hWnd, // @pyparm <o PyHANDLE>|hWnd||Handle to a window that has a window region. (see <om win32gui.SetWindowRgn>) RECT *OUTPUT); ! // @pyswig |ValidateRgn|Removes a region from a window's update region BOOLAPI ValidateRgn( --- 5222,5227 ---- HWND hWnd, // @pyparm <o PyHANDLE>|hWnd||Handle to a window that has a window region. (see <om win32gui.SetWindowRgn>) RECT *OUTPUT); ! // @comm Only available in winxpgui ! #endif // @pyswig |ValidateRgn|Removes a region from a window's update region BOOLAPI ValidateRgn( |
From: Mark H. <mha...@us...> - 2007-01-03 03:39:38
|
Update of /cvsroot/pywin32/pywin32/isapi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28375 Modified Files: install.py Log Message: Don't die at uninstall if the 'Filters' folder doesn't exist for a site Index: install.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/isapi/install.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** install.py 18 May 2006 08:32:35 -0000 1.9 --- install.py 3 Jan 2007 03:39:37 -0000 1.10 *************** *** 285,289 **** _CallHook(filterParams, "PreRemove", options) server = FindWebServer(options, filterParams.Server) ! filters = GetObject(server+"/Filters") try: filters.Delete(_IIS_FILTER, filterParams.Name) --- 285,296 ---- _CallHook(filterParams, "PreRemove", options) server = FindWebServer(options, filterParams.Server) ! ob_path = server+"/Filters" ! try: ! filters = GetObject(ob_path) ! except pythoncom.com_error, details: ! # failure to open the filters just means a totally clean IIS install ! # (IIS5 at least has no 'Filters' key when freshly installed). ! log(2, "ISAPI filter path '%s' did not exist." % (ob_path,)) ! return try: filters.Delete(_IIS_FILTER, filterParams.Name) |
From: Roger U. <ru...@us...> - 2007-01-02 08:06:27
|
Update of /cvsroot/pywin32/pywin32/win32/Demos In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5532/win32/Demos Modified Files: win32gui_demo.py Log Message: Add demo of some of the drawing functions Index: win32gui_demo.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Demos/win32gui_demo.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** win32gui_demo.py 7 Apr 2003 13:01:45 -0000 1.3 --- win32gui_demo.py 2 Jan 2007 08:06:26 -0000 1.4 *************** *** 2,6 **** # Feel free to contribute more demos back ;-) ! import win32gui def _MyCallback( hwnd, extra ): --- 2,7 ---- # Feel free to contribute more demos back ;-) ! import win32gui, win32con, win32api ! import time, math def _MyCallback( hwnd, extra ): *************** *** 17,21 **** --- 18,71 ---- print "Hrmmmm - I'm very surprised to not find a 'tooltips_class32' class." + + def OnPaint(hwnd, msg, wp, lp): + dc, ps=win32gui.BeginPaint(hwnd) + win32gui.SetGraphicsMode(dc, win32con.GM_ADVANCED) + br=win32gui.CreateSolidBrush(win32api.RGB(255,0,0)) + win32gui.SelectObject(dc, br) + angle=win32gui.GetWindowLong(hwnd, win32con.GWL_USERDATA) + win32gui.SetWindowLong(hwnd, win32con.GWL_USERDATA, angle+2) + r_angle=angle*(math.pi/180) + win32gui.SetWorldTransform(dc, + {'M11':math.cos(r_angle), 'M12':math.sin(r_angle), 'M21':math.sin(r_angle)*-1, 'M22':math.cos(r_angle),'Dx':250,'Dy':250}) + win32gui.MoveToEx(dc,250,250) + win32gui.BeginPath(dc) + win32gui.Pie(dc, 10, 70, 200, 200, 350, 350, 75, 10) + win32gui.Chord(dc, 200, 200, 850, 0, 350, 350, 75, 10) + win32gui.LineTo(dc, 300,300) + win32gui.LineTo(dc, 100, 20) + win32gui.LineTo(dc, 20, 100) + win32gui.LineTo(dc, 400, 0) + win32gui.LineTo(dc, 0, 400) + win32gui.EndPath(dc) + win32gui.StrokeAndFillPath(dc) + win32gui.EndPaint(hwnd, ps) + return 0 + + def wndproc(hwnd, msg, wp, lp): + if msg==win32con.WM_PAINT: + return OnPaint(hwnd, msg, wp, lp) + return win32gui.DefWindowProc(hwnd, msg, wp, lp) + + def TestSetWorldTransform(): + wc = win32gui.WNDCLASS() + wc.lpszClassName = 'test_win32gui' + wc.style = win32con.CS_GLOBALCLASS|win32con.CS_VREDRAW | win32con.CS_HREDRAW + wc.hbrBackground = win32con.COLOR_WINDOW+1 + wc.lpfnWndProc=wndproc + class_atom=win32gui.RegisterClass(wc) + hwnd = win32gui.CreateWindow(class_atom,'Spin the Lobster!', + win32con.WS_CAPTION|win32con.WS_VISIBLE, + 100,100,900,900, 0, 0, 0, None) + for x in xrange(500): + win32gui.InvalidateRect(hwnd,None,True) + win32gui.PumpWaitingMessages() + time.sleep(0.01) + win32gui.DestroyWindow(hwnd) + win32gui.UnregisterClass(class_atom,None) + print "Enumerating all windows..." TestEnumWindows() + print "Testing drawing functions ..." + TestSetWorldTransform() print "All tests done!" |
From: Roger U. <ru...@us...> - 2007-01-02 07:30:52
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24006/win32/src Modified Files: win32gui.i Log Message: Revise stack allocations for Swig typemaps, and use more descriptive names for parameters Gdi objects treated as PyHANDLE subclass (PyGdiHANDLE) Add region functions using above Add ExtCreatePen and CreateBrushIndirect Remove a few more places where handles were parsed as "l" or "i" ScrollWindowEx rcUpdate parameter is output instead of input (could break code) Various Autoduck fixes Index: win32gui.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32gui.i,v retrieving revision 1.94 retrieving revision 1.95 diff -C2 -d -r1.94 -r1.95 *** win32gui.i 2 Jan 2007 00:53:02 -0000 1.94 --- win32gui.i 2 Jan 2007 07:30:50 -0000 1.95 *************** *** 116,120 **** // @object PyBLENDFUNCTION|Tuple of four small ints used to fill a BLENDFUNCTION struct ! // All 4 ints must fit in a byte (0-255). // @pyseeapi BLENDFUNCTION BOOL PyWinObject_AsBLENDFUNCTION(PyObject *obbl, BLENDFUNCTION *pbl) --- 116,120 ---- // @object PyBLENDFUNCTION|Tuple of four small ints used to fill a BLENDFUNCTION struct ! // Each int must fit in a byte (0-255). // @pyseeapi BLENDFUNCTION [...1459 lines suppressed...] + if (!PyArg_ParseTuple(args, "kkO|O:ExtCreatePen", + &style, // @pyparm int|PenStyle||Combination of win32con.PS_*. Must contain either PS_GEOMETRIC or PS_COSMETIC. + &width, // @pyparm int|Width||Width of pen in logical units. Must be 1 for PS_COSMETIC. + &oblb, // @pyparm <o PyLOGBRUSH>|lb||Dict containing brush creation parameters + &obcustom_style)) // @pyparm (int, ...)|Style|None|Sequence containing lengths of dashes and spaces Used only with PS_USERSTYLE, otherwise must be None. + return NULL; + if (!PyWinObject_AsLOGBRUSH(oblb, &lb)) + return NULL; + if (!PyWinObject_AsDWORDArray(obcustom_style, &custom_style, &custom_style_cnt, TRUE)) + return NULL; + hpen=ExtCreatePen(style, width, &lb, custom_style_cnt, custom_style); + if (custom_style) + free(custom_style); + if (hpen==NULL) + return PyWin_SetAPIError("ExtCreatePen"); + return PyWinObject_FromGdiHANDLE(hpen); + } + %} + %native (CreateBrushIndirect) PyCreateBrushIndirect; + %native (ExtCreatePen) PyExtCreatePen; |
From: Mark H. <mha...@us...> - 2007-01-02 00:53:04
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3600 Modified Files: win32gui.i Log Message: Don't have SWIG generate temp variables in their own scope - they will then only live as long as the scope. Index: win32gui.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32gui.i,v retrieving revision 1.93 retrieving revision 1.94 diff -C2 -d -r1.93 -r1.94 *** win32gui.i 24 Dec 2006 06:44:56 -0000 1.93 --- win32gui.i 2 Jan 2007 00:53:02 -0000 1.94 *************** *** 338,347 **** %typemap(python,in) RECT *INPUT { ! RECT r; if (PyTuple_Check($source)) { ! if (PyArg_ParseTuple($source, "llll", &r.left, &r.top, &r.right, &r.bottom) == 0) { return PyErr_Format(PyExc_TypeError, "%s: This param must be a tuple of four integers", "$name"); } ! $target = &r; } else { return PyErr_Format(PyExc_TypeError, "%s: This param must be a tuple of four integers", "$name"); --- 338,347 ---- %typemap(python,in) RECT *INPUT { ! RECT *r = (RECT *)_alloca(sizeof(RECT)); if (PyTuple_Check($source)) { ! if (PyArg_ParseTuple($source, "llll", &r->left, &r->top, &r->right, &r->bottom) == 0) { return PyErr_Format(PyExc_TypeError, "%s: This param must be a tuple of four integers", "$name"); } ! $target = r; } else { return PyErr_Format(PyExc_TypeError, "%s: This param must be a tuple of four integers", "$name"); *************** *** 350,359 **** %typemap(python,in) RECT *INPUT_NULLOK { ! RECT r; if (PyTuple_Check($source)) { ! if (PyArg_ParseTuple($source, "llll", &r.left, &r.top, &r.right, &r.bottom) == 0) { return PyErr_Format(PyExc_TypeError, "%s: This param must be a tuple of four integers or None", "$name"); } ! $target = &r; } else { if ($source == Py_None) { --- 350,359 ---- %typemap(python,in) RECT *INPUT_NULLOK { ! RECT *r = (RECT *)_alloca(sizeof(RECT)); if (PyTuple_Check($source)) { ! if (PyArg_ParseTuple($source, "llll", &r->left, &r->top, &r->right, &r->bottom) == 0) { return PyErr_Format(PyExc_TypeError, "%s: This param must be a tuple of four integers or None", "$name"); } ! $target = r; } else { if ($source == Py_None) { *************** *** 425,432 **** %typemap(python,in) POINT *INPUT { ! POINT pt; ! if (!PyWinObject_AsPOINT($source, &pt)) return NULL; ! $target = &pt; } --- 425,432 ---- %typemap(python,in) POINT *INPUT { ! POINT *pt = (POINT *)_alloca(sizeof(POINT)); ! if (!PyWinObject_AsPOINT($source, pt)) return NULL; ! $target = pt; } *************** *** 436,453 **** %typemap(python,in) SIZE *INPUT{ ! SIZE s; ! if (!PyWinObject_AsSIZE($source, &s)) return NULL; ! $target = &s; } %typemap(python,in) ICONINFO *INPUT { ! ICONINFO s; if (PyTuple_Check($source)) { ! if (PyArg_ParseTuple($source, "lllll", &s.fIcon, &s.xHotspot, &s.yHotspot, ! &s.hbmMask, &s.hbmColor) == 0) { return PyErr_Format(PyExc_TypeError, "%s: a ICONINFO must be a tuple of integers", "$name"); } ! $target = &s; } else { return PyErr_Format(PyExc_TypeError, "%s: a ICONINFO must be a tuple of integers", "$name"); --- 436,453 ---- %typemap(python,in) SIZE *INPUT{ ! SIZE *s = (SIZE *)_alloca(sizeof(SIZE)); ! if (!PyWinObject_AsSIZE($source, s)) return NULL; ! $target = s; } %typemap(python,in) ICONINFO *INPUT { ! ICONINFO *s = (ICONINFO *)_alloca(sizeof(ICONINFO)); if (PyTuple_Check($source)) { ! if (PyArg_ParseTuple($source, "lllll", &s->fIcon, &s->xHotspot, &s->yHotspot, ! &s->hbmMask, &s->hbmColor) == 0) { return PyErr_Format(PyExc_TypeError, "%s: a ICONINFO must be a tuple of integers", "$name"); } ! $target = s; } else { return PyErr_Format(PyExc_TypeError, "%s: a ICONINFO must be a tuple of integers", "$name"); *************** *** 482,489 **** %typemap(python,in) BLENDFUNCTION *INPUT { ! BLENDFUNCTION bf; ! if (!PyWinObject_AsBLENDFUNCTION($source, &bf)) return NULL; ! $target = &bf; } --- 482,489 ---- %typemap(python,in) BLENDFUNCTION *INPUT { ! BLENDFUNCTION *bf = (BLENDFUNCTION *)_alloca(sizeof(BLENDFUNCTION)); ! if (!PyWinObject_AsBLENDFUNCTION($source, bf)) return NULL; ! $target = bf; } *************** *** 521,525 **** %typemap(python,in) PAINTSTRUCT *INPUT { ! PAINTSTRUCT r; char *szReserved; int lenReserved; --- 521,525 ---- %typemap(python,in) PAINTSTRUCT *INPUT { ! PAINTSTRUCT *r = (PAINTSTRUCT *)_alloca(sizeof(PAINTSTRUCT)); char *szReserved; int lenReserved; *************** *** 527,544 **** if (!PyArg_ParseTuple($source, "ll(iiii)lls#", ! &r.hdc, ! &r.fErase, ! &r.rcPaint.left, &r.rcPaint.top, &r.rcPaint.right, &r.rcPaint.bottom, ! &r.fRestore, ! &r.fIncUpdate, &szReserved, &lenReserved)) { return NULL; } ! if (lenReserved != sizeof(r.rgbReserved)) return PyErr_Format(PyExc_ValueError, "%s: last element must be string of %d bytes", ! "$name", sizeof(r.rgbReserved)); ! memcpy(&r.rgbReserved, szReserved, sizeof(r.rgbReserved)); ! $target = &r; } else { return PyErr_Format(PyExc_TypeError, "%s: a PAINTSTRUCT must be a tuple", "$name"); --- 527,544 ---- if (!PyArg_ParseTuple($source, "ll(iiii)lls#", ! &r->hdc, ! &r->fErase, ! &r->rcPaint.left, &r->rcPaint.top, &r->rcPaint.right, &r->rcPaint.bottom, ! &r->fRestore, ! &r->fIncUpdate, &szReserved, &lenReserved)) { return NULL; } ! if (lenReserved != sizeof(r->rgbReserved)) return PyErr_Format(PyExc_ValueError, "%s: last element must be string of %d bytes", ! "$name", sizeof(r->rgbReserved)); ! memcpy(&r->rgbReserved, szReserved, sizeof(r->rgbReserved)); ! $target = r; } else { return PyErr_Format(PyExc_TypeError, "%s: a PAINTSTRUCT must be a tuple", "$name"); *************** *** 548,558 **** // @object TRACKMOUSEEVENT|A tuple of (dwFlags, hwndTrack, dwHoverTime) %typemap(python,in) TRACKMOUSEEVENT *INPUT { ! TRACKMOUSEEVENT e; ! e.cbSize = sizeof e; if (PyTuple_Check($source)) { ! if (PyArg_ParseTuple($source, "lll", &e.dwFlags, &e.hwndTrack, &e.dwHoverTime) == 0) { return PyErr_Format(PyExc_TypeError, "%s: a TRACKMOUSEEVENT must be a tuple of 3 integers", "$name"); } ! $target = &e; } else { return PyErr_Format(PyExc_TypeError, "%s: a TRACKMOUSEEVENT must be a tuple of 3 integers", "$name"); --- 548,558 ---- // @object TRACKMOUSEEVENT|A tuple of (dwFlags, hwndTrack, dwHoverTime) %typemap(python,in) TRACKMOUSEEVENT *INPUT { ! TRACKMOUSEEVENT *e = (TRACKMOUSEEVENT*)_alloca(sizeof(TRACKMOUSEEVENT)); ! e->cbSize = sizeof e; if (PyTuple_Check($source)) { ! if (PyArg_ParseTuple($source, "lll", &e->dwFlags, &e->hwndTrack, &e->dwHoverTime) == 0) { return PyErr_Format(PyExc_TypeError, "%s: a TRACKMOUSEEVENT must be a tuple of 3 integers", "$name"); } ! $target = e; } else { return PyErr_Format(PyExc_TypeError, "%s: a TRACKMOUSEEVENT must be a tuple of 3 integers", "$name"); |
From: Roger U. <ru...@us...> - 2006-12-27 04:41:16
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14936/win32/src Modified Files: PyWinTypes.h PyWinTypesmodule.cpp win32credmodule.cpp Log Message: Move PyWinObject_AsDWORDArray into pywintypes so it can be used in win32gui Index: win32credmodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32credmodule.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** win32credmodule.cpp 26 Dec 2006 03:02:03 -0000 1.3 --- win32credmodule.cpp 27 Dec 2006 04:41:15 -0000 1.4 *************** *** 246,290 **** } - BOOL PyWinObject_AsDWORDArray(PyObject *obdwords, DWORD **pdwords, DWORD *item_cnt, BOOL bNoneOk=TRUE) - { - BOOL ret=TRUE; - DWORD bufsize, tuple_index; - PyObject *dwords_tuple=NULL, *tuple_item; - *pdwords=NULL; - *item_cnt=0; - if (obdwords==Py_None){ - if (bNoneOk) - return TRUE; - PyErr_SetString(PyExc_ValueError,"Sequence of dwords cannot be None"); - return FALSE; - } - if ((dwords_tuple=PySequence_Tuple(obdwords))==NULL) - return FALSE; // last exit without cleaning up - *item_cnt=PyTuple_Size(dwords_tuple); - bufsize=*item_cnt * sizeof(DWORD); - *pdwords=(DWORD *)malloc(bufsize); - if (*pdwords==NULL){ - PyErr_Format(PyExc_MemoryError, "Unable to allocate %d bytes", bufsize); - ret=FALSE; - } - else - for (tuple_index=0; tuple_index<*item_cnt; tuple_index++){ - tuple_item=PyTuple_GET_ITEM(dwords_tuple,tuple_index); - (*pdwords)[tuple_index]=PyInt_AsLong(tuple_item); - if (((*pdwords)[tuple_index]==-1) && PyErr_Occurred()){ - ret=FALSE; - break; - } - } - if (!ret) - if (*pdwords!=NULL){ - free(*pdwords); - *pdwords=NULL; - *item_cnt=0; - } - Py_XDECREF(dwords_tuple); - return ret; - } - void PyWinObject_FreeCREDENTIAL_TARGET_INFORMATION(PCREDENTIAL_TARGET_INFORMATION targetinfo) { --- 246,249 ---- Index: PyWinTypesmodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWinTypesmodule.cpp,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** PyWinTypesmodule.cpp 11 Jul 2006 11:30:08 -0000 1.22 --- PyWinTypesmodule.cpp 27 Dec 2006 04:41:14 -0000 1.23 *************** *** 474,477 **** --- 474,519 ---- } + // Alocates and populates an array of DWORDS from a sequence of Python ints + BOOL PyWinObject_AsDWORDArray(PyObject *obdwords, DWORD **pdwords, DWORD *item_cnt, BOOL bNoneOk) + { + BOOL ret=TRUE; + DWORD bufsize, tuple_index; + PyObject *dwords_tuple=NULL, *tuple_item; + *pdwords=NULL; + *item_cnt=0; + if (obdwords==Py_None){ + if (bNoneOk) + return TRUE; + PyErr_SetString(PyExc_ValueError,"Sequence of dwords cannot be None"); + return FALSE; + } + if ((dwords_tuple=PySequence_Tuple(obdwords))==NULL) + return FALSE; // last exit without cleaning up + *item_cnt=PyTuple_Size(dwords_tuple); + bufsize=*item_cnt * sizeof(DWORD); + *pdwords=(DWORD *)malloc(bufsize); + if (*pdwords==NULL){ + PyErr_Format(PyExc_MemoryError, "Unable to allocate %d bytes", bufsize); + ret=FALSE; + } + else + for (tuple_index=0; tuple_index<*item_cnt; tuple_index++){ + tuple_item=PyTuple_GET_ITEM(dwords_tuple,tuple_index); + (*pdwords)[tuple_index]=PyInt_AsLong(tuple_item); + if (((*pdwords)[tuple_index]==-1) && PyErr_Occurred()){ + ret=FALSE; + break; + } + } + if (!ret) + if (*pdwords!=NULL){ + free(*pdwords); + *pdwords=NULL; + *item_cnt=0; + } + Py_XDECREF(dwords_tuple); + return ret; + } + /* List of functions exported by this module */ // @module pywintypes|A module which supports common Windows types. Index: PyWinTypes.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWinTypes.h,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** PyWinTypes.h 3 Aug 2006 02:46:30 -0000 1.30 --- PyWinTypes.h 27 Dec 2006 04:41:14 -0000 1.31 *************** *** 323,326 **** --- 323,329 ---- PYWINTYPES_EXPORT PyObject *PyWinObject_FromIO_COUNTERS(PIO_COUNTERS pioc); + // Make an array of DWORD's from a sequence of Python ints + PYWINTYPES_EXPORT BOOL PyWinObject_AsDWORDArray(PyObject *obdwords, DWORD **pdwords, DWORD *item_cnt, BOOL bNoneOk=TRUE); + /* ** SECURITY_ATTRIBUTES support *************** *** 359,362 **** --- 362,368 ---- PYWINTYPES_EXPORT PyObject *PyWinObject_FromSECURITY_DESCRIPTOR(PSECURITY_DESCRIPTOR psd); + PYWINTYPES_EXPORT BOOL _MakeAbsoluteSD(PSECURITY_DESCRIPTOR psd_relative, PSECURITY_DESCRIPTOR *ppsd_absolute); + PYWINTYPES_EXPORT void FreeAbsoluteSD(PSECURITY_DESCRIPTOR psd); + /* ** SID support |
From: Roger U. <ru...@us...> - 2006-12-26 03:02:06
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27383/win32/src Modified Files: win32credmodule.cpp Log Message: Fix bug in PyWinObject_AsDWORDArray Index: win32credmodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32credmodule.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** win32credmodule.cpp 8 Sep 2006 06:49:55 -0000 1.2 --- win32credmodule.cpp 26 Dec 2006 03:02:03 -0000 1.3 *************** *** 271,276 **** for (tuple_index=0; tuple_index<*item_cnt; tuple_index++){ tuple_item=PyTuple_GET_ITEM(dwords_tuple,tuple_index); ! *pdwords[tuple_index]=PyInt_AsLong(tuple_item); ! if (*pdwords[tuple_index]==-1 && PyErr_Occurred()){ ret=FALSE; break; --- 271,276 ---- for (tuple_index=0; tuple_index<*item_cnt; tuple_index++){ tuple_item=PyTuple_GET_ITEM(dwords_tuple,tuple_index); ! (*pdwords)[tuple_index]=PyInt_AsLong(tuple_item); ! if (((*pdwords)[tuple_index]==-1) && PyErr_Occurred()){ ret=FALSE; break; |
From: Roger U. <ru...@us...> - 2006-12-24 06:44:58
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24853/win32/src Modified Files: win32gui.i Log Message: Add more drawing and DC functions Load function pointers for some functions formerly only in winxpgui so they can be used on Win2k Remove some instances of handles converted using PyArg_ParseTuple "l" format Index: win32gui.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32gui.i,v retrieving revision 1.92 retrieving revision 1.93 diff -C2 -d -r1.92 -r1.93 *** win32gui.i 20 Dec 2006 16:57:08 -0000 1.92 --- win32gui.i 24 Dec 2006 06:44:56 -0000 1.93 *************** *** 42,45 **** --- 42,47 ---- typedef BOOL (WINAPI *GetLayeredWindowAttributesfunc)(HWND, COLORREF *, BYTE *, DWORD *); static GetLayeredWindowAttributesfunc pfnGetLayeredWindowAttributes=NULL; + typedef BOOL (WINAPI *UpdateLayeredWindowfunc)(HWND,HDC,POINT *,SIZE *,HDC,POINT *,COLORREF,BLENDFUNCTION *,DWORD); + static UpdateLayeredWindowfunc pfnUpdateLayeredWindow=NULL; typedef BOOL (WINAPI *AngleArcfunc)(HDC, int, int, DWORD, FLOAT, FLOAT); static AngleArcfunc pfnAngleArc=NULL; *************** *** 54,57 **** --- 56,73 ---- typedef BOOL (WINAPI *CombineTransformfunc)(LPXFORM,CONST XFORM *,CONST XFORM *); static CombineTransformfunc pfnCombineTransform=NULL; + typedef BOOL (WINAPI *GradientFillfunc)(HDC,PTRIVERTEX,ULONG,PVOID,ULONG,ULONG); + static GradientFillfunc pfnGradientFill=NULL; + typedef BOOL (WINAPI *TransparentBltfunc)(HDC,int,int,int,int,HDC,int,int,int,int,UINT); + static TransparentBltfunc pfnTransparentBlt=NULL; + typedef BOOL (WINAPI *MaskBltfunc)(HDC,int,int,int,int,HDC,int,int,HBITMAP,int,int,DWORD); + static MaskBltfunc pfnMaskBlt=NULL; + typedef BOOL (WINAPI *AlphaBlendfunc)(HDC,int,int,int,int,HDC,int,int,int,int,BLENDFUNCTION); + static AlphaBlendfunc pfnAlphaBlend=NULL; + typedef BOOL (WINAPI *AnimateWindowfunc)(HWND,DWORD,DWORD); + static AnimateWindowfunc pfnAnimateWindow=NULL; + typedef DWORD (WINAPI *GetLayoutfunc)(HDC); + static GetLayoutfunc pfnGetLayout=NULL; + typedef DWORD (WINAPI *SetLayoutfunc)(HDC, DWORD); + static SetLayoutfunc pfnSetLayout=NULL; static PyObject *g_AtomMap = NULL; // Mapping class atoms to Python WNDPROC *************** *** 98,101 **** --- 114,144 ---- } } + + // @object PyBLENDFUNCTION|Tuple of four small ints used to fill a BLENDFUNCTION struct + // All 4 ints must fit in a byte (0-255). + // @pyseeapi BLENDFUNCTION + BOOL PyWinObject_AsBLENDFUNCTION(PyObject *obbl, BLENDFUNCTION *pbl) + { + if (!PyTuple_Check(obbl)){ + PyErr_SetString(PyExc_TypeError, "BLENDFUNCTION must be a tuple of four small ints (0-255)"); + return FALSE; + } + return PyArg_ParseTuple(obbl, "BBBB:BLENDFUNCTION", + &pbl->BlendOp, // @tupleitem 0|int|BlendOp|Only defined value is AC_SRC_OVER (0) + &pbl->BlendFlags, // @tupleitem 1|int|BlendFlags|None currently defined, must be 0 + &pbl->SourceConstantAlpha, // @tupleitem 2|int|SourceConstantAlpha|Transparency to be applied to entire source. (255 is opaque) + &pbl->AlphaFormat); // @tupleitem 3|int|AlphaFormat|Only defined flag is AC_SRC_ALPHA, used when src bitmap contains per-pixel alpha + } + + // @object PySIZE|Tuple of two ints (cx,cy) representing a SIZE struct + BOOL PyWinObject_AsSIZE(PyObject *obsize, SIZE *psize) + { + if (!PyTuple_Check(obsize)){ + PyErr_SetString(PyExc_TypeError, "SIZE must be a tuple of 2 ints (x,y)"); + return FALSE; + } + return PyArg_ParseTuple(obsize, "ll;SIZE must be a tuple of 2 ints (x,y)", + &psize->cx, &psize->cy); + } %} *************** *** 114,117 **** --- 157,162 ---- if (strcmp(pmd->ml_name, "SetLayeredWindowAttributes")==0 || strcmp(pmd->ml_name, "GetLayeredWindowAttributes")==0 || + strcmp(pmd->ml_name, "UpdateLayeredWindow")==0 || + strcmp(pmd->ml_name, "AnimateWindow")==0 || strcmp(pmd->ml_name, "GetOpenFileNameW")==0 || strcmp(pmd->ml_name, "GetSaveFileNameW")==0 || *************** *** 125,128 **** --- 170,175 ---- pfnSetLayeredWindowAttributes=(SetLayeredWindowAttributesfunc)GetProcAddress(hmodule,"SetLayeredWindowAttributes"); pfnGetLayeredWindowAttributes=(GetLayeredWindowAttributesfunc)GetProcAddress(hmodule,"GetLayeredWindowAttributes"); + pfnUpdateLayeredWindow=(UpdateLayeredWindowfunc)GetProcAddress(hmodule,"UpdateLayeredWindow"); + pfnAnimateWindow=(AnimateWindowfunc)GetProcAddress(hmodule,"AnimateWindow"); } *************** *** 137,142 **** --- 184,201 ---- pfnModifyWorldTransform=(ModifyWorldTransformfunc)GetProcAddress(hmodule,"ModifyWorldTransform"); pfnCombineTransform=(CombineTransformfunc)GetProcAddress(hmodule,"CombineTransform"); + pfnMaskBlt=(MaskBltfunc)GetProcAddress(hmodule,"MaskBlt"); + pfnGetLayout=(GetLayoutfunc)GetProcAddress(hmodule,"GetLayout"); + pfnSetLayout=(SetLayoutfunc)GetProcAddress(hmodule,"SetLayout"); + } + hmodule=GetModuleHandle("msimg32.dll"); + if (hmodule==NULL) + hmodule=LoadLibrary("msimg32.dll"); + if (hmodule){ + pfnGradientFill=(GradientFillfunc)GetProcAddress(hmodule,"GradientFill"); + pfnTransparentBlt=(TransparentBltfunc)GetProcAddress(hmodule,"TransparentBlt"); + pfnAlphaBlend=(AlphaBlendfunc)GetProcAddress(hmodule,"AlphaBlend"); + } %} *************** *** 366,378 **** %typemap(python,in) POINT *INPUT { ! POINT r; ! if (PyTuple_Check($source)) { ! if (PyArg_ParseTuple($source, "ll", &r.x, &r.y) == 0) { ! return PyErr_Format(PyExc_TypeError, "%s: a POINT must be a tuple of integers", "$name"); ! } ! $target = &r; ! } else { ! return PyErr_Format(PyExc_TypeError, "%s: a POINT must be a tuple of integers", "$name"); ! } } --- 425,432 ---- %typemap(python,in) POINT *INPUT { ! POINT pt; ! if (!PyWinObject_AsPOINT($source, &pt)) ! return NULL; ! $target = &pt; } *************** *** 381,394 **** %typemap(python,argout) POINT *BOTH = POINT *OUTPUT; ! %typemap(python,in) SIZE *INPUT { SIZE s; ! if (PyTuple_Check($source)) { ! if (PyArg_ParseTuple($source, "ll", &s.cx, &s.cy) == 0) { ! return PyErr_Format(PyExc_TypeError, "%s: a SIZE must be a tuple of integers", "$name"); ! } ! $target = &s; ! } else { ! return PyErr_Format(PyExc_TypeError, "%s: a SIZE must be a tuple of integers", "$name"); ! } } --- 435,443 ---- %typemap(python,argout) POINT *BOTH = POINT *OUTPUT; ! %typemap(python,in) SIZE *INPUT{ SIZE s; ! if (!PyWinObject_AsSIZE($source, &s)) ! return NULL; ! $target = &s; } *************** *** 434,447 **** %typemap(python,in) BLENDFUNCTION *INPUT { BLENDFUNCTION bf; ! if (PyTuple_Check($source)) { ! if (PyArg_ParseTuple($source, "bbbb:" "$name" " tuple", ! &bf.BlendOp, &bf.BlendFlags, ! &bf.SourceConstantAlpha, &bf.AlphaFormat) == 0) { ! return NULL; ! } ! $target = &bf; ! } else { ! return PyErr_Format(PyExc_TypeError, "%s: This param must be a tuple of four integers", "$name"); ! } } --- 483,489 ---- %typemap(python,in) BLENDFUNCTION *INPUT { BLENDFUNCTION bf; ! if (!PyWinObject_AsBLENDFUNCTION($source, &bf)) ! return NULL; ! $target = &bf; } *************** *** 1172,1179 **** { PyObject *obFamily; ! PyObject *obProc; PyObject *obExtra = Py_None; ! long hdc; ! // @pyparm int|hdc||Handle to a device context for which to enumerate available fonts // @pyparm string/<o PyUnicode>|Family||Family of fonts to enumerate. If none, first member of each font family will be returned. // @pyparm function|EnumFontFamProc||The Python function called with each font family. This function is called with 4 arguments. --- 1214,1221 ---- { PyObject *obFamily; ! PyObject *obProc, *obdc; PyObject *obExtra = Py_None; ! HDC hdc; ! // @pyparm <o PyHANDLE>|hdc||Handle to a device context for which to enumerate available fonts // @pyparm string/<o PyUnicode>|Family||Family of fonts to enumerate. If none, first member of each font family will be returned. // @pyparm function|EnumFontFamProc||The Python function called with each font family. This function is called with 4 arguments. *************** *** 1185,1189 **** // object - The Param originally passed in to EnumFontFamilies ! if (!PyArg_ParseTuple(args, "lOO|O", &hdc, &obFamily, &obProc, &obExtra)) return NULL; if (!PyCallable_Check(obProc)) { --- 1227,1233 ---- // object - The Param originally passed in to EnumFontFamilies ! if (!PyArg_ParseTuple(args, "OOO|O", &obdc, &obFamily, &obProc, &obExtra)) ! return NULL; ! if (!PyWinObject_AsHANDLE(obdc, (HANDLE *)&hdc, FALSE)) return NULL; if (!PyCallable_Check(obProc)) { *************** *** 1195,1199 **** return NULL; PyObject *lparam = Py_BuildValue("OO", obProc, obExtra); ! int rc = EnumFontFamilies((HDC)hdc, szFamily, EnumFontFamProc, (LPARAM)lparam); Py_XDECREF(lparam); PyWinObject_FreeTCHAR(szFamily); --- 1239,1243 ---- return NULL; PyObject *lparam = Py_BuildValue("OO", obProc, obExtra); ! int rc = EnumFontFamilies(hdc, szFamily, EnumFontFamProc, (LPARAM)lparam); Py_XDECREF(lparam); PyWinObject_FreeTCHAR(szFamily); *************** *** 1243,1254 **** %{ ! // @pyswig object|GetObject| static PyObject *PyGetObject(PyObject *self, PyObject *args) { ! long hob; ! // @pyparm int|handle||Handle to the object. ! if (!PyArg_ParseTuple(args, "l", &hob)) return NULL; ! DWORD typ = GetObjectType((HGDIOBJ)hob); // @comm The result depends on the type of the handle. // For example, if the handle identifies a Font, a <o LOGFONT> object --- 1287,1301 ---- %{ ! // @pyswig object|GetObject|Returns a struct containing the parameters used to create a GDI object static PyObject *PyGetObject(PyObject *self, PyObject *args) { ! HGDIOBJ hob; ! PyObject *ob; ! // @pyparm <o PyHANDLE>|handle||Handle to the object. ! if (!PyArg_ParseTuple(args, "O", &ob)) return NULL; ! if (!PyWinObject_AsHANDLE(ob, &hob, FALSE)) ! return NULL; ! DWORD typ = GetObjectType(hob); // @comm The result depends on the type of the handle. // For example, if the handle identifies a Font, a <o LOGFONT> object *************** *** 1257,1261 **** case OBJ_FONT: { LOGFONT lf; ! if (GetObject((HGDIOBJ)hob, sizeof(LOGFONT), &lf)==0) return PyWin_SetAPIError("GetObject"); return new PyLOGFONT(&lf); --- 1304,1308 ---- case OBJ_FONT: { LOGFONT lf; ! if (GetObject(hob, sizeof(LOGFONT), &lf)==0) return PyWin_SetAPIError("GetObject"); return new PyLOGFONT(&lf); *************** *** 1263,1267 **** case OBJ_BITMAP: { BITMAP bm; ! if (GetObject((HGDIOBJ)hob, sizeof(BITMAP), &bm)==0) return PyWin_SetAPIError("GetObject"); return new PyBITMAP(&bm); --- 1310,1314 ---- case OBJ_BITMAP: { BITMAP bm; ! if (GetObject(hob, sizeof(BITMAP), &bm)==0) return PyWin_SetAPIError("GetObject"); return new PyBITMAP(&bm); *************** *** 1281,1286 **** HANDLE h; DWORD t; ! // @pyparm int|h||A handle to a GDI object ! if (!PyArg_ParseTuple(args, "l:GetObjectType", &h)) return NULL; t=GetObjectType(h); --- 1328,1336 ---- HANDLE h; DWORD t; ! PyObject *ob; ! // @pyparm <o PyHANDLE>|h||A handle to a GDI object ! if (!PyArg_ParseTuple(args, "O:GetObjectType", &ob)) ! return NULL; ! if (!PyWinObject_AsHANDLE(ob, &h, FALSE)) return NULL; t=GetObjectType(h); *************** *** 1531,1551 **** #ifndef MS_WINCE // @pyswig int|FlashWindow|The FlashWindow function flashes the specified window one time. It does not change the active state of the window. ! // @pyparm int|hwnd|| ! // @pyparm int|bInvert|| BOOL FlashWindow(HWND hwnd, BOOL bInvert); - // @pyswig int|FlashWindowEx|The FlashWindowEx function flashes the specified window a specified number of times. %{ PyObject *PyFlashWindowEx(PyObject *self, PyObject *args) { ! PyObject *ret; BOOL rc; FLASHWINFO f; f.cbSize = sizeof f; ! // @pyparm int|hwnd|| ! // @pyparm int|dwFlags|| ! // @pyparm int|uCount|| ! // @pyparm int|dwTimeout|| ! if (!PyArg_ParseTuple(args, "iiii", &f.hwnd, &f.dwFlags, &f.uCount, &f.dwTimeout)) return NULL; // not on NT --- 1581,1603 ---- #ifndef MS_WINCE // @pyswig int|FlashWindow|The FlashWindow function flashes the specified window one time. It does not change the active state of the window. ! // @pyparm <o PyHANDLE>|hwnd||Handle to a window ! // @pyparm int|bInvert||Indicates if window should toggle between active and inactive BOOL FlashWindow(HWND hwnd, BOOL bInvert); + // @pyswig int|FlashWindowEx|The FlashWindowEx function flashes the specified window a specified number of times. %{ PyObject *PyFlashWindowEx(PyObject *self, PyObject *args) { ! PyObject *ret, *obhwnd; BOOL rc; FLASHWINFO f; f.cbSize = sizeof f; ! // @pyparm <o PyHANDLE>|hwnd||Handle to a window ! // @pyparm int|dwFlags||Combination of win32con.FLASHW_* flags ! // @pyparm int|uCount||Nbr of times to flash ! // @pyparm int|dwTimeout||Elapsed time between flashes, in milliseconds ! if (!PyArg_ParseTuple(args, "Oiii", &obhwnd, &f.dwFlags, &f.uCount, &f.dwTimeout)) ! return NULL; ! if (!PyWinObject_AsHANDLE(obhwnd, (HANDLE *)&f.hwnd, FALSE)) return NULL; // not on NT *************** *** 1568,1599 **** #endif // MS_WINCE - // To avoid LoadLibrary etc (ie, keep my life simple) for functions - // that don't exist on NT, only put them in winxpgui. - %ifdef WINXPGUI - - // @pyswig |AnimateWindow|Enables you to produce special effects when showing or hiding windows. There are three types of animation: roll, slide, and alpha-blended fade. - // @comm To avoid complications with Windows NT, this function only exists in winxpgui (not win32gui) - BOOLAPI AnimateWindow( - HWND hwnd, // @pyparm int|hwnd||handle to window - DWORD dwTime, // @pyparm int|dwTime||duration of animation - DWORD dwFlags // @pyparm int|dwFlags||animation type - ); - - // @pyswig |UpdateLayeredWindow|Updates the position, size, shape, content, and translucency of a layered window. - // @comm To avoid complications with Windows NT, this function only exists in winxpgui (not win32gui) - BOOLAPI UpdateLayeredWindow( - HWND hwnd, // @pyparm int|hwnd||handle to layered window - HDC hdcDst, // @pyparm int|hdcDst||handle to screen DC - POINT *INPUT, // @pyparm (x,y)|pointDest||new screen position - SIZE *INPUT, // @pyparm (cx, cy)|size||new size of the layered window - HDC hdcSrc, // @pyparm int|hdcSrc||handle to surface DC - POINT *INPUT, // @pyparm (x,y)|pointSrc||layer position - COLORREF crKey, // @pyparm int|colorKey||color key - BLENDFUNCTION *INPUT, // @pyparm (int, int, int, int)|blend||blend function - DWORD dwFlags // @pyparm int|flags||options - ); - - %endif // End of winxpgui only functions - // @pyswig int|GetWindowLong| --- 1620,1623 ---- *************** *** 1613,1622 **** HWND hwnd; int index; ! PyObject *ob; long l; // @pyparm int|hwnd||The handle to the window // @pyparm int|index||The index of the item to set. // @pyparm object|value||The value to set. ! if (!PyArg_ParseTuple(args, "liO", &hwnd, &index, &ob)) return NULL; switch (index) { --- 1637,1648 ---- HWND hwnd; int index; ! PyObject *ob, *obhwnd; long l; // @pyparm int|hwnd||The handle to the window // @pyparm int|index||The index of the item to set. // @pyparm object|value||The value to set. ! if (!PyArg_ParseTuple(args, "OiO", &obhwnd, &index, &ob)) ! return NULL; ! if (!PyWinObject_AsHANDLE(obhwnd, (HANDLE *)&hwnd, FALSE)) return NULL; switch (index) { *************** *** 2460,2483 **** #endif /* not MS_WINCE */ ! %ifdef WINXPGUI // @pyswig |MaskBlt|Combines the color data for the source and destination // bitmaps using the specified mask and raster operation. ! // @comm This function is available only in winxpgui, as it is not supported ! // on Win9x. ! BOOLAPI MaskBlt( ! HDC hdcDest, // handle to destination DC ! int nXDest, // x-coord of destination upper-left corner ! int nYDest, // y-coord of destination upper-left corner ! int nWidth, // width of source and destination ! int nHeight, // height of source and destination ! HDC hdcSrc, // handle to source DC ! int nXSrc, // x-coord of upper-left corner of source ! int nYSrc, // y-coord of upper-left corner of source ! HBITMAP hbmMask, // handle to monochrome bit mask ! int xMask, // horizontal offset into mask bitmap ! int yMask, // vertical offset into mask bitmap ! DWORD dwRop // raster operation code ! ); ! %endif // @pyswig int|ImageList_Add|Adds an image or images to an image list. --- 2486,2612 ---- #endif /* not MS_WINCE */ ! %{ ! // @pyswig |TransparentBlt|Transfers color from one DC to another, with one color treated as transparent ! static PyObject *PyTransparentBlt(PyObject *self, PyObject *args) ! { ! CHECK_PFN(TransparentBlt); ! PyObject *obsrc, *obdst; ! HDC src, dst; ! int src_x, src_y, src_width, src_height; ! int dst_x, dst_y, dst_width, dst_height; ! UINT transparent; ! BOOL ret; ! if (!PyArg_ParseTuple(args,"OiiiiOiiiiI:TransparentBlt", ! &obdst, // @pyparm <o PyHANDLE>|Dest||Destination device context handle ! &dst_x, // @pyparm int|XOriginDest||X pos of dest rect ! &dst_y, // @pyparm int|YOriginDest||Y pos of dest rect ! &dst_width, // @pyparm int|WidthDest||Width of dest rect ! &dst_height, // @pyparm int|HeightDest||Height of dest rect ! &obsrc, // @pyparm <o PyHANDLE>|Src||Source DC handle ! &src_x, // @pyparm int|XOriginSrc||X pos of src rect ! &src_y, // @pyparm int|YOriginSrc||Y pos of src rect ! &src_width, // @pyparm int|WidthSrc||Width of src rect ! &src_height, // @pyparm int|HeightSrc||Height of src rect ! &transparent)) // @pyparm int|Transparent||RGB color value that will be transparent ! return NULL; ! if (!PyWinObject_AsHANDLE(obdst, (HANDLE *)&dst, FALSE)) ! return NULL; ! if (!PyWinObject_AsHANDLE(obsrc, (HANDLE *)&src, FALSE)) ! return NULL; ! Py_BEGIN_ALLOW_THREADS ! ret=(*pfnTransparentBlt)( ! dst, dst_x, dst_y, dst_width, dst_height, ! src, src_x, src_y, src_width, src_height, ! transparent); ! Py_END_ALLOW_THREADS ! if (!ret) ! return PyWin_SetAPIError("TransparentBlt"); ! Py_INCREF(Py_None); ! return Py_None; ! } ! // @pyswig |MaskBlt|Combines the color data for the source and destination // bitmaps using the specified mask and raster operation. ! // @comm This function is not supported on Win9x. ! // @pyseeapi MaskBlt ! static PyObject *PyMaskBlt(PyObject *self, PyObject *args) ! { ! CHECK_PFN(MaskBlt); ! PyObject *obsrc, *obdst, *obmask; ! HDC src, dst; ! HBITMAP mask; ! int dst_x, dst_y, dst_width, dst_height; ! int src_x, src_y; ! int mask_x, mask_y; ! DWORD rop; ! if (!PyArg_ParseTuple(args,"OiiiiOiiOiik:MaskBlt", ! &obdst, // @pyparm <o PyHANDLE>|Dest||Destination device context handle ! &dst_x, // @pyparm int|XDest||X pos of dest rect ! &dst_y, // @pyparm int|YDest||Y pos of dest rect ! &dst_width, // @pyparm int|Width||Width of rect to be copied ! &dst_height, // @pyparm int|Height||Height of rect to be copied ! &obsrc, // @pyparm <o PyHANDLE>|Src||Source DC handle ! &src_x, // @pyparm int|XSrc||X pos of src rect ! &src_y, // @pyparm int|YSrc||Y pos of src rect ! &obmask, // @pyparm <o PyHANDLE>|Mask||Handle to monochrome bitmap used to mask color ! &mask_x, // @pyparm int|xMask||X pos in mask ! &mask_y, // @pyparm int|yMask||Y pos in mask ! &rop)) // @pyparm int|Rop||Foreground and background raster operations. See MSDN docs for how to construct this value. ! return NULL; ! if (!PyWinObject_AsHANDLE(obdst, (HANDLE *)&dst, FALSE)) ! return NULL; ! if (!PyWinObject_AsHANDLE(obsrc, (HANDLE *)&src, FALSE)) ! return NULL; ! if (!PyWinObject_AsHANDLE(obmask, (HANDLE *)&mask, FALSE)) ! return NULL; ! if (!(*pfnMaskBlt)( ! dst, dst_x, dst_y, dst_width, dst_height, ! src, src_x, src_y, ! mask, mask_x, mask_y, rop)) ! return PyWin_SetAPIError("MaskBlt"); ! Py_INCREF(Py_None); ! return Py_None; ! } ! ! // @pyswig |AlphaBlend|Transfers color information using alpha blending ! static PyObject *PyAlphaBlend(PyObject *self, PyObject *args) ! { ! CHECK_PFN(AlphaBlend); ! PyObject *obsrc, *obdst, *obbl; ! HDC src, dst; ! int src_x, src_y, src_width, src_height; ! int dst_x, dst_y, dst_width, dst_height; ! BLENDFUNCTION bl; ! if (!PyArg_ParseTuple(args,"OiiiiOiiiiO:AlphaBlend", ! &obdst, // @pyparm <o PyHANDLE>|Dest||Destination device context handle ! &dst_x, // @pyparm int|XOriginDest||X pos of dest rect ! &dst_y, // @pyparm int|YOriginDest||Y pos of dest rect ! &dst_width, // @pyparm int|WidthDest||Width of dest rect ! &dst_height, // @pyparm int|HeightDest||Height of dest rect ! &obsrc, // @pyparm <o PyHANDLE>|Src||Source DC handle ! &src_x, // @pyparm int|XOriginSrc||X pos of src rect ! &src_y, // @pyparm int|YOriginSrc||Y pos of src rect ! &src_width, // @pyparm int|WidthSrc||Width of src rect ! &src_height, // @pyparm int|HeightSrc||Height of src rect ! &obbl)) // @pyparm <o PyBLENDFUNCTION>|blendFunction||Alpha blending parameters ! return NULL; ! if (!PyWinObject_AsHANDLE(obdst, (HANDLE *)&dst, FALSE)) ! return NULL; ! if (!PyWinObject_AsHANDLE(obsrc, (HANDLE *)&src, FALSE)) ! return NULL; ! if (!PyWinObject_AsBLENDFUNCTION(obbl, &bl)) ! return NULL; ! if (!(*pfnAlphaBlend)( ! dst, dst_x, dst_y, dst_width, dst_height, ! src, src_x, src_y, src_width, src_height, ! bl)) ! return PyWin_SetAPIError("AlphaBlend"); ! Py_INCREF(Py_None); ! return Py_None; ! } ! %} ! %native (TransparentBlt) PyTransparentBlt; ! %native (MaskBlt) PyMaskBlt; ! %native (AlphaBlend) PyAlphaBlend; // @pyswig int|ImageList_Add|Adds an image or images to an image list. *************** *** 2734,2737 **** --- 2863,2871 ---- ); + // @pyswig <o PyHANDLE>|GetCurrentObject|Retrieves currently selected object from a DC + HGDIOBJ GetCurrentObject( + HDC hdc, // @pyparm <o PyHANDLE>|hdc||Handle to a device context + UINT ObjectType); // @pyparm int|ObjectType||Type of object to retrieve, one of win32con.OBJ_*; + HINSTANCE GetModuleHandle(TCHAR *INPUT_NULLOK); *************** *** 2767,2772 **** PyGetWindowPlacement(PyObject *self, PyObject *args) { ! int hwnd; ! if (!PyArg_ParseTuple(args, "i:GetWindowPlacement", &hwnd)) return NULL; --- 2901,2909 ---- PyGetWindowPlacement(PyObject *self, PyObject *args) { ! HWND hwnd; ! PyObject *obhwnd; ! if (!PyArg_ParseTuple(args, "O:GetWindowPlacement", &obhwnd)) ! return NULL; ! if (!PyWinObject_AsHANDLE(obhwnd, (HANDLE *)&hwnd)) return NULL; *************** *** 2775,2779 **** BOOL ok; Py_BEGIN_ALLOW_THREADS ! ok = GetWindowPlacement( (HWND)hwnd, &pment ); Py_END_ALLOW_THREADS if (!ok) --- 2912,2916 ---- BOOL ok; Py_BEGIN_ALLOW_THREADS ! ok = GetWindowPlacement(hwnd, &pment ); Py_END_ALLOW_THREADS if (!ok) *************** *** 3384,3387 **** --- 3521,3531 ---- HDC hdc); // @pyparm <o PyHANDLE>|hdc||Handle to a device context + // @pyswig RedrawWindow|Causes a portion of a window to be redrawn + BOOLAPI RedrawWindow( + HWND hWnd, // @pyparm <o PyHANDLE>|hWnd||Handle to window to be redrawn + RECT *INPUT_NULLOK, // @pyparm (int,int,int,int)|rcUpdate||Rectangle (left, top, right, bottom) identifying part of window to be redrawn, can be None + HRGN hrgnUpdate, // @pyparm <o PyHANDLE>|hrgnUpdate||Handle to region to be updated + UINT flags); // @pyparm int|flags||Combination of win32con.RDW_* flags + %{ // @pyswig cx, cy|GetTextExtentPoint32|Computes the width and height of the specified string of text. *************** *** 3613,3616 **** --- 3757,3799 ---- return PyInt_FromLong(prevmode); } + + // @pyswig int|GetLayout|Retrieves the layout mode of a device context + // @rdesc Returns one of win32con.LAYOUT_* + static PyObject *PyGetLayout(PyObject *self, PyObject *args) + { + CHECK_PFN(GetLayout); + HDC hdc; + PyObject *obdc; + DWORD prevlayout; + if (!PyArg_ParseTuple(args, "O:GetLayout", + &obdc)) // @pyparm <o PyHANDLE>|hdc||Handle to a device context + return NULL; + if (!PyWinObject_AsHANDLE(obdc, (HANDLE *)&hdc, FALSE)) + return NULL; + prevlayout=(*pfnGetLayout)(hdc); + if (prevlayout==GDI_ERROR) + return PyWin_SetAPIError("GetLayout"); + return PyLong_FromUnsignedLong(prevlayout); + } + + // @pyswig int|SetLayout|Sets the layout for a device context + // @rdesc Returns the previous layout mode + static PyObject *PySetLayout(PyObject *self, PyObject *args) + { + CHECK_PFN(SetLayout); + HDC hdc; + PyObject *obdc; + DWORD newlayout, prevlayout; + if (!PyArg_ParseTuple(args, "Ok:SetLayout", + &obdc, // @pyparm <o PyHANDLE>|hdc||Handle to a device context + &newlayout)) // @pyparm int|Layout||One of win32con.LAYOUT_* constants + return NULL; + if (!PyWinObject_AsHANDLE(obdc, (HANDLE *)&hdc, FALSE)) + return NULL; + prevlayout=(*pfnSetLayout)(hdc, newlayout); + if (prevlayout==GDI_ERROR) + return PyWin_SetAPIError("SetLayout"); + return PyLong_FromUnsignedLong(prevlayout); + } %} *************** *** 3626,3629 **** --- 3809,3814 ---- %native (GetGraphicsMode) PyGetGraphicsMode; %native (SetGraphicsMode) PySetGraphicsMode; + %native (GetLayout) PyGetLayout; + %native (SetLayout) PySetLayout; %{ *************** *** 3867,3870 **** --- 4052,4221 ---- %native (SetViewportExtEx) PySetViewportExtEx; + %{ + // @object PyTRIVERTEX|Dict representing a TRIVERTEX struct containing color information at a point + // @pyseeapi TRIVERTEX + BOOL PyWinObject_AsTRIVERTEX(PyObject *obtv, TRIVERTEX *ptv) + { + static char *keywords[]={"x","y","Red","Green","Blue","Alpha", NULL}; + if (!PyDict_Check(obtv)){ + PyErr_SetString(PyExc_TypeError,"TRIVERTEX must be a dict"); + return FALSE; + } + PyObject *dummy_tuple=PyTuple_New(0); + if (dummy_tuple==NULL) + return FALSE; + BOOL ret=PyArg_ParseTupleAndKeywords(dummy_tuple, obtv, "llHHHH", keywords, + &ptv->x, // @prop int|x|X coord in logical units + &ptv->y, // @prop int|y|Y coord in logical units + &ptv->Red, // @prop int|Red|Red component + &ptv->Green, // @prop int|Green|Green component + &ptv->Blue, // @prop int|Blue|Blue component + &ptv->Alpha); // @prop int|Alpha|Transparency value + Py_DECREF(dummy_tuple); + return ret; + } + + BOOL PyWinObject_AsTRIVERTEXArray(PyObject *obtvs, TRIVERTEX **ptvs, DWORD *item_cnt) + { + BOOL ret=TRUE; + DWORD bufsize, tuple_index; + PyObject *trivertex_tuple=NULL, *tuple_item; + *ptvs=NULL; + *item_cnt=0; + + if ((trivertex_tuple=PySequence_Tuple(obtvs))==NULL) + return FALSE; + *item_cnt=PyTuple_GET_SIZE(trivertex_tuple); + bufsize=*item_cnt * sizeof(TRIVERTEX); + *ptvs=(TRIVERTEX *)malloc(bufsize); + if (*ptvs==NULL){ + PyErr_Format(PyExc_MemoryError, "Unable to allocate %d bytes", bufsize); + ret=FALSE; + } + else + for (tuple_index=0; tuple_index<*item_cnt; tuple_index++){ + tuple_item=PyTuple_GET_ITEM(trivertex_tuple,tuple_index); + if (!PyWinObject_AsTRIVERTEX(tuple_item, &(*ptvs)[tuple_index])){ + ret=FALSE; + break; + } + } + if (!ret) + if (*ptvs!=NULL){ + free(*ptvs); + *ptvs=NULL; + *item_cnt=0; + } + Py_XDECREF(trivertex_tuple); + return ret; + } + + BOOL PyWinObject_AsMeshArray(PyObject *obmesh, ULONG mode, void **pmesh, DWORD *item_cnt) + { + BOOL ret=TRUE, triangle; + DWORD bufsize, tuple_index; + PyObject *mesh_tuple=NULL, *tuple_item; + *pmesh=NULL; + *item_cnt=0; + + if ((mesh_tuple=PySequence_Tuple(obmesh))==NULL) + return FALSE; + *item_cnt=PyTuple_GET_SIZE(mesh_tuple); + switch (mode){ + case GRADIENT_FILL_TRIANGLE: + bufsize=*item_cnt * sizeof(GRADIENT_TRIANGLE); + triangle=TRUE; + break; + case GRADIENT_FILL_RECT_H: + case GRADIENT_FILL_RECT_V: + bufsize=*item_cnt * sizeof(GRADIENT_RECT); + triangle=FALSE; + break; + default: + PyErr_Format(PyExc_ValueError,"Unrecognized value for gradient fill mode: %d", mode); + return FALSE; + } + + *pmesh=malloc(bufsize); + if (*pmesh==NULL){ + PyErr_Format(PyExc_MemoryError, "Unable to allocate %d bytes", bufsize); + ret=FALSE; + } + else + for (tuple_index=0; tuple_index<*item_cnt; tuple_index++){ + tuple_item=PyTuple_GET_ITEM(mesh_tuple,tuple_index); + if (!PyTuple_Check(tuple_item)){ + PyErr_SetString(PyExc_TypeError,"Mesh elements must be tuples of 2 or 3 ints"); + ret=FALSE; + break; + } + if (triangle){ + if (!PyArg_ParseTuple(tuple_item, "kkk:GRADIENT_TRIANGLE", + &((GRADIENT_TRIANGLE *)(*pmesh))[tuple_index].Vertex1, + &((GRADIENT_TRIANGLE *)(*pmesh))[tuple_index].Vertex2, + &((GRADIENT_TRIANGLE *)(*pmesh))[tuple_index].Vertex3)){ + ret=FALSE; + break; + } + } + else + if (!PyArg_ParseTuple(tuple_item, "kk:GRADIENT_RECT", + &((GRADIENT_RECT *)(*pmesh))[tuple_index].UpperLeft, + &((GRADIENT_RECT *)(*pmesh))[tuple_index].LowerRight)){ + ret=FALSE; + break; + } + } + if (!ret) + if (*pmesh!=NULL){ + free(*pmesh); + *pmesh=NULL; + *item_cnt=0; + } + Py_XDECREF(mesh_tuple); + return ret; + } + + // @pyswig |GradientFill|Shades triangles or rectangles by interpolating between vertex colors + static PyObject *PyGradientFill(PyObject *self, PyObject *args) + { + CHECK_PFN(GradientFill); + HDC hdc; + PTRIVERTEX ptv=NULL; + ULONG tv_cnt, mesh_cnt, mode; + PVOID pmesh=NULL; + BOOL bres; + PyObject *obdc, *obtvs, *obmesh, *ret=NULL; + if (!PyArg_ParseTuple(args, "OOOk:GradientFill", + &obdc, // @pyparm int|hdc||Handle to device context + &obtvs, // @pyparm (<o PyTRIVERTEX>,...)|Vertex||Sequence of TRIVERTEX dicts defining color info + &obmesh, // @pyparm tuple|Mesh||Sequence of tuples containing either 2 or 3 ints that index into the trivertex array to define either triangles or rectangles + &mode)) // @pyparm int|Mode||win32con.GRADIENT_FILL_* value defining whether to fill by triangle or by rectangle + return NULL; + if (!PyWinObject_AsHANDLE(obdc, (HANDLE *)&hdc, FALSE)) + return NULL; + if (!PyWinObject_AsTRIVERTEXArray(obtvs, &ptv, &tv_cnt)) + goto cleanup; + if (!PyWinObject_AsMeshArray(obmesh, mode, &pmesh, &mesh_cnt)) + goto cleanup; + Py_BEGIN_ALLOW_THREADS + bres=(*pfnGradientFill)(hdc, ptv, tv_cnt, pmesh, mesh_cnt, mode); + Py_END_ALLOW_THREADS + if (!bres) + PyWin_SetAPIError("GradientFill"); + else{ + Py_INCREF(Py_None); + ret=Py_None; + } + cleanup: + if (ptv) + free(ptv); + if (pmesh) + free(pmesh); + return ret; + } + %} + %native (GradientFill) PyGradientFill; + // @pyswig int|GetOpenFileName|Creates an Open dialog box that lets the user specify the drive, directory, and the name of a file or set of files to open. *************** *** 6248,6249 **** --- 6599,6700 ---- PyCFunction pfnPyGetLayeredWindowAttributes=(PyCFunction)PyGetLayeredWindowAttributes; %} + + // @pyswig |UpdateLayeredWindow|Updates the position, size, shape, content, and translucency of a layered window. + // @comm This function is only available on Windows 2000 and later + // @comm Accepts keyword arguments. + %{ + PyObject *PyUpdateLayeredWindow(PyObject *self, PyObject *args, PyObject *kwargs) + { + CHECK_PFN(UpdateLayeredWindow); + static char *keywords[]={"hwnd","hdcDst","ptDst","size","hdcSrc", + "ptSrc","Key","blend","Flags", NULL}; + HWND hwnd; + HDC hdcDst, hdcSrc; + PyObject *obhwnd, *obsrc=Py_None, *obdst=Py_None; + PyObject *obptSrc=Py_None, *obptDst=Py_None, *obsize=Py_None, *obblend=Py_None; + COLORREF crKey=0; + POINT ptSrc, ptDst; + POINT *pptSrc=NULL, *pptDst=NULL; + SIZE size; + SIZE *psize=NULL; + BLENDFUNCTION blend={0,0,255,0}; + DWORD Flags=0; + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|OOOOOkOk:UpdateLayeredWindow", keywords, + &obhwnd, // @pyparm <o PyHANDLE>|hwnd||handle to layered window + &obdst, // @pyparm <o PyHANDLE>|hdcDst|None|handle to screen DC, can be None. *Must* be None if hdcSrc is None + &obptDst, // @pyparm (x,y)|ptDst|None|New screen position, can be None. + &obsize, // @pyparm (cx, cy)|size|None|New size of the layered window, can be None. *Must* be None if hdcSrc is None. + &obsrc, // @pyparm int|hdcSrc|None|handle to surface DC for the window, can be None + &obptSrc, // @pyparm (x,y)|ptSrc|None|layer position, can be None. *Must* be None if hdcSrc is None. + &crKey, // @pyparm int|Key|0|Color key, generate using <om win32api.RGB> + &obblend, // @pyparm (int, int, int, int)|blend|(0,0,255,0)|<o PyBLENDFUNCTION> specifying alpha blending parameters + &Flags)) // @pyparm int|Flags|0|One of the win32con.ULW_* values. Use 0 if hdcSrc is None. + return NULL; + if (!PyWinObject_AsHANDLE(obhwnd, (HANDLE *)&hwnd, FALSE)) + return NULL; + if (!PyWinObject_AsHANDLE(obdst, (HANDLE *)&hdcDst, TRUE)) + return NULL; + if (!PyWinObject_AsHANDLE(obsrc, (HANDLE *)&hdcSrc, TRUE)) + return NULL; + if (obblend!=Py_None) + if (!PyWinObject_AsBLENDFUNCTION(obblend, &blend)) + return NULL; + if (obptDst!=Py_None){ + if (!PyWinObject_AsPOINT(obptDst, &ptDst)) + return NULL; + pptDst=&ptDst; + } + if (obsize!=Py_None){ + if (!PyWinObject_AsSIZE(obsize, &size)) + return NULL; + psize=&size; + } + if (obptSrc!=Py_None){ + if (!PyWinObject_AsPOINT(obptSrc, &ptSrc)) + return NULL; + pptSrc=&ptSrc; + } + + BOOL ret; + Py_BEGIN_ALLOW_THREADS + ret=(*pfnUpdateLayeredWindow)(hwnd, hdcDst, pptDst, psize, hdcSrc, pptSrc, crKey, &blend, Flags); + Py_END_ALLOW_THREADS + if (!ret) + return PyWin_SetAPIError("UpdateLayeredWindow"); + Py_INCREF(Py_None); + return Py_None; + } + PyCFunction pfnPyUpdateLayeredWindow=(PyCFunction)PyUpdateLayeredWindow; + %} + %native (UpdateLayeredWindow) pfnPyUpdateLayeredWindow; + + %{ + // @pyswig |AnimateWindow|Enables you to produce special effects when showing or hiding windows. There are three types of animation: roll, slide, and alpha-blended fade. + // @comm This function is available on Win2k and later + // @comm Accepts keyword args + PyObject *PyAnimateWindow(PyObject *self, PyObject *args, PyObject *kwargs) + { + CHECK_PFN(AnimateWindow); + static char *keywords[]={"hwnd","Time","Flags", NULL}; + PyObject *obhwnd; + HWND hwnd; + DWORD duration, flags; + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Okk", keywords, + &obhwnd, // @pyparm <o PyHANDLE>|hwnd||handle to window + &duration, // @pyparm int|Time||Duration of animation in ms + &flags)) // @pyparm int|Flags||Animation type, combination of win32con.AW_* flags + return NULL; + if (!PyWinObject_AsHANDLE(obhwnd, (HANDLE *)&hwnd, FALSE)) + return NULL; + BOOL ret; + Py_BEGIN_ALLOW_THREADS + ret=(*pfnAnimateWindow)(hwnd, duration, flags); + Py_END_ALLOW_THREADS + if (!ret) + return PyWin_SetAPIError("AnimateWindow"); + Py_INCREF(Py_None); + return Py_None; + } + PyCFunction pfnPyAnimateWindow=(PyCFunction)PyAnimateWindow; + %} + %native (AnimateWindow) pfnPyAnimateWindow; |
From: Roger U. <ru...@us...> - 2006-12-24 06:00:18
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7893/win32/Lib Modified Files: win32con.py Log Message: Add layout flags Index: win32con.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/win32con.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** win32con.py 8 Dec 2006 10:48:42 -0000 1.16 --- win32con.py 24 Dec 2006 06:00:13 -0000 1.17 *************** *** 4307,4310 **** --- 4307,4312 ---- RGN_MIN = RGN_AND RGN_MAX = RGN_COPY + + ## Stretching modes used with Get/SetStretchBltMode BLACKONWHITE = 1 WHITEONBLACK = 2 *************** *** 4312,4318 **** --- 4314,4333 ---- HALFTONE = 4 MAXSTRETCHBLTMODE = 4 + STRETCH_ANDSCANS = BLACKONWHITE + STRETCH_ORSCANS = WHITEONBLACK + STRETCH_DELETESCANS = COLORONCOLOR + STRETCH_HALFTONE = HALFTONE + ALTERNATE = 1 WINDING = 2 POLYFILL_LAST = 2 + + ## flags used with SetLayout + LAYOUT_RTL = 1 + LAYOUT_BTT = 2 + LAYOUT_VBH = 4 + LAYOUT_ORIENTATIONMASK = LAYOUT_RTL|LAYOUT_BTT|LAYOUT_VBH + LAYOUT_BITMAPORIENTATIONPRESERVED = 8 + TA_NOUPDATECP = 0 TA_UPDATECP = 1 |
From: Mark H. <mha...@us...> - 2006-12-22 03:57:54
|
Update of /cvsroot/pywin32/pywin32/Pythonwin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27395 Modified Files: pythondoc.h Log Message: Grab GIL to report error. Index: pythondoc.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pythondoc.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** pythondoc.h 30 Mar 2000 02:12:44 -0000 1.2 --- pythondoc.h 22 Dec 2006 03:57:52 -0000 1.3 *************** *** 134,137 **** --- 134,138 ---- CVirtualHelper helper( "OnOpenDocument", this ); if (!helper.HaveHandler()) { + CEnterLeavePython _celp; // grab lock to report error PyErr_SetString(ui_module_error,"PyCDocument::OnOpenDocument handler does not exist."); gui_print_error(); *************** *** 164,170 **** int ret; // @rdesc TRUE if a new document could be created, else FALSE. ! if (helper.retval(ret)) return ret; else { PyErr_SetString(PyExc_TypeError, "PyCDocument.OnNewDocument - bad return type."); gui_print_error(); --- 165,172 ---- int ret; // @rdesc TRUE if a new document could be created, else FALSE. ! if (helper.retval(ret)) return ret; else { + CEnterLeavePython _celp; // grab lock to report error PyErr_SetString(PyExc_TypeError, "PyCDocument.OnNewDocument - bad return type."); gui_print_error(); |
From: Sidnei da S. <dre...@us...> - 2006-12-21 23:17:22
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19745/com/win32com/src Modified Files: Tag: AMD64 oleargs.cpp Log Message: - Initial work on AMD64 support Index: oleargs.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/oleargs.cpp,v retrieving revision 1.36 retrieving revision 1.36.2.1 diff -C2 -d -r1.36 -r1.36.2.1 *** oleargs.cpp 21 Jun 2006 12:18:51 -0000 1.36 --- oleargs.cpp 21 Dec 2006 23:17:15 -0000 1.36.2.1 *************** *** 398,402 **** if (dimNo==nDims && vt==VT_UI1 && obj->ob_type->tp_as_buffer) { PyBufferProcs *pb = obj->ob_type->tp_as_buffer; ! int bufSize; if (pb->bf_getreadbuffer && pb->bf_getsegcount && --- 398,402 ---- if (dimNo==nDims && vt==VT_UI1 && obj->ob_type->tp_as_buffer) { PyBufferProcs *pb = obj->ob_type->tp_as_buffer; ! Py_ssize_t bufSize; if (pb->bf_getreadbuffer && pb->bf_getsegcount && |