Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - How to get event that selected tab is change
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

How to get event that selected tab is change

 Post Reply Post Reply
Author
Message
hiro-ta View Drop Down
Groupie
Groupie


Joined: 11 July 2013
Status: Offline
Points: 61
Post Options Post Options   Thanks (0) Thanks(0)   Quote hiro-ta Quote  Post ReplyReply Direct Link To This Post Topic: How to get event that selected tab is change
    Posted: 28 November 2016 at 1:13am
Hi,

Please teach me how to get event that current ribbon tab is changed.
Back to Top
olebed View Drop Down
Admin Group
Admin Group


Joined: 01 July 2014
Location: Ukraine
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote olebed Quote  Post ReplyReply Direct Link To This Post Posted: 29 November 2016 at 8:49am
Hello,

See our RibbonSample  Samples\Ribbon\RibbonSample\MainFrm.cpp
BEGIN_MESSAGE_MAP(CMainFrame, CXTPFrameWnd)
    ....
    ON_NOTIFY(TCN_SELCHANGE, XTP_ID_RIBBONCONTROLTAB, OnRibbonTabChanged)
    ON_NOTIFY(TCN_SELCHANGING, XTP_ID_RIBBONCONTROLTAB, OnRibbonTabChanging)
    ....
END_MESSAGE_MAP()

void CMainFrame::OnRibbonTabChanged(NMHDR* pNMHDR, LRESULT* pRes) 
{
    NMXTPTABCHANGE* pNMTabChanged = (NMXTPTABCHANGE*)pNMHDR;

    if (pNMTabChanged->pTab)
    {
        TRACE(_T("Tab Changed, Caption = %s\n"), (LPCTSTR)pNMTabChanged->pTab->GetCaption());
    }
    
    *pRes = 0;
}

void CMainFrame::OnRibbonTabChanging(NMHDR* /*pNMHDR*/, LRESULT* pRes) 
{

    *pRes = 0;    
}

Code which handle these messages is
BOOL CXTPRibbonBar::OnTabChanging(CXTPRibbonTab* pTab)
{
    NMXTPTABCHANGE nm;
    nm.pTab = pTab;

    return (BOOL)m_pControlTab->NotifySite(TCN_SELCHANGING, &nm);
}

void CXTPRibbonBar::OnTabChanged(CXTPRibbonTab* pTab)
{
    NMXTPTABCHANGE nm;
    nm.pTab = pTab;

    m_pControlTab->NotifySite(TCN_SELCHANGE, &nm);
}

Regards,
 Oleksandr Lebed
Back to Top
hiro-ta View Drop Down
Groupie
Groupie


Joined: 11 July 2013
Status: Offline
Points: 61
Post Options Post Options   Thanks (0) Thanks(0)   Quote hiro-ta Quote  Post ReplyReply Direct Link To This Post Posted: 30 November 2016 at 5:34am
Thanks.

But not get the event that [File] tab is selected.
Is there a way?
Back to Top
olebed View Drop Down
Admin Group
Admin Group


Joined: 01 July 2014
Location: Ukraine
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote olebed Quote  Post ReplyReply Direct Link To This Post Posted: 30 November 2016 at 8:05am
[File] is not ribbon's tab, it is "systemButton"  which call BackStage.

I can't find how catch that event, but can offer to handle message of changing backstage tab, which also raised when backstage became visible.
BEGIN_MESSAGE_MAP(CMainFrame, CXTPFrameWnd)
    ...
    ON_MESSAGE(WM_XTP_COMMAND, OnBackstageTabChanged)
END_MESSAGE_MAP()

LRESULT CMainFrame::OnBackstageTabChanged(WPARAM wParam, LPARAM lParam)
{
    UNUSED_ALWAYS(wParam);

    NMXTPCONTROL* tagNMCONTROL = (NMXTPCONTROL*)lParam;
    if (tagNMCONTROL && tagNMCONTROL->hdr.code == XTP_BS_TABCHANGED)
    {
        CXTPRibbonBackstageTab* pNewTab = DYNAMIC_DOWNCAST(CXTPRibbonBackstageTab, tagNMCONTROL->pControl);
    }

    return 0;
}
Back to Top
hiro-ta View Drop Down
Groupie
Groupie


Joined: 11 July 2013
Status: Offline
Points: 61
Post Options Post Options   Thanks (0) Thanks(0)   Quote hiro-ta Quote  Post ReplyReply Direct Link To This Post Posted: 30 November 2016 at 8:47pm
Hi, 
Thank you for your response. It works well.
Problem solved.
Back to Top
olebed View Drop Down
Admin Group
Admin Group


Joined: 01 July 2014
Location: Ukraine
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote olebed Quote  Post ReplyReply Direct Link To This Post Posted: 01 December 2016 at 6:12am
I have tested and unfortunately found that CMainFrame::OnBackstageTabChanged() isn't raised when backstage have only commands, without tabs.
Take this into account.
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.156 seconds.