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
URL: http://forum.codejock.com/forum_posts.asp?TID=23594
Printed Date: 28 March 2024 at 6:11am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


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)
            ActivateNextItem(FindItem((HWND)wParam));
        else if (m_afterCloseTabPosition == xtpWorkspaceActivateTopmost)
        //    ActivateNextTopmostItem(FindItem((HWND)wParam));
    }

...



Replies:
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

Regards,
 Oleksandr Lebed



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