Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - [solved] CXTPTabClientWnd::OnMDIDestroy bug?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

[solved] CXTPTabClientWnd::OnMDIDestroy bug?

 Post Reply Post Reply
Author
Message
rdhd View Drop Down
Senior Member
Senior Member
Avatar

Joined: 13 August 2007
Location: United States
Status: Offline
Points: 605
Post Options Post Options   Thanks (2) Thanks(2)   Quote rdhd Quote  Post ReplyReply Direct Link To This Post Topic: [solved] CXTPTabClientWnd::OnMDIDestroy bug?
    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));
    }

...
Back to Top
rdhd View Drop Down
Senior Member
Senior Member
Avatar

Joined: 13 August 2007
Location: United States
Status: Offline
Points: 605
Post Options Post Options   Thanks (0) Thanks(0)   Quote rdhd Quote  Post ReplyReply Direct Link To This Post 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!
Back to Top
olebed View Drop Down
Admin Group
Admin Group
Avatar

Joined: 01 July 2014
Location: Ukraine
Status: Offline
Points: 831
Post Options Post Options   Thanks (0) Thanks(0)   Quote olebed Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down



This page was generated in 0.109 seconds.