Print Page | Close Window

[solved] CXTPTabClientWnd::OnMDIDestroy bug?

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
Printed Date: 21 March 2019 at 2:16pm

Topic: [solved] CXTPTabClientWnd::OnMDIDestroy bug?
Posted By: rdhd
Subject: [solved] CXTPTabClientWnd::OnMDIDestroy bug?
Date Posted: 05 March 2018 at 4:55pm
Is this an oversight/bug?

In CXTPTabClientWnd::OnMDIDestroy, the method always calls either ActivateNextItem or ActivateNextTopmostItem. So what happens if I have, for example, three documents opened and I hit the "x" on the tab of a window that is not the active MDI window?

CodeJock deactivates the active window and activates another window depending on the tab order. This seems wrong since clicking the "x" on an inactive window does not MDI activate that window (which happens to be one of the big benefits in our system to using MDI tabs).

To see this open three documents. We are using "new tabs on the left flag". Activate the doc that goes with the right-most tab. Now hit the "x" on the middle tab. The document associated with the left-most tab activates and the active document deactivates. Since the document being closed was not active, why pick another document to activate?

I "fixed" this by getting the active window and seeing if it is the one being closed. Only if it is do I activate another document.


    CWnd* pActive = MDIGetActive();

    bool bClosingActive = false;

    if( pActive )
        if( pActive->GetSafeHwnd() == (HWND)wParam )
            bClosingActive = true;
    if( bClosingActive )
        if (m_afterCloseTabPosition == xtpWorkspaceActivateNextToClosed)
        else if (m_afterCloseTabPosition == xtpWorkspaceActivateTopmost)
        //    ActivateNextTopmostItem(FindItem((HWND)wParam));


Posted By: rdhd
Date Posted: 05 March 2018 at 4:58pm
Ignore that "//" in front of ActivateNextTopmostItem. I was experimenting with the code since we have our own logic to determine which window to activate. Any CJ change would want to keep that line!

Posted By: olebed
Date Posted: 03 April 2018 at 9:04am
Hello RDHD,

You are right, it is bug. I have added your changes to CXTPTabClientWnd::OnMDIDestroy.

Note that ActivateNextTopmostItem() call there  need for handling case when used several tab groups. Related bug could be reproduce without this line as described below:

- Launch GUI_VisualStudio sample
- Open 5 new documents
- Drag Untitled6 to a new horizontal tabgroup
- Open 4 more documents in that new group
- Select Untitled9
- Select Untitled4
- Click on close button of Untitled9
- Now Untitled8 (tab) is selected, but view is Untitled10 - after clicking in the bottom view tab Untitled10 gets selected ok

 Oleksandr Lebed

Print Page | Close Window