Print Page | Close Window

BackstageView & CommandUpdate Mechanism

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=17955
Printed Date: 03 May 2024 at 8:23pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: BackstageView & CommandUpdate Mechanism
Posted By: MGebler
Subject: BackstageView & CommandUpdate Mechanism
Date Posted: 24 February 2011 at 2:24pm
Is it possible to use the 'MFC Updating Command Mechanism' (ON_UPDATE_COMMAND_UI) for the commands and tabs, which were added by the AddCommand and AddTab methods?
 
A quick look inside the CXTPRibbonBackstageView implementation shows up that this general feature is not supported.

Even a hard coded version does not work:

            CXTPControl* p = pView->AddCommand(ID_FILE_SAVE);
            p->SetEnabled( FALSE );

Am I wrong or was this feature simple forgotten?

Thanks





Replies:
Posted By: Oleg
Date Posted: 25 February 2011 at 8:37am
Hi,

yes, Update handler and Enabled property is not implemented for Backstage  buttons.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: MGebler
Date Posted: 28 February 2011 at 4:13am
Are there any plans to implement this feature?


Posted By: Oleg
Date Posted: 28 February 2011 at 5:55am
yes, already done for 15.0.2
Thanks for these points


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: cpede
Date Posted: 28 March 2011 at 9:03am
Hi Oleg,
 
Could you please provide a small code example. If I assign a button to a command id handled by the normal command routing, it is not working?
 
-cpede


-------------
Product: Xtreme ToolkitPro (20.3.0)
Platform: Windows 10 (x64)
Language: Visual Studio 2017 (C++)


Posted By: Oleg
Date Posted: 29 March 2011 at 8:15am
What not working ?

-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: cpede
Date Posted: 29 March 2011 at 8:27am
If I add the ID of an existing control to a backstage button, it does not automatically use the command routing already existing. Enabling and disabling the control etc.
 
If I add a ON_UPDATE_COMMAND_UI handler to my backstage page for e.g. a button, it is not called.
 
-cpede


-------------
Product: Xtreme ToolkitPro (20.3.0)
Platform: Windows 10 (x64)
Language: Visual Studio 2017 (C++)


Posted By: MGebler
Date Posted: 29 March 2011 at 8:28am
If you implement the command handling with

BEGIN_MESSAGE_MAP(CBackstagePage, CXTPRibbonBackstagePage)
    ON_COMMAND_EX(IDC_BUTTON,OnCommand)
    ON_UPDATE_COMMAND_UI(IDC_BUTTON,OnUpdateCommand)
END_MESSAGE_MAP()


the OnCommand mechanism works fine but the update handler OnUpdateCommand is never called.

With best regards
  Marcus


Posted By: leeyn
Date Posted: 30 March 2011 at 5:40am
Originally posted by oleg oleg wrote:

yes, already done for 15.0.2
Thanks for these points

great news....Clap


Posted By: MGebler
Date Posted: 21 April 2011 at 3:59am

Another problem in paradise.

We need a trigger to determine, when a backstage page becomes active/inactive.

Although the CXTPRibbonBackstagePage inherits from CXTPResizePropertyPage the methods ‘OnSetActive’ and ‘OnKillActive’ are never called.

The approach to use the the OnShowWindow method works only for the case that the page becomes inactive.

So we patched the CXTPRibbonBackstageView::SetActiveTab method and handle the notification inside each backstage page.

if (pNewContent)
{
    pNewContent->ModifyStyle(WS_POPUP, WS_CHILD);
    pNewContent->ModifyStyleEx(0, WS_EX_CONTROLPARENT);
    pNewContent->SetParent(this);
/* *** */
    pNewContent->SendMessage( WM_NOTIFY, PSN_SETACTIVE, NULL );
/* *** */

}

if (pOldContent && pOldContent != pNewContent)
{

/* *** */

    pOldContent->SendMessage( WM_NOTIFY, PSN_KILLACTIVE, NULL );
/* *** */

    pOldContent->ShowWindow(SW_HIDE);
    pOldContent->SetParent(GetSite());
}


Is there a better solution?


With best regards

    Marcus


Posted By: Oleg
Date Posted: 21 April 2011 at 5:27am
Thanks, we will add something like it also.

-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: cpede
Date Posted: 14 September 2016 at 10:58am
In v17.2.0 you now call both OnSetActive and OnKillActive.

But you forgot to implement the return value for OnKillActive correctly. If returning FALSE I would expect that the backstage page would not close. This could be a way to prevent the page from changing if e.g. something needs to be addresses before closing. Or is there another way to prevent the page from closing?

-cpede


-------------
Product: Xtreme ToolkitPro (20.3.0)
Platform: Windows 10 (x64)
Language: Visual Studio 2017 (C++)


Posted By: olebed
Date Posted: 16 September 2016 at 2:11pm
Hello cpede,

I have added appropriate changes
void CXTPRibbonBackstageView::SetActiveTab(CXTPRibbonBackstageTab* pTab)
{
    CWnd* pOldContent = GetActiveControlPane();

    if (pOldContent && pOldContent->IsKindOf(RUNTIME_CLASS(CPropertyPage)))
    {
        if (((CPropertyPage*)pOldContent)->OnKillActive() == FALSE)
            return;
    }

    m_pActiveTab = pTab;

    CWnd* pNewContent = GetActiveControlPane();

    if (pNewContent)
    {
        pNewContent->ModifyStyle(WS_POPUP, WS_CHILD);
        pNewContent->ModifyStyleEx(0, WS_EX_CONTROLPARENT);
        pNewContent->SetParent(this);
    }

    if (pOldContent && pOldContent != pNewContent)
    {
        pOldContent->ShowWindow(SW_HIDE);
        pOldContent->SetParent(GetSite());
    }

    if (m_pActiveTab)
    {
        m_pActiveTab->NotifySite(XTP_BS_TABCHANGED);
    }

    if (pNewContent && pNewContent->IsKindOf(RUNTIME_CLASS(CPropertyPage)))
    {
        ((CPropertyPage*)pNewContent)->OnSetActive();
    }

    RecalcLayout();
}


Thank you to bringing this to our attention.
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