[pywin32-checkins] pywin32/win32/src win32gui.i,1.102,1.103
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2007-03-05 05:55:49
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7127 Modified Files: win32gui.i Log Message: Move SetMenuInfo and GetMenuInfo into win32gui as winxpgui now fails to import on win2k and earlier Index: win32gui.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32gui.i,v retrieving revision 1.102 retrieving revision 1.103 diff -C2 -d -r1.102 -r1.103 *** win32gui.i 22 Feb 2007 20:40:54 -0000 1.102 --- win32gui.i 5 Mar 2007 05:55:47 -0000 1.103 *************** *** 66,69 **** --- 66,73 ---- typedef BOOL (WINAPI *AnimateWindowfunc)(HWND,DWORD,DWORD); static AnimateWindowfunc pfnAnimateWindow=NULL; + typedef BOOL (WINAPI *GetMenuInfofunc)(HMENU, LPCMENUINFO); + static GetMenuInfofunc pfnGetMenuInfo=NULL; + typedef BOOL (WINAPI *SetMenuInfofunc)(HMENU, LPCMENUINFO); + static GetMenuInfofunc pfnSetMenuInfo=NULL; typedef DWORD (WINAPI *GetLayoutfunc)(HDC); static GetLayoutfunc pfnGetLayout=NULL; *************** *** 247,250 **** --- 251,256 ---- pfnUpdateLayeredWindow=(UpdateLayeredWindowfunc)GetProcAddress(hmodule,"UpdateLayeredWindow"); pfnAnimateWindow=(AnimateWindowfunc)GetProcAddress(hmodule,"AnimateWindow"); + pfnGetMenuInfo=(GetMenuInfofunc)GetProcAddress(hmodule,"GetMenuInfo"); + pfnSetMenuInfo=(SetMenuInfofunc)GetProcAddress(hmodule,"SetMenuInfo"); } *************** *** 4535,4555 **** ); - %ifdef WINXPGUI // @pyswig |SetMenuInfo|Sets information for a specified menu. ! // @comm To avoid complications with Windows NT, this function only exists in winxpgui (not win32gui) ! BOOLAPI SetMenuInfo( ! HMENU hmenu, // @pyparm int|hmenu||handle to menu ! MENUINFO *INPUT // @pyparm <o MENUINFO>|info||menu information in the format of a buffer. ! // See win32gui_struct for helper functions. ! ); // @pyswig |GetMenuInfo|Gets information about a specified menu. ! // @comm To avoid complications with Windows NT, this function only exists in winxpgui (not win32gui) ! BOOLAPI GetMenuInfo( ! HMENU hMenu, // @pyparm int|hmenu||handle to menu ! MENUINFO *BOTH // @pyparm buffer|info||A buffer to fill with the information. ! ); ! %endif // @pyswig |DrawFocusRect|Draws a standard focus outline around a rectangle --- 4541,4617 ---- ); // @pyswig |SetMenuInfo|Sets information for a specified menu. ! // @comm See win32gui_struct for helper functions. ! // @comm This function will raise NotImplementedError on early platforms (eg, Windows NT.) ! %{ ! PyObject *PySetMenuInfo(PyObject *self, PyObject *args) ! { ! CHECK_PFN(SetMenuInfo); ! PyObject *obMenu, *obInfo; ! HMENU hmenu; ! int cbInfo; ! MENUINFO *pInfo; ! BOOL result; ! // @pyparm int|hmenu||handle to menu ! // @pyparm <o MENUINFO>|info||menu information in the format of a buffer. ! if (!PyArg_ParseTuple(args, "OO", &obMenu, &obInfo)) ! return NULL; ! ! if (!PyWinObject_AsHANDLE(obMenu, (HANDLE *)&hmenu, FALSE)) ! return NULL; ! ! if (0 != PyObject_AsReadBuffer(obInfo, (const void **)&pInfo, &cbInfo)) ! return NULL; ! if (sizeof MENUINFO != cbInfo) ! return PyErr_Format(PyExc_TypeError, "Argument must be a %d byte string/buffer (got %d bytes)", sizeof MENUINFO, cbInfo); ! ! Py_BEGIN_ALLOW_THREADS ! result = (*pfnSetMenuInfo)(hmenu, pInfo); ! Py_END_ALLOW_THREADS ! if (!result) ! return PyWin_SetAPIError("SetMenuInfo"); ! Py_INCREF(Py_None); ! return Py_None; ! } ! %} ! %native (SetMenuInfo) PySetMenuInfo; ! // @pyswig |GetMenuInfo|Gets information about a specified menu. ! // @comm See win32gui_struct for helper functions. ! // @comm This function will raise NotImplementedError on early platforms (eg, Windows NT.) ! %{ ! PyObject *PyGetMenuInfo(PyObject *self, PyObject *args) ! { ! CHECK_PFN(GetMenuInfo); ! PyObject *obMenu, *obInfo; ! HMENU hmenu; ! int cbInfo; ! MENUINFO *pInfo; ! BOOL result; ! // @pyparm int|hmenu||handle to menu ! // @pyparm buffer|info||A buffer to fill with the information. ! if (!PyArg_ParseTuple(args, "OO", &obMenu, &obInfo)) ! return NULL; ! ! if (!PyWinObject_AsHANDLE(obMenu, (HANDLE *)&hmenu, FALSE)) ! return NULL; ! ! if (0 != PyObject_AsWriteBuffer(obInfo, (void **)&pInfo, &cbInfo)) ! return NULL; ! if (sizeof MENUINFO != cbInfo) ! return PyErr_Format(PyExc_TypeError, "Argument must be a %d byte buffer (got %d bytes)", sizeof MENUINFO, cbInfo); + Py_BEGIN_ALLOW_THREADS + result = (*pfnGetMenuInfo)(hmenu, pInfo); + Py_END_ALLOW_THREADS + if (!result) + return PyWin_SetAPIError("GetMenuInfo"); + Py_INCREF(Py_None); + return Py_None; + } + %} + + %native (GetMenuInfo) PyGetMenuInfo; // @pyswig |DrawFocusRect|Draws a standard focus outline around a rectangle |