Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - BackstageView & CommandUpdate Mechanism
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

BackstageView & CommandUpdate Mechanism

 Post Reply Post Reply
Author
Message
MGebler View Drop Down
Groupie
Groupie


Joined: 18 May 2006
Location: Germany
Status: Offline
Points: 64
Post Options Post Options   Thanks (0) Thanks(0)   Quote MGebler Quote  Post ReplyReply Direct Link To This Post Topic: BackstageView & CommandUpdate Mechanism
    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


Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
MGebler View Drop Down
Groupie
Groupie


Joined: 18 May 2006
Location: Germany
Status: Offline
Points: 64
Post Options Post Options   Thanks (0) Thanks(0)   Quote MGebler Quote  Post ReplyReply Direct Link To This Post Posted: 28 February 2011 at 4:13am
Are there any plans to implement this feature?
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 28 February 2011 at 5:55am
yes, already done for 15.0.2
Thanks for these points
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
cpede View Drop Down
Senior Member
Senior Member


Joined: 13 August 2004
Location: Denmark
Status: Offline
Points: 645
Post Options Post Options   Thanks (0) Thanks(0)   Quote cpede Quote  Post ReplyReply Direct Link To This Post 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++)
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 29 March 2011 at 8:15am
What not working ?
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
cpede View Drop Down
Senior Member
Senior Member


Joined: 13 August 2004
Location: Denmark
Status: Offline
Points: 645
Post Options Post Options   Thanks (0) Thanks(0)   Quote cpede Quote  Post ReplyReply Direct Link To This Post 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++)
Back to Top
MGebler View Drop Down
Groupie
Groupie


Joined: 18 May 2006
Location: Germany
Status: Offline
Points: 64
Post Options Post Options   Thanks (0) Thanks(0)   Quote MGebler Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
leeyn View Drop Down
Newbie
Newbie


Joined: 18 March 2011
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote leeyn Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
MGebler View Drop Down
Groupie
Groupie


Joined: 18 May 2006
Location: Germany
Status: Offline
Points: 64
Post Options Post Options   Thanks (0) Thanks(0)   Quote MGebler Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 21 April 2011 at 5:27am
Thanks, we will add something like it also.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
cpede View Drop Down
Senior Member
Senior Member


Joined: 13 August 2004
Location: Denmark
Status: Offline
Points: 645
Post Options Post Options   Thanks (1) Thanks(1)   Quote cpede Quote  Post ReplyReply Direct Link To This Post 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++)
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: 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
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.