@@ -44,23 +44,30 @@ def onItemDoubleClicked(self, item):
44
44
# 如果数量等于4说明之前已经嵌入了一个窗口,现在需要把它释放出来
45
45
self .restore ()
46
46
hwnd , phwnd = int (hwnd ), int (phwnd )
47
+ # 嵌入之前的属性
48
+ style = win32gui .GetWindowLong (hwnd , win32con .GWL_STYLE )
49
+ exstyle = win32gui .GetWindowLong (hwnd , win32con .GWL_EXSTYLE )
50
+ print ('save' , hwnd , style , exstyle )
51
+
47
52
widget = QWidget .createWindowContainer (QWindow .fromWinId (hwnd ))
48
53
widget .hwnd = hwnd # 窗口句柄
49
54
widget .phwnd = phwnd # 父窗口句柄
50
- widget .style = win32gui .GetWindowLong (hwnd , win32con .GWL_STYLE ) # 窗口样式
51
- widget .exstyle = win32gui .GetWindowLong (
52
- hwnd , win32con .GWL_EXSTYLE ) # 窗口额外样式
55
+ widget .style = style # 窗口样式
56
+ widget .exstyle = exstyle # 窗口额外样式
53
57
self .layout ().addWidget (widget )
54
58
55
59
def restore (self ):
56
60
"""归还窗口"""
61
+ # 有bug,归还后窗口没有了WS_VISIBLE样式,不可见
57
62
widget = self .layout ().itemAt (3 ).widget ()
63
+ print ('restore' , widget .hwnd , widget .style , widget .exstyle )
58
64
win32gui .SetParent (widget .hwnd , widget .phwnd ) # 让它返回它的父窗口
59
65
win32gui .SetWindowLong (
60
- widget .hwnd , win32con .GWL_STYLE , widget .style ) # 恢复样式
66
+ widget .hwnd , win32con .GWL_STYLE , widget .style | win32con . WS_VISIBLE ) # 恢复样式
61
67
win32gui .SetWindowLong (
62
68
widget .hwnd , win32con .GWL_EXSTYLE , widget .exstyle ) # 恢复样式
63
- win32gui .ShowWindow (widget .hwnd , win32con .SW_SHOW ) # 显示窗口OF
69
+ win32gui .ShowWindow (
70
+ widget .hwnd , win32con .SW_SHOW ) # 显示窗口
64
71
widget .close ()
65
72
self .layout ().removeWidget (widget ) # 从布局中移出
66
73
widget .deleteLater ()
0 commit comments