diff --git a/LunaTranslator/LunaTranslator/LunaTranslator.py b/LunaTranslator/LunaTranslator/LunaTranslator.py index d5380f15..64018f64 100644 --- a/LunaTranslator/LunaTranslator/LunaTranslator.py +++ b/LunaTranslator/LunaTranslator/LunaTranslator.py @@ -1069,7 +1069,7 @@ class MAINUI: except: return if widget == self.translation_ui: - winsharedutils.showintab(int(widget.winId()), globalconfig["showintab"]) + winsharedutils.showintab_ex(int(widget.winId()), globalconfig["showintab"]) return window_flags = widget.windowFlags() if ( @@ -1190,7 +1190,7 @@ class MAINUI: self.parsedefaultfont() self.loadmetadatas() self.translation_ui = QUnFrameWindow() - winsharedutils.showintab( + winsharedutils.showintab_ex( int(self.translation_ui.winId()), globalconfig["showintab"] ) self.translation_ui.show() diff --git a/LunaTranslator/LunaTranslator/gui/translatorUI.py b/LunaTranslator/LunaTranslator/gui/translatorUI.py index 3a15e03c..94926392 100644 --- a/LunaTranslator/LunaTranslator/gui/translatorUI.py +++ b/LunaTranslator/LunaTranslator/gui/translatorUI.py @@ -621,8 +621,7 @@ class QUnFrameWindow(resizableframeless): super(QUnFrameWindow, self).__init__( None, flags=Qt.WindowType.FramelessWindowHint - | Qt.WindowType.WindowMinimizeButtonHint - | Qt.WindowType.Tool, + | Qt.WindowType.WindowMinimizeButtonHint, poslist=globalconfig["transuigeo"], ) # 设置为顶级窗口,无边框 icon = getExeIcon(sys.argv[0]) #'./LunaTranslator.exe')# QIcon() diff --git a/LunaTranslator/LunaTranslator/winsharedutils.py b/LunaTranslator/LunaTranslator/winsharedutils.py index aa4bc463..51004218 100644 --- a/LunaTranslator/LunaTranslator/winsharedutils.py +++ b/LunaTranslator/LunaTranslator/winsharedutils.py @@ -252,6 +252,8 @@ def SetTheme(hwnd, dark, backdrop): showintab = utilsdll.showintab showintab.argtypes = HWND, c_bool +showintab_ex = utilsdll.showintab_ex +showintab_ex.argtypes = HWND, c_bool class windowstatus(Structure): diff --git a/plugins/winsharedutils/hwnd.cpp b/plugins/winsharedutils/hwnd.cpp index 21b07cca..84a00f3a 100644 --- a/plugins/winsharedutils/hwnd.cpp +++ b/plugins/winsharedutils/hwnd.cpp @@ -20,6 +20,23 @@ DECLARE void showintab(HWND hwnd, bool show) SetWindowLong(hwnd, GWL_EXSTYLE, style_ex); } +DECLARE void showintab_ex(HWND hwnd, bool show) +{ + LONG style = GetWindowLong(hwnd, GWL_STYLE); + auto style_ex = GetWindowLong(hwnd, GWL_EXSTYLE); + if (show) + { + style_ex |= WS_EX_APPWINDOW; + style_ex &= ~WS_EX_TOOLWINDOW; + } + else + { + style_ex &= ~WS_EX_APPWINDOW; + style_ex |= WS_EX_TOOLWINDOW; + } + SetWindowLong(hwnd, GWL_EXSTYLE, style_ex); +} + struct windowstatus { WINDOWPLACEMENT wpc;