Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Redocking Tab windows
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Redocking Tab windows

 Post Reply Post Reply
Author
Message
xsensordev View Drop Down
Groupie
Groupie


Joined: 19 August 2021
Location: Canada
Status: Offline
Points: 24
Post Options Post Options   Thanks (0) Thanks(0)   Quote xsensordev Quote  Post ReplyReply Direct Link To This Post Topic: Redocking Tab windows
    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
Back to Top
xsensordev View Drop Down
Groupie
Groupie


Joined: 19 August 2021
Location: Canada
Status: Offline
Points: 24
Post Options Post Options   Thanks (0) Thanks(0)   Quote xsensordev Quote  Post ReplyReply Direct Link To This Post 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.

Back to Top
Fredrik View Drop Down
Senior Member
Senior Member


Joined: 22 June 2005
Status: Offline
Points: 235
Post Options Post Options   Thanks (1) Thanks(1)   Quote Fredrik Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
xsensordev View Drop Down
Groupie
Groupie


Joined: 19 August 2021
Location: Canada
Status: Offline
Points: 24
Post Options Post Options   Thanks (0) Thanks(0)   Quote xsensordev Quote  Post ReplyReply Direct Link To This Post Posted: 06 September 2022 at 12:23pm
Thank you Fredrik, that sets me off in a good direction!
Back to Top
xsensordev View Drop Down
Groupie
Groupie


Joined: 19 August 2021
Location: Canada
Status: Offline
Points: 24
Post Options Post Options   Thanks (0) Thanks(0)   Quote xsensordev Quote  Post ReplyReply Direct Link To This Post 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;
}
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.203 seconds.