Пример #1
0
    def AppendChildWindows(self, parentHwnd, item):
        for hwnd in GetHwndChildren(parentHwnd, self.includeInvisible):
            name = GetWindowText(hwnd)
            className = GetClassName(hwnd)
            if name != "":
                name = "\"" + name + "\" "
            index = self.AppendItem(item, name + className, 0)
            self.SetPyData(index, hwnd)
            if className == "Edit" or className == "TEdit":
                self.SetItemImage(index, 1, which=wx.TreeItemIcon_Normal)
            elif className == "Static" or className == "TStaticText":
                self.SetItemImage(index, 2, which=wx.TreeItemIcon_Normal)
            elif className == "Button" or className == "TButton":
                self.SetItemImage(index, 3, which=wx.TreeItemIcon_Normal)
            elif GetClassName(parentHwnd) == "MDIClient":
                icon = GetHwndIcon(hwnd)
                if icon:
                    iconIndex = self.imageList.AddIcon(icon)
                    self.SetItemImage(
                        index,
                        iconIndex,
                        which=wx.TreeItemIcon_Normal
                    )

            if HwndHasChildren(hwnd, self.includeInvisible):
                self.SetItemHasChildren(index, True)
 def AppendToplevelWindows(self, pid, item):
     hwnds = self.pids[pid]
     for hwnd in hwnds:
         try:
             name = GetWindowText(hwnd)
             className = GetClassName(hwnd)
             icon = GetHwndIcon(hwnd)
         except:
             continue
         if name != '':
             name = '"%s"' % name
         iconIndex = 0
         if icon:
             iconIndex = self.imageList.AddIcon(icon)
         newItem = self.AppendItem(item, name)
         self.SetPyData(newItem, hwnd)
         self.SetItemText(newItem, name + className)
         self.SetItemImage(newItem, iconIndex, which=wx.TreeItemIcon_Normal)
         if HwndHasChildren(hwnd, self.includeInvisible):
             self.SetItemHasChildren(newItem, True)