2006年09月29日 星期五 10:11
python-chinese: 各位,谁用过 win32gui.SendMessage(ctrl, commctrl.LVM_GETITEM, i, buf) 取得ListView的Item信息? 怎么我这里一运行到这里,程序就死掉呢? 代码如下: ============================================================== #coding=gb18030 import sys if "--noxp" in sys.argv: import win32gui else: import winxpgui as win32gui import commctrl import win32gui_struct def EnumChildProc(hwndChild, lParam): lParam.append(hwndChild) return True def GetAllControlsID(oWinID): if oWinID<=0: return () controlsID = [oWinID] win32gui.EnumChildWindows(oWinID, EnumChildProc, controlsID) return tuple(controlsID) #主程序部分,主要用于调试 if __name__=='__main__': owinid = win32gui.FindWindow(None,'发送消息') print owinid ctrlsID = GetAllControlsID(owinid) for ctrl in ctrlsID: classname = win32gui.GetClassName(ctrl) print ctrl,':',classname,'\t==>\t',win32gui.GetWindowText(ctrl) if classname=='TListView' or classname=='SysListView32': count = win32gui.SendMessage(ctrl, commctrl.LVM_GETITEMCOUNT) print ' >',count for i in xrange(count): buf,extra = win32gui_struct.EmptyTVITEM(0) a=win32gui.SendMessage(ctrl, commctrl.LVM_GETITEM, i, buf) print a,' >> %d ==> "%s"' %(i, a) break =================================================================================== 致 礼! 风尘无限 Bejing HATL Information Technology Co. Ltd. tianyu263在163.com 2006-09-29 10:09:01
Zeuux © 2025
京ICP备05028076号