[pywin32-checkins] pywin32/win32/Lib win32gui_struct.py,1.2,1.3
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2004-04-09 11:23:16
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25825 Modified Files: win32gui_struct.py Log Message: Various fixes and extra listview notification unpacking Index: win32gui_struct.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/win32gui_struct.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** win32gui_struct.py 12 Mar 2004 09:21:19 -0000 1.2 --- win32gui_struct.py 9 Apr 2004 11:09:57 -0000 1.3 *************** *** 45,49 **** # structure to avoid the caller needing to explicitly check validity # (None is used if the mask excludes/should exclude the value) ! menuitem_fmt = '9IP2I' def PackMENUITEMINFO(fType=None, fState=None, wID=None, hSubMenu=None, --- 45,49 ---- # structure to avoid the caller needing to explicitly check validity # (None is used if the mask excludes/should exclude the value) ! menuitem_fmt = '9iP2i' def PackMENUITEMINFO(fType=None, fState=None, wID=None, hSubMenu=None, *************** *** 69,73 **** assert hbmpUnchecked is not None, \ "neither or both checkmark bmps must be given" ! fMask |= win32con.MMIM_CHECKMARKS if dwTypeData is None: dwTypeData = 0 else: fMask |= win32con.MIIM_DATA --- 69,73 ---- assert hbmpUnchecked is not None, \ "neither or both checkmark bmps must be given" ! fMask |= win32con.MIIM_CHECKMARKS if dwTypeData is None: dwTypeData = 0 else: fMask |= win32con.MIIM_DATA *************** *** 76,79 **** --- 76,81 ---- if text is not None: fMask |= win32con.MIIM_STRING + if isinstance(text, unicode): + text = text.encode("mbcs") str_buf = array.array("c", text+'\0') cch = len(str_buf) *************** *** 107,111 **** def UnpackMENUITEMINFO(s): ! cb, fMask, fType, --- 109,113 ---- def UnpackMENUITEMINFO(s): ! (cb, fMask, fType, *************** *** 118,122 **** lptext, cch, ! hbmpItem = struct.unpack(menuitem_fmt, s) assert cb==len(s) if fMask & win32con.MIIM_FTYPE==0: fType = None --- 120,124 ---- lptext, cch, ! hbmpItem) = struct.unpack(menuitem_fmt, s) assert cb==len(s) if fMask & win32con.MIIM_FTYPE==0: fType = None *************** *** 128,136 **** if fMask & win32con.MIIM_BITMAP==0: hbmpItem = None if fMask & win32con.MIIM_STRING: ! text = PyGetString(lptext, cch) else: text = None ! return fType, fState, wID, hSubMenu, bmpChecked, bmpUnchecked, \ ! dwTypeData, text, hbmpItem ########################################################################## --- 130,171 ---- if fMask & win32con.MIIM_BITMAP==0: hbmpItem = None if fMask & win32con.MIIM_STRING: ! text = win32gui.PyGetString(lptext, cch) else: text = None ! return fType, fState, wID, hSubMenu, hbmpChecked, hbmpUnchecked, \ ! dwItemData, text, hbmpItem ! ! def EmptyMENUITEMINFO(mask = None, text_buf_size=512): ! extra = [] ! if mask is None: ! mask = win32con.MIIM_BITMAP | win32con.MIIM_CHECKMARKS | \ ! win32con.MIIM_DATA | win32con.MIIM_FTYPE | \ ! win32con.MIIM_ID | win32con.MIIM_STATE | \ ! win32con.MIIM_STRING | win32con.MIIM_SUBMENU | \ ! win32con.MIIM_TYPE ! ! if mask & win32con.MIIM_STRING: ! 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 ! ! buf = struct.pack( ! menuitem_fmt, ! struct.calcsize(menuitem_fmt), # cbSize ! mask, ! 0, #fType, ! 0, #fState, ! 0, #wID, ! 0, #hSubMenu, ! 0, #hbmpChecked, ! 0, #hbmpUnchecked, ! 0, #dwItemData, ! text_addr, ! text_len, ! 0, #hbmpItem ! ) ! return array.array("c", buf), extra ########################################################################## *************** *** 174,177 **** --- 209,214 ---- 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) *************** *** 236,241 **** hwndFrom, id, code, action, buf_old, buf_new \ = struct.unpack(format, buf) ! item_old = UnpackTVItem(buf_old) ! item_new = UnpackTVItem(buf_new) return hwndFrom, id, code, action, item_old, item_new --- 273,278 ---- hwndFrom, id, code, action, buf_old, buf_new \ = struct.unpack(format, buf) ! item_old = UnpackTVITEM(buf_old) ! item_new = UnpackTVITEM(buf_new) return hwndFrom, id, code, action, item_old, item_new *************** *** 244,248 **** buf = win32gui.PyMakeBuffer(struct.calcsize(format), lparam) hwndFrom, id, code, buf_item = struct.unpack(format, buf) ! item = UnpackTVItem(buf_item) return hwndFrom, id, code, item --- 281,285 ---- buf = win32gui.PyMakeBuffer(struct.calcsize(format), lparam) hwndFrom, id, code, buf_item = struct.unpack(format, buf) ! item = UnpackTVITEM(buf_item) return hwndFrom, id, code, item *************** *** 264,267 **** --- 301,306 ---- 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) *************** *** 294,297 **** --- 333,353 ---- text, item_image, item_param, item_indent + # Unpack an "LVNOTIFY" message + def UnpackLVDISPINFO(lparam): + format = "iii40s" + buf = win32gui.PyMakeBuffer(struct.calcsize(format), lparam) + hwndFrom, id, code, buf_item = struct.unpack(format, buf) + item = UnpackLVITEM(buf_item) + return hwndFrom, id, code, item + + def UnpackLVNOTIFY(lparam): + format = "3i8i" + buf = win32gui.PyMakeBuffer(struct.calcsize(format), lparam) + hwndFrom, id, code, item, subitem, newstate, oldstate, \ + changed, pt_x, pt_y, lparam = struct.unpack(format, buf) + return hwndFrom, id, code, item, subitem, newstate, oldstate, \ + changed, (pt_x, pt_y), lparam + + # Make a new buffer suitable for querying an items attributes. def EmptyLVITEM(item, subitem, mask = None, text_buf_size=512): *************** *** 328,331 **** --- 384,389 ---- 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) |