void SetTabsInTitlebar(WindowInfo *win, bool set) { if (set == win->tabsInTitlebar) return; if (set) { // make sure to load Dwmapi.dll before WndProcFrame -> CustomCaptionFrameProc -> // dwm::DefWindowProc_ -> dwm::Initialize might produce an infinite loop dwm::Initialize(); } win->tabsInTitlebar = set; TabPainter *tab = (TabPainter *)GetWindowLongPtr(win->hwndTabBar, GWLP_USERDATA); tab->inTitlebar = set; SetParent(win->hwndTabBar, set ? win->hwndCaption : win->hwndFrame); ShowWindow(win->hwndCaption, set ? SW_SHOW : SW_HIDE); if (set != win->isMenuHidden) ShowHideMenuBar(win); if (set) { win->caption->UpdateTheme(); win->caption->UpdateColors(win->hwndFrame == GetForegroundWindow()); win->caption->UpdateBackgroundAlpha(); RelayoutCaption(win); } else if (dwm::IsCompositionEnabled()) { // remove the extended frame MARGINS margins = { 0 }; dwm::ExtendFrameIntoClientArea(win->hwndFrame, &margins); win->extendedFrameHeight = 0; } SetWindowPos(win->hwndFrame, nullptr, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE); }
void SetTabsInTitlebar(WindowInfo *win, bool set) { if (set == win->tabsInTitlebar) return; win->tabsInTitlebar = set; TabPainter *tab = (TabPainter *)GetWindowLongPtr(win->hwndTabBar, GWLP_USERDATA); tab->inTitlebar = set; SetParent(win->hwndTabBar, set ? win->hwndCaption : win->hwndFrame); ShowWindow(win->hwndCaption, set ? SW_SHOW : SW_HIDE); if (set != win->isMenuHidden) ShowHideMenuBar(win); if (set) { win->caption->UpdateTheme(); win->caption->UpdateColors(win->hwndFrame == GetForegroundWindow()); win->caption->UpdateBackgroundAlpha(); RelayoutCaption(win); } else if (dwm::IsCompositionEnabled()) { // remove the extended frame MARGINS margins = { 0 }; dwm::ExtendFrameIntoClientArea(win->hwndFrame, &margins); win->extendedFrameHeight = 0; } SetWindowPos(win->hwndFrame, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE); }