pywin32-checkins Mailing List for Python for Windows Extensions (Page 133)
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: Mark H. <mha...@us...> - 2004-05-26 08:56:05
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9663 Modified Files: shell.cpp Log Message: Add SHGetSettings and FILEGROUPDESCRIPTOR support. Index: shell.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/shell.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** shell.cpp 10 May 2004 20:26:06 -0000 1.25 --- shell.cpp 26 May 2004 08:55:55 -0000 1.26 *************** *** 342,345 **** --- 342,395 ---- } + BOOL PyObject_AsTBBUTTONs( PyObject *ob, TBBUTTON **ppButtons, UINT *pnButtons ) + { + *ppButtons = NULL; + if (ob==Py_None) { + *pnButtons = 0; + return TRUE; + } + if (!PySequence_Check(ob)) { + PyErr_Format(PyExc_TypeError, "TBBUTTONs must be a sequence (got %s)", ob->ob_type->tp_name); + return FALSE; + } + UINT seqsize = PySequence_Size(ob); + UINT i; + if (seqsize == -1) + return FALSE; + *ppButtons = (TBBUTTON *)malloc(seqsize * sizeof(TBBUTTON)); + if (!*ppButtons) { + PyErr_NoMemory(); + return FALSE; + } + memset(*ppButtons, 0, seqsize * sizeof(TBBUTTON)); + for (i=0;i<seqsize;i++) { + TBBUTTON *pThis = (*ppButtons)+i; + PyObject *sub = PySequence_GetItem(ob, i); + if (!sub) goto failed; + int ok = PyArg_ParseTuple(sub, "iiBB|li", + &pThis->iBitmap, + &pThis->idCommand, + &pThis->fsState, + &pThis->fsStyle, + &pThis->dwData, + &pThis->iString); + Py_DECREF(sub); + if (!ok) goto failed; + } + *pnButtons = seqsize; + return TRUE; + failed: + if (*ppButtons) + free(*ppButtons); + *ppButtons = NULL; + return FALSE; + } + + void PyObject_FreeTBBUTTONs(TBBUTTON *p) + { + if (p) + free(p); + } + PyObject *PyWinObject_FromRESOURCESTRING(LPCSTR str) { *************** *** 1434,1437 **** --- 1484,1820 ---- } + #define CHECK_SET_VAL(mask1, mask2, x) \ + if (mask1 & mask2 ) PyDict_SetItemString(ret, #x, state.x ? Py_True : Py_False); + + // @pymethod dict|SHGetSettings|Retrieves the current shell option settings. + static PyObject *PySHGetSettings(PyObject *self, PyObject *args) + { + DWORD mask = -1; + // @pyparm int|mask|-1|The values being requested - one of the shellcon.SSF_* constants + if (!PyArg_ParseTuple(args, "|l:SHGetSettings", &mask)) + return NULL; + SHELLFLAGSTATE state; + SHGetSettings(&state, mask); + PyObject *ret = PyDict_New(); + CHECK_SET_VAL(SSF_DESKTOPHTML, mask, fDesktopHTML); + + CHECK_SET_VAL(SSF_DONTPRETTYPATH, mask, fDontPrettyPath); + CHECK_SET_VAL(SSF_DOUBLECLICKINWEBVIEW, mask, fDoubleClickInWebView); + CHECK_SET_VAL(SSF_HIDEICONS, mask, fHideIcons); + CHECK_SET_VAL(SSF_MAPNETDRVBUTTON, mask, fMapNetDrvBtn); + CHECK_SET_VAL(SSF_NOCONFIRMRECYCLE, mask, fNoConfirmRecycle); + CHECK_SET_VAL(SSF_SHOWALLOBJECTS, mask, fShowAllObjects); + CHECK_SET_VAL(SSF_SHOWATTRIBCOL, mask, fShowAttribCol); + CHECK_SET_VAL(SSF_SHOWCOMPCOLOR, mask, fShowCompColor); + CHECK_SET_VAL(SSF_SHOWEXTENSIONS, mask, fShowExtensions); + CHECK_SET_VAL(SSF_SHOWINFOTIP, mask, fShowInfoTip); + CHECK_SET_VAL(SSF_SHOWSYSFILES, mask, fShowSysFiles); + CHECK_SET_VAL(SSF_WIN95CLASSIC, mask, fWin95Classic); + // If requesting any of the top 3 bits, return them as well + if (mask & 0xE000) { + PyObject *val = PyInt_FromLong(state.fRestFlags); + if (val) { + PyDict_SetItemString(ret, "fRestFlags", val); + Py_DECREF(val); + } + } + return ret; + // @rdesc, the resule is a dictionary, the contents of which depend on + // the mask param. Key names are the same as the SHELLFLAGSTATE + // structure members - 'fShowExtensions', 'fNoConfirmRecycle', etc + } + + // @pymethod string|shell|FILEGROUPDESCRIPTORAsString|Creates a FILEGROUPDESCRIPTOR from a sequence of mapping objects, each with FILEDESCRIPTOR attributes + static PyObject *PyFILEGROUPDESCRIPTORAsString(PyObject *self, PyObject *args) + { + PyObject *ret = NULL; + FILEGROUPDESCRIPTORA *fgd = NULL; + FILEGROUPDESCRIPTORW *fgdw = NULL; + PyObject *ob; + int i; + // @pyparm [FILEDESCRIPTOR, ...]|descriptors||A sequence of FILEDESCRIPTOR objects. + // Each filedescriptor object must be a mapping/dictionary, with the following + // optional attributes: dwFlags, clsid, sizel, pointl, dwFileAttributes, + // ftCreationTime, ftLastAccessTime, ftLastWriteTime, nFileSize + // If these attributes do not exist, or are None, they will be ignored - hence + // you only need specify attributes you care about. + // <nl>In general, you can omit dwFlags - it will be set correctly based + // on what other attributes exist. + // @pyparm bool|make_unicode|False|Should a FILEDESCRIPTORW be created? + int make_unicode = FALSE; + if (!PyArg_ParseTuple(args, "O|i", &ob, &make_unicode)) + return NULL; + if (!PySequence_Check(ob)) + return PyErr_Format(PyExc_TypeError, "must be a sequence of mapping objects (got '%s')", + ob->ob_type->tp_name); + int num = PySequence_Length(ob); + if (num==-1) + return NULL; + int cb; + if (make_unicode) + cb = sizeof(FILEGROUPDESCRIPTORW) + sizeof(FILEDESCRIPTORW)*(num-1); + else + cb = sizeof(FILEGROUPDESCRIPTORA) + sizeof(FILEDESCRIPTORA)*(num-1); + PyObject *ret_string = PyString_FromStringAndSize(NULL, cb); + if (!ret_string) goto done; + fgd = (FILEGROUPDESCRIPTORA *)PyString_AS_STRING(ret_string); + fgdw = (FILEGROUPDESCRIPTORW *)PyString_AS_STRING(ret_string); + memset(fgd, 0, cb); + fgd->cItems = num; + for (i=0;i<num;i++) { + BOOL ok = TRUE; + FILEDESCRIPTORA *fd = fgd->fgd+i; + FILEDESCRIPTORW *fdw = fgdw->fgd+i; + // These structures are the same until the very end, where the + // unicode/ascii buffer is - so we can use either pointer + PyObject *attr; + PyObject *sub = PySequence_GetItem(ob, i); + if (!sub) goto done; + if (!PyMapping_Check(sub)) { + PyErr_Format(PyExc_TypeError, "sub-items must be mapping objects (got '%s')", + sub->ob_type->tp_name); + goto loop_failed; + } + + attr = PyMapping_GetItemString(sub, "dwFlags"); + if (attr==NULL) PyErr_Clear(); + if (attr && attr != Py_None) { + fd->dwFlags = PyInt_AsLong(attr); + ok = !PyErr_Occurred(); + } + Py_XDECREF(attr); + if (!ok) goto loop_failed; + + attr = PyMapping_GetItemString(sub, "clsid"); + if (attr==NULL) PyErr_Clear(); + if (attr && attr != Py_None) { + fd->dwFlags |= FD_CLSID; + ok = PyWinObject_AsIID(attr, &fd->clsid); + } + Py_XDECREF(attr); + if (!ok) goto loop_failed; + + attr = PyMapping_GetItemString(sub, "sizel"); + if (attr==NULL) PyErr_Clear(); + if (attr && attr != Py_None) { + fd->dwFlags |= FD_SIZEPOINT; + ok = PyArg_ParseTuple(attr, "ii", &fd->sizel.cx, &fd->sizel.cy); + } + Py_XDECREF(attr); + if (!ok) goto loop_failed; + + attr = PyMapping_GetItemString(sub, "pointl"); + if (attr==NULL) PyErr_Clear(); + if (attr && attr != Py_None) { + fd->dwFlags |= FD_SIZEPOINT; + ok = PyArg_ParseTuple(attr, "ii", &fd->pointl.x, &fd->pointl.y); + } + Py_XDECREF(attr); + if (!ok) goto loop_failed; + + attr = PyMapping_GetItemString(sub, "dwFileAttributes"); + if (attr==NULL) PyErr_Clear(); + if (attr && attr != Py_None) { + fd->dwFlags |= FD_ATTRIBUTES; + fd->dwFileAttributes = PyInt_AsLong(attr); + ok = !PyErr_Occurred(); + } + Py_XDECREF(attr); + if (!ok) goto loop_failed; + + attr = PyMapping_GetItemString(sub, "ftCreationTime"); + if (attr==NULL) PyErr_Clear(); + if (attr && attr != Py_None) { + fd->dwFlags |= FD_CREATETIME; + ok = PyWinObject_AsFILETIME(attr, &fd->ftCreationTime); + } + Py_XDECREF(attr); + if (!ok) goto loop_failed; + + attr = PyMapping_GetItemString(sub, "ftLastAccessTime"); + if (attr==NULL) PyErr_Clear(); + if (attr && attr != Py_None) { + fd->dwFlags |= FD_ACCESSTIME; + ok = PyWinObject_AsFILETIME(attr, &fd->ftLastAccessTime); + } + Py_XDECREF(attr); + if (!ok) goto loop_failed; + + attr = PyMapping_GetItemString(sub, "ftLastWriteTime"); + if (attr==NULL) PyErr_Clear(); + if (attr && attr != Py_None) { + fd->dwFlags |= FD_WRITESTIME; + ok = PyWinObject_AsFILETIME(attr, &fd->ftLastWriteTime); + } + Py_XDECREF(attr); + if (!ok) goto loop_failed; + + attr = PyMapping_GetItemString(sub, "nFileSize"); + if (attr==NULL) PyErr_Clear(); + if (attr && attr != Py_None) { + fd->dwFlags |= FD_FILESIZE; + ok = PyLong_AsTwoI32(attr, (int *)&fd->nFileSizeHigh, (unsigned *)&fd->nFileSizeLow); + } + Py_XDECREF(attr); + if (!ok) goto loop_failed; + + attr = PyMapping_GetItemString(sub, "cFileName"); + if (attr==NULL) PyErr_Clear(); + if (attr && attr != Py_None) { + // no filename flags?? + if (make_unicode) { + WCHAR *t; + ok = PyWinObject_AsWCHAR(attr, &t); + if (ok) { + wcsncpy(fdw->cFileName, t, sizeof(fdw->cFileName)/sizeof(WCHAR)); + PyWinObject_FreeWCHAR(t); + } + } else { + char *t; + ok = PyWinObject_AsString(attr, &t); + if (ok) { + strncpy(fd->cFileName, t, sizeof(fd->cFileName)/sizeof(char)); + PyWinObject_FreeString(t); + } + } + } + Py_XDECREF(attr); + if (!ok) goto loop_failed; + + Py_DECREF(sub); + continue; // don't fall through to loop error! + loop_failed: + Py_DECREF(sub); + goto done; + } + // all worked - setup result. + ret = ret_string; + ret_string = NULL; + done: + Py_XDECREF(ret_string); + return ret; + } + + // @pymethod [dict, ...]|shell|StringAsFILEGROUPDESCRIPTOR|Decodes a FILEGROUPDESCRIPTOR packed in a string + static PyObject *PyStringAsFILEGROUPDESCRIPTOR(PyObject *self, PyObject *args) + { + PyObject *ret = NULL; + FILEGROUPDESCRIPTORA *fgd = NULL; + FILEGROUPDESCRIPTORW *fgdw = NULL; + void *buf; + int i, cb, size_a, size_w, num; + BOOL ok = FALSE; + // @pyparm buffer|buf||A string packed as either FILEGROUPDESCRIPTORW or FILEGROUPDESCRIPTORW + // @pyparm bool|make_unicode|-1|Should this be treated as a FILEDESCRIPTORW? If -1 + // the size of the buffer will be used to make that determination. Thus, if + // the buffer is not the exact size of a correct FILEDESCRIPTORW or FILEDESCRIPTORA, + // you will need to specify this parameter. + int make_unicode = -1; + if (!PyArg_ParseTuple(args, "z#|i", &buf, &cb, make_unicode)) + return NULL; + if (!buf) { + Py_INCREF(Py_None); + return Py_None; + } + if (cb < sizeof(UINT)) + return PyErr_Format(PyExc_ValueError, "The buffer is way too small!"); + fgd = (FILEGROUPDESCRIPTORA *)buf; + fgdw = (FILEGROUPDESCRIPTORW *)buf; + num = fgd->cItems; + size_a = sizeof(FILEGROUPDESCRIPTORA) + sizeof(FILEDESCRIPTORA)*(num-1); + size_w = sizeof(FILEGROUPDESCRIPTORW) + sizeof(FILEDESCRIPTORW)*(num-1); + if (make_unicode==-1) { + // allow an extra byte that may be added! + if (cb==size_a || cb-1==size_a) + make_unicode = 0; + else if (cb==size_w || cb-1==size_w) + make_unicode = 1; + } + if (make_unicode==-1) + return PyErr_Format(PyExc_ValueError, + "You must specify a value for make_unicode - got a " + "buffer of %d bytes, but an ascii one would be %d " + "bytes, and unicode %d bytes", cb, size_a, size_w); + if ((make_unicode && cb < size_w) || (!make_unicode && cb < size_a)) { + return PyErr_Format(PyExc_ValueError, + "The buffer is too small - require %d bytes, but " + "only %d supplied", make_unicode ? size_w : size_a, + cb); + } + ret = PyList_New(num); + if (!ret) return NULL; + for (i=0;i<num;i++) { + FILEDESCRIPTORA *fd = fgd->fgd+i; + FILEDESCRIPTORW *fdw = fgdw->fgd+i; + PyObject *sub = PyDict_New(); + if (!sub) goto done; + PyObject *val; + // These structures are the same until the very end, where the + // unicode/ascii buffer is - so we can use either pointer + val = PyInt_FromLong(fd->dwFlags); + if (val) PyDict_SetItemString(sub, "dwFlags", val); + Py_XDECREF(val); + + if (fd->dwFlags & FD_CLSID) { + val = PyWinObject_FromIID(fd->clsid); + if (val) PyDict_SetItemString(sub, "clsid", val); + Py_XDECREF(val); + } + + if (fd->dwFlags & FD_SIZEPOINT) { + val = Py_BuildValue("ii", fd->sizel.cx, fd->sizel.cy); + if (val) PyDict_SetItemString(sub, "sizel", val); + Py_XDECREF(val); + val = Py_BuildValue("ii", fd->pointl.x, fd->pointl.y); + if (val) PyDict_SetItemString(sub, "pointl", val); + Py_XDECREF(val); + } + + if (fd->dwFlags & FD_ATTRIBUTES) { + val = PyInt_FromLong(fd->dwFileAttributes); + if (val) PyDict_SetItemString(sub, "dwFileAttributes", val); + Py_XDECREF(val); + } + + if (fd->dwFlags & FD_CREATETIME) { + val = PyWinObject_FromFILETIME(fd->ftCreationTime); + if (val) PyDict_SetItemString(sub, "ftCreationTime", val); + Py_XDECREF(val); + } + + if (fd->dwFlags & FD_ACCESSTIME) { + val = PyWinObject_FromFILETIME(fd->ftLastAccessTime); + if (val) PyDict_SetItemString(sub, "ftLastAccessTime", val); + Py_XDECREF(val); + } + + if (fd->dwFlags & FD_WRITESTIME) { + val = PyWinObject_FromFILETIME(fd->ftLastWriteTime); + if (val) PyDict_SetItemString(sub, "ftLastWriteTime", val); + Py_XDECREF(val); + } + + if (fd->dwFlags & FD_FILESIZE) { + val = PyLong_FromTwoInts(fd->nFileSizeHigh, fd->nFileSizeLow); + if (val) PyDict_SetItemString(sub, "nFileSize", val); + Py_XDECREF(val); + } + // no filename flags?? + if (make_unicode) + val = PyWinObject_FromWCHAR(fdw->cFileName); + else + val = PyString_FromString(fd->cFileName); + if (val) PyDict_SetItemString(sub, "cFileName", val); + Py_XDECREF(val); + PyList_SET_ITEM(ret, i, sub); // 'sub' reference consumed. + } + ok = TRUE; + done: + if (!ok) { + Py_DECREF(ret); + ret = NULL; + } + return ret; + } /* List of module functions */ *************** *** 1463,1466 **** --- 1846,1852 ---- { "AddressAsPIDL", PyAddressAsPIDL, 1}, // @pymeth AddressAsPIDL|Given the address of a PIDL, return a PIDL object (ie, a list of strings) { "PIDLAsString", PyPIDLAsString, 1}, // @pymeth PIDLAsString|Given a PIDL object, return the raw PIDL bytes as a string + { "SHGetSettings", PySHGetSettings, 1}, // @pymeth SHGetSettings|Retrieves the current shell option settings. + { "FILEGROUPDESCRIPTORAsString", PyFILEGROUPDESCRIPTORAsString, 1}, // @pymeth FILEGROUPDESCRIPTORAsString|Creates a FILEGROUPDESCRIPTOR from a sequence of mapping objects, each with FILEDESCRIPTOR attributes + { "StringAsFILEGROUPDESCRIPTOR", PyStringAsFILEGROUPDESCRIPTOR, 1}, // @pymeth StringAsFILEGROUPDESCRIPTOR|Decodes a FILEGROUPDESCRIPTOR packed in a string { NULL, NULL }, }; *************** *** 1470,1476 **** --- 1856,1865 ---- { PYCOM_INTERFACE_CLIENT_ONLY (ShellLink), + PYCOM_INTERFACE_IID_ONLY (ShellLinkA), PYCOM_INTERFACE_CLSID_ONLY (ShellLink), + PYCOM_INTERFACE_IID_ONLY (ShellLinkW), PYCOM_INTERFACE_FULL(ContextMenu), PYCOM_INTERFACE_FULL(ExtractIcon), + PYCOM_INTERFACE_IID_ONLY (ExtractIconW), PYCOM_INTERFACE_FULL(ShellExtInit), PYCOM_INTERFACE_FULL(ShellFolder), |
|
From: Mark H. <mha...@us...> - 2004-05-26 08:54:38
|
Update of /cvsroot/pywin32/pywin32/win32/Demos In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9472 Modified Files: win32rcparser_demo.py Log Message: Initialize all the common-controls before showing our dialogs with them! Index: win32rcparser_demo.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Demos/win32rcparser_demo.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** win32rcparser_demo.py 9 Apr 2004 11:13:18 -0000 1.1 --- win32rcparser_demo.py 26 May 2004 08:54:29 -0000 1.2 *************** *** 5,8 **** --- 5,9 ---- import win32con import win32rcparser + import commctrl import sys, os *************** *** 69,71 **** --- 70,83 ---- if __name__=='__main__': + flags = 0 + for flag in """ICC_DATE_CLASSES ICC_ANIMATE_CLASS ICC_ANIMATE_CLASS + ICC_BAR_CLASSES ICC_COOL_CLASSES ICC_DATE_CLASSES + ICC_HOTKEY_CLASS ICC_INTERNET_CLASSES ICC_LISTVIEW_CLASSES + ICC_PAGESCROLLER_CLASS ICC_PROGRESS_CLASS ICC_TAB_CLASSES + ICC_TREEVIEW_CLASSES ICC_UPDOWN_CLASS ICC_USEREX_CLASSES + ICC_WIN95_CLASSES """.split(): + flags |= getattr(commctrl, flag) + win32gui.InitCommonControlsEx(flags) + # Need to do this go get rich-edit working. + win32api.LoadLibrary("riched20.dll") DemoModal() |
|
From: Mark H. <mha...@us...> - 2004-05-26 08:53:17
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9236 Modified Files: commctrl.py Log Message: New BTNS_ constants. Index: commctrl.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/commctrl.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** commctrl.py 2 Jul 2003 03:39:12 -0000 1.2 --- commctrl.py 26 May 2004 08:53:08 -0000 1.3 *************** *** 250,253 **** --- 250,263 ---- TBSTYLE_TRANSPARENT = 32768 TBSTYLE_EX_DRAWDDARROWS = 1 + BTNS_BUTTON = TBSTYLE_BUTTON + BTNS_SEP = TBSTYLE_SEP # 0x0001 + BTNS_CHECK = TBSTYLE_CHECK # 0x0002 + BTNS_GROUP = TBSTYLE_GROUP # 0x0004 + BTNS_CHECKGROUP = TBSTYLE_CHECKGROUP # (TBSTYLE_GROUP | TBSTYLE_CHECK) + BTNS_DROPDOWN = TBSTYLE_DROPDOWN # 0x0008 + BTNS_AUTOSIZE = TBSTYLE_AUTOSIZE # 0x0010; automatically calculate the cx of the button + BTNS_NOPREFIX = TBSTYLE_NOPREFIX # 0x0020; this button should not have accel prefix + BTNS_SHOWTEXT = 64 # 0x0040 // ignored unless TBSTYLE_EX_MIXEDBUTTONS is set + BTNS_WHOLEDROPDOWN = 128 # 0x0080 // draw drop-down arrow, but without split arrow section TBCDRF_NOEDGES = 65536 # Don't draw button edges TBCDRF_HILITEHOTTRACK = 131072 # Use color of the button bk when hottracked |
|
From: Mark H. <mha...@us...> - 2004-05-26 08:52:37
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9162 Modified Files: win32gui_struct.py Log Message: If the lsitview state mask is not specified, assume it is the same as the state itself. Index: win32gui_struct.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/win32gui_struct.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** win32gui_struct.py 13 May 2004 14:17:31 -0000 1.4 --- win32gui_struct.py 26 May 2004 08:52:25 -0000 1.5 *************** *** 294,297 **** --- 294,300 ---- if not mask & commctrl.LVIF_STATE: stateMask = 0 + else: + if stateMask is None: + stateMask = state mask, text = _GetMaskAndVal(text, None, mask, commctrl.LVIF_TEXT) mask, image = _GetMaskAndVal(image, 0, mask, commctrl.LVIF_IMAGE) |
|
From: Mark H. <mha...@us...> - 2004-05-26 08:51:45
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8998 Modified Files: PyUnicode.cpp Log Message: Indicate the type of the object that caused us to raise a TypeError. Index: PyUnicode.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyUnicode.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** PyUnicode.cpp 24 Nov 2003 09:13:11 -0000 1.19 --- PyUnicode.cpp 26 May 2004 08:51:33 -0000 1.20 *************** *** 136,140 **** if (!PyString_Check(stringObject)) { ! PyErr_SetString(PyExc_TypeError, "The object must be a string or unicode object"); return FALSE; } --- 136,141 ---- if (!PyString_Check(stringObject)) { ! PyErr_Format(PyExc_TypeError, "The object must be a string or unicode object (got '%s')", ! stringObject->ob_type->tp_name); return FALSE; } |
|
From: Mark H. <mha...@us...> - 2004-05-26 08:51:16
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8754 Modified Files: PyLARGE_INTEGER.cpp Log Message: A 64bit int with the high-bit of the loword set would create a negative large int. Index: PyLARGE_INTEGER.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyLARGE_INTEGER.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PyLARGE_INTEGER.cpp 7 Nov 2003 03:58:17 -0000 1.7 --- PyLARGE_INTEGER.cpp 26 May 2004 08:51:04 -0000 1.8 *************** *** 100,104 **** PyObject *PyLong_FromTwoInts(int hidword, unsigned lodword) { ! if (hidword==0) return PyInt_FromLong(lodword); else { --- 100,105 ---- PyObject *PyLong_FromTwoInts(int hidword, unsigned lodword) { ! // If it fits in a normal Python int, we return one of them. ! if (hidword==0 && (lodword & 0x8000==0)) return PyInt_FromLong(lodword); else { |
|
From: Mark H. <mha...@us...> - 2004-05-26 08:31:54
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5740 Modified Files: PyIID.cpp Log Message: Allow IIDs to be created from raw bytes, and supply a buffer interface so the GUID raw bytes are available. Index: PyIID.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyIID.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PyIID.cpp 7 Nov 2003 03:58:17 -0000 1.6 --- PyIID.cpp 26 May 2004 08:31:44 -0000 1.7 *************** *** 16,21 **** // @pyparm string/Unicode|iidString||A string representation of an IID, or a ProgID. ! if ( !PyArg_ParseTuple(args, "O", &obIID) ) return NULL; // Already an IID? Return self. if ( PyIID_Check(obIID) ) { --- 16,37 ---- // @pyparm string/Unicode|iidString||A string representation of an IID, or a ProgID. ! // @pyparm bool|is_bytes|False|Indicates if the first param is actually the bytes of an IID structure. ! int isBytes = FALSE; ! if ( !PyArg_ParseTuple(args, "O|i", &obIID, &isBytes) ) return NULL; + if (isBytes) { + const void *buf; + int cb; + if (!PyObject_CheckReadBuffer(obIID)) + return PyErr_Format(PyExc_TypeError, "object must be a read-buffer to read the CLSID bytes"); + if (PyObject_AsReadBuffer(obIID, &buf, &cb)) + return NULL; + if (cb<sizeof(IID)) + return PyErr_Format(PyExc_ValueError, + "string too small - must be at least %d bytes (got %d)", + sizeof(IID), cb); + iid = *((IID *)buf); + return PyWinObject_FromIID(iid); + } // Already an IID? Return self. if ( PyIID_Check(obIID) ) { *************** *** 115,118 **** --- 131,159 ---- } + static int getreadbuf(PyObject *self, int index, const void **ptr) + { + if ( index != 0 ) { + PyErr_SetString(PyExc_SystemError, + "accessing non-existent IID segment"); + return -1; + } + PyIID *pyiid = (PyIID *)self; + *ptr = &pyiid->m_iid; + return sizeof(IID); + } + + static int getsegcount(PyObject *self, int *lenp) + { + if ( lenp ) + *lenp = sizeof(IID); + return 1; + } + + static PyBufferProcs PyIID_as_buffer = { + (getreadbufferproc)getreadbuf, + (getwritebufferproc)0, + (getsegcountproc)getsegcount, + (getcharbufferproc)0, + }; // @object PyIID|A Python object, representing an IID/CLSID. *************** *** 143,146 **** --- 184,191 ---- // @pymeth __str__|Used whenever a string representation of the IID is required. PyIID::strFunc, /* tp_str */ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + // @comm Note that IID objects support the buffer interface. Thus buffer(iid) can be used to obtain the raw bytes. + &PyIID_as_buffer, /*tp_as_buffer*/ }; |
|
From: Mark H. <mha...@us...> - 2004-05-26 08:30:52
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5567 Modified Files: PyTime.cpp Log Message: Allow any object with a 'timetuple' method to be converted to a PyWin32 time object (eg, the standard datetime module objects) Index: PyTime.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyTime.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** PyTime.cpp 25 Apr 2004 06:46:47 -0000 1.11 --- PyTime.cpp 26 May 2004 08:30:41 -0000 1.12 *************** *** 55,58 **** --- 55,69 ---- } else *****/ + // Support objects with a "timetuple" method. + PyObject *method = PyObject_GetAttrString(timeOb, "timetuple"); + if (method==NULL) + PyErr_Clear(); + else { + timeOb = PyEval_CallObject(method, NULL); + Py_DECREF(method); + if (!timeOb) + return NULL; + // now we should fall into the sequence check! + } if ( PyNumber_Check(timeOb) ) { |
|
From: Mark H. <mha...@us...> - 2004-05-26 08:29:43
|
Update of /cvsroot/pywin32/pywin32/win32/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5368 Modified Files: test_pywintypes.py Log Message: Test we can create a GUID from raw bytes. Index: test_pywintypes.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/test_pywintypes.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_pywintypes.py 22 Jan 2004 04:39:48 -0000 1.2 --- test_pywintypes.py 26 May 2004 08:29:20 -0000 1.3 *************** *** 22,25 **** --- 22,33 ---- return + def testGUID(self): + s = "{00020400-0000-0000-C000-000000000046}" + iid = pywintypes.IID(s) + iid2 = pywintypes.IID(buffer(iid), True) + self.assertEquals(iid, iid2) + self.assertRaises(ValueError, pywintypes.IID, '00', True) # too short + self.assertRaises(TypeError, pywintypes.IID, 0, True) # no buffer + if __name__ == '__main__': unittest.main() |
|
From: Mark H. <mha...@us...> - 2004-05-26 08:28:32
|
Update of /cvsroot/pywin32/pywin32/win32/test/win32rcparser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5247 Modified Files: test.h test.rc Log Message: Add more complex dialogs for testing Index: test.rc =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/win32rcparser/test.rc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test.rc 9 Apr 2004 11:13:20 -0000 1.1 --- test.rc 26 May 2004 08:28:22 -0000 1.2 *************** *** 60,63 **** --- 60,65 ---- DEFPUSHBUTTON "OK",IDOK,129,7,50,14 PUSHBUTTON "Cancel",IDCANCEL,129,24,50,14 + ICON IDI_PYTHON,IDC_STATIC,142,47,21,20 + LTEXT "An icon",IDC_STATIC,140,70,34,9 END *************** *** 68,72 **** BEGIN DEFPUSHBUTTON "OK",IDOK,129,7,50,14 ! PUSHBUTTON "Cancel",IDCANCEL,129,24,50,14 END --- 70,121 ---- BEGIN DEFPUSHBUTTON "OK",IDOK,129,7,50,14 ! PUSHBUTTON "Cancel",IDCANCEL,129,24,50,14,NOT WS_TABSTOP ! CONTROL 103,IDC_STATIC,"Static",SS_BITMAP,139,49,32,32 ! LTEXT "A bitmap",IDC_STATIC,135,72,34,9 ! EDITTEXT IDC_EDIT1,59,7,59,14,ES_AUTOHSCROLL ! EDITTEXT IDC_EDIT2,59,31,60,15,ES_AUTOHSCROLL | NOT WS_TABSTOP ! LTEXT "Tabstop",IDC_STATIC,7,9,43,10 ! LTEXT "Not Tabstop",IDC_STATIC,7,33,43,10 ! END ! ! IDD_TEST_DIALOG3 DIALOGEX 0, 0, 232, 310 ! STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU ! CAPTION "Dialog" ! FONT 8, "MS Sans Serif", 0, 0, 0x1 ! BEGIN ! GROUPBOX "Frame",IDC_STATIC,7,7,218,41 ! LTEXT "Left Static",IDC_STATIC,16,17,73,11 ! EDITTEXT IDC_EDIT1,103,15,112,12,ES_AUTOHSCROLL ! LTEXT "Right Static",IDC_STATIC,16,30,73,11,0,WS_EX_RIGHT ! CONTROL "",IDC_RICHEDIT1,"RICHEDIT",ES_AUTOHSCROLL | WS_BORDER | ! WS_TABSTOP,103,31,113,14 ! CONTROL "Check1",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | ! WS_TABSTOP,7,52,68,12 ! COMBOBOX IDC_COMBO1,85,52,82,35,CBS_DROPDOWNLIST | CBS_SORT | ! WS_VSCROLL | WS_TABSTOP ! CONTROL "Spin1",IDC_SPIN1,"msctls_updown32",UDS_ARROWKEYS,7,71, ! 14,22 ! CONTROL "Progress1",IDC_PROGRESS1,"msctls_progress32",WS_BORDER, ! 39,72,153,13 ! SCROLLBAR IDC_SCROLLBAR2,207,55,13,57,SBS_VERT ! CONTROL "Slider1",IDC_SLIDER1,"msctls_trackbar32",TBS_BOTH | ! TBS_NOTICKS | WS_TABSTOP,35,91,159,7 ! SCROLLBAR IDC_SCROLLBAR1,37,102,155,11 ! CONTROL "Tab1",IDC_TAB1,"SysTabControl32",0x0,7,120,217,43 ! CONTROL "Animate1",IDC_ANIMATE1,"SysAnimate32",WS_BORDER | ! WS_TABSTOP,7,171,46,42 ! CONTROL "List1",IDC_LIST1,"SysListView32",WS_BORDER | WS_TABSTOP, ! 63,171,53,43 ! CONTROL "Tree1",IDC_TREE1,"SysTreeView32",WS_BORDER | WS_TABSTOP, ! 126,171,50,43 ! CONTROL "MonthCalendar1",IDC_MONTHCALENDAR1,"SysMonthCal32", ! MCS_NOTODAY | WS_TABSTOP,7,219,140,84 ! CONTROL "DateTimePicker1",IDC_DATETIMEPICKER1,"SysDateTimePick32", ! DTS_RIGHTALIGN | WS_TABSTOP,174,221,51,15 ! DEFPUSHBUTTON "OK",IDOK,175,289,50,14 ! PUSHBUTTON "Hello",IDC_HELLO,175,271,50,14 ! PUSHBUTTON "Hello",IDC_HELLO2,175,240,50,26,BS_ICON ! LISTBOX IDC_LIST2,184,171,40,45,LBS_SORT | LBS_NOINTEGRALHEIGHT | ! WS_VSCROLL | WS_TABSTOP END *************** *** 95,98 **** --- 144,155 ---- BOTTOMMARGIN, 88 END + + IDD_TEST_DIALOG3, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 225 + TOPMARGIN, 7 + BOTTOMMARGIN, 303 + END END #endif // APSTUDIO_INVOKED *************** *** 117,120 **** --- 174,192 ---- ///////////////////////////////////////////////////////////////////////////// // + // Dialog Info + // + + IDD_TEST_DIALOG3 DLGINIT + BEGIN + IDC_COMBO1, 0x403, 6, 0 + 0x7449, 0x6d65, 0x0031, + IDC_COMBO1, 0x403, 6, 0 + 0x7449, 0x6d65, 0x0032, + 0 + END + + + ///////////////////////////////////////////////////////////////////////////// + // // String Table // Index: test.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/win32rcparser/test.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test.h 9 Apr 2004 11:13:20 -0000 1.1 --- test.h 26 May 2004 08:28:22 -0000 1.2 *************** *** 3,17 **** // Used by test.rc // ! #define IDS_TEST_STRING1 1 ! #define IDS_TEST_STRING2 2 ! #define IDS_TEST_STRING3 3 ! #define IDS_TEST_STRING4 4 ! #define IDS_TEST_STRING5 5 ! #define IDS_TEST_STRING6 6 ! #define IDS_TEST_STRING7 7 #define IDD_TEST_DIALOG1 101 #define IDD_TEST_DIALOG2 102 - #define IDI_PYTHON 102 #define IDB_PYTHON 103 // Next default values for new objects --- 3,37 ---- // Used by test.rc // ! #define IDS_TEST_STRING1 51 ! #define IDS_TEST_STRING2 52 ! #define IDS_TEST_STRING3 53 ! #define IDS_TEST_STRING4 54 ! #define IDS_TEST_STRING5 55 ! #define IDS_TEST_STRING6 56 ! #define IDS_TEST_STRING7 57 #define IDD_TEST_DIALOG1 101 #define IDD_TEST_DIALOG2 102 #define IDB_PYTHON 103 + #define IDI_PYTHON 105 + #define IDD_TEST_DIALOG3 105 + #define IDC_EDIT1 1000 + #define IDC_CHECK1 1001 + #define IDC_EDIT2 1001 + #define IDC_COMBO1 1002 + #define IDC_SPIN1 1003 + #define IDC_PROGRESS1 1004 + #define IDC_SLIDER1 1005 + #define IDC_LIST1 1006 + #define IDC_TREE1 1007 + #define IDC_TAB1 1008 + #define IDC_ANIMATE1 1009 + #define IDC_RICHEDIT1 1010 + #define IDC_DATETIMEPICKER1 1011 + #define IDC_MONTHCALENDAR1 1012 + #define IDC_SCROLLBAR1 1013 + #define IDC_SCROLLBAR2 1014 + #define IDC_LIST2 1015 + #define IDC_HELLO 1016 + #define IDC_HELLO2 1017 // Next default values for new objects *************** *** 19,25 **** #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS ! #define _APS_NEXT_RESOURCE_VALUE 105 #define _APS_NEXT_COMMAND_VALUE 40002 ! #define _APS_NEXT_CONTROL_VALUE 1000 #define _APS_NEXT_SYMED_VALUE 101 #endif --- 39,45 ---- #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS ! #define _APS_NEXT_RESOURCE_VALUE 107 #define _APS_NEXT_COMMAND_VALUE 40002 ! #define _APS_NEXT_CONTROL_VALUE 1018 #define _APS_NEXT_SYMED_VALUE 101 #endif |
|
From: Mark H. <mha...@us...> - 2004-05-26 08:27:57
|
Update of /cvsroot/pywin32/pywin32/win32/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5126 Modified Files: test_win32rcparser.py Log Message: Test standard Windows control IDs are included, and that the default styles are set for some controls. Index: test_win32rcparser.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/test_win32rcparser.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test_win32rcparser.py 15 Apr 2004 07:54:44 -0000 1.1 --- test_win32rcparser.py 26 May 2004 08:27:48 -0000 1.2 *************** *** 2,5 **** --- 2,6 ---- import unittest import win32rcparser + import win32con class TestParser(unittest.TestCase): *************** *** 18,21 **** --- 19,48 ---- self.assertEqual(got, expected) + def testStandardIds(self): + for idc in "IDOK IDCANCEL".split(): + correct = getattr(win32con, idc) + self.assertEqual(self.resources.names[correct], idc) + self.assertEqual(self.resources.ids[idc], correct) + + def testTabStop(self): + d = self.resources.dialogs["IDD_TEST_DIALOG2"] + tabstop_names = ["IDC_EDIT1", "IDOK"] # should have WS_TABSTOP + tabstop_ids = [self.resources.ids[name] for name in tabstop_names] + notabstop_names = ["IDC_EDIT2"] # should have WS_TABSTOP + notabstop_ids = [self.resources.ids[name] for name in notabstop_names] + num_ok = 0 + for cdef in d[1:]: # skip dlgdef + #print cdef + cid = cdef[2] + style = cdef[-2] + styleex = cdef[-1] + if cid in tabstop_ids: + self.failUnlessEqual(style & win32con.WS_TABSTOP, win32con.WS_TABSTOP) + num_ok += 1 + elif cid in notabstop_ids: + self.failUnlessEqual(style & win32con.WS_TABSTOP, 0) + num_ok += 1 + self.failUnlessEqual(num_ok, len(tabstop_ids) + len(notabstop_ids)) + if __name__=='__main__': unittest.main() |
|
From: Mark H. <mha...@us...> - 2004-05-26 08:26:49
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4991 Modified Files: win32rcparser.py Log Message: Correct a number of parsing error, and fix the default styles for many controls. Index: win32rcparser.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/win32rcparser.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** win32rcparser.py 25 Apr 2004 10:24:13 -0000 1.2 --- win32rcparser.py 26 May 2004 08:26:39 -0000 1.3 *************** *** 9,12 **** --- 9,13 ---- """ __author__="Adam Walker" + __version__="0.10" import sys, os, shlex, stat *************** *** 27,40 **** "COMBOBOX":0x85, "EDITTEXT":0x81, } ! _addDefaults = {"EDITTEXT":win32con.WS_BORDER, "GROUPBOX":win32con.BS_GROUPBOX, "LTEXT":win32con.SS_LEFT, ! "DEFPUSHBUTTON":win32con.BS_DEFPUSHBUTTON, "CTEXT":win32con.SS_CENTER, ! "RTEXT":win32con.SS_RIGHT} defaultControlStyle = win32con.WS_CHILD | win32con.WS_VISIBLE class DialogDef: name = "" --- 28,47 ---- "COMBOBOX":0x85, "EDITTEXT":0x81, + "ICON":0x82, + "RICHEDIT":"RichEdit20A" } ! _addDefaults = {"EDITTEXT":win32con.WS_BORDER | win32con.WS_TABSTOP, "GROUPBOX":win32con.BS_GROUPBOX, "LTEXT":win32con.SS_LEFT, ! "DEFPUSHBUTTON":win32con.BS_DEFPUSHBUTTON | win32con.WS_TABSTOP, ! "PUSHBUTTON": win32con.WS_TABSTOP, "CTEXT":win32con.SS_CENTER, ! "RTEXT":win32con.SS_RIGHT, ! "ICON":win32con.SS_ICON} defaultControlStyle = win32con.WS_CHILD | win32con.WS_VISIBLE + defaultControlStyleEx = 0 + class DialogDef: name = "" *************** *** 75,78 **** --- 82,86 ---- idNum = 0 style = defaultControlStyle + styleEx = defaultControlStyleEx label = "" x = 0 *************** *** 82,85 **** --- 90,94 ---- def __init__(self): self.styles = [] + self.stylesEx = [] def toString(self): s = "<Control id:"+self.id+" controlType:"+self.controlType+" subType:"+self.subType\ *************** *** 91,99 **** if "CONTROL"==ct: ct = self.subType - if ct in _addDefaults: - self.style |= _addDefaults[ct] if ct in _controlMap: ct = _controlMap[ct] ! t = [ct, self.label, self.idNum, (self.x, self.y, self.w, self.h), self.style] #print t return t --- 100,106 ---- if "CONTROL"==ct: ct = self.subType if ct in _controlMap: ct = _controlMap[ct] ! t = [ct, self.label, self.idNum, (self.x, self.y, self.w, self.h), self.style, self.styleEx] #print t return t *************** *** 113,116 **** --- 120,124 ---- def __init__(self): + self.ungot = False self.ids = {"IDC_STATIC": -1} self.names = {-1:"IDC_STATIC"} *************** *** 124,127 **** --- 132,139 ---- def getToken(self): + if self.ungot: + self.ungot = False + self.debug("getToken returns (ungot):", self.token) + return self.token self.token = self.lex.get_token() self.debug("getToken returns:", self.token) *************** *** 130,133 **** --- 142,148 ---- return self.token + def ungetToken(self): + self.ungot = True + def getCheckToken(self, expected): tok = self.getToken() *************** *** 138,141 **** --- 153,184 ---- return self.getCheckToken(",") + # Return the *current* token as a number, only consuming a token + # if it is the negative-sign. + def currentNumberToken(self): + mult = 1 + if self.token=='-': + mult = -1 + self.getToken() + return int(self.token) * mult + + # Return the *current* token as a string literal (ie, self.token will be a + # quote. consumes all tokens until the end of the string + def currentQuotedString(self): + # Handle quoted strings - pity shlex doesn't handle it. + assert self.token.startswith('"'), self.token + bits = [self.token] + while 1: + tok = self.getToken() + if not tok.startswith('"'): + self.ungetToken() + break + bits.append(tok) + sval = "".join(bits)[1:-1] # Remove end quotes. + # Fixup quotes in the body, and all (some?) quoted characters back + # to their raw value. + for i, o in ('""', '"'), ("\\r", "\r"), ("\\n", "\n"), ("\\t", "\t"): + sval = sval.replace(i, o) + return sval + def load(self, rcstream): """ *************** *** 169,175 **** self.ids[n] = i if self.names.has_key(i): # ignore AppStudio special ones ! if not n.startswith("_APS_"): ! print "Duplicate id",i,"for",n,"is", self.names[i] else: self.names[i] = n --- 212,222 ---- self.ids[n] = i if self.names.has_key(i): + # Dupe ID really isn't a problem - most consumers + # want to go from name->id, and this is OK. + # It means you can't go from id->name though. + pass # ignore AppStudio special ones ! #if not n.startswith("_APS_"): ! # print "Duplicate id",i,"for",n,"is", self.names[i] else: self.names[i] = n *************** *** 220,224 **** --- 267,275 ---- rp(resource_id) else: + # We don't know what the resource type is, but we + # have already consumed the next, which can cause problems, + # so push it back. self.debug("Skipping top-level '%s'" % base_token) + self.ungetToken() def addId(self, id_name): *************** *** 226,237 **** id = self.ids[id_name] else: ! # IDOK and IDCANCEL are special - if a real resource has a value ! # of OK or CANCEL (1 or 2), we still want the user's name. ! if id_name == "IDOK": ! self.ids[id_name] = win32con.IDOK ! return win32con.IDOK ! if id_name == "IDCANCEL": ! self.ids[id_name] = win32con.IDCANCEL ! return win32con.IDCANCEL id = self.next_id self.next_id += 1 --- 277,287 ---- id = self.ids[id_name] else: ! # IDOK, IDCANCEL etc are special - if a real resource has this value ! for n in ["IDOK","IDCANCEL","IDYES","IDNO", "IDABORT"]: ! if id_name == n: ! v = getattr(win32con, n) ! self.ids[n] = v ! self.names[v] = n ! return v id = self.next_id self.next_id += 1 *************** *** 255,273 **** while self.getToken() != "BEGIN": pass - self.getToken() while 1: if self.token == "END": break sid = self.token ! # Handle quoted strings - pity shlex doesn't handle it. ! bits = [self.getToken()] ! while 1: ! tok = self.getToken() ! if not tok.startswith('"'): ! break ! bits.append(tok) ! sval = "".join(bits)[1:-1] # and remove end quotes. ! sval = sval.replace('""', '"') # And fixup quotes in the body ! sd = StringDef(sid, self.addId(sid), sval) self.stringTable[sid] = sd --- 305,315 ---- while self.getToken() != "BEGIN": pass while 1: + self.getToken() if self.token == "END": break sid = self.token ! self.getToken() ! sd = StringDef(sid, self.addId(sid), self.currentQuotedString()) self.stringTable[sid] = sd *************** *** 280,288 **** def parse_bitmap_or_icon(self, name, dic): self.getToken() ! if self.token=="DISCARDABLE": self.getToken() - if self.token=="MOVEABLE": - self.getToken() # PURE - self.getToken() # bmpname bmf = self.token[1:-1] # quotes dic[name] = bmf --- 322,327 ---- def parse_bitmap_or_icon(self, name, dic): self.getToken() ! while not self.token.startswith('"'): self.getToken() bmf = self.token[1:-1] # quotes dic[name] = bmf *************** *** 384,417 **** def controls(self, dlg): if self.token=="BEGIN": self.getToken() while self.token!="END": control = ControlDef() control.controlType = self.token; - #print self.token self.getToken() ! if self.token[0:1]=='"': ! control.label = self.token[1:-1] ! self.getCommaToken() ! self.getToken() ! elif self.token.isdigit(): ! control.label = self.token self.getCommaToken() self.getToken() ! # msvc seems to occasionally replace "IDC_STATIC" with -1 ! if self.token=='-': ! if self.getToken() != '1': ! raise RuntimeError, \ ! "Negative literal in rc script (other than -1) - don't know what to do" ! self.token = "IDC_STATIC" ! control.id = self.token ! control.idNum = self.addId(control.id) self.getCommaToken() if control.controlType == "CONTROL": self.getToken() control.subType = self.token[1:-1] # Styles self.getCommaToken() self.getToken() ! control.style, control.styles = self.styles([], defaultControlStyle) ! #self.getToken() #, # Rect control.x = int(self.getToken()) --- 423,473 ---- def controls(self, dlg): if self.token=="BEGIN": self.getToken() + # All controls look vaguely like: + # TYPE [text, ] Control_id, l, t, r, b [, style] + # .rc parser documents all control types as: + # CHECKBOX, COMBOBOX, CONTROL, CTEXT, DEFPUSHBUTTON, EDITTEXT, GROUPBOX, + # ICON, LISTBOX, LTEXT, PUSHBUTTON, RADIOBUTTON, RTEXT, SCROLLBAR + without_text = ["EDITTEXT", "COMBOBOX", "LISTBOX", "SCROLLBAR"] while self.token!="END": control = ControlDef() control.controlType = self.token; self.getToken() ! if control.controlType not in without_text: ! if self.token[0:1]=='"': ! control.label = self.currentQuotedString() ! # Some funny controls, like icons and picture controls use ! # the "window text" as extra resource ID (ie, the ID of the ! # icon itself). This may be either a literal, or an ID string. ! elif self.token=="-" or self.token.isdigit(): ! control.label = str(self.currentNumberToken()) ! else: ! # An ID - use the numeric equiv. ! control.label = str(self.addId(self.token)) self.getCommaToken() self.getToken() ! # Control IDs may be "names" or literal ints ! if self.token=="-" or self.token.isdigit(): ! control.id = self.currentNumberToken() ! control.idNum = control.id ! else: ! # name of an ID ! control.id = self.token ! control.idNum = self.addId(control.id) self.getCommaToken() + if control.controlType == "CONTROL": self.getToken() control.subType = self.token[1:-1] + thisDefaultStyle = defaultControlStyle | \ + _addDefaults.get(control.subType, 0) # Styles self.getCommaToken() self.getToken() ! control.style, control.styles = self.styles([], thisDefaultStyle) ! else: ! thisDefaultStyle = defaultControlStyle | \ ! _addDefaults.get(control.controlType, 0) ! # incase no style is specified. ! control.style = thisDefaultStyle # Rect control.x = int(self.getToken()) *************** *** 426,430 **** if self.token==",": self.getToken() ! control.style, control.styles = self.styles([], defaultControlStyle) #print control.toString() dlg.controls.append(control) --- 482,489 ---- if self.token==",": self.getToken() ! control.style, control.styles = self.styles([], thisDefaultStyle) ! if self.token==",": ! self.getToken() ! control.styleEx, control.stylesEx = self.styles([], defaultControlStyleEx) #print control.toString() dlg.controls.append(control) *************** *** 483,486 **** --- 542,546 ---- out.write("#%s\n" % output_name) out.write("#This is a generated file. Please edit %s instead.\n" % rc_name) + out.write("__version__=%r\n" % __version__) out.write("_rc_size_=%d\n_rc_mtime_=%d\n" % (in_stat[stat.ST_SIZE], in_stat[stat.ST_MTIME])) out.write("class FakeParser:\n") |
|
From: Roger U. <ru...@us...> - 2004-05-26 02:58:44
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21068/win32/src Modified Files: win32security.i Log Message: Add SECURITY_INFORMATION parm to SetSecurityInfo, add Get/SetNamedSecurityInfo Index: win32security.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32security.i,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** win32security.i 27 Feb 2004 23:36:20 -0000 1.15 --- win32security.i 26 May 2004 02:58:33 -0000 1.16 *************** *** 14,17 **** --- 14,19 ---- %{ #include "windows.h" + #define SECURITY_WIN32 + #include "security.h" #include "PySecurityObjects.h" #include "accctrl.h" *************** *** 102,105 **** --- 104,108 ---- // @comm This is a sequence (eg, list) of (id, attributes) %{ + PyObject *PyWinObject_FromTOKEN_PRIVILEGES(TOKEN_PRIVILEGES *tp) { *************** *** 665,668 **** --- 668,672 ---- %native(GetBinarySid) PyGetBinarySid; + // @pyswig |SetSecurityInfo|Sets security info for an object by handle %native(SetSecurityInfo) SetSecurityInfo; %{ *************** *** 681,723 **** SE_OBJECT_TYPE typeHandle; HANDLE handle; ! if (!PyArg_ParseTuple(args, "Ol|OOOO:SetSecurityInfo", ! &obHandle, ! (long *)(&typeHandle), ! &obSidOwner, ! &obSidGroup, ! &obDacl, ! &obSacl)) return NULL; if (!PyWinObject_AsHANDLE(obHandle, &handle, FALSE )) return NULL; ! if (obSidOwner!=Py_None) { ! info |= OWNER_SECURITY_INFORMATION; ! if (!PyWinObject_AsSID(obSidOwner, &pSidOwner, FALSE)) ! return NULL; ! } ! if (obSidGroup!=Py_None) { ! info |= GROUP_SECURITY_INFORMATION; ! if (!PyWinObject_AsSID(obSidGroup, &pSidGroup, FALSE)) ! return NULL; ! } ! if (obDacl!=Py_None) { ! info |= DACL_SECURITY_INFORMATION; ! if (!PyWinObject_AsACL(obDacl, &pDacl, FALSE)) ! return NULL; ! } ! if (obSacl!=Py_None) { ! info |= SACL_SECURITY_INFORMATION; ! if (!PyWinObject_AsACL(obSacl, &pSacl, FALSE)) ! return NULL; ! } ! if (info==0) { ! PyErr_SetString(PyExc_TypeError, "No new security information was specified"); return NULL; - } - if (!SetSecurityInfo(handle, typeHandle, info, pSidOwner, pSidGroup, pDacl, pSacl)) - return PyWin_SetAPIError("SetSecurityInfo"); Py_INCREF(Py_None); return Py_None; --- 685,714 ---- SE_OBJECT_TYPE typeHandle; HANDLE handle; + DWORD err; ! if (!PyArg_ParseTuple(args, "Oll|OOOO:SetSecurityInfo", ! &obHandle, // @pyparm int/<o PyHANDLE>|handle||Handle to object ! (long *)(&typeHandle), // @pyparm int|ObjectType||Value from SE_OBJECT_TYPE enum ! &info, // @pyparm int|SecurityInfo||Combination of SECURITY_INFORMATION constants ! &obSidOwner, // @pyparm <o PySID>|Owner||Sid to set as owner of object, can be None ! &obSidGroup, // @pyparm <o PySID>|Group||Group Sid, can be None ! &obDacl, // @pyparm <o PyACL>|Dacl||Discretionary ACL to set for object, can be None ! &obSacl)) // @pyparm <o PyACL>|Sacl||System Audit ACL to set for object, can be None return NULL; if (!PyWinObject_AsHANDLE(obHandle, &handle, FALSE )) return NULL; ! if (!PyWinObject_AsSID(obSidOwner, &pSidOwner, TRUE)) ! return NULL; ! if (!PyWinObject_AsSID(obSidGroup, &pSidGroup, TRUE)) ! return NULL; ! if (!PyWinObject_AsACL(obDacl, &pDacl, TRUE)) ! return NULL; ! if (!PyWinObject_AsACL(obSacl, &pSacl, TRUE)) return NULL; + err=SetSecurityInfo(handle, typeHandle, info, pSidOwner, pSidGroup, pDacl, pSacl); + if (err!=ERROR_SUCCESS) + return PyWin_SetAPIError("SetSecurityInfo",err); Py_INCREF(Py_None); return Py_None; *************** *** 725,728 **** --- 716,837 ---- %} + // @pyswig <o PySECURITY_DESCRIPTOR>|GetSecurityInfo|Retrieve security info for an object by handle + // @comm Separate owner, group, dacl, and sacl are not returned as they can be easily retrieved from + // the returned PySECURITY_DESCRIPTOR + %native(GetSecurityInfo) PyGetSecurityInfo; + %{ + static PyObject *PyGetSecurityInfo(PyObject *self, PyObject *args) + { + HANDLE handle; + PSECURITY_DESCRIPTOR pSD=NULL; + SE_OBJECT_TYPE object_type; + SECURITY_INFORMATION required_info; + DWORD err; + PyObject *ret=NULL, *obhandle=NULL; + // @pyparm int/<o PyHANDLE>|handle||Handle to object + // @pyparm int|ObjectType||Value from SE_OBJECT_TYPE enum + // @pyparm int|SecurityInfo||Combination of SECURITY_INFORMATION constants + if (!PyArg_ParseTuple(args, "Oll:GetSecurityInfo",&obhandle, &object_type, &required_info)) + return NULL; + if (!PyWinObject_AsHANDLE(obhandle, &handle, FALSE)) + return NULL; + + err=GetSecurityInfo(handle, object_type, required_info, NULL, NULL, NULL, NULL, &pSD); + if (err==ERROR_SUCCESS) + ret=new PySECURITY_DESCRIPTOR(pSD); + else + PyWin_SetAPIError("GetSecurityInfo",err); + if (pSD) + LocalFree(pSD); + return ret; + } + %} + + // @pyswig |SetNamedSecurityInfo|Sets security info for an object by name + %native(SetNamedSecurityInfo) SetNamedSecurityInfo; + %{ + PyObject *SetNamedSecurityInfo(PyObject *self, PyObject *args) + { + PSID pSidOwner = NULL; + PSID pSidGroup = NULL; + PACL pDacl= NULL; + PACL pSacl = NULL; + PyObject *obObjectName=NULL, *ret=NULL; + PyObject *obSidOwner = Py_None; + PyObject *obSidGroup = Py_None; + PyObject *obDacl = Py_None; + PyObject *obSacl = Py_None; + SECURITY_INFORMATION info = 0; + SE_OBJECT_TYPE ObjectType; + WCHAR *ObjectName=NULL; + DWORD err; + + if (!PyArg_ParseTuple(args, "Oll|OOOO:SetNamedSecurityInfo", + &obObjectName, // @pyparm str/unicode|ObjectName||Name of object + &ObjectType, // @pyparm int|ObjectType||Value from SE_OBJECT_TYPE enum + &info, // @pyparm int|SecurityInfo||Combination of SECURITY_INFORMATION constants + &obSidOwner, // @pyparm <o PySID>|Owner||Sid to set as owner of object, can be None + &obSidGroup, // @pyparm <o PySID>|Group||Group Sid, can be None + &obDacl, // @pyparm <o PyACL>|Dacl||Discretionary ACL to set for object, can be None + &obSacl)) // @pyparm <o PyACL>|Sacl||System Audit ACL to set for object, can be None + return NULL; + + if (!PyWinObject_AsSID(obSidOwner, &pSidOwner, TRUE)) + return NULL; + if (!PyWinObject_AsSID(obSidGroup, &pSidGroup, TRUE)) + return NULL; + if (!PyWinObject_AsACL(obDacl, &pDacl, TRUE)) + return NULL; + if (!PyWinObject_AsACL(obSacl, &pSacl, TRUE)) + return NULL; + if (!PyWinObject_AsWCHAR(obObjectName, &ObjectName, FALSE )) + return NULL; + + err=SetNamedSecurityInfo(ObjectName, ObjectType, info, pSidOwner, pSidGroup, pDacl, pSacl); + if (err==ERROR_SUCCESS){ + Py_INCREF(Py_None); + ret=Py_None; + } + else + PyWin_SetAPIError("SetNamedSecurityInfo",err); + PyWinObject_FreeWCHAR(ObjectName); + return ret; + } + %} + + + // @pyswig <o PySECURITY_DESCRIPTOR>|GetNamedSecurityInfo|Retrieve security info for an object by name + // @comm Separate owner, group, dacl, and sacl are not returned as they can be easily retrieved from + // the returned PySECURITY_DESCRIPTOR + %native(GetNamedSecurityInfo) PyGetNamedSecurityInfo; + %{ + static PyObject *PyGetNamedSecurityInfo(PyObject *self, PyObject *args) + { + WCHAR *ObjectName=NULL; + PSECURITY_DESCRIPTOR pSD=NULL; + SE_OBJECT_TYPE object_type; + SECURITY_INFORMATION required_info; + DWORD err; + PyObject *ret=NULL, *obObjectName=NULL; + // @pyparm str/unicode|ObjectName||Name of object + // @pyparm int|ObjectType||Value from SE_OBJECT_TYPE enum + // @pyparm int|SecurityInfo||Combination of SECURITY_INFORMATION constants + if (!PyArg_ParseTuple(args, "Oll:GetNamedSecurityInfo",&obObjectName, &object_type, &required_info)) + return NULL; + if (!PyWinObject_AsWCHAR(obObjectName, &ObjectName, FALSE)) + return NULL; + + err=GetNamedSecurityInfoW(ObjectName, object_type, required_info, NULL, NULL, NULL, NULL, &pSD); + if (err==ERROR_SUCCESS) + ret=new PySECURITY_DESCRIPTOR(pSD); + else + PyWin_SetAPIError("GetNamedSecurityInfo",err); + PyWinObject_FreeWCHAR(ObjectName); + if (pSD) + LocalFree(pSD); + return ret; + } + %} + // @pyswig int|OpenProcessToken| BOOLAPI OpenProcessToken( *************** *** 1203,1206 **** --- 1312,1317 ---- rc = PyWinObject_FromSECURITY_DESCRIPTOR(psd); done: + if (psd) + free(psd); return rc; } *************** *** 1217,1222 **** unsigned long info; ! // @pyparm <o PyHANDLE>|handle||The handle to set. ! // @pyparm int|info||The type of information to set. // @pyparm <o PySECURITY_DESCRIPTOR>|security||The security information if (!PyArg_ParseTuple(args, "OlO", &obHandle, &info, &obsd)) --- 1328,1333 ---- unsigned long info; ! // @pyparm <o PyHANDLE>|handle||The handle to an object for which security information will be set. ! // @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)) *************** *** 1230,1234 **** if (!PyWinObject_AsSECURITY_DESCRIPTOR(obsd, &psd)) goto done; ! if (SetUserObjectSecurity(handle, &info, psd)) { PyWin_SetAPIError("SetUserObjectSecurity"); goto done; --- 1341,1345 ---- if (!PyWinObject_AsSECURITY_DESCRIPTOR(obsd, &psd)) goto done; ! if (!SetUserObjectSecurity(handle, &info, psd)) { PyWin_SetAPIError("SetUserObjectSecurity"); goto done; *************** *** 1276,1279 **** --- 1387,1392 ---- rc = PyWinObject_FromSECURITY_DESCRIPTOR(psd); done: + if (psd!=NULL) + free(psd); return rc; } *************** *** 1290,1295 **** unsigned long info; ! // @pyparm <o PyHANDLE>|handle||The handle to set. ! // @pyparm int|info||The type of information to set. // @pyparm <o PySECURITY_DESCRIPTOR>|security||The security information if (!PyArg_ParseTuple(args, "OlO", &obHandle, &info, &obsd)) --- 1403,1408 ---- unsigned long info; ! // @pyparm <o PyHANDLE>|handle||The handle to an object for which security information will be set. ! // @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)) *************** *** 1303,1307 **** if (!PyWinObject_AsSECURITY_DESCRIPTOR(obsd, &psd)) goto done; ! if (SetKernelObjectSecurity(handle, info, psd)) { PyWin_SetAPIError("SetKernelObjectSecurity"); goto done; --- 1416,1420 ---- if (!PyWinObject_AsSECURITY_DESCRIPTOR(obsd, &psd)) goto done; ! if (!SetKernelObjectSecurity(handle, info, psd)) { PyWin_SetAPIError("SetKernelObjectSecurity"); goto done; *************** *** 2012,2016 **** %} ! // @pyswig object|LsaRegisterPolicyChangeNotification|Register an event handle to receive policy change events %native(LsaRegisterPolicyChangeNotification) PyLsaRegisterPolicyChangeNotification; %{ --- 2125,2129 ---- %} ! // @pyswig |LsaRegisterPolicyChangeNotification|Register an event handle to receive policy change events %native(LsaRegisterPolicyChangeNotification) PyLsaRegisterPolicyChangeNotification; %{ *************** *** 2040,2044 **** %} ! // @pyswig object|LsaUnregisterPolicyChangeNotification|Stop receiving policy change notification %native(LsaUnregisterPolicyChangeNotification) PyLsaUnregisterPolicyChangeNotification; %{ --- 2153,2157 ---- %} ! // @pyswig |LsaUnregisterPolicyChangeNotification|Stop receiving policy change notification %native(LsaUnregisterPolicyChangeNotification) PyLsaUnregisterPolicyChangeNotification; %{ *************** *** 2120,2123 **** --- 2233,2280 ---- %} + + // @pyswig (dict,...)|EnumerateSecurityPackages|List available security packages as a sequence of dictionaries representing SecPkgInfo structures + %native(EnumerateSecurityPackages) PyEnumerateSecurityPackages; + %{ + static PyObject *PyEnumerateSecurityPackages(PyObject *self, PyObject *args) + { + if (!PyArg_ParseTuple(args, ":EnumerateSecurityPackages")) + return NULL; + PSecPkgInfoW pbuf=NULL, psecpkg=NULL; + PyObject *ret=NULL, *obsecpkg=NULL; + SECURITY_STATUS result; + ULONG pkg_cnt, pkg_ind; + result = EnumerateSecurityPackagesW(&pkg_cnt, &pbuf); + if (result!=SEC_E_OK) + goto done; + ret=PyTuple_New(pkg_cnt); + if (ret==NULL) + goto done; + psecpkg=pbuf; + for (pkg_ind=0;pkg_ind<pkg_cnt;pkg_ind++){ + obsecpkg=Py_BuildValue("{s:l,s:l,s:l,s:l,s:u,s:u}", + "Capabilities", psecpkg->fCapabilities, + "Version", psecpkg->wVersion, + "RPCID", psecpkg->wRPCID, + "MaxToken", psecpkg->cbMaxToken, + "Name", psecpkg->Name, + "Comment", psecpkg->Comment); + if (obsecpkg==NULL){ + Py_DECREF(ret); + ret=NULL; + break; + } + PyTuple_SetItem(ret,pkg_ind,obsecpkg); + psecpkg++; + } + done: + if (pbuf!=NULL) + FreeContextBuffer(pbuf); + return ret; + } + %} + + + #define TOKEN_ADJUST_DEFAULT TOKEN_ADJUST_DEFAULT // Required to change the default ACL, primary group, or owner of an access token. #define TOKEN_ADJUST_GROUPS TOKEN_ADJUST_GROUPS // Required to change the groups specified in an access token. *************** *** 2397,2398 **** --- 2554,2571 ---- #define SDDL_REVISION_1 SDDL_REVISION_1 + + #define SECPKG_FLAG_INTEGRITY SECPKG_FLAG_INTEGRITY + #define SECPKG_FLAG_PRIVACY SECPKG_FLAG_PRIVACY + #define SECPKG_FLAG_TOKEN_ONLY SECPKG_FLAG_TOKEN_ONLY + #define SECPKG_FLAG_DATAGRAM SECPKG_FLAG_DATAGRAM + #define SECPKG_FLAG_CONNECTION SECPKG_FLAG_CONNECTION + #define SECPKG_FLAG_MULTI_REQUIRED SECPKG_FLAG_MULTI_REQUIRED + #define SECPKG_FLAG_CLIENT_ONLY SECPKG_FLAG_CLIENT_ONLY + #define SECPKG_FLAG_EXTENDED_ERROR SECPKG_FLAG_EXTENDED_ERROR + #define SECPKG_FLAG_IMPERSONATION SECPKG_FLAG_IMPERSONATION + #define SECPKG_FLAG_ACCEPT_WIN32_NAME SECPKG_FLAG_ACCEPT_WIN32_NAME + #define SECPKG_FLAG_STREAM SECPKG_FLAG_STREAM + + #define SECPKG_CRED_INBOUND SECPKG_CRED_INBOUND + #define SECPKG_CRED_OUTBOUND SECPKG_CRED_OUTBOUND + #define SECPKG_CRED_BOTH SECPKG_CRED_BOTH |
|
From: Roger U. <ru...@us...> - 2004-05-21 04:49:55
|
Update of /cvsroot/pywin32/pywin32/win32/src/win32net In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28064/win32/src/win32net Modified Files: win32netmodule.cpp Log Message: Fix leak in ReturnNetError, add more NetMessageName functions Index: win32netmodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32net/win32netmodule.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** win32netmodule.cpp 30 Mar 2004 04:38:17 -0000 1.14 --- win32netmodule.cpp 21 May 2004 04:49:41 -0000 1.15 *************** *** 44,56 **** PyObject *ReturnNetError(char *fnName, long err /*=0*/) { if (err==0) err = GetLastError(); if(err >= NERR_BASE && err <= MAX_NERR) { ! HMODULE hModule; ! hModule = LoadLibraryEx( ! TEXT("netmsg.dll"), ! NULL, ! LOAD_LIBRARY_AS_DATAFILE ! ); ! if(hModule != NULL) { DWORD dwFormatFlags = FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS | --- 44,57 ---- PyObject *ReturnNetError(char *fnName, long err /*=0*/) { + static HMODULE hModule=NULL; + if (hModule==NULL) + hModule = LoadLibraryEx( + TEXT("netmsg.dll"), + NULL, + LOAD_LIBRARY_AS_DATAFILE); + if (err==0) err = GetLastError(); if(err >= NERR_BASE && err <= MAX_NERR) { ! if(hModule != NULL) { DWORD dwFormatFlags = FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS | *************** *** 599,602 **** --- 600,721 ---- } + // @pymethod |win32net|NetMessageNameAdd|Adds a message alias for specified machine + PyObject *PyNetMessageNameAdd(PyObject *self, PyObject *args) + { + NET_API_STATUS err; + WCHAR *server=NULL, *alias=NULL; + PyObject *observer=NULL, *obalias=NULL, *ret=NULL; + // @pyparm str/unicode|server||Name of server on which to execute - leading backslashes required on NT - local machine used if None + // @pyparm str/unicode|msgname||Message alias to add, 15 characters max + if (!PyArg_ParseTuple(args,"OO:NetMessageNameAdd",&observer,&obalias)) + goto done; + if (!PyWinObject_AsWCHAR(observer,&server,TRUE)) + goto done; + if (!PyWinObject_AsWCHAR(obalias,&alias,FALSE)) + goto done; + + err=NetMessageNameAdd(server, alias); + if (err==NERR_Success){ + Py_INCREF(Py_None); + ret=Py_None; + } + else + ReturnNetError("NetMessageNameAdd",err); + done: + if (server!=NULL) + PyWinObject_FreeWCHAR(server); + if (alias!=NULL) + PyWinObject_FreeWCHAR(alias); + return ret; + } + + // @pymethod |win32net|NetMessageNameDel|Removes a message alias for specified machine + PyObject *PyNetMessageNameDel(PyObject *self, PyObject *args) + { + NET_API_STATUS err; + WCHAR *server=NULL, *alias=NULL; + PyObject *observer=NULL, *obalias=NULL, *ret=NULL; + // @pyparm str/unicode|server||Name of server on which to execute - leading backslashes required on NT - local machine used if None + // @pyparm str/unicode|msgname||Message alias to delete for specified machine + if (!PyArg_ParseTuple(args,"OO:NetMessageNameDel",&observer,&obalias)) + goto done; + if (!PyWinObject_AsWCHAR(observer,&server,TRUE)) + goto done; + if (!PyWinObject_AsWCHAR(obalias,&alias,FALSE)) + goto done; + + err=NetMessageNameDel(server, alias); + if (err==NERR_Success){ + Py_INCREF(Py_None); + ret=Py_None; + } + else + ReturnNetError("NetMessageNameDel",err); + done: + if (server!=NULL) + PyWinObject_FreeWCHAR(server); + if (alias!=NULL) + PyWinObject_FreeWCHAR(alias); + return ret; + } + + // @pymethod |win32net|NetMessageNameEnum|Lists aliases for a computer + PyObject *PyNetMessageNameEnum(PyObject *self, PyObject *args) + { + NET_API_STATUS err=ERROR_MORE_DATA; + DWORD maxlen=MAX_PREFERRED_LENGTH, level=0; + #ifdef Py_DEBUG + maxlen=128; + #endif + DWORD entriesread=0, totalentries=0, resume_handle=0; + DWORD msg_ind; + WCHAR *server=NULL; + BYTE *buf; + MSG_INFO_0 *pmsg0; + PyObject *observer=NULL, *ret=NULL, *msg_item=NULL; + if (!PyArg_ParseTuple(args,"|O:NetMessageNameEnum",&observer)) + return NULL; + // @pyparm str/unicode|Server||Name of server on which to execute - leading backslashes required on NT - local machine used if None + if (observer!=NULL) + if (!PyWinObject_AsWCHAR(observer,&server,TRUE)) + return NULL; + + ret=PyList_New(0); + if (!ret) + return NULL; + while (TRUE){ + buf=NULL; + err=NetMessageNameEnum(server,level,&buf,maxlen,&entriesread,&totalentries,&resume_handle); + if ((err==NERR_Success)||(err==ERROR_MORE_DATA)){ + pmsg0=(MSG_INFO_0 *)buf; + for (msg_ind=0;msg_ind<entriesread;msg_ind++){ + msg_item=PyWinObject_FromWCHAR(pmsg0->msgi0_name); + if (!msg_item){ + Py_DECREF(ret); + ret=NULL; + break; + } + PyList_Append(ret,msg_item); + Py_DECREF(msg_item); + pmsg0++; + } + } + else{ + ReturnNetError("NetMessageNameEnum",err); + Py_DECREF(ret); + ret=NULL; + } + if (buf) + NetApiBufferFree(buf); + // With certain buffer size/return size combinations, function can actually return + // ERROR_MORE_DATA when done, while setting resume_handle to 0, resulting in an infinite + // loop if you use only the return code + if ((ret==NULL)||(resume_handle==0)) + break; + } + if (server!=NULL) + PyWinObject_FreeWCHAR(server); + return ret; + } PyObject *PyDoSetInfo(PyObject *self, PyObject *args, PFNSETINFO pfn, char *fnname, PyNET_STRUCT *pInfos) *************** *** 959,962 **** --- 1078,1084 ---- {"NetMessageBufferSend", PyNetMessageBufferSend, 1}, // @pymeth NetMessageBufferSend|sends a string to a registered message alias. + {"NetMessageNameAdd", PyNetMessageNameAdd, 1}, // @pymeth NetMessageNameAdd|Add a message alias for a computer + {"NetMessageNameDel", PyNetMessageNameDel, 1}, // @pymeth NetMessageNameDel|Removes a message alias + {"NetMessageNameEnum", PyNetMessageNameEnum, 1}, // @pymeth NetMessageNameEnum|List message aliases for a computer {"NetServerEnum", PyNetServerEnum, 1}, // @pymeth NetServerEnum|Retrieves information about all servers of a specific type |
|
From: Mark H. <mha...@us...> - 2004-05-19 10:33:28
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3755 Modified Files: win32gui.i Log Message: Enable tooltips in taskbar icons, as contributed by 'alch' in [ 944453 ] win32gui patch to enable balloon tooltips Index: win32gui.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32gui.i,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** win32gui.i 19 May 2004 10:24:37 -0000 1.40 --- win32gui.i 19 May 2004 10:33:18 -0000 1.41 *************** *** 3,6 **** --- 3,11 ---- %module win32gui // A module which provides an interface to the native win32 GUI + // alch begin 29/04/2004 to enable balloon notifications in Shell_NotifyIcon + %{ + #define _WIN32_IE 0x0501 + %} + // alch end %include "typemaps.i" %include "pywintypes.i" *************** *** 1979,1986 **** BOOL PyObject_AsNOTIFYICONDATA(PyObject *ob, NOTIFYICONDATA *pnid) { ! 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) { --- 1984,1995 ---- BOOL PyObject_AsNOTIFYICONDATA(PyObject *ob, NOTIFYICONDATA *pnid) { ! 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) { *************** *** 1991,1994 **** --- 2000,2017 ---- PyWinObject_FreeTCHAR(szTip); } + if (obInfo) { + TCHAR *szInfo; + if (!PyWinObject_AsTCHAR(obInfo, &szInfo)) + return NULL; + _tcsncpy(pnid->szInfo, szInfo, sizeof(pnid->szInfo)/sizeof(TCHAR)); + PyWinObject_FreeTCHAR(szInfo); + } + if (obInfoTitle) { + TCHAR *szInfoTitle; + if (!PyWinObject_AsTCHAR(obInfoTitle, &szInfoTitle)) + return NULL; + _tcsncpy(pnid->szInfoTitle, szInfoTitle, sizeof(pnid->szInfoTitle)/sizeof(TCHAR)); + PyWinObject_FreeTCHAR(szInfoTitle); + } return TRUE; } *************** *** 1997,2000 **** --- 2020,2029 ---- #define NIF_MESSAGE NIF_MESSAGE #define NIF_TIP NIF_TIP + #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 + #define NIM_ADD NIM_ADD // Adds an icon to the status area. #define NIM_DELETE NIM_DELETE // Deletes an icon from the status area. |
|
From: Mark H. <mha...@us...> - 2004-05-19 10:24:47
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1932 Modified Files: win32gui.i Log Message: Add IsWindowEnabled, CopyIcon, GetCursor, GetCursorInfo and InitCommonControlsEx, Index: win32gui.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32gui.i,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** win32gui.i 13 May 2004 14:16:13 -0000 1.39 --- win32gui.i 19 May 2004 10:24:37 -0000 1.40 *************** *** 1461,1464 **** --- 1461,1482 ---- void InitCommonControls(); + %{ + // @pyswig |InitCommonControlsEx|Initializes specific common controls. + static PyObject *PyInitCommonControlsEx(PyObject *self, PyObject *args) + { + int flag; + // @pyparm int|flag||One of the ICC_ constants + if (!PyArg_ParseTuple(args, "i", &flag)) + return NULL; + INITCOMMONCONTROLSEX cc; + cc.dwSize = sizeof(cc); + cc.dwICC = flag; + if (!InitCommonControlsEx(&cc)) + return PyWin_SetAPIError("InitCommonControlsEx"); + Py_INCREF(Py_None); + return Py_None; + } + %} + %native (InitCommonControlsEx) PyInitCommonControlsEx; // @pyswig HCURSOR|LoadCursor|Loads a cursor. *************** *** 1473,1476 **** --- 1491,1512 ---- ); + // @pyswig HCURSOR|GetCursor| + HCURSOR GetCursor(); + + %{ + // @pyswig flags, hcursor, (x,y)|GetCursorInfo|Retrieves information about the global cursor. + PyObject *PyGetCursorInfo(PyObject *self, PyObject *args) + { + 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); + } + %} + %native(GetCursorInfo) PyGetCursorInfo; + // @pyswig HACCEL|CreateAcceleratorTable|Creates an accelerator table %{ *************** *** 1540,1543 **** --- 1576,1583 ---- HICON LoadIcon(HINSTANCE hInst, RESOURCE_ID name); + // @pyswig HICON|CopyIcon|Copies an icon + // #pyparm int|hicon||Existing icon + HICON CopyIcon(HICON hicon); + // @pyswig HANDLE|LoadImage|Loads a bitmap, cursor or icon HANDLE LoadImage(HINSTANCE hInst, // @pyparm int|hinst||Handle to an instance of the module that contains the image to be loaded. To load an OEM image, set this parameter to zero. *************** *** 1700,1703 **** --- 1740,1747 ---- BOOL IsWindowVisible(HWND hwnd); + // @pyswig int|IsWindowEnabled|Indicates if the window is enabled. + // @pyparm int|hwnd||The handle to the window + BOOL IsWindowEnabled(HWND hwnd); + // @pyswig |SetFocus|Sets focus to the specified window. // @pyparm int|hwnd||The handle to the window |
|
From: Mark H. <mha...@us...> - 2004-05-13 14:23:28
|
Update of /cvsroot/pywin32/pywin32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17136 Modified Files: .cvsignore Removed Files: PyWin32.kpf Log Message: No longer keep my .kpf under CVS. Index: .cvsignore =================================================================== RCS file: /cvsroot/pywin32/pywin32/.cvsignore,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** .cvsignore 7 Feb 2004 10:03:09 -0000 1.5 --- .cvsignore 13 May 2004 14:23:05 -0000 1.6 *************** *** 19,20 **** --- 19,21 ---- *.suo temp-* + PyWin32.kpf --- PyWin32.kpf DELETED --- |
|
From: Mark H. <mha...@us...> - 2004-05-13 14:17:41
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16099/win32/lib Modified Files: win32gui_struct.py Log Message: New LVCOLUMN and HDITEM structs. Index: win32gui_struct.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/win32gui_struct.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** win32gui_struct.py 9 Apr 2004 11:09:57 -0000 1.3 --- win32gui_struct.py 13 May 2004 14:17:31 -0000 1.4 *************** *** 396,399 **** --- 396,436 ---- return array.array("c", buf), extra + def UnpackLVCOLUMN(lparam): + format = "iiiiiiii" + mask, fmt, cx, text_addr, text_size, subItem, image, order = \ + struct.unpack(format, lparam) + # ensure only items listed by the mask are valid + if not (mask & commctrl.LVCF_FMT): fmt = None + if not (mask & commctrl.LVCF_WIDTH): cx = None + if not (mask & commctrl.LVCF_TEXT): text_addr = test_size = None + if not (mask & commctrl.LVCF_SUBITEM): subItem = None + if not (mask & commctrl.LVCF_IMAGE): image = None + if not (mask & commctrl.LVCF_ORDER): order = None + if text_addr: + text = win32gui.PyGetString(text_addr) + else: + text = None + return fmt, cx, text, subItem, image, order + + + # Make a new buffer suitable for querying an items attributes. + def EmptyLVCOLUMN(mask = None, text_buf_size=512): + extra = [] # objects we must keep references to + if mask is None: + mask = commctrl.LVCF_FMT | commctrl.LVCF_WIDTH | commctrl.LVCF_TEXT | \ + commctrl.LVCF_SUBITEM | commctrl.LVCF_IMAGE | commctrl.LVCF_ORDER + if mask & commctrl.LVCF_TEXT: + text_buffer = array.array("c", "\0" * text_buf_size) + extra.append(text_buffer) + text_addr, text_len = text_buffer.buffer_info() + else: + text_addr = text_len = 0 + format = "iiiiiiii" + buf = struct.pack(format, + mask, 0, 0, + text_addr, text_len, # text + 0, 0, 0) + return array.array("c", buf), extra + # List view hit-test. def PackLVHITTEST(pt): *************** *** 408,409 **** --- 445,473 ---- x, y, flags, item, subitem = struct.unpack(format, buf) return (x,y), flags, item, subitem + + def PackHDITEM(cxy = None, text = None, hbm = None, fmt = None, + param = None, image = None, order = None): + extra = [] # objects we must keep references to + mask = 0 + mask, cxy = _GetMaskAndVal(cxy, 0, mask, commctrl.HDI_HEIGHT) + mask, text = _GetMaskAndVal(text, None, mask, commctrl.LVCF_TEXT) + mask, hbm = _GetMaskAndVal(hbm, 0, mask, commctrl.HDI_BITMAP) + mask, fmt = _GetMaskAndVal(fmt, 0, mask, commctrl.HDI_FORMAT) + mask, param = _GetMaskAndVal(param, 0, mask, commctrl.HDI_LPARAM) + mask, image = _GetMaskAndVal(image, 0, mask, commctrl.HDI_IMAGE) + mask, order = _GetMaskAndVal(order, 0, mask, commctrl.HDI_ORDER) + + if text is None: + text_addr = text_len = 0 + else: + if isinstance(text, unicode): + text = text.encode("mbcs") + text_buffer = array.array("c", text+"\0") + extra.append(text_buffer) + text_addr, text_len = text_buffer.buffer_info() + + format = "iiiiiiiiiii" + buf = struct.pack(format, + mask, cxy, text_addr, hbm, text_len, + fmt, param, image, order, 0, 0) + return array.array("c", buf), extra |
|
From: Mark H. <mha...@us...> - 2004-05-13 14:16:39
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15827/win32/src Modified Files: win32gui.i Log Message: Add sorting for listview controls. Index: win32gui.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32gui.i,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** win32gui.i 25 Apr 2004 11:17:43 -0000 1.38 --- win32gui.i 13 May 2004 14:16:13 -0000 1.39 *************** *** 2645,2646 **** --- 2645,2756 ---- %native (GetClassName) PyGetClassName; + // Sorting for controls + %{ + + // Callbacks + struct PySortCallback { + PyObject *fn; + PyObject *data; + }; + + int CALLBACK CompareFunc(); + + int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, + LPARAM lParamSort); + + static int CALLBACK PySortFunc( + LPARAM lParam1, + LPARAM lParam2, + LPARAM lParamSort + ) + { + int rc = 0; + PyObject *result = NULL; + PyObject *args = NULL; + PyGILState_STATE state = PyGILState_Ensure(); + PySortCallback *pc = (PySortCallback *)lParamSort; + if (!pc) { + PySys_WriteStderr("Control sort function callback with no data!\n"); + goto done; + } + assert(!PyErr_Occurred()); + args = Py_BuildValue("llO", lParam1, lParam2, pc->data); + if (!args) goto done; + result = PyEval_CallObject(pc->fn, args); + // API says must return 0, but there might be a good reason. + if (!result) goto done; + if (!PyInt_Check(result)) { + PyErr_SetString(PyExc_TypeError, "The sort function must return an integer"); + goto done; + } + rc = PyInt_AsLong(result); + done: + if (PyErr_Occurred()) { + PySys_WriteStderr("ListView sort callback failed!\n"); + PyErr_Print(); + } + Py_XDECREF(args); + Py_XDECREF(result); + PyGILState_Release(state); + return rc; + } + + + // @pyswig |ListView_SortItems|Uses an application-defined comparison function to sort the items of a list view control. + static PyObject * + PyListView_SortItems(PyObject *self, PyObject *args) + { + 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)) + return PyErr_Format(PyExc_TypeError, + "2nd param must be callable (got type %s)", ob->ob_type->tp_name); + PySortCallback cb = {ob, obParam}; + BOOL ok; + GUI_BGN_SAVE; + ok = ListView_SortItems(hwnd, PySortFunc, &cb); + GUI_END_SAVE; + if (!ok) { + PyWin_SetAPIError("ListView_SortItems"); + return NULL; + } + Py_INCREF(Py_None); + return Py_None; + } + // @pyswig |ListView_SortItemsEx|Uses an application-defined comparison function to sort the items of a list view control. + static PyObject * + PyListView_SortItemsEx(PyObject *self, PyObject *args) + { + 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)) + return PyErr_Format(PyExc_TypeError, + "2nd param must be callable (got type %s)", ob->ob_type->tp_name); + PySortCallback cb = {ob, obParam}; + BOOL ok; + GUI_BGN_SAVE; + ok = ListView_SortItemsEx(hwnd, PySortFunc, &cb); + GUI_END_SAVE; + if (!ok) { + PyWin_SetAPIError("ListView_SortItemsEx"); + return NULL; + } + Py_INCREF(Py_None); + return Py_None; + } + %} + + %native (ListView_SortItems) PyListView_SortItems; + %native (ListView_SortItemsEx) PyListView_SortItemsEx; |
|
From: Mark H. <mha...@us...> - 2004-05-13 14:15:38
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15744/win32/src Modified Files: win32process.i Log Message: Few new CreateProcess constants. Index: win32process.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32process.i,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** win32process.i 21 Apr 2004 06:41:56 -0000 1.13 --- win32process.i 13 May 2004 14:15:28 -0000 1.14 *************** *** 1307,1311 **** #define CREATE_SHARED_WOW_VDM CREATE_SHARED_WOW_VDM // Windows NT: The flag is valid only when starting a 16-bit Windows-based application. If the DefaultSeparateVDM switch in the Windows section of WIN.INI is TRUE, this flag causes the CreateProcess function to override the switch and run the new process in the shared Virtual DOS Machine. ! #define CREATE_UNICODE_ENVIRONMENT CREATE_UNICODE_ENVIRONMENT // If set, the environment block pointed to by lpEnvironment uses Unicode characters. If clear, the environment block uses ANSI characters. #endif // MS_WINCE --- 1307,1315 ---- #define CREATE_SHARED_WOW_VDM CREATE_SHARED_WOW_VDM // Windows NT: The flag is valid only when starting a 16-bit Windows-based application. If the DefaultSeparateVDM switch in the Windows section of WIN.INI is TRUE, this flag causes the CreateProcess function to override the switch and run the new process in the shared Virtual DOS Machine. ! #define CREATE_UNICODE_ENVIRONMENT CREATE_UNICODE_ENVIRONMENT // If set, the environment block pointed to by lpEnvironment uses Unicode characters. If clear, the environment block uses ANSI characters. ! #define CREATE_BREAKAWAY_FROM_JOB CREATE_BREAKAWAY_FROM_JOB ! #define CREATE_PRESERVE_CODE_AUTHZ_LEVEL CREATE_PRESERVE_CODE_AUTHZ_LEVEL ! #define CREATE_NO_WINDOW CREATE_NO_WINDOW ! #endif // MS_WINCE |
|
From: Mark H. <mha...@us...> - 2004-05-13 14:15:11
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15093/win32/src Modified Files: win32trace.cpp Log Message: Double the buffer, and check if it is nearly full before writing, rather than after. The latter change alone fixes clients that spew huge amounts, and the buffer doubling is for extra measure! (128k of memory-mapped space is reasonable these days) Index: win32trace.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32trace.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** win32trace.cpp 31 Aug 2003 23:05:53 -0000 1.10 --- win32trace.cpp 13 May 2004 14:14:53 -0000 1.11 *************** *** 40,44 **** ! const size_t BUFFER_SIZE = 0x10000; // Includes size integer. const char *MAP_OBJECT_NAME = "PythonTraceOutputMapping"; const char *MUTEX_OBJECT_NAME = "PythonTraceOutputMutex"; --- 40,44 ---- ! const size_t BUFFER_SIZE = 0x20000; // Includes size integer. const char *MAP_OBJECT_NAME = "PythonTraceOutputMapping"; const char *MUTEX_OBJECT_NAME = "PythonTraceOutputMutex"; *************** *** 301,305 **** while (len) { unsigned len_this = min(len, BUFFER_SIZE/2); ! if (GetMyMutex()) { size_t *pLen = (size_t *)pMapBaseWrite; char *buffer = (char *)(((size_t *)pMapBaseWrite)+1); --- 301,317 ---- while (len) { unsigned len_this = min(len, BUFFER_SIZE/2); ! BOOL ok = GetMyMutex(); ! if (ok) { ! size_t *pLen = (size_t *)pMapBaseWrite; ! size_t sizeLeft = (BUFFER_SIZE-sizeof(size_t)) - *pLen; ! // If less than double we need left, wait for it to empty, or .1 sec. ! if (sizeLeft < len_this * 2) { ! ReleaseMyMutex(); ! SetEvent(hEvent); ! WaitForSingleObject(hEventEmpty, 100); ! ok = GetMyMutex(); ! } ! } ! if (ok) { size_t *pLen = (size_t *)pMapBaseWrite; char *buffer = (char *)(((size_t *)pMapBaseWrite)+1); *************** *** 314,323 **** data_this += len_this; len -= len_this; - if (len) { - // If we had to split up the data, we can have little sleep - // to let a reader grab the data (but if a reader empties us - // before the timeout, then we wake up) - WaitForSingleObject(hEventEmpty, 10); - } } } --- 326,329 ---- |
|
From: Thomas H. <th...@us...> - 2004-05-10 20:26:16
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26532 Modified Files: shell.cpp Log Message: COmment marker was missing. Index: shell.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/shell.cpp,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** shell.cpp 6 May 2004 03:39:01 -0000 1.24 --- shell.cpp 10 May 2004 20:26:06 -0000 1.25 *************** *** 872,876 **** // and the rest are integers. See the Microsoft documentation for // SHBrowseForFolder, or the browse_for_folder.py shell sample for more ! information. } --- 872,876 ---- // and the rest are integers. See the Microsoft documentation for // SHBrowseForFolder, or the browse_for_folder.py shell sample for more ! // information. } |
|
From: Mark H. <mha...@us...> - 2004-05-06 03:41:35
|
Update of /cvsroot/pywin32/pywin32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22810 Modified Files: setup_win32all.py MANIFEST.in Log Message: Add new shell demos. Index: MANIFEST.in =================================================================== RCS file: /cvsroot/pywin32/pywin32/MANIFEST.in,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MANIFEST.in 25 Apr 2004 10:20:23 -0000 1.2 --- MANIFEST.in 6 May 2004 03:41:27 -0000 1.3 *************** *** 46,49 **** --- 46,50 ---- include com/win32comext/shell/src/*.h include com/win32comext/shell/demos/servers/*.py + include com/win32comext/shell/demos/*.py include com/win32comext/taskscheduler/src/*.h Index: setup_win32all.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/setup_win32all.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** setup_win32all.py 27 Apr 2004 00:58:17 -0000 1.18 --- setup_win32all.py 6 May 2004 03:41:27 -0000 1.19 *************** *** 994,997 **** --- 994,998 ---- 'com/win32comext/shell/test/*.py', 'com/win32comext/shell/demos/servers/*.py', + 'com/win32comext/shell/demos/*.py', 'com/win32comext/taskscheduler/test/*.py', ]) + |
|
From: Mark H. <mha...@us...> - 2004-05-06 03:41:00
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/demos In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22711 Added Files: browse_for_folder.py Log Message: Demo of SHBrowseForFolder, including callbacks. --- NEW FILE: browse_for_folder.py --- # A couple of samples using SHBrowseForFolder import sys, os from win32com.shell import shell, shellcon import win32gui # A callback procedure - called by SHBrowseForFolder def BrowseCallbackProc(hwnd, msg, lp, data): if msg== shellcon.BFFM_INITIALIZED: win32gui.SendMessage(hwnd, shellcon.BFFM_SETSELECTION, 1, data) elif msg == shellcon.BFFM_SELCHANGED: # Set the status text of the # For this message, 'lp' is the address of the PIDL. pidl = shell.AddressAsPIDL(lp) try: path = shell.SHGetPathFromIDList(pidl) win32gui.SendMessage(hwnd, shellcon.BFFM_SETSTATUSTEXT, 0, path) except shell.error: # No path for this PIDL pass if __name__=='__main__': # Demonstrate a dialog with the cwd selected as the default - this # must be done via a callback function. flags = shellcon.BIF_STATUSTEXT shell.SHBrowseForFolder(0, # parent HWND None, # root PIDL. "Default of %s" % os.getcwd(), # title flags, # flags BrowseCallbackProc, # callback function os.getcwd() # 'data' param for the callback ) # Browse from this directory down only. # Get the PIDL for the cwd. desktop = shell.SHGetDesktopFolder() cb, pidl, extra = desktop.ParseDisplayName(0, None, os.getcwd()) shell.SHBrowseForFolder(0, # parent HWND pidl, # root PIDL. "From %s down only" % os.getcwd(), # title ) |
|
From: Mark H. <mha...@us...> - 2004-05-06 03:39:10
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22286 Modified Files: shell.cpp Log Message: Add support for a callback in SHBrowseForFolder, add shell.error as an alias for pywintypes.com_error. Add AddressAsPIDL to convert an address, without a known size, as a PIDL. This is safe as our PIDL extraction code catches win32 exceptions. Index: shell.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/shell.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** shell.cpp 4 May 2004 05:59:51 -0000 1.23 --- shell.cpp 6 May 2004 03:39:01 -0000 1.24 *************** *** 760,763 **** --- 760,803 ---- } + // Callback for BrowseForFolder + struct PyCallback { + PyObject *fn; + PyObject *data; + }; + + static int CALLBACK PyBrowseCallbackProc( + HWND hwnd, + UINT uMsg, + LPARAM lParam, + LPARAM lpData + ) + { + int rc = 0; + PyObject *result = NULL; + PyObject *args = NULL; + PyGILState_STATE state = PyGILState_Ensure(); + PyCallback *pc = (PyCallback *)lpData; + if (!pc) { + PySys_WriteStderr("SHBrowseForFolder callback with no data!\n"); + goto done; + } + assert(!PyErr_Occurred()); + args = Py_BuildValue("lilO", hwnd, uMsg, lParam, pc->data); + if (!args) goto done; + result = PyEval_CallObject(pc->fn, args); + // API says must return 0, but there might be a good reason. + if (result && PyInt_Check(result)) + rc = PyInt_AsLong(result); + done: + if (PyErr_Occurred()) { + PySys_WriteStderr("SHBrowseForFolder callback failed!\n"); + PyErr_Print(); + } + Py_XDECREF(args); + Py_XDECREF(result); + PyGILState_Release(state); + return rc; + } + ////////////////////////////////////////////////////////////// // *************** *** 773,793 **** PyObject *obPIDL = Py_None; PyObject *obTitle = Py_None; ! PyObject *none_for_now = Py_None; TCHAR retPath[MAX_PATH]; bi.pszDisplayName = retPath; LPITEMIDLIST pl = NULL; ! if(!PyArg_ParseTuple(args, "|lOOlOl:SHBrowseForFolder", &bi.hwndOwner, // @pyparm int|hwndOwner|0| &obPIDL, // @pyparm <o PyIDL>|pidlRoot|None| &obTitle, // @pyparm <o Unicode>/string|title|None| &bi.ulFlags, // @pyparm int|flags|0| ! &none_for_now, // @pyparm object|callback||Not yet supported - must be None ! &bi.lParam)) // @pyparm int|callbackParam|0| return NULL; ! if (none_for_now != Py_None) { ! PyErr_SetString(PyExc_TypeError, "Callback item must be None"); ! goto done; ! } if (!PyObject_AsPIDL(obPIDL, (LPITEMIDLIST *)&bi.pidlRoot, TRUE)) goto done; --- 813,842 ---- PyObject *obPIDL = Py_None; PyObject *obTitle = Py_None; ! PyObject *obcb = Py_None; ! PyObject *obcbparam = Py_None; TCHAR retPath[MAX_PATH]; bi.pszDisplayName = retPath; LPITEMIDLIST pl = NULL; + PyCallback pycb; ! if(!PyArg_ParseTuple(args, "|lOOlOO:SHBrowseForFolder", &bi.hwndOwner, // @pyparm int|hwndOwner|0| &obPIDL, // @pyparm <o PyIDL>|pidlRoot|None| &obTitle, // @pyparm <o Unicode>/string|title|None| &bi.ulFlags, // @pyparm int|flags|0| ! &obcb, // @pyparm object|callback|None|A callable object to be used as the callback, or None ! &obcbparam)) // @pyparm object|callback_data|None|An object passed to the callback function return NULL; ! ! if (obcb != Py_None) { ! if (!PyCallable_Check(obcb)) { ! PyErr_SetString(PyExc_TypeError, "Callback item must None or a callable object"); ! goto done; ! } ! pycb.fn = obcb; ! pycb.data = obcbparam; ! bi.lParam = (LPARAM)&pycb; ! bi.lpfn = PyBrowseCallbackProc; ! } // else bi.lParam/lpfn remains 0 if (!PyObject_AsPIDL(obPIDL, (LPITEMIDLIST *)&bi.pidlRoot, TRUE)) goto done; *************** *** 819,822 **** --- 868,876 ---- if (bi.lpszTitle) PyWinObject_FreeTCHAR((TCHAR *)bi.lpszTitle); return rc; + // @comm If you provide a callback function, it should take 4 args: + // hwnd, msg, lp, data. Data will be whatever you passed as callback_data, + // and the rest are integers. See the Microsoft documentation for + // SHBrowseForFolder, or the browse_for_folder.py shell sample for more + information. } *************** *** 1347,1350 **** --- 1401,1414 ---- } + // @pymethod <o PIDL>|shell|AddressAsPIDL|Given the address of a PIDL in memory, return a PIDL object (ie, a list of strings) + static PyObject *PyAddressAsPIDL(PyObject *self, PyObject *args) + { + long lpidl; + // @pyparm int|address||The address of the PIDL + if (!PyArg_ParseTuple(args, "l:AddressAsPIDL", &lpidl)) + return NULL; + return PyObject_FromPIDL((LPCITEMIDLIST)lpidl, FALSE); + } + // @pymethod <o PIDL>, list|shell|StringAsCIDA|Given a CIDA as a raw string, return the folder PIDL and list of children static PyObject *PyStringAsCIDA(PyObject *self, PyObject *args) *************** *** 1397,1400 **** --- 1461,1465 ---- { "CIDAAsString", PyCIDAAsString, 1}, // @pymeth CIDAAsString|Given a (pidl, child_pidls) object, return a CIDA as a string { "StringAsPIDL", PyStringAsPIDL, 1}, // @pymeth StringAsPIDL|Given a PIDL as a raw string, return a PIDL object (ie, a list of strings) + { "AddressAsPIDL", PyAddressAsPIDL, 1}, // @pymeth AddressAsPIDL|Given the address of a PIDL, return a PIDL object (ie, a list of strings) { "PIDLAsString", PyPIDLAsString, 1}, // @pymeth PIDLAsString|Given a PIDL object, return the raw PIDL bytes as a string { NULL, NULL }, *************** *** 1457,1460 **** --- 1522,1526 ---- if (!dict) return; /* Another serious error!*/ + PyDict_SetItemString(dict, "error", PyWinExc_COMError); // Register all of our interfaces, gateways and IIDs. PyCom_RegisterExtensionSupport(dict, g_interfaceSupportData, sizeof(g_interfaceSupportData)/sizeof(PyCom_InterfaceSupportInfo)); |