Print Page | Close Window

Redocking Tab windows

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=24323
Printed Date: 06 May 2024 at 2:24pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Redocking Tab windows
Posted By: xsensordev
Subject: Redocking Tab windows
Date Posted: 29 August 2022 at 5:44pm
So CXTPTabClientWnd::MDITile can be used to programmatically tile tab clients when grouping is enabled.

Is there a way to programmatically undo this tiling and place all the clients back in the tab bar?

This is with ToolkitPro V20.3.0



Replies:
Posted By: xsensordev
Date Posted: 04 September 2022 at 7:29pm
I was wrong when I thought being an active subscriber would at least get a comment from the developer.

Oh well. Guess not every developer is attentive to their clients as I am.



Posted By: Fredrik
Date Posted: 06 September 2022 at 9:05am
You have maximize the active frame window and then call ShowWorkspace(TRUE) on your CXTPTabClientWnd member.

They way I have solved it is to implement OnSysCommand for my CMDIChildWnds. If the mdi frames gets maximized, then I show tabs, otherwise the tabs are hidden. You may want to always see the tabs of course.


void MyMDIChildWnd::OnSysCommand(UINT nID, LPARAM lParam)
{
   const auto pMainFrame = static_cast<MyMainFrame*>(AfxGetMainWnd());

   if ((nID & 0xFFF0) == SC_MAXIMIZE) // Show tabs
      pMainFrame->GetTabClientWnd().ShowWorkspace (TRUE);
   else if ((nID & 0xFFF0) == SC_MINIMIZE || (nID & 0xFFF0) == SC_RESTORE) // Hide tabs
      pMainFrame->GetTabClientWnd().ShowWorkspace (FALSE);

   CMDIChildWnd::OnSysCommand(nID, lParam);
}


But you will also need to add code when the last frame window is closed to hide the workspace, and then also to hide the workspace when you cascade, restore and tile windows. I also had to add code to close frame windows with middle mouse button and double click to maxmi



-------------
Windows 10, Visual Studio 20157, Toolkit Pro 18.3.0


Posted By: xsensordev
Date Posted: 06 September 2022 at 12:23pm
Thank you Fredrik, that sets me off in a good direction!


Posted By: xsensordev
Date Posted: 06 September 2022 at 3:08pm
Thanks again Fredrik, your answer basically confirmed that there is no method to undo the tiling. This freed me to make my own.

In the case where tearoffs are not used. (ie: CMainFrame is derived from CXTPMDIFrameWnd and _MTIClientWnd.EnableTearOff() is not called:
 
Toggling between MDI tiled and tabbed is as easy as:
void CXsensorView::OnTestToggle()
{
    static bool toggle = false;
    if (!toggle)
    {
        GETMAINFRAME()->GetTabClientWnd()->MDITile(TRUE);
    }
    else
    {
        GETMAINFRAME()->GetTabClientWnd()->Detach();
        GETMAINFRAME()->GetTabClientWnd()->Attach(GETMAINFRAME(), TRUE);
        GETMAINFRAME()->GetTabClientWnd()->ShowWorkspace(TRUE);
    }

    toggle = !toggle;
}


In the case where tearoffs are used, (ie: CXTPMDIFrameWndEx), I rolled my own solution with the following toolkit modifications:

public:
void CXTPMDIFrameWndEx::RedockAllTearoffs()
{
    CArray<CXTPTabClientWnd*, CXTPTabClientWnd*> tabClients;

    CXTPTabClientWnd* pTabClient = GetTabClientWnd();
    if(pTabClient == nullptr)
        return;

    if(pTabClient->GetWorkspaceCount() == 0)
        return;

    pTabClient->GetTabClients(tabClients);

    for (int i = 0; i < tabClients.GetSize(); i++)
    {
        if (pTabClient != tabClients.GetAt(i))
        {
            CXTPTearOffFrame* pTearOffFrame =
                DYNAMIC_DOWNCAST(CXTPTearOffFrame, tabClients.GetAt(i)->GetParentFrame());

            if (pTearOffFrame != nullptr)
                pTearOffFrame->RedockWorkSpace(pTabClient);
        }
    }
}

public:
void CXTPTearOffFrame::RedockWorkSpace(CXTPTabClientWnd* pTarget)
{
    ChangeMDIChildFrame(pTarget, 0, xtpTabClientStickerCenter);
}

void CXsensorView::OnTestToggle()
{
    static bool toggle = false;
    if (!toggle)
    {
        GETMAINFRAME()->GetTabClientWnd()->MDITile(TRUE);
    }
    else
    {
        GETMAINFRAME()->RedockAllTearoffs();

        GETMAINFRAME()->GetTabClientWnd()->Detach();
        GETMAINFRAME()->GetTabClientWnd()->Attach(GETMAINFRAME(), TRUE);
        GETMAINFRAME()->GetTabClientWnd()->ShowWorkspace(TRUE);
    }
    toggle = !toggle;
}



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net