def _CreateChildWindow(self, prev): # Creates the list view window. assert self.hwnd_child is None, "already have a window" assert self.cur_foldersettings is not None, "no settings" style = win32con.WS_CHILD | win32con.WS_VISIBLE | win32con.WS_BORDER | \ commctrl.LVS_SHAREIMAGELISTS | commctrl.LVS_EDITLABELS view_mode, view_flags = self.cur_foldersettings if view_mode==shellcon.FVM_ICON: style |= commctrl.LVS_ICON | commctrl.LVS_AUTOARRANGE elif view_mode==shellcon.FVM_SMALLICON: style |= commctrl.LVS_SMALLICON | commctrl.LVS_AUTOARRANGE elif view_mode==shellcon.FVM_LIST: style |= commctrl.LVS_LIST | commctrl.LVS_AUTOARRANGE elif view_mode==shellcon.FVM_DETAILS: style |= commctrl.LVS_REPORT | commctrl.LVS_AUTOARRANGE else: # XP 'thumbnails' etc view_mode = shellcon.FVM_DETAILS # Default to 'report' style |= commctrl.LVS_REPORT | commctrl.LVS_AUTOARRANGE for f_flag, l_flag in [ (shellcon.FWF_SINGLESEL, commctrl.LVS_SINGLESEL), (shellcon.FWF_ALIGNLEFT, commctrl.LVS_ALIGNLEFT), (shellcon.FWF_SHOWSELALWAYS, commctrl.LVS_SHOWSELALWAYS), ]: if view_flags & f_flag: style |= l_flag self.hwnd_child = win32gui.CreateWindowEx( win32con.WS_EX_CLIENTEDGE, "SysListView32", None, style, 0, 0, 0, 0, self.hwnd, 1000, 0, None) cr = win32gui.GetClientRect(self.hwnd) win32gui.MoveWindow(self.hwnd_child, 0, 0, cr[2]-cr[0], cr[3]-cr[1], True) # Setup the columns for the view. lvc, extras = win32gui_struct.PackLVCOLUMN(fmt=commctrl.LVCFMT_LEFT, subItem=1, text='Name', cx=300) win32gui.SendMessage(self.hwnd_child, commctrl.LVM_INSERTCOLUMN, 0, lvc) lvc, extras = win32gui_struct.PackLVCOLUMN(fmt=commctrl.LVCFMT_RIGHT, subItem=1, text='Exists', cx=50) win32gui.SendMessage(self.hwnd_child, commctrl.LVM_INSERTCOLUMN, 1, lvc) # and fill it with the content self.Refresh()
def _testPackUnpack(self, text): vals = dict(fmt=1, cx=2, text=text, subItem=3, image=4, order=5) ti, extra = win32gui_struct.PackLVCOLUMN(**vals) fmt, cx, text, subItem, image, order = win32gui_struct.UnpackLVCOLUMN(ti) self.assertDictEquals( vals, fmt=fmt, cx=cx, text=text, subItem=subItem, image=image, order=order )