[pywin32-checkins] pywin32/win32/src win32gui.i,1.105,1.106
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Roger U. <ru...@us...> - 2007-05-07 06:00:31
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1498/win32/src Modified Files: win32gui.i Log Message: Add EnumPropsEx Allow window class to be None in FindWindow and FindWindowEx Index: win32gui.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32gui.i,v retrieving revision 1.105 retrieving revision 1.106 diff -C2 -d -r1.105 -r1.106 *** win32gui.i 1 Apr 2007 13:24:04 -0000 1.105 --- win32gui.i 7 May 2007 06:00:30 -0000 1.106 *************** *** 1611,1623 **** - %typedef TCHAR *STRING_OR_ATOM %typedef TCHAR *STRING_OR_ATOM_CW ! %typemap(python,arginit) STRING_OR_ATOM, STRING_OR_ATOM_CW, RESOURCE_ID{ $target=NULL; } ! %typemap(python,in) STRING_OR_ATOM, STRING_OR_ATOM_CW { ! if (!PyWinObject_AsResourceId($source, &$target)) return NULL; } --- 1611,1629 ---- %typedef TCHAR *STRING_OR_ATOM_CW + %typedef TCHAR *RESOURCE_ID + %typedef TCHAR *RESOURCE_ID_NULLOK ! %typemap(python,arginit) STRING_OR_ATOM_CW, RESOURCE_ID, RESOURCE_ID_NULLOK{ $target=NULL; } ! %typemap(python,in) RESOURCE_ID { ! if (!PyWinObject_AsResourceId($source, &$target, FALSE)) ! return NULL; ! } ! ! %typemap(python,in) STRING_OR_ATOM_CW, RESOURCE_ID_NULLOK { ! if (!PyWinObject_AsResourceId($source, &$target, TRUE)) return NULL; } *************** *** 1643,1654 **** } ! %typedef TCHAR *RESOURCE_ID ! ! %typemap(python,in) RESOURCE_ID { ! if (!PyWinObject_AsResourceId($source, &$target)) ! return NULL; ! } ! ! %typemap(python,freearg) RESOURCE_ID { PyWinObject_FreeResourceId($source); } --- 1649,1653 ---- } ! %typemap(python,freearg) RESOURCE_ID,RESOURCE_ID_NULLOK { PyWinObject_FreeResourceId($source); } *************** *** 2824,2839 **** BOOL bEnable); // @pyparm boolean|bEnable||True to enable input to the window, False to disable input ! // @pyswig int|FindWindow|Retrieves a handle to the top-level window whose class name and window name match the specified strings. HWND FindWindow( ! STRING_OR_ATOM className, // @pyparm int/string|className|| ! TCHAR *INPUT_NULLOK); // @pyparm string|WindowName|| #ifndef MS_WINCE ! // @pyswig int|FindWindowEx|Retrieves a handle to the top-level window whose class name and window name match the specified strings. HWND FindWindowEx( ! HWND parent, // @pyparm int|hwnd|| ! HWND childAfter, // @pyparm int|childAfter|| ! STRING_OR_ATOM className, // @pyparm int/string|className|| ! TCHAR *INPUT_NULLOK); // @pyparm string|WindowName|| // @pyswig |DragAcceptFiles|Registers whether a window accepts dropped files. --- 2823,2838 ---- BOOL bEnable); // @pyparm boolean|bEnable||True to enable input to the window, False to disable input ! // @pyswig <o PyHANDLE>|FindWindow|Retrieves a handle to the top-level window whose class name and window name match the specified strings. HWND FindWindow( ! RESOURCE_ID_NULLOK className, // @pyparm <o PyResourceId>|ClassName||Name or atom of window class to find, can be None ! TCHAR *INPUT_NULLOK); // @pyparm string|WindowName||Title of window to find, can be None #ifndef MS_WINCE ! // @pyswig <o PyHANDLE>|FindWindowEx|Retrieves a handle to the top-level window whose class name and window name match the specified strings. HWND FindWindowEx( ! HWND parent, // @pyparm <o PyHANDLE>|Parent||Window whose child windows will be searched. If 0, desktop window is assumed. ! HWND childAfter, // @pyparm <o PyHANDLE>|ChildAfter||Child window after which to search in Z-order, can be 0 to search all ! RESOURCE_ID_NULLOK className, // @pyparm <o PyResourceId>|ClassName||Name or atom of window class to find, can be None ! TCHAR *INPUT_NULLOK); // @pyparm string|WindowName||Title of window to find, can be None // @pyswig |DragAcceptFiles|Registers whether a window accepts dropped files. *************** *** 6203,6207 **** PyWinObject_AsWCHAR(obTitle, (WCHAR **)&pofn->lpstrTitle, TRUE) && PyWinObject_AsWCHAR(obDefExt, (WCHAR **)&pofn->lpstrDefExt, TRUE) && ! ((obTemplateName==Py_None)||PyWinObject_AsResourceIdW(obTemplateName, (WCHAR **)&pofn->lpTemplateName)); done: --- 6202,6206 ---- PyWinObject_AsWCHAR(obTitle, (WCHAR **)&pofn->lpstrTitle, TRUE) && PyWinObject_AsWCHAR(obDefExt, (WCHAR **)&pofn->lpstrDefExt, TRUE) && ! PyWinObject_AsResourceIdW(obTemplateName, (WCHAR **)&pofn->lpTemplateName, TRUE); done: *************** *** 7227,7228 **** --- 7226,7287 ---- %} %native (DrawTextW) pfnPyDrawTextW; + + %{ + BOOL CALLBACK PyEnumPropsExCallback(HWND hwnd, LPWSTR propname, HANDLE propdata, ULONG_PTR callback_data) + { + PyObject *args=NULL, *obret=NULL; + BOOL ret; + CEnterLeavePython _celp; + PyObject **callback_objects=(PyObject **)callback_data; + args=Py_BuildValue("NNNO", + PyWinLong_FromHANDLE(hwnd), + IS_INTRESOURCE(propname) ? PyWinLong_FromVoidPtr(propname):PyWinObject_FromWCHAR(propname), + PyWinLong_FromHANDLE(propdata), + callback_objects[1]); + if (args==NULL) + return FALSE; + obret=PyObject_Call(callback_objects[0], args, NULL); + if (obret==NULL) + ret=FALSE; + else + ret=TRUE; + + Py_XDECREF(args); + Py_XDECREF(obret); + return ret; + } + + // @pyswig |EnumPropsEx|Enumerates properties attached to a window. + // Each property is passed to a callback function, which receives 4 arguments:<nl> + // Handle to the window, name of the property, handle to the property data, and Param object passed to this function + // + PyObject *PyEnumPropsEx(PyObject *self, PyObject *args) + { + HWND hwnd; + PyObject *obhwnd, *callback, *callback_data; + PyObject *callback_objects[2]; + + if (!PyArg_ParseTuple(args, "OOO:EnumPropsEx", + &obhwnd, // @pyparm <o PyHANDLE>|hWnd||Handle to a window + &callback, // @pyparm function|EnumFunc||Callback function + &callback_data)) // @pyparm object|Param||Arbitrary object to be passed to callback function + return NULL; + if (!PyWinObject_AsHANDLE(obhwnd, (HANDLE *)&hwnd, FALSE)) + return NULL; + if (!PyCallable_Check(callback)){ + PyErr_SetString(PyExc_TypeError,"EnumFunc must be callable"); + return NULL; + } + callback_objects[0]=callback; + callback_objects[1]=callback_data; + + if (!EnumPropsExW(hwnd, PyEnumPropsExCallback, (LPARAM)callback_objects)){ + if (!PyErr_Occurred()) + PyWin_SetAPIError("EnumPropsEx"); + return NULL; + } + Py_INCREF(Py_None); + return Py_None; + } + %} + %native(EnumPropsEx) PyEnumPropsEx; |