列表双击选择事件
(self, item)
| 60 | win32gui.EnumWindows(self._enumWindows, None) |
| 61 | |
| 62 | def onItemDoubleClicked(self, item): |
| 63 | """列表双击选择事件""" |
| 64 | # 先移除掉item |
| 65 | self.windowList.takeItem(self.windowList.indexFromItem(item).row()) |
| 66 | hwnd, phwnd, _, _ = item.text().split('|') |
| 67 | # 开始嵌入 |
| 68 | self.releaseWidget() |
| 69 | hwnd, phwnd = int(hwnd), int(phwnd) |
| 70 | # 嵌入之前的属性 |
| 71 | style = win32gui.GetWindowLong(hwnd, win32con.GWL_STYLE) |
| 72 | exstyle = win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE) |
| 73 | wrect = win32gui.GetWindowRect(hwnd)[:2] + win32gui.GetClientRect(hwnd)[2:] |
| 74 | print('save', hwnd, style, exstyle, wrect) |
| 75 | |
| 76 | widget = QWidget.createWindowContainer(QWindow.fromWinId(hwnd)) |
| 77 | widget.hwnd = hwnd # 窗口句柄 |
| 78 | widget.phwnd = phwnd # 父窗口句柄 |
| 79 | widget.style = style # 窗口样式 |
| 80 | widget.exstyle = exstyle # 窗口额外样式 |
| 81 | widget.wrect = wrect # 窗口位置 |
| 82 | self.layout().addWidget(widget) |
| 83 | |
| 84 | widget.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint) |
| 85 | win32gui.SetParent(hwnd, int(self.winId())) |
| 86 | |
| 87 | def restore(self): |
| 88 | """归还窗口""" |
nothing calls this directly
no test coverage detected