Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » Drop-downs with image have problems Collapse All
Subject Author Date
Robert Webb Sep 11, 2008 - 1:03 AM

When I create a split drop-down item in the ribbon bar (__ECTN_TBB_SEPARATED_DROPDOWN) and put icons beside the items on the drop-down, the text for the parent button no longer appears.



Also, I’m playing with the __ECTN_TBB_AUTOCHANGE_ID property, and need a few things it can’t do:



1 - I’d like the tip to also be inherited from the chosen drop-down item.



2 - I’d like to put CExtRibbonNode items in the drop-down, rather than just CExtCustomizeCmdTreeNode.  The latter can only provide an icon in one size.  It would make more sense to use CExtRibbonNodes which have two icon sizes, which could both be inherited by the main button when an item is selected.  That way the button can be resized and make use of the two icons.  Currently if I try this, the menu looks fine, but the parent button shows no icon nor text!



I attach a test program below.  These files replace the matching ones from the RibbonBarMDI sample code.  See the start of MainFrm.cpp for an explanation, and change the TEST_NUMBER #define to try the different test cases.



So let me know what you think of the three main points ASAP:



1 - Can the missing button text be fixed?

2 - Can tips be inherited along with the icon/text?

3 - Is there a way to make it work with CExtRibbonNodes on the drop-down?



Thanks,

Rob.


Sorry, can’t see a way to attach a file, so I’ll have to paste them below.  There’s two: MainFrm.h and MainFrm.cpp:


========== MainFrm.h ==================


// MainFrm.h : interface of the CMainFrame class

//

/////////////////////////////////////////////////////////////////////////////



#if !defined(AFX_MAINFRM_H__8AD8EDA0_FE43_4657_B159_597A63DD8A98__INCLUDED_)

#define AFX_MAINFRM_H__8AD8EDA0_FE43_4657_B159_597A63DD8A98__INCLUDED_



#if _MSC_VER > 1000

#pragma once

#endif // _MSC_VER > 1000



#define ID_RIBBON_PAGE_CLIPBOARD                                      9000

#define ID_RIBBON_PAGE_FONT                                           9001

#define ID_RIBBON_PAGE_PARAGRAPH                                      9002

#define ID_MAILINGS_RULES                                             9003

#define ID_MAILINGS_GOTO_RECORD                                       9004

#define ID_TRANSLATION_TOOL_TIP                                       9005

#define ID_SHOW_HIDE_RULER                                            9006

#define ID_SHOW_HIDE_GRIDLINES                                        9007

#define ID_SHOW_HIDE_PROPERTIES                                       9008

#define ID_SHOW_HIDE_DOCUMENT_MAP                                     9009

#define ID_SHOW_HIDE_THUMBNAILS                                       9010

#define ID_SHOW_HIDE_DOCUMENT_ACTION_BAR                              9011

#define ID_RIBBON_PAGE_STYLE                                          9012

#define ID_RIBBON_PAGE_INSERT_PAGES                                   9013

#define ID_RIBBON_PAGE_INSERT_TABLE                                   9014

#define ID_RIBBON_PAGE_INSERT_ILLUSTRATIONS                           9015

#define ID_RIBBON_PAGE_INSERT_LINKS                                   9016

#define ID_RIBBON_PAGE_INSERT_HEADER_AND_FOOTER                       9017

#define ID_RIBBON_PAGE_INSERT_TEXT                                    9018

#define ID_RIBBON_PAGE_INSERT_SYMBOLS                                 9019

#define ID_RIBBON_PAGE_PL_THEMES                                      9020

#define ID_RIBBON_PAGE_PL_PAGE_SETUP                                  9021

#define ID_RIBBON_PAGE_PL_PAGE_BACKGROUND                             9022

#define ID_RIBBON_PAGE_PL_PARAGRAPH                                   9023

#define ID_RIBBON_PAGE_PL_ARRANGE                                     9024

#define ID_RIBBON_PAGE_REF_TOC                                        9025

#define ID_RIBBON_PAGE_REF_FOOTNOTES                                  9026

#define ID_RIBBON_PAGE_REF_CB                                         9027

#define ID_RIBBON_PAGE_REF_CAPTIONS                                   9028

#define ID_RIBBON_PAGE_REF_INDEX                                      9029

#define ID_RIBBON_PAGE_REF_TOA                                        9030

#define ID_RIBBON_PAGE_MAIL_CREATE                                    9031

#define ID_RIBBON_PAGE_MAIL_SMM                                       9032

#define ID_RIBBON_PAGE_MAIL_WIF                                       9033

#define ID_RIBBON_PAGE_MAIL_PREVIEW_RESULTS                           9034

#define ID_RIBBON_PAGE_MAIL_FINISH                                    9035

#define ID_RIBBON_PAGE_REVIEW_PROOFING                                9036

#define ID_RIBBON_PAGE_REVIEW_COMMENTS                                9037

#define ID_RIBBON_PAGE_REVIEW_TRACKING                                9038

#define ID_RIBBON_PAGE_REVIEW_CHANGES                                 9039

#define ID_RIBBON_PAGE_REVIEW_COMPARE                                 9040

#define ID_RIBBON_PAGE_REVIEW_PROTECT                                 9041

#define ID_RIBBON_PAGE_VIEW_DV                                        9042

#define ID_RIBBON_PAGE_VIEW_SHOW_HIDE                                 9043

#define ID_RIBBON_PAGE_VIEW_ZOOM                                      9044

#define ID_RIBBON_PAGE_VIEW_WINDOW                                    9044

#define ID_FB_FINISH_RESTRICT_PERMISSION_UNRESTRICTED_ACCESS          9044

#define ID_FB_FINISH_RESTRICT_PERMISSION_DO_NOT_DISTRIBUTE            9045

#define ID_FB_FINISH_RESTRICT_PERMISSION_AS                           9046

#define ID_SAVE_SELECTION_AS_NEW_QUICK_STYLE                          9047

#define ID_CLEAR_FORMATTING                                           9048

#define ID_APPLY_STYLES                                               9049

#define ID_FONT_MORE_UNDERLINES                                       9050

#define ID_FONT_CASE_SENTENCE                                         9051

#define ID_FONT_CASE_LOWER                                            9052

#define ID_FONT_CASE_UPPPER                                           9053

#define ID_FONT_CASE_CAPITALIZE_EACH_WORD                             9054

#define ID_FONT_CASE_TOGGLE                                           9055

#define ID_EDIT_PASTE_AS_HYPERLINK                                    9056

#define ID_PARAGRAPH_LINE_SPACING_10                                  9057

#define ID_PARAGRAPH_LINE_SPACING_15                                  9058

#define ID_PARAGRAPH_LINE_SPACING_20                                  9059

#define ID_PARAGRAPH_LINE_SPACING_25                                  9060

#define ID_PARAGRAPH_LINE_SPACING_30                                  9061

#define ID_PARAGRAPH_LINE_SPACING_MORE                                9062

#define ID_PARAGRAPH_LINE_SPACING_SPACE_BEFORE                        9063

#define ID_PARAGRAPH_LINE_SPACING_NO_SPACE_AFTER                      9064

#define ID_DEFINE_NEW_BULLET                                          9065

#define ID_DEFINE_NEW_MULTILEVEL_LIST                                 9066

#define ID_DEFINE_NEW_LIST_STYLE                                      9067

#define ID_SE_FONT_LIST                                               9068

#define ID_SE_SIZE                                                    9069

#define ID_RTL                                                        9070

#define ID_RIBBON_PAGE_TEST                                           9071



#include "ChildView.h"



#if !defined(__EXT_TEMPL_H)

    #include <ExtTempl.h>

#endif



#define ID_WINDOWS_LIST ID_WINDOW_SWITCH_LARGE



/////////////////////////////////////////////////////////////////////////////

// CMyUserDefinedRibbonOptionsPage



class CMyUserDefinedRibbonOptionsPage : public CExtRibbonOptionsPage

{

public:

    DECLARE_DYNCREATE( CMyUserDefinedRibbonOptionsPage );



    CMyUserDefinedRibbonOptionsPage();

    virtual ~CMyUserDefinedRibbonOptionsPage();

    virtual UINT RibbonOptionsPage_GetID() const;

    virtual bool RibbonOptionsPage_InitContent();

    virtual void RibbonOptionsPage_Apply();

    virtual void RibbonOptionsPage_Cancel();



// Attributes

public:

// Dialog Data

    //{{AFX_DATA(CMyUserDefinedRibbonOptionsPage)

    CExtLabel m_label;

    //}}AFX_DATA



// Implementation

protected:

    //{{AFX_VIRTUAL(CExtRibbonBar)

protected:

    virtual void DoDataExchange(CDataExchange* pDX);

    virtual BOOL OnInitDialog();

    //}}AFX_VIRTUAL



protected:

    // Generated message map functions

    //{{AFX_MSG(CMyUserDefinedRibbonOptionsPage)

    //}}AFX_MSG

    DECLARE_MESSAGE_MAP()

}; // class CMyUserDefinedRibbonOptionsPage



/////////////////////////////////////////////////////////////////////////////

// CMyRibbonBar



#define __SO_FONT_SIZE_MIN    4.0f

#define __SO_FONT_SIZE_MAX    200.f



class CMyRibbonBar : public CExtRibbonBar

{

public:

    HICON m_hIconPara, m_hIconFontTT, m_hIconFontPix;

    CString m_sDecimalSeparator, m_sCurrentFontFaceName;

    float m_lfCurrentFontSize;



    COLORREF m_clrFontColor;

    COLORREF m_clrTextHighlightColor;



    CMyRibbonBar();

    virtual ~CMyRibbonBar();



    virtual void OnRibbonGalleryInitContent(

        CExtRibbonGalleryWnd & wndRG,

        CExtRibbonGalleryPopupMenuWnd * pGalleryPopup,

        CExtRibbonButtonGallery * pRibbonGalleryTBB

        );

    virtual void OnRibbonOptionsDialogInitPageRTCs(

        CExtRibbonOptionsDialog & dlgRibbonOptions

        );



    virtual bool OnPopupListBoxGetStyles(

        CExtBarButton * pTBB,

        CExtCustomizeCmdTreeNode * pNode,

        DWORD & dwListBoxStyles

        ) const;

    virtual bool OnPopupListBoxInitContent(

        CExtBarButton * pTBB,

        CExtCustomizeCmdTreeNode * pNode,

        CListBox & wndListBox

        );

    virtual CSize OnPopupListBoxMeasureTrackSize(

        const CExtBarButton * pTBB,

        const CExtCustomizeCmdTreeNode * pNode

        ) const;

    virtual bool OnPopupListBoxItemDraw(

        CExtBarButton * pTBB,

        CExtCustomizeCmdTreeNode * pNode,

        CListBox & wndListBox,

        LPDRAWITEMSTRUCT pDIS

        );

    virtual bool OnPopupListBoxItemMeasure(

        CExtBarButton * pTBB,

        CExtCustomizeCmdTreeNode * pNode,

        CListBox & wndListBox,

        LPMEASUREITEMSTRUCT pMIS

        );

    static int CALLBACK stat_FillFontListBoxProc(

        ENUMLOGFONTEX * pEnumLogFontEx,

        NEWTEXTMETRICEX * pNewTextMetriCEx,

        int nFontType,

        CListBox * pListBox

        );

    virtual bool OnTextFieldVerify(

        CExtBarTextFieldButton * pTextFieldTBB,

        CExtCustomizeCmdTreeNode * pNode,

        __EXT_MFC_SAFE_LPCTSTR sTextOld,

        __EXT_MFC_SAFE_LPCTSTR sTextNew

        );

    virtual void OnTextFieldInplaceTextGet(

        const CExtBarTextFieldButton * pTextFieldTBB,

        const CExtCustomizeCmdTreeNode * pNode,

        CExtSafeString & sTextFieldBuffer

        );

    virtual void OnTextFieldInplaceTextSet(

        CExtBarTextFieldButton * pTextFieldTBB,

        CExtCustomizeCmdTreeNode * pNode,

        CExtSafeString & sTextFieldBuffer,

        __EXT_MFC_SAFE_LPCTSTR sTextNew

        );



    virtual bool OnColorItemValueGet(

        CExtBarColorButton * pTBB,

        CExtCustomizeCmdTreeNode * pNode,

        COLORREF & clr,

        bool bSelected

        );

    virtual bool OnColorItemValueSet(

        CExtBarColorButton * pTBB,

        CExtCustomizeCmdTreeNode * pNode,

        COLORREF & clr,

        bool bSelected

        );

    virtual bool OnColorItemCustom(

        CExtCustomizeCmdTreeNode * pNode

        );

};



/////////////////////////////////////////////////////////////////////////////

// CMainFrame



class CMainFrame : public CExtNCW < CMDIFrameWnd >

{

public:

    CMainFrame();

protected:

    DECLARE_DYNAMIC(CMainFrame)



// Attributes

public:



#ifndef __EXT_MFC_NO_MDI_WINDOWS_LIST_DIALOG   

   

    class CMyMdiWindowsListDlg : public CExtMdiWindowsListDlg

    {

    public:

        CMyMdiWindowsListDlg(

                CMDIFrameWnd * pMDIFrameWnd,

                CWnd * pParent = NULL

                )

            : CExtMdiWindowsListDlg(

                pMDIFrameWnd,

                pParent

                )

        {

        }

        CMyMdiWindowsListDlg(

                HWND hMDIFrameWnd,

                CWnd * pParent = NULL

                )

            : CExtMdiWindowsListDlg(

                hMDIFrameWnd,

                pParent

                )

        {

        }

    protected:

        virtual void OnUpdateButtons()

        {

            CExtMdiWindowsListDlg::OnUpdateButtons();

            m_btnSave.ShowWindow(SW_HIDE);

        }

    }; // class CMyMdiWindowsListDlg : public CExtMdiWindowsListDlg

   

#endif // #ifndef __EXT_MFC_NO_MDI_WINDOWS_LIST_DIALOG   



private:

    // window placement persistence

    WINDOWPLACEMENT m_dataFrameWP;



// Operations

public:



// Overrides

    // ClassWizard generated virtual function overrides

    //{{AFX_VIRTUAL(CMainFrame)

    public:

    virtual BOOL PreCreateWindow(CREATESTRUCT& cs);

    virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo);

    virtual BOOL PreTranslateMessage(MSG* pMsg);

    virtual BOOL DestroyWindow();

    virtual void ActivateFrame(int nCmdShow = -1);

    //}}AFX_VIRTUAL



// Implementation

public:

    virtual ~CMainFrame();

    virtual void RecalcLayout(BOOL bNotify = TRUE);

#ifdef _DEBUG

    virtual void AssertValid() const;

    virtual void Dump(CDumpContext& dc) const;

#endif



    class CMDITabs : public CExtTabMdiWnd

    {

    protected:

        bool OnHookWndMsg( LRESULT & lResult, HWND hWndHooked, UINT nMessage, WPARAM & wParam, LPARAM & lParam )

        {

            __PROF_UIS_MANAGE_STATE;

            if( hWndHooked == _GetHwndMdiArea() )

            {

                switch( nMessage )

                {

                case WM_ERASEBKGND:

                    lResult = 1L;

                    return true;

                case WM_PAINT:

                    {

                        CWnd * pWnd = CWnd::FromHandle( hWndHooked );

                        CPaintDC dc( pWnd );

                        CRect rcClient;

                        ::GetClientRect( hWndHooked, &rcClient );

                        if( ! g_PaintManager->PaintDockerBkgnd(

                                true,

                                dc,

                                pWnd

                                )

                            )

                            dc.FillSolidRect(

                                &rcClient,

                                g_PaintManager->GetColor( CExtPaintManager::CLR_3DFACE_OUT )

                                );

                    }

                    lResult = 1L;

                    return true;

                case WM_NCCALCSIZE:

                    lResult = 0L;

                    return true;

                } // switch( nMessage )

            } // if( hWndHooked == _GetHwndMdiArea() )

            return CExtTabMdiWnd::OnHookWndMsg( lResult, hWndHooked, nMessage, wParam, lParam );

        }

    };



protected:  // control bar embedded members

    CMyRibbonBar                      m_wndRibbonBar;

    CExtStatusControlBar              m_wndStatusBar;

//    CExtMenuControlBar                m_wndMenuBar;

    CExtToolControlBar                m_wndToolBar;

    CExtThemeSwitcherToolControlBar   m_wndToolBarUiLook;

    CExtZoomScrollBar                 m_wndZoomScrollBar;

    CMDITabs                          m_wndMdiTabs;



// Generated message map functions

protected:

    //{{AFX_MSG(CMainFrame)

    afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);

    //}}AFX_MSG

    afx_msg void OnUpdateControlBarMenu(CCmdUI* pCmdUI);

    afx_msg BOOL OnBarCheck(UINT nID);

    DECLARE_MESSAGE_MAP()



    void _AdjustRTL();



    CExtRibbonNode * m_pRibbonNode;

    void _InitRibbonBar();

    CExtRibbonNodeRightButtonsCollection * _InitRibbon_RightButtonsCollection();

    CExtRibbonNodeQuickAccessButtonsCollection * _InitRibbon_QuickAccessButtonsCollection();

    CExtRibbonNodeFile * _InitRibbon_FileMenu();



    CExtRibbonNode * _InitRibbonPage_Test();

    CExtRibbonNode * _InitRibbonNode_Test_Test();

};



/////////////////////////////////////////////////////////////////////////////



//{{AFX_INSERT_LOCATION}}

// Microsoft Visual C++ will insert additional declarations immediately before the previous line.



#endif // !defined(AFX_MAINFRM_H__8AD8EDA0_FE43_4657_B159_597A63DD8A98__INCLUDED_)


================= MainFrm.cpp ======================


// MainFrm.cpp : implementation of the CMainFrame class

//

#include "stdafx.h"



//

// The problem: text for a drop-down button disappear when the drop-down

// contains images.

//

// Try changing #define TEST_NUMBER below to one of the following numbers:

//

// 1 - No drop-down used.  Shows that without a drop-down, the icon and

// text for the button work as expected.

//

// 2 - Now button has an auto-change drop-down, and no images appear in the

// drop-down menu.  This case also works as expected, with text appearing for

// the button, and changing depending on the item selected.

//

// 3 - Shows that when the drop-down items contain icons, the button’s text is

// missing.  In this case the __ECTN_TBB_AUTOCHANGE_ID property is NOT used.

//

// 4 - Similar to 3, but with auto-change-id (__ECTN_TBB_AUTOCHANGE_ID).

// Selecting an item changes the main icon as expected, but the text which

// should also change remains blank.

//

// 5 - Like 3, but using CExtRibbonNodes as drop-down items rather than

// CExtCustomizeCmdTreeNode.  Result is that the menu itself looks fine, but

// somehow the parent button has lost both its icon AND its text.

//

// 6 - Like 4, but using CExtRibbonNodes as drop-down items rather than

// CExtCustomizeCmdTreeNode.  Result is same as case 5.  Selecting a menu item

// does not put an icon or text on the button either.

//

// Cases 5 and 6 would be ideal, since the button could then inherit its

// child’s small and large icons, to be used according to the size of the

// button at the time (CExtCustomizeCmdTreeNode only has one icon size).

// I’d like large icons on the menu, but to still allow the parent button to be

// resized as necessary.

//

// Finally, I’d like the tip text to also be transfered to the parent button

// when an item is selected.  That is, the tip for the menu item should now be

// the tip for the button (along with its icon and text).  This could be

// handled via an additional flag maybe for people who use

// __ECTN_TBB_AUTOCHANGE_ID but don’t necessarily want this behaviour.

//

// - Robert Webb

//

#define TEST_NUMBER        4

//

#if (TEST_NUMBER == 1)

//# define USE_DROP_DOWN

//# define USE_AUTO_CHANGE

//# define TRY_RIBBON_NODES_IN_MENU

//# define SHOW_ICONS_IN_MENU

#elif (TEST_NUMBER == 2)

# define USE_DROP_DOWN

# define USE_AUTO_CHANGE

//# define TRY_RIBBON_NODES_IN_MENU

//# define SHOW_ICONS_IN_MENU

#elif (TEST_NUMBER == 3)

# define USE_DROP_DOWN

//# define USE_AUTO_CHANGE

//# define TRY_RIBBON_NODES_IN_MENU

# define SHOW_ICONS_IN_MENU

#elif (TEST_NUMBER == 4)

# define USE_DROP_DOWN

# define USE_AUTO_CHANGE

//# define TRY_RIBBON_NODES_IN_MENU

# define SHOW_ICONS_IN_MENU

#elif (TEST_NUMBER == 5)

# define USE_DROP_DOWN

//# define USE_AUTO_CHANGE

# define TRY_RIBBON_NODES_IN_MENU

# define SHOW_ICONS_IN_MENU

#elif (TEST_NUMBER == 6)

# define USE_DROP_DOWN

# define USE_AUTO_CHANGE

# define TRY_RIBBON_NODES_IN_MENU

# define SHOW_ICONS_IN_MENU

#endif

#include "RibbonBarMDI.h"



#include "MainFrm.h"



#if (!defined __RibbonIcons_H)

    #include "res/RibbonIcons.h"

#endif // (!defined __RibbonIcons_H)



#ifdef _DEBUG

#define new DEBUG_NEW

#undef THIS_FILE

static char THIS_FILE[] = __FILE__;

#endif



/////////////////////////////////////////////////////////////////////////////

// CMyUserDefinedRibbonOptionsPage



IMPLEMENT_DYNCREATE( CMyUserDefinedRibbonOptionsPage, CExtRibbonOptionsPage );



CMyUserDefinedRibbonOptionsPage::CMyUserDefinedRibbonOptionsPage()

    : CExtRibbonOptionsPage( IDD_MY_USER_DEFINED_OPTIONS_PAGE )

{

    //{{AFX_DATA_INIT(CMyUserDefinedRibbonOptionsPage)

    //}}AFX_DATA_INIT

}



CMyUserDefinedRibbonOptionsPage::~CMyUserDefinedRibbonOptionsPage()

{

}



UINT CMyUserDefinedRibbonOptionsPage::RibbonOptionsPage_GetID() const

{

    ASSERT_VALID( this );

    return IDD_MY_USER_DEFINED_OPTIONS_PAGE;

}



bool CMyUserDefinedRibbonOptionsPage::RibbonOptionsPage_InitContent()

{

    ASSERT_VALID( this );

//CExtRibbonOptionsDialog * pDialogRibbonOptions =

//        RibbonOptionsPage_GetContainer();

//    if( pDialogRibbonOptions == NULL )

//        return false;

    return true;

}



void CMyUserDefinedRibbonOptionsPage::RibbonOptionsPage_Apply()

{

    ASSERT_VALID( this );

}



void CMyUserDefinedRibbonOptionsPage::RibbonOptionsPage_Cancel()

{

    ASSERT_VALID( this );

}



void CMyUserDefinedRibbonOptionsPage::DoDataExchange(CDataExchange* pDX)

{

    CExtRibbonOptionsPage::DoDataExchange(pDX);

    //{{AFX_DATA_MAP(CMyUserDefinedRibbonOptionsPage)

    DDX_Control( pDX, IDC_MY_STATIC, m_label );

    //}}AFX_DATA_MAP

}



BEGIN_MESSAGE_MAP( CMyUserDefinedRibbonOptionsPage, CExtRibbonOptionsPage )

    //{{AFX_MSG_MAP(CMyUserDefinedRibbonOptionsPage)

    //}}AFX_MSG_MAP

END_MESSAGE_MAP()



BOOL CMyUserDefinedRibbonOptionsPage::OnInitDialog()

{

    if( ! CExtRibbonOptionsPage::OnInitDialog() )

    {

        ASSERT( FALSE );

        return FALSE;

    }

    m_label.SetBkColor( m_clrPageBkgnd );

    m_label.SetTextColor( true, m_clrPageText );

    return TRUE;

}



/////////////////////////////////////////////////////////////////////////////

// CMyRibbonBar



CMyRibbonBar::CMyRibbonBar()

{

    ::GetLocaleInfo(

        ::GetSystemDefaultLCID(),

        LOCALE_SDECIMAL,

        m_sDecimalSeparator.GetBuffer( 64 ),

        63

        );

    m_sDecimalSeparator.ReleaseBuffer();

    m_sDecimalSeparator.TrimLeft( _T(" \r\n\t") );

    m_sDecimalSeparator.TrimRight( _T(" \r\n\t") );

    if( m_sDecimalSeparator.GetLength() == 0 )

        m_sDecimalSeparator = _T(’.’);



    m_hIconFontTT = AfxGetApp()->LoadIcon(IDI_ICON_FONT_TT);

    ASSERT( m_hIconFontTT != NULL );

    m_hIconFontPix = AfxGetApp()->LoadIcon(IDI_ICON_FONT_PIX);

    ASSERT( m_hIconFontPix != NULL );



    m_sCurrentFontFaceName = _T("Arial");

    m_lfCurrentFontSize = 12.0f;



    m_clrFontColor = RGB(255,0,0);

    m_clrTextHighlightColor = RGB(255,255,0);

}



CMyRibbonBar::~CMyRibbonBar()

{

    ::DestroyIcon( m_hIconFontTT );

    ::DestroyIcon( m_hIconFontPix );

}



int CALLBACK CMyRibbonBar::stat_FillFontListBoxProc(

    ENUMLOGFONTEX * pEnumLogFontEx,

    NEWTEXTMETRICEX * pNewTextMetriCEx,

    int nFontType,

    CListBox * pListBox

    )

{

    pNewTextMetriCEx;

    nFontType;

bool bAt =

        ( pEnumLogFontEx->elfLogFont.lfFaceName[0] == _T(’@’) )

            ? true : false;

    if( bAt )

        return 1; // current version hides tool fonts

LPCTSTR sFaceName =

        bAt

            ? ((LPCTSTR)&(pEnumLogFontEx->elfLogFont.lfFaceName))+1

            : pEnumLogFontEx->elfLogFont.lfFaceName

            ;

    if( pListBox->FindStringExact( 0, sFaceName ) == CB_ERR )

    {

        int nItemIdx = pListBox->AddString( sFaceName );

        DWORD dwItemData =

                ( bAt ? 1L : 0L )

            |    DWORD( pEnumLogFontEx->elfLogFont.lfPitchAndFamily ) << 1

            |    DWORD( pEnumLogFontEx->elfLogFont.lfOutPrecision ) << 9

            |    DWORD( pEnumLogFontEx->elfLogFont.lfCharSet) << 17

            ;

        pListBox->SetItemData( nItemIdx, dwItemData );

    } // if( pListBox->FindStringExact( 0, sFaceName ) == CB_ERR )

    return 1;

}



void CMyRibbonBar::OnRibbonGalleryInitContent(

    CExtRibbonGalleryWnd & wndRG,

    CExtRibbonGalleryPopupMenuWnd * pGalleryPopup,

    CExtRibbonButtonGallery * pRibbonGalleryTBB

    )

{

    ASSERT_VALID( this );

    ASSERT( GetSafeHwnd() != NULL );

    ASSERT_VALID( (&wndRG) );

    ASSERT( wndRG.GetSafeHwnd() != NULL );

#ifdef _DEBUG

    if( pGalleryPopup != NULL )

    {

        ASSERT_VALID( pGalleryPopup );

        ASSERT( pGalleryPopup->GetSafeHwnd() != NULL );

    }

#endif // _DEBUG

UINT nCmdID = 0;

    if( pRibbonGalleryTBB != NULL )

    {

        ASSERT_VALID( pRibbonGalleryTBB );

        nCmdID = pRibbonGalleryTBB->GetCmdID();

    } // if( pRibbonGalleryTBB != NULL )

    else

    {

        ASSERT( pGalleryPopup != NULL );

        CExtCustomizeCmdTreeNode * pNode = pGalleryPopup->_CmdNodeGet();

        ASSERT_VALID( pNode );

        nCmdID = pNode->GetCmdID();

    }

    switch( nCmdID )

    {

    case ID_QUICK_STYLES_BIG:

        {

            wndRG.ModifyToolBoxWndStyle( __TBWS_ZERO_HEIGHT_CAPTIONS );

            CExtToolBoxWnd::TOOLBOX_ITEM_DATA * pTBCI_GalleryGroup =

                wndRG.ItemInsert( NULL, _T("Gallery group"), (HICON) NULL );

            ASSERT( pTBCI_GalleryGroup != NULL );

            CExtBitmap _bmp;

            VERIFY( _bmp.LoadBMP_Resource( MAKEINTRESOURCE(ID_RIBBON_GALLERY_STYLES) ) );

            CSize _sizeBmp = _bmp.GetSize();

            static const INT nItemWidth = 64;

            CRect rcItem( 0, 0, nItemWidth, _sizeBmp.cy );

            INT nItemIndex, nItemCount = _sizeBmp.cx / nItemWidth;

            for( nItemIndex = 0; nItemIndex < nItemCount; nItemIndex++ )

            {

                CExtCmdIcon _icon;

                _icon.m_bmpNormal.FromBitmap( _bmp, &rcItem );

                rcItem.OffsetRect( nItemWidth, 0 );

                CExtSafeString str;

                str.Format( _T("Style %d"), nItemIndex + 1 );

                CExtToolBoxWnd::TOOLBOX_ITEM_DATA * pTBCI_GalleryItem =

                    wndRG.ItemInsert( pTBCI_GalleryGroup, str, &_icon );

                ASSERT( pTBCI_GalleryItem != NULL );

                if( nItemIndex == 0 )

                    pTBCI_GalleryItem->ModifyItemStyle( __TBWI_SELECTED );

            } // for( nItemIndex = 0; nItemIndex < nItemCount; nItemIndex++ )

            pTBCI_GalleryGroup->ModifyItemStyle( 0, __TBWI_LISTBOX_VIEW );

            wndRG.ItemExpand( pTBCI_GalleryGroup );

            wndRG.ItemSetActive( pTBCI_GalleryGroup );

            wndRG.UpdateToolBoxWnd( true );

        }

        break; // case ID_QUICK_STYLES_BIG

    case ID_FONT_UNDERLINE:

        {

            wndRG.ModifyToolBoxWndStyle( __TBWS_ZERO_HEIGHT_CAPTIONS );

            CExtToolBoxWnd::TOOLBOX_ITEM_DATA * pTBCI_GalleryGroup =

                wndRG.ItemInsert( NULL, _T("Gallery group"), (HICON) NULL );

            ASSERT( pTBCI_GalleryGroup != NULL );

            CExtBitmap _bmp;

            VERIFY( _bmp.LoadBMP_Resource( MAKEINTRESOURCE(ID_RIBBON_GALLERY_UNDERLINES) ) );

            CSize _sizeBmp = _bmp.GetSize();

            static const INT nItemHeight = 26;

            CRect rcItem( 0, 0, _sizeBmp.cx, nItemHeight );

            INT nItemIndex, nItemCount = _sizeBmp.cy / nItemHeight;

            for( nItemIndex = 0; nItemIndex < nItemCount; nItemIndex++ )

            {

                CExtCmdIcon _icon;

                _icon.m_bmpNormal.FromBitmap( _bmp, &rcItem );

                rcItem.OffsetRect( 0, nItemHeight );

                CExtSafeString str;

                str.Format( _T("Underline Style %d"), nItemIndex + 1 );

                CExtToolBoxWnd::TOOLBOX_ITEM_DATA * pTBCI_GalleryItem =

                    wndRG.ItemInsert( pTBCI_GalleryGroup, str, &_icon );

                ASSERT( pTBCI_GalleryItem != NULL );

                if( nItemIndex == 0 )

                    pTBCI_GalleryItem->ModifyItemStyle( __TBWI_SELECTED );

            } // for( nItemIndex = 0; nItemIndex < nItemCount; nItemIndex++ )

            pTBCI_GalleryGroup->ModifyItemStyle( 0, __TBWI_LISTBOX_VIEW );

            wndRG.ItemExpand( pTBCI_GalleryGroup );

            wndRG.ItemSetActive( pTBCI_GalleryGroup );

            wndRG.UpdateToolBoxWnd( true );

        }

        break; // case ID_FONT_UNDERLINE

    case ID_PARAGRAPH_BULLETS:

        {

            CExtToolBoxWnd::TOOLBOX_ITEM_DATA * pTBCI_GalleryGroup0 =

                wndRG.ItemInsert( NULL, _T("Recently Used Bullets"), (HICON) NULL );

            ASSERT( pTBCI_GalleryGroup0 != NULL );

            CExtToolBoxWnd::TOOLBOX_ITEM_DATA * pTBCI_GalleryGroup1 =

                wndRG.ItemInsert( NULL, _T("Bullet Library"), (HICON) NULL );

            ASSERT( pTBCI_GalleryGroup1 != NULL );

            CExtToolBoxWnd::TOOLBOX_ITEM_DATA * pTBCI_GalleryGroup2 =

                wndRG.ItemInsert( NULL, _T("Document Bullets"), (HICON) NULL );

            ASSERT( pTBCI_GalleryGroup2 != NULL );

            CExtBitmap _bmp;

            VERIFY( _bmp.LoadBMP_Resource( MAKEINTRESOURCE(ID_RIBBON_GALLERY_BULLETS) ) );

            CSize _sizeBmp = _bmp.GetSize();

            static const INT nItemWidth = 40;

            CRect rcItem( 0, 0, nItemWidth, _sizeBmp.cy );

            INT nItemIndex, nItemCount = _sizeBmp.cx / nItemWidth;

            for( nItemIndex = 0; nItemIndex < nItemCount; nItemIndex++ )

            {

                CExtCmdIcon _icon;

                _icon.m_bmpNormal.FromBitmap( _bmp, &rcItem );

                rcItem.OffsetRect( nItemWidth, 0 );

                CExtSafeString str;

                if( nItemIndex == 0 )

                    str = _T("None");

                else

                    str.Format( _T("Bullet %d"), nItemIndex + 1 );



                CExtToolBoxWnd::TOOLBOX_ITEM_DATA * pTBCI_GalleryItem =

                    wndRG.ItemInsert( pTBCI_GalleryGroup1, str, &_icon );

                ASSERT( pTBCI_GalleryItem != NULL );

                if( nItemIndex == 0 )

                    pTBCI_GalleryItem->ModifyItemStyle( __TBWI_SELECTED );



                if( nItemIndex == 1 )

                {

                    pTBCI_GalleryItem =

                        wndRG.ItemInsert( pTBCI_GalleryGroup0, str, &_icon );

                    ASSERT( pTBCI_GalleryItem != NULL );



                    pTBCI_GalleryItem =

                        wndRG.ItemInsert( pTBCI_GalleryGroup2, str, &_icon );

                    ASSERT( pTBCI_GalleryItem != NULL );

                }

            } // for( nItemIndex = 0; nItemIndex < nItemCount; nItemIndex++ )

            pTBCI_GalleryGroup0->ModifyItemStyle( 0, __TBWI_LISTBOX_VIEW );

            pTBCI_GalleryGroup1->ModifyItemStyle( 0, __TBWI_LISTBOX_VIEW );

            pTBCI_GalleryGroup2->ModifyItemStyle( 0, __TBWI_LISTBOX_VIEW );

            wndRG.ItemExpand( pTBCI_GalleryGroup0 );

            wndRG.ItemExpand( pTBCI_GalleryGroup1 );

            wndRG.ItemExpand( pTBCI_GalleryGroup2 );

            wndRG.ItemSetActive( pTBCI_GalleryGroup1 );

            wndRG.UpdateToolBoxWnd( true );

        }

        break; // case ID_PARAGRAPH_BULLETS

    case ID_PARAGRAPH_NUMBERING:

        {

            CExtToolBoxWnd::TOOLBOX_ITEM_DATA * pTBCI_GalleryGroup0 =

                wndRG.ItemInsert( NULL, _T("Recently Used Number Formats"), (HICON) NULL );

            ASSERT( pTBCI_GalleryGroup0 != NULL );

            CExtToolBoxWnd::TOOLBOX_ITEM_DATA * pTBCI_GalleryGroup1 =

                wndRG.ItemInsert( NULL, _T("Numbering Library"), (HICON) NULL );

            ASSERT( pTBCI_GalleryGroup1 != NULL );

            CExtBitmap _bmp;

            VERIFY( _bmp.LoadBMP_Resource( MAKEINTRESOURCE(ID_RIBBON_GALLERY_NUMBERING) ) );

            CSize _sizeBmp = _bmp.GetSize();

            static const INT nItemWidth = 76;

            CRect rcItem( 0, 0, nItemWidth, _sizeBmp.cy );

            INT nItemIndex, nItemCount = _sizeBmp.cx / nItemWidth;

            for( nItemIndex = 0; nItemIndex < nItemCount; nItemIndex++ )

            {

                CExtCmdIcon _icon;

                _icon.m_bmpNormal.FromBitmap( _bmp, &rcItem );

                rcItem.OffsetRect( nItemWidth, 0 );

                CExtSafeString str;

                if( nItemIndex == 0 )

                    str = _T("None");

                else

                    str.Format( _T("Number Format %d"), nItemIndex + 1 );



                CExtToolBoxWnd::TOOLBOX_ITEM_DATA * pTBCI_GalleryItem =

                    wndRG.ItemInsert( pTBCI_GalleryGroup1, str, &_icon );

                ASSERT( pTBCI_GalleryItem != NULL );

                if( nItemIndex == 0 )

                    pTBCI_GalleryItem->ModifyItemStyle( __TBWI_SELECTED );



                if( nItemIndex == 1 )

                {

                    pTBCI_GalleryItem =

                        wndRG.ItemInsert( pTBCI_GalleryGroup0, str, &_icon );

                    ASSERT( pTBCI_GalleryItem != NULL );

                }

            } // for( nItemIndex = 0; nItemIndex < nItemCount; nItemIndex++ )

            pTBCI_GalleryGroup0->ModifyItemStyle( 0, __TBWI_LISTBOX_VIEW );

            pTBCI_GalleryGroup1->ModifyItemStyle( 0, __TBWI_LISTBOX_VIEW );

            wndRG.ItemExpand( pTBCI_GalleryGroup0 );

            wndRG.ItemExpand( pTBCI_GalleryGroup1 );

            wndRG.ItemSetActive( pTBCI_GalleryGroup1 );

            wndRG.UpdateToolBoxWnd( true );

        }

        break; // case ID_PARAGRAPH_NUMBERING

    case ID_PARAGRAPH_MULTILEVEL_LIST:

        {

            CExtToolBoxWnd::TOOLBOX_ITEM_DATA * pTBCI_GalleryGroup0 =

                wndRG.ItemInsert( NULL, _T("Current List"), (HICON) NULL );

            ASSERT( pTBCI_GalleryGroup0 != NULL );

            CExtToolBoxWnd::TOOLBOX_ITEM_DATA * pTBCI_GalleryGroup1 =

                wndRG.ItemInsert( NULL, _T("My Lists"), (HICON) NULL );

            ASSERT( pTBCI_GalleryGroup1 != NULL );

            CExtToolBoxWnd::TOOLBOX_ITEM_DATA * pTBCI_GalleryGroup2 =

                wndRG.ItemInsert( NULL, _T("Lists in Current Document"), (HICON) NULL );

            ASSERT( pTBCI_GalleryGroup2 != NULL );

            CExtBitmap _bmp;

            VERIFY( _bmp.LoadBMP_Resource( MAKEINTRESOURCE(ID_RIBBON_GALLERY_MULTILEVEL_LIST) ) );

            CSize _sizeBmp = _bmp.GetSize();

            static const INT nItemWidth = 76;

            CRect rcItem( 0, 0, nItemWidth, _sizeBmp.cy );

            INT nItemIndex, nItemCount = _sizeBmp.cx / nItemWidth;

            for( nItemIndex = 0; nItemIndex < nItemCount; nItemIndex++ )

            {

                CExtCmdIcon _icon;

                _icon.m_bmpNormal.FromBitmap( _bmp, &rcItem );

                rcItem.OffsetRect( nItemWidth, 0 );

                CExtSafeString str;

                if( nItemIndex == 0 )

                    str = _T("None");

                else

                    str.Format( _T("List Format %d"), nItemIndex + 1 );



                CExtToolBoxWnd::TOOLBOX_ITEM_DATA * pTBCI_GalleryItem =

                    wndRG.ItemInsert( pTBCI_GalleryGroup1, str, &_icon );

                ASSERT( pTBCI_GalleryItem != NULL );

                if( nItemIndex == 0 )

                    pTBCI_GalleryItem->ModifyItemStyle( __TBWI_SELECTED );



                if( nItemIndex == 1 )

                {

                    pTBCI_GalleryItem =

                        wndRG.ItemInsert( pTBCI_GalleryGroup0, str, &_icon );

                    ASSERT( pTBCI_GalleryItem != NULL );



                    pTBCI_GalleryItem =

                        wndRG.ItemInsert( pTBCI_GalleryGroup2, str, &_icon );

                    ASSERT( pTBCI_GalleryItem != NULL );

                }

            } // for( nItemIndex = 0; nItemIndex < nItemCount; nItemIndex++ )

            pTBCI_GalleryGroup0->ModifyItemStyle( 0, __TBWI_LISTBOX_VIEW );

            pTBCI_GalleryGroup1->ModifyItemStyle( 0, __TBWI_LISTBOX_VIEW );

            pTBCI_GalleryGroup2->ModifyItemStyle( 0, __TBWI_LISTBOX_VIEW );

            wndRG.ItemExpand( pTBCI_GalleryGroup0 );

            wndRG.ItemExpand( pTBCI_GalleryGroup1 );

            wndRG.ItemExpand( pTBCI_GalleryGroup2 );

            wndRG.ItemSetActive( pTBCI_GalleryGroup1 );

            wndRG.UpdateToolBoxWnd( true );

        }

        break; // case ID_PARAGRAPH_MULTILEVEL_LIST

    case ID_CHANGE_LIST_LEVEL:

        {

            wndRG.ModifyToolBoxWndStyle( __TBWS_ZERO_HEIGHT_CAPTIONS );

            CExtToolBoxWnd::TOOLBOX_ITEM_DATA * pTBCI_GalleryGroup =

                wndRG.ItemInsert( NULL, _T("Gallery group"), (HICON) NULL );

            ASSERT( pTBCI_GalleryGroup != NULL );

            CExtBitmap _bmp;

            VERIFY( _bmp.LoadBMP_Resource( MAKEINTRESOURCE(ID_RIBBON_GALLERY_CHANGE_LIST_LEVEL) ) );

            CSize _sizeBmp = _bmp.GetSize();

            static const INT nItemHeight = 30;

            CRect rcItem( 0, 0, _sizeBmp.cx, nItemHeight );

            INT nItemIndex, nItemCount = _sizeBmp.cy / nItemHeight;

            for( nItemIndex = 0; nItemIndex < nItemCount; nItemIndex++ )

            {

                CExtCmdIcon _icon;

                _icon.m_bmpNormal.FromBitmap( _bmp, &rcItem );

                rcItem.OffsetRect( 0, nItemHeight );

                CExtSafeString str;

                str.Format( _T("Level %d"), nItemIndex + 1 );

                CExtToolBoxWnd::TOOLBOX_ITEM_DATA * pTBCI_GalleryItem =

                    wndRG.ItemInsert( pTBCI_GalleryGroup, str, &_icon );

                ASSERT( pTBCI_GalleryItem != NULL );

                if( nItemIndex == 0 )

                    pTBCI_GalleryItem->ModifyItemStyle( __TBWI_SELECTED );

            } // for( nItemIndex = 0; nItemIndex < nItemCount; nItemIndex++ )

            pTBCI_GalleryGroup->ModifyItemStyle( 0, __TBWI_LISTBOX_VIEW );

            wndRG.ItemExpand( pTBCI_GalleryGroup );

            wndRG.ItemSetActive( pTBCI_GalleryGroup );

            wndRG.UpdateToolBoxWnd( true );

        }

        break; // case ID_CHANGE_LIST_LEVEL

    default:

        if( (pGalleryPopup->TrackFlagsGet()&TPMX_RIBBON_FILE_MENU) )

        {

            CExtToolBoxWnd::TOOLBOX_ITEM_DATA * pTBCI_GalleryGroup =

                wndRG.ItemInsert( NULL, _T("Recent Documents"), (HICON) NULL );

            ASSERT( pTBCI_GalleryGroup != NULL );

            INT nItemIndex, nItemCount = 5;

            for( nItemIndex = 0; nItemIndex < nItemCount; nItemIndex++ )

            {

                CExtSafeString str;

                str.Format( _T(" %d  Recent Document Name"), nItemIndex + 1 );

                CExtToolBoxWnd::TOOLBOX_ITEM_DATA * pTBCI_GalleryItem =

                    wndRG.ItemInsert( pTBCI_GalleryGroup, str, (HICON)NULL );

                ASSERT( pTBCI_GalleryItem != NULL );

                pTBCI_GalleryItem;

            } // for( nItemIndex = 0; nItemIndex < nItemCount; nItemIndex++ )

            wndRG.ItemExpand( pTBCI_GalleryGroup );

            wndRG.ItemSetActive( pTBCI_GalleryGroup );

            wndRG.UpdateToolBoxWnd( true );

        } // if( (pGalleryPopup->TrackFlagsGet()&TPMX_RIBBON_FILE_MENU) )

        break; // default

    } // switch( nCmdID )

}



void CMyRibbonBar::OnRibbonOptionsDialogInitPageRTCs(

    CExtRibbonOptionsDialog & dlgRibbonOptions

    )

{

    ASSERT_VALID( this );

    CExtRibbonBar::OnRibbonOptionsDialogInitPageRTCs( dlgRibbonOptions );

    dlgRibbonOptions.m_arrPageRTCs.Add(

        RUNTIME_CLASS( CMyUserDefinedRibbonOptionsPage )

        );

}



bool CMyRibbonBar::OnColorItemValueGet(

    CExtBarColorButton * pTBB,

    CExtCustomizeCmdTreeNode * pNode,

    COLORREF & clr,

    bool bSelected

    )

{

    ASSERT_VALID( this );

    ASSERT_VALID( pNode );

CExtRibbonPage * pRibbonPage = GetMainRibbonPage();

    if( pRibbonPage == NULL )

    {

        UINT nCmdID = pNode->GetCmdID(false);

        switch( nCmdID )

        {

        case ID_FONT_CHAR_COLOR:

            if( bSelected )

                clr = m_clrFontColor;

            else

                clr = RGB(255,0,0);

            break;

        case ID_FONT_TEXT_HIGHLIGHT_COLOR:

            if( bSelected )

                clr = m_clrTextHighlightColor;

            else

                clr = RGB(255,255,0);

            break;

        default:

            return

                CExtRibbonBar::OnColorItemValueGet(

                    pTBB,

                    pNode,

                    clr,

                    bSelected

                    );

        }

        return true;

    }

    else

        return

            pRibbonPage->OnColorItemValueGet(

                pTBB,

                pNode,

                clr,

                bSelected

                );

}



bool CMyRibbonBar::OnColorItemValueSet(

    CExtBarColorButton * pTBB,

    CExtCustomizeCmdTreeNode * pNode,

    COLORREF & clr,

    bool bSelected

    )

{

    ASSERT_VALID( this );

    ASSERT_VALID( pNode );

CExtRibbonPage * pRibbonPage = GetMainRibbonPage();

    if( pRibbonPage == NULL )

    {

        UINT nCmdID = pNode->GetCmdID(false);

        switch( nCmdID )

        {

        case ID_FONT_CHAR_COLOR:

            if( clr == COLORREF(-1L) )

                m_clrFontColor = RGB(255,0,0);

            else

                m_clrFontColor = clr;

            break;

        case ID_FONT_TEXT_HIGHLIGHT_COLOR:

            if( clr == COLORREF(-1L) )

                m_clrTextHighlightColor = RGB(255,255,0);

            else

                m_clrTextHighlightColor = clr;

            break;

        default:

            return

                CExtRibbonBar::OnColorItemValueSet(

                    pTBB,

                    pNode,

                    clr,

                    bSelected

                    );

        }

        CExtRibbonBar::RedrawCommandItems( nCmdID );

        return true;

    }

    else

        return

            pRibbonPage->OnColorItemValueSet(

                pTBB,

                pNode,

                clr,

                bSelected

                );

}



bool CMyRibbonBar::OnColorItemCustom(

    CExtCustomizeCmdTreeNode * pNode

    )

{

    ASSERT_VALID( this );

    ASSERT_VALID( pNode );

CExtRibbonPage * pRibbonPage = GetMainRibbonPage();

    if( pRibbonPage == NULL )

    {

        CExtColorDlg dlg;

        UINT nCmdID = pNode->GetCmdID(false);

        switch( nCmdID )

        {

        case ID_FONT_CHAR_COLOR:

            dlg.m_clrInit = dlg.m_clrNew = m_clrFontColor;

            break;

        case ID_FONT_TEXT_HIGHLIGHT_COLOR:

            dlg.m_clrInit = dlg.m_clrNew = m_clrTextHighlightColor;

            break;

        default:

            return CExtRibbonBar::OnColorItemCustom( pNode );

        }

        if( dlg.DoModal() != IDOK )

            return false;

        switch( nCmdID )

        {

        case ID_FONT_CHAR_COLOR:

            m_clrFontColor = dlg.m_clrNew;

            break;

        case ID_FONT_TEXT_HIGHLIGHT_COLOR:

            m_clrTextHighlightColor = dlg.m_clrNew;

            break;

        }

        CExtRibbonBar::RedrawCommandItems( nCmdID );

        return true;

    }

    else

        return pRibbonPage->OnColorItemCustom( pNode );

}



bool CMyRibbonBar::OnPopupListBoxGetStyles(

    CExtBarButton * pTBB,

    CExtCustomizeCmdTreeNode * pNode,

    DWORD & dwListBoxStyles

    ) const

{

    ASSERT_VALID( this );

#ifdef _DEBUG

    if( pTBB != NULL )

    {

        ASSERT_VALID( pTBB );

        ASSERT_VALID( pTBB->GetBar() );

    }

#endif // _DEBUG

    ASSERT_VALID( pNode );

UINT nCmdID = pNode->GetCmdID(false);

    if( nCmdID == ID_SE_FONT_LIST )

    {

        dwListBoxStyles |= LBS_SORT;

        return true;

    } // if( nCmdID == ID_SE_FONT_LIST )

    return

        CExtRibbonBar::OnPopupListBoxGetStyles(

            pTBB,

            pNode,

            dwListBoxStyles

            );

}



static void stat_FormatFontSize(

    CExtSafeString & sText,

    LPCTSTR sDecimalSeparator,

    float fFontSize

    )

{

    ASSERT( sDecimalSeparator != NULL );

float fFL = (float)floor(fFontSize);

    if( fFL == fFontSize )

        sText.Format( _T("%.0f"), fFontSize );

    else

    {

//        double fDiv = double(fFontSize) - double(fFL);

//        fDiv *= 10.0;

//        fDiv = ceil(fDiv);

//        int nDiv = (int)fDiv;

//        sText.Format(

//            _T("%.0f%s%d"),

//            fFL,

//            sDecimalSeparator,

//            nDiv

//            );

        sText.Format( _T("%.1f"), fFontSize );

        sText.Replace( __EXT_MFC_SAFE_LPCTSTR(_T(".")), __EXT_MFC_SAFE_LPCTSTR(sDecimalSeparator) );

    }

}



bool CMyRibbonBar::OnPopupListBoxInitContent(

    CExtBarButton * pTBB,

    CExtCustomizeCmdTreeNode * pNode,

    CListBox & wndListBox

    )

{

#ifdef _DEBUG

    if( pTBB != NULL )

    {

        ASSERT_VALID( pTBB );

        ASSERT_VALID( pTBB->GetBar() );

    }

#endif // _DEBUG

    ASSERT_VALID( pNode );

    ASSERT_VALID( (&wndListBox) );

    pTBB;

UINT nCmdID = pNode->GetCmdID(false);

    switch( nCmdID )

    {

    case ID_SE_FONT_LIST:

        {

            CClientDC dc( this );

            LOGFONT lf;

            ::memset( &lf, 0, sizeof(LOGFONT) );

            lf.lfCharSet = DEFAULT_CHARSET;

            ::EnumFontFamiliesEx(

                dc.m_hDC,

                &lf,

                (FONTENUMPROC)stat_FillFontListBoxProc,

                (LPARAM)&wndListBox,

                0

                );

            LPCTSTR sFieldText = (LPCTSTR)pNode->m_sDefInplaceEditBuffer;

            if( sFieldText != NULL && _tcslen(sFieldText) > 0 )

                wndListBox.SelectString( -1, sFieldText );

            return true;

        } // case ID_SE_FONT_LIST

    case ID_SE_SIZE:

        {

            static const float arr_sizes[] = {

                8.0f, 9.0f, 10.0f, 10.5f, 11.0f, 12.0f, 14.0f, 16.0f,

                18.0f, 20.0f, 22.0f, 24.0f, 26.0f, 28.0f, 36.0f, 48.0f, 72.0f

            };

            for(    int nItemIdx = 0;

                    nItemIdx < sizeof(arr_sizes)/sizeof(arr_sizes[0]);

                    nItemIdx++

                    )

            {

                CExtSafeString sText;

                float fFontSize = arr_sizes[nItemIdx];

                ASSERT( __SO_FONT_SIZE_MIN <= fFontSize );

                ASSERT( fFontSize <= __SO_FONT_SIZE_MAX );

                stat_FormatFontSize(

                    sText,

                    m_sDecimalSeparator,

                    fFontSize

                    );

                wndListBox.AddString( (LPCTSTR)sText );

                wndListBox.SetItemData( nItemIdx, (DWORD)fFontSize );

            }



            CExtSafeString sFieldText;

                stat_FormatFontSize(

                    sFieldText,

                    m_sDecimalSeparator,

                    m_lfCurrentFontSize

                    );

            if( !sFieldText.IsEmpty() )

                wndListBox.SelectString( -1, sFieldText );

            return true;

        } // case ID_SE_FONT_LIST

    } // switch( nCmdID )

    return false;

}



CSize CMyRibbonBar::OnPopupListBoxMeasureTrackSize(

    const CExtBarButton * pTBB,

    const CExtCustomizeCmdTreeNode * pNode

    ) const

{

#ifdef _DEBUG

    if( pTBB != NULL )

    {

        ASSERT_VALID( pTBB );

        ASSERT_VALID( pTBB->GetBar() );

    }

#endif // _DEBUG

    ASSERT_VALID( pNode );

    pTBB;

UINT nCmdID = pNode->GetCmdID(false);

    switch( nCmdID )

    {

    case ID_SE_FONT_LIST:

            return CSize( 300, 400 );

    } // switch( nCmdID )

    return CSize( 0, 0 ); // this is not our business, let the bar button compute it

}



bool CMyRibbonBar::OnPopupListBoxItemDraw(

    CExtBarButton * pTBB,

    CExtCustomizeCmdTreeNode * pNode,

    CListBox & wndListBox,

    LPDRAWITEMSTRUCT pDIS

    )

{

    pTBB;

#ifdef _DEBUG

    if( pTBB != NULL )

    {

        ASSERT_VALID( pTBB );

        ASSERT_VALID( pTBB->GetBar() );

    }

#endif // _DEBUG

    ASSERT_VALID( pNode );

    ASSERT_VALID( (&wndListBox) );

    ASSERT( pDIS != NULL && pDIS->hDC != NULL );

    wndListBox;

UINT nCmdID = pNode->GetCmdID(false);

    switch( nCmdID )

    {

    case ID_SE_FONT_LIST:

        {

            ASSERT( (wndListBox.GetStyle() & LBS_HASSTRINGS) != 0 );

            if( ((INT)pDIS->itemID) < 0 || ((INT)pDIS->itemID) >= wndListBox.GetCount() )

                return true;



            CString sText;

            wndListBox.GetText( (INT)pDIS->itemID, sText );

            ASSERT( !sText.IsEmpty() );

            DWORD dwItemData = DWORD( wndListBox.GetItemData( (INT)pDIS->itemID ) );

            bool bSymbols =

                ( (( ((DWORD)(dwItemData)) >> 17)&0x0FF) == SYMBOL_CHARSET )

                ? true : false;



            HFONT hDefFont = (HFONT)g_PaintManager->m_FontNormal.GetSafeHandle();

            if( hDefFont == NULL )

                hDefFont = (HFONT)::GetStockObject(DEFAULT_GUI_FONT);

            if( hDefFont == NULL )

                hDefFont = (HFONT)::GetStockObject(SYSTEM_FONT);

            ASSERT( hDefFont != NULL );

            LOGFONT lf;

            ::memset( &lf, 0, sizeof(LOGFONT) );

            if(    ::GetObject(

                    (HGDIOBJ)hDefFont,

                    sizeof(LOGFONT),

                    &lf

                    ) != sizeof(LOGFONT)

                )

            {

                ASSERT( FALSE );

                return true;

            }

            __EXT_MFC_STRNCPY(

                lf.lfFaceName,

                LF_FACESIZE,

                LPCTSTR(sText),

                LF_FACESIZE

                );

            lf.lfHeight = ::MulDiv( lf.lfHeight, 13, 8 );

            lf.lfOutPrecision    = BYTE( (dwItemData >> 9) & 0x0FF);

            lf.lfCharSet        = BYTE( (dwItemData >> 17) & 0x0FF);

            lf.lfQuality        = PROOF_QUALITY;

            CFont font;

            if( !font.CreateFontIndirect( &lf ) )

            {

                ASSERT( FALSE );

                return true;

            }



            CDC dc;

            dc.Attach( pDIS->hDC );

            dc.FillSolidRect(

                &pDIS->rcItem,

                g_PaintManager->GetColor(

                    ( pDIS->itemState & ODS_SELECTED )

                        ? COLOR_HIGHLIGHT

                        : COLOR_WINDOW

                        ,

                    this

                    )

                );



            CRect rcText( pDIS->rcItem );

            //rcText.DeflateRect( OnPopupListBoxCalcItemExtraSizes(pTBB) );

            ASSERT( m_hIconFontTT != NULL );

            ASSERT( m_hIconFontPix != NULL );



            dc.DrawIcon(

                rcText.TopLeft(),

                (dwItemData & 2) ? m_hIconFontPix : m_hIconFontTT

                );

            rcText.left += 18;



            COLORREF clrTextOld =

                dc.SetTextColor(

                    g_PaintManager->GetColor(

                        ( pDIS->itemState & ODS_SELECTED )

                            ? COLOR_HIGHLIGHTTEXT

                            : COLOR_BTNTEXT

                            ,

                        this

                        )

                    );

            int nOldBkMode = dc.SetBkMode( TRANSPARENT );



            HGDIOBJ hOldFont = dc.SelectObject( (HGDIOBJ)hDefFont );



            if( bSymbols )

            {

                CRect rcTextMeasure( 0, 0, 0, 0 );

                dc.DrawText(

                    sText,

                    &rcTextMeasure,

                    DT_SINGLELINE|DT_LEFT|DT_TOP|DT_NOPREFIX|DT_CALCRECT

                    );

                dc.DrawText(

                    sText,

                    &rcText,

                    DT_SINGLELINE|DT_LEFT|DT_VCENTER|DT_NOPREFIX

                    );

                rcText.left += rcTextMeasure.Width() + 4;

            } // if( bSymbols )



            dc.SelectObject( &font );

            dc.DrawText(

                sText,

                &rcText,

                DT_SINGLELINE|DT_LEFT|DT_VCENTER|DT_NOPREFIX

                );

            dc.SetBkMode( nOldBkMode );

            dc.SetTextColor( clrTextOld );

            dc.SelectObject( (HGDIOBJ)hOldFont );



            if( pDIS->itemState & ODS_SELECTED )

            {

                COLORREF clrTextOld =

                    dc.SetTextColor(

                        ::GetSysColor( COLOR_HIGHLIGHTTEXT )

                        );

                COLORREF clrBkOld = dc.SetBkColor( RGB(0,0,0) );

                dc.DrawFocusRect( &pDIS->rcItem );

                dc.SetBkColor( clrBkOld );

                dc.SetTextColor( clrTextOld );

            }   



            dc.Detach();

            return true;

        } // case ID_SE_FONT_LIST

    } // switch( nCmdID )

    return false; // this is not our business, let the bar button paint it

}



bool CMyRibbonBar::OnPopupListBoxItemMeasure(

    CExtBarButton * pTBB,

    CExtCustomizeCmdTreeNode * pNode,

    CListBox & wndListBox,

    LPMEASUREITEMSTRUCT pMIS

    )

{

    pTBB;

#ifdef _DEBUG

    if( pTBB != NULL )

    {

        ASSERT_VALID( pTBB );

        ASSERT_VALID( pTBB->GetBar() );

    }

#endif // _DEBUG

    ASSERT_VALID( pNode );

    ASSERT_VALID( (&wndListBox) );

    ASSERT( pMIS != NULL );

    wndListBox;

UINT nCmdID = pNode->GetCmdID(false);

    switch( nCmdID )

    {

    case ID_SE_FONT_LIST:

        {

            ASSERT( (wndListBox.GetStyle() & LBS_HASSTRINGS) != 0 );

            if( ((INT)pMIS->itemID) < 0 || ((INT)pMIS->itemID) >= wndListBox.GetCount() )

                return true;



            CString sText;

            wndListBox.GetText( (INT)pMIS->itemID, sText );

            ASSERT( !sText.IsEmpty() );

            DWORD dwItemData = DWORD( wndListBox.GetItemData( (INT)pMIS->itemID ) );



            HFONT hDefFont = (HFONT)g_PaintManager->m_FontNormal.GetSafeHandle();

            if( hDefFont == NULL )

                hDefFont = (HFONT)::GetStockObject(DEFAULT_GUI_FONT);

            if( hDefFont == NULL )

                hDefFont = (HFONT)::GetStockObject(SYSTEM_FONT);

            ASSERT( hDefFont != NULL );

            LOGFONT lf;

            ::memset( &lf, 0, sizeof(LOGFONT) );

            if(    ::GetObject(

                    (HGDIOBJ)hDefFont,

                    sizeof(LOGFONT),

                    &lf

                    ) != sizeof(LOGFONT)

                )

            {

                ASSERT( FALSE );

                return true;

            }

            __EXT_MFC_STRNCPY(

                lf.lfFaceName,

                LF_FACESIZE,

                LPCTSTR(sText),

                LF_FACESIZE

                );

            lf.lfHeight = ::MulDiv( lf.lfHeight, 13, 8 );

            lf.lfOutPrecision    = BYTE( (dwItemData >> 9) & 0x0FF);

            lf.lfCharSet        = BYTE( (dwItemData >> 17) & 0x0FF);

            lf.lfQuality        = PROOF_QUALITY;

            CFont font;

            if( !font.CreateFontIndirect( &lf ) )

            {

                ASSERT( FALSE );

                return true;

            }



            //CSize sizeExtra = OnPopupListBoxCalcItemExtraSizes( pTBB );

            //sizeExtra.cx *= 2;

            //sizeExtra.cy *= 2;

            CClientDC dc( this );



            HGDIOBJ hOldFont = dc.SelectObject( (HGDIOBJ)hDefFont );

            CRect rcText( 0, 0, 0, 0 );

            dc.DrawText(

                sText,

                &rcText,

                DT_SINGLELINE|DT_LEFT|DT_TOP|DT_NOPREFIX|DT_CALCRECT

                );

            CSize sizeBtn( rcText.Size() );

            dc.SelectObject( &font );

            rcText.SetRect( 0, 0, 0, 0 );

            dc.DrawText(

                sText,

                &rcText,

                DT_SINGLELINE|DT_LEFT|DT_TOP|DT_NOPREFIX|DT_CALCRECT

                );

            sizeBtn.cx = max( sizeBtn.cx, rcText.Width() );

            sizeBtn.cy = max( sizeBtn.cy, rcText.Height() );

            dc.SelectObject( hOldFont );



            sizeBtn.cx += 18; // icon

            sizeBtn.cy = max( 16, sizeBtn.cy ); // icon

            //sizeBtn += sizeExtra;



            pMIS->itemWidth = sizeBtn.cx;

            pMIS->itemHeight = sizeBtn.cy;

            return true;

        } // case ID_SE_FONT_LIST

    } // switch( nCmdID )

    return false; // this is not our business, let the bar button measure it

}



bool CMyRibbonBar::OnTextFieldVerify(

    CExtBarTextFieldButton * pTextFieldTBB,

    CExtCustomizeCmdTreeNode * pNode,

    __EXT_MFC_SAFE_LPCTSTR sTextOld,

    __EXT_MFC_SAFE_LPCTSTR sTextNew

    )

{

    ASSERT_VALID( this );

#ifdef _DEBUG

    if( pTextFieldTBB != NULL )

    {

        ASSERT_VALID( pTextFieldTBB );

        ASSERT_VALID( pTextFieldTBB->GetBar() );

    }

#endif // _DEBUG

    ASSERT_VALID( pNode );

    ASSERT( sTextOld != NULL );

    ASSERT( sTextNew != NULL );

    pTextFieldTBB;

    sTextOld;



UINT nCmdID = pNode->GetCmdID(false);

    if( nCmdID == ID_SE_SIZE )

    {

        int nTextLenNew = int( _tcslen( sTextNew ) );

        //if( nTextLenNew == 0 )

        //    return false;

        int nSepLen = m_sDecimalSeparator.GetLength();

        ASSERT( nSepLen > 0 );

        bool bSeparatorPassed = false;

        for( int nChrIdx = 0; nChrIdx < nTextLenNew; nChrIdx++ )

        {

            TCHAR chr = sTextNew[nChrIdx];

            if( _istdigit(chr) )

                continue;

            if( bSeparatorPassed )

                return false;

            if( _tcsncmp(

                    ((LPCTSTR)sTextNew) + nChrIdx,

                    m_sDecimalSeparator,

                    nSepLen

                    )

                )

                return false;

            bSeparatorPassed = true;

            nChrIdx += nSepLen - 1;

        } // for( int nChrIdx = 0; nChrIdx < nTextLenNew; nChrIdx++ )

        return true;

    } // if( nCmdID == ID_SE_SIZE )



    return true;

}



void CMyRibbonBar::OnTextFieldInplaceTextGet(

    const CExtBarTextFieldButton * pTextFieldTBB,

    const CExtCustomizeCmdTreeNode * pNode,

    CExtSafeString & sTextFieldBuffer

    )

{

#ifdef _DEBUG

    if( pTextFieldTBB != NULL )

    {

        ASSERT_VALID( pTextFieldTBB );

        ASSERT_VALID( pTextFieldTBB->GetBar() );

    }

#endif // _DEBUG

    ASSERT_VALID( pNode );

    pTextFieldTBB;

UINT nCmdID = pNode->GetCmdID(false);

    switch( nCmdID )

    {

    case ID_SE_FONT_LIST:

        sTextFieldBuffer = m_sCurrentFontFaceName;

        return;

    case ID_SE_SIZE:

        {

            float fFontSize = m_lfCurrentFontSize;

            ASSERT( __SO_FONT_SIZE_MIN <= fFontSize );

            ASSERT( fFontSize <= __SO_FONT_SIZE_MAX );

            stat_FormatFontSize(

                sTextFieldBuffer,

                m_sDecimalSeparator,

                fFontSize

                );

            return;

        } // case ID_SE_FONT_LIST

    } // switch( nCmdID )

}



void CMyRibbonBar::OnTextFieldInplaceTextSet(

    CExtBarTextFieldButton * pTextFieldTBB,

    CExtCustomizeCmdTreeNode * pNode,

    CExtSafeString & sTextFieldBuffer,

    __EXT_MFC_SAFE_LPCTSTR sTextNew

    )

{

    ASSERT_VALID( this );

#ifdef _DEBUG

    if( pTextFieldTBB != NULL )

    {

        ASSERT_VALID( pTextFieldTBB );

        ASSERT_VALID( pTextFieldTBB->GetBar() );

    }

#endif // _DEBUG

    ASSERT_VALID( pNode );

    ASSERT( sTextNew != NULL );

    pTextFieldTBB;

CString sTextAdjusted;

    sTextAdjusted = LPCTSTR(sTextNew);

UINT nCmdID = pNode->GetCmdID(false);

    switch( nCmdID )

    {

    case ID_SE_FONT_LIST:

        sTextFieldBuffer = LPCTSTR(sTextAdjusted);

         m_sCurrentFontFaceName =  LPCTSTR(sTextAdjusted);

        CExtRibbonBar::RedrawCommandItems( nCmdID );

        break;

    case ID_SE_SIZE:

        {

            sTextAdjusted.Replace(

                LPCTSTR(m_sDecimalSeparator),

                _T(".")

                );

            sTextAdjusted.Replace( _T(" "), _T("") );

            TCHAR * pEndPtr = NULL;

            float fFontSize =

                (float) _tcstod( (LPCTSTR)sTextAdjusted, &pEndPtr );

            m_lfCurrentFontSize = fFontSize;

            ASSERT( __SO_FONT_SIZE_MIN <= fFontSize );

            ASSERT( fFontSize <= __SO_FONT_SIZE_MAX );

            stat_FormatFontSize(

                sTextFieldBuffer,

                m_sDecimalSeparator,

                fFontSize

                );

            CExtRibbonBar::RedrawCommandItems( nCmdID );

            break;

        } // case ID_SE_FONT_LIST

    } // switch( nCmdID )

CExtPopupMenuWnd * pPopup =

        CExtPopupMenuWnd::GetTrackingMenu();

    if(        pPopup->GetSafeHwnd() != NULL

        &&    ::IsWindow( pPopup->GetSafeHwnd() )

        )

    {

        ::PostMessage(

            pPopup->GetSafeHwnd(),

            WM_CANCELMODE,

            0,

            0

            );

    }

//     if(        m_wndView.GetSafeHwnd() != NULL

//         &&    ::IsWindow( m_wndView.GetSafeHwnd() )

//         )

//     {

//         m_wndView.Invalidate();

//         m_wndView.UpdateWindow();

//     }

    CExtRibbonBar::OnTextFieldInplaceTextSet(

        pTextFieldTBB,

        pNode,

        sTextFieldBuffer,

        sTextNew

        );

}



/////////////////////////////////////////////////////////////////////////////

// CMainFrame



IMPLEMENT_DYNAMIC( CMainFrame, CMDIFrameWnd )



BEGIN_MESSAGE_MAP( CMainFrame, CMDIFrameWnd )

    //{{AFX_MSG_MAP(CMainFrame)

    ON_WM_CREATE()

    //}}AFX_MSG_MAP



//    ON_COMMAND_EX(ID_VIEW_MENUBAR, OnBarCheck )

//    ON_UPDATE_COMMAND_UI(ID_VIEW_MENUBAR, OnUpdateControlBarMenu)



    ON_COMMAND_EX(ID_VIEW_UI_LOOK_BAR, OnBarCheck )

    ON_UPDATE_COMMAND_UI(ID_VIEW_UI_LOOK_BAR, OnUpdateControlBarMenu)



END_MESSAGE_MAP()



static UINT indicators[] =

{

    ID_SEPARATOR,           // status line indicator

    ID_INDICATOR_CAPS,

    ID_INDICATOR_NUM,

    ID_INDICATOR_SCRL,

    ID_INDICATOR_ZOOM

};



void CMainFrame::OnUpdateControlBarMenu(CCmdUI* pCmdUI)

{

    CExtControlBar::DoFrameBarCheckUpdate( this, pCmdUI, true );

}



BOOL CMainFrame::OnBarCheck(UINT nID)

{

    return CExtControlBar::DoFrameBarCheckCmd( this, nID, true );

}



/////////////////////////////////////////////////////////////////////////////

// CMainFrame construction/destruction



CMainFrame::CMainFrame()

    : m_pRibbonNode( NULL )

{

CWinApp * pApp = ::AfxGetApp();

    ASSERT( pApp != NULL );

    ASSERT( pApp->m_pszRegistryKey != NULL );

    ASSERT( pApp->m_pszRegistryKey[0] != _T(’\0’) );

    ASSERT( pApp->m_pszProfileName != NULL );

    ASSERT( pApp->m_pszProfileName[0] != _T(’\0’) );



    if( ! g_PaintManager.PaintManagerStateLoad(

            pApp->m_pszRegistryKey,

            pApp->m_pszProfileName,

            pApp->m_pszProfileName

            )

        )

        g_PaintManager.InstallPaintManager(

            RUNTIME_CLASS(CExtPaintManagerOffice2007_R3_Silver)

            );

//                            if( ! g_PaintManager.PaintManagerStateLoad(

//                                    pApp->m_pszRegistryKey,

//                                    pApp->m_pszProfileName,

//                                    pApp->m_pszProfileName

//                                    )

//                                )

//                            {

//                                CExtPaintManagerSkin * pPM = new CExtPaintManagerSkin;

//                                bool bLoaded = true;

//                                if( ! pPM->m_Skin.SearchAndLoadSkinFile( _T("BlackDiamond.Skin"), false ) )

//                                {

//                                    if( ! pPM->m_Skin.SearchAndLoadSkinFile( _T("..\\..\\Skins\\Binary\\Aqua.Skin"), false ) )

//                                    {

//                                        bLoaded = false;

//                                        ::AfxMessageBox( _T("Failed to load initial skin.") );

//                                        delete pPM;

//                                    }

//                                }

//                                if( bLoaded )

//                                    g_PaintManager.InstallPaintManager( pPM );

//                            }



    CExtPopupMenuWnd::g_bMenuExpanding = false;

    CExtPopupMenuWnd::g_bMenuHighlightRarely = false;



    // window placement persistence

    ::memset( &m_dataFrameWP, 0, sizeof(WINDOWPLACEMENT) );

    m_dataFrameWP.length = sizeof(WINDOWPLACEMENT);

    m_dataFrameWP.showCmd = SW_HIDE;

}



CMainFrame::~CMainFrame()

{

    if( m_pRibbonNode != NULL )

        delete m_pRibbonNode;

}



void CMainFrame::RecalcLayout(BOOL bNotify)

{

    CExtNCW < CMDIFrameWnd > :: RecalcLayout( bNotify );

}



int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)

{

    if( CExtNCW < CMDIFrameWnd > :: OnCreate( lpCreateStruct ) == -1 )

        return -1;



CWinApp * pApp = ::AfxGetApp();

    ASSERT( pApp != NULL );

    ASSERT( pApp->m_pszRegistryKey != NULL );

    ASSERT( pApp->m_pszRegistryKey[0] != _T(’\0’) );

    ASSERT( pApp->m_pszProfileName != NULL );

    ASSERT( pApp->m_pszProfileName[0] != _T(’\0’) );

    ASSERT( pApp->m_pszProfileName != NULL );



HICON hIcon = pApp->LoadIcon( IDR_MAINFRAME );

    ASSERT( hIcon != NULL );

    SetIcon( hIcon, TRUE );

    SetIcon( hIcon, FALSE );

   

    g_CmdManager->ProfileSetup(

        pApp->m_pszProfileName,

        GetSafeHwnd()

        );

    VERIFY(

        g_CmdManager->UpdateFromMenu(

            pApp->m_pszProfileName,

            IDR_MAINFRAME

            )

        );



    if(    ! m_wndRibbonBar.Create(

            NULL,

            this

            )

        )

    {

        TRACE0("Failed to create the m_wndRibbonBar toolbar\n");

        return -1;      // fail to create

    }

//m_wndRibbonBar.ModifyStyleEx( 0, WS_EX_LAYOUTRTL, SWP_FRAMECHANGED );

//m_wndView.ModifyStyleEx( 0, WS_EX_LAYOUTRTL, SWP_FRAMECHANGED );

//g_ResourceManager->SetLangLayout( LAYOUT_RTL );

    _InitRibbonBar();



    m_wndToolBarUiLook.m_bEnableOffice2007r3 = true;

    if(        (! m_wndToolBarUiLook.Create( NULL, this, ID_VIEW_UI_LOOK_BAR ) )

        ||    (! m_wndToolBarUiLook.ThemeSwitcherInit() )

        )

    {

        TRACE0("Failed to create the m_wndToolBarUiLook toolbar\n");

        return -1;      // fail to create

    }



    m_wndStatusBar.m_bDrawPaneSeparatorsInsteadOfBorders = true;

    if(        (! m_wndStatusBar.Create( this ) )

        ||    (! m_wndStatusBar.SetIndicators(

                indicators,

                sizeof(indicators)/sizeof(UINT)

                ) )

        ||    (! m_wndZoomScrollBar.Create(

                WS_CHILD|WS_VISIBLE|SBS_HORZ,

                CRect(0,0,0,21),

                &m_wndStatusBar,

                ID_INDICATOR_ZOOM

                )

            )

        ||    (!    m_wndStatusBar.SetPaneControl(

                &m_wndZoomScrollBar,

                ID_INDICATOR_ZOOM,

                true

                )

            )

        )

    {

        TRACE0("Failed to create status bar\n");

        return -1;      // fail to create

    }

    m_wndStatusBar.GetStatusBarCtrl().SetMinHeight( 23 );

INT nZoomPaneIndex = m_wndStatusBar.CommandToIndex( ID_INDICATOR_ZOOM );

    m_wndStatusBar.SetPaneWidth( nZoomPaneIndex, 120 );

    m_wndZoomScrollBar.SetScrollRange( 0, 100 );

    m_wndZoomScrollBar.SetScrollPos( 50 );

    m_wndZoomScrollBar.m_bEnabledToolTips         = true;

    m_wndZoomScrollBar.m_strTipTextForThumbButton = _T("Zoom");

    m_wndZoomScrollBar.m_strTipTextForUpButton    = _T("Zoom Out");

    m_wndZoomScrollBar.m_strTipTextForDownButton  = _T("Zoom In");

    m_wndZoomScrollBar.m_eSO = CExtScrollBar::__ESO_BOTTOM;



    m_wndToolBarUiLook.EnableDocking( CBRS_ALIGN_ANY );



    if( ! CExtControlBar::FrameEnableDocking( this ) )

    {

        ASSERT( FALSE );

        return -1;

    }



    _AdjustRTL();

   

    m_wndRibbonBar.CustomizeStateLoad(

        pApp->m_pszRegistryKey,

        pApp->m_pszProfileName,

        pApp->m_pszProfileName

        );



    if( ! CExtControlBar::ProfileBarStateLoad(

            this,

            pApp->m_pszRegistryKey,

            pApp->m_pszProfileName,

            pApp->m_pszProfileName,

            &m_dataFrameWP

            )

        )

    {

        DockControlBar( &m_wndToolBarUiLook, AFX_IDW_DOCKBAR_RIGHT );

        RecalcLayout();

    }



    if( m_wndMdiTabs.Create( this ) )

        m_wndMdiTabs.OrientationSet( __ETWS_ORIENT_BOTTOM );



    return 0;

}



BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)

{

    if( ! CExtNCW < CMDIFrameWnd > :: PreCreateWindow( cs ) )

        return FALSE;

    cs.dwExStyle &= ~(WS_EX_CLIENTEDGE|WS_EX_LAYOUT_RTL);

    cs.lpszClass =

        ::AfxRegisterWndClass(

            CS_BYTEALIGNCLIENT,

            ::LoadCursor( NULL, IDC_ARROW ),

            NULL,

            NULL

            );

    cs.style |= WS_CLIPSIBLINGS|WS_CLIPCHILDREN;

//cs.dwExStyle |= WS_EX_LAYOUTRTL;

    return TRUE;

}



/////////////////////////////////////////////////////////////////////////////

// CMainFrame diagnostics



#ifdef _DEBUG

void CMainFrame::AssertValid() const

{

    CExtNCW < CMDIFrameWnd > :: AssertValid();

}



void CMainFrame::Dump(CDumpContext& dc) const

{

    CExtNCW < CMDIFrameWnd > :: Dump( dc );

}



#endif //_DEBUG



/////////////////////////////////////////////////////////////////////////////

// CMainFrame message handlers



BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)

{

    if( nID == ID_RIBBON_MINIMIZE_RESTORE )

    {

        if( nCode == CN_UPDATE_COMMAND_UI )

        {

            ((CCmdUI *)pExtra)->Enable();

            ((CCmdUI *)pExtra)->SetCheck( m_wndRibbonBar.RibbonPage_ExpandedModeGet() );

        }

        else if( pExtra == NULL )

        {

            m_wndRibbonBar.RibbonPage_ExpandedModeSet( ! m_wndRibbonBar.RibbonPage_ExpandedModeGet(), true );

        }

        return TRUE;

    }



#if (!defined __EXT_MFC_NO_MDI_WINDOWS_LIST_DIALOG)

    if( nCode == CN_COMMAND || nCode == CN_UPDATE_COMMAND_UI )

    {

        if( nID == ID_WINDOWS_LIST )

        {

            if( pExtra == NULL && nCode == CN_COMMAND )

            {

                CMyMdiWindowsListDlg dlg( this );

                dlg.DoModal();

            }

            else if( nCode == CN_UPDATE_COMMAND_UI )

                ((CCmdUI*)pExtra)->Enable();

            return TRUE;

        }

    }

#endif // (!defined __EXT_MFC_NO_MDI_WINDOWS_LIST_DIALOG)



//    // TEST FOR INDETERIMINATE BUTTON STATE IN RIBBONs

//    if(        nID == ID_EDIT_PASTE

//        ||    nID == ID_EDIT_COPY

//        ||    nID == ID_EDIT_FIND

//        ||    nID == ID_EDIT_REPLACE

//        ||    nID == ID_FONT_BOLD

//        ||    nID == ID_PB_NO_BORDER

//        )

//    {

//        if( nCode == CN_UPDATE_COMMAND_UI )

//        {

//            ((CCmdUI*)pExtra)->Enable();

//            ((CCmdUI*)pExtra)->SetCheck( 2 );

//        }

//        return TRUE;

//    }



    if( nID == ID_RTL )

    {

        if( nCode == CN_UPDATE_COMMAND_UI )

        {

            ((CCmdUI *)pExtra)->Enable( g_PaintManager.m_bIsWinNT );

            if( g_PaintManager.m_bIsWinNT )

                ((CCmdUI *)pExtra)->SetCheck(

                    ( (GetExStyle()&WS_EX_LAYOUT_RTL) != 0 ) ? 1 : 0

                    );

        }

        else if( pExtra == NULL && g_PaintManager.m_bIsWinNT )

        {

            CExtNcFrameImpl::m_bNcFrameImpl_IsEnabled = false;

            if( (GetExStyle()&WS_EX_LAYOUT_RTL) != 0 )

                ModifyStyleEx( WS_EX_LAYOUT_RTL, 0, SWP_FRAMECHANGED );

            else

                ModifyStyleEx( 0, WS_EX_LAYOUT_RTL, SWP_FRAMECHANGED );

            CExtNcFrameImpl::m_bNcFrameImpl_IsEnabled = true;

            _AdjustRTL();

        }

        return TRUE;

    }



//    if( nID == ID_EDIT_COPY && nCode == CN_COMMAND )

//    { // correct

//        if( pExtra == NULL )

//        {

//            int x = 0;

//            x;

//            AfxMessageBox("Edit Copy");

//        }

//        return TRUE; // this should be invoked even if pExtra != NULL

//    } // correct



    // otherwise, do default handling

//    return CExtNCW < CMDIFrameWnd > :: OnCmdMsg( nID, nCode, pExtra, pHandlerInfo );

    CExtNCW < CMDIFrameWnd > :: OnCmdMsg( nID, nCode, pExtra, pHandlerInfo );

    return TRUE;

}



BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)

{

    if( m_wndToolBarUiLook.PreTranslateMessage( pMsg ) )

        return TRUE;

    if( m_wndRibbonBar.TranslateMainFrameMessage(pMsg) )

        return TRUE;

    return CExtNCW < CMDIFrameWnd > :: PreTranslateMessage(pMsg);

}



BOOL CMainFrame::DestroyWindow()

{

CWinApp * pApp = ::AfxGetApp();

    ASSERT( pApp != NULL );

    ASSERT( pApp->m_pszRegistryKey != NULL );

    ASSERT( pApp->m_pszRegistryKey[0] != _T(’\0’) );

    ASSERT( pApp->m_pszProfileName != NULL );

    ASSERT( pApp->m_pszProfileName[0] != _T(’\0’) );



    m_wndRibbonBar.CustomizeStateSave(

        pApp->m_pszRegistryKey,

        pApp->m_pszProfileName,

        pApp->m_pszProfileName

        );

    VERIFY(

        CExtControlBar::ProfileBarStateSave(

            this,

            pApp->m_pszRegistryKey,

            pApp->m_pszProfileName,

            pApp->m_pszProfileName

            )

        );

    VERIFY(

        g_PaintManager.PaintManagerStateSave(

            pApp->m_pszRegistryKey,

            pApp->m_pszProfileName,

            pApp->m_pszProfileName

            )

        );



    g_CmdManager->ProfileWndRemove( GetSafeHwnd() );

   

    return CExtNCW < CMDIFrameWnd > :: DestroyWindow();

}



void CMainFrame::ActivateFrame(int nCmdShow)

{

bool bDwmMode = NcFrameImpl_IsDwmCaptionReplacement();

    // window placement persistence

    if( m_dataFrameWP.showCmd != SW_HIDE )

    {

        if( bDwmMode )

            NcFrameImpl_NcLock( true );

        SetWindowPlacement( &m_dataFrameWP );

        CExtNCW < CMDIFrameWnd > :: ActivateFrame( m_dataFrameWP.showCmd );

        m_dataFrameWP.showCmd = SW_HIDE;

        if( bDwmMode )

        {

            NcFrameImpl_NcLock( false );

            NcFrameImpl_RecalcNcFrame();

        }

        return;

    }

    CExtNCW < CMDIFrameWnd > :: ActivateFrame( nCmdShow );

    if( bDwmMode )

        NcFrameImpl_RecalcNcFrame();

}



void CMainFrame::_AdjustRTL()

{

    ASSERT_VALID( this );

    if( (GetExStyle()&WS_EX_LAYOUT_RTL) != 0 )

    {

        CExtNcFrameImpl::m_dwNcFrameImpl_StyleExInitial |= WS_EX_LAYOUT_RTL;

        m_wndRibbonBar.ModifyStyleEx( 0, WS_EX_LAYOUTRTL, 0 );

        g_ResourceManager->SetLangLayout( LAYOUT_RTL );

    }

    else

    {

        CExtNcFrameImpl::m_dwNcFrameImpl_StyleExInitial &= ~(WS_EX_LAYOUT_RTL);

        m_wndRibbonBar.ModifyStyleEx( WS_EX_LAYOUTRTL, 0, 0 );

        g_ResourceManager->SetLangLayout( LAYOUT_LTR );

    }

    m_wndRibbonBar.Ribbon_UpdateLayout( true );

    CExtNcFrameImpl::NcFrameImpl_RecalcNcFrame();

    CExtNcFrameImpl::NcFrameImpl_SetupRgn();

    if( IsWindowVisible() )

        RedrawWindow( NULL, NULL, RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN );

}



void CMainFrame::_InitRibbonBar()

{

    ASSERT_VALID( this );

    ASSERT( m_pRibbonNode == NULL );

    m_pRibbonNode = new CExtRibbonNode;

CExtRibbonNodeTabPageCollection * pRibbonNodeTabPageCollection =

        new CExtRibbonNodeTabPageCollection;

    m_pRibbonNode->InsertNode( NULL, pRibbonNodeTabPageCollection );

            pRibbonNodeTabPageCollection->InsertNode( NULL, _InitRibbonPage_Test() );

    pRibbonNodeTabPageCollection->PageSelectionSet( 0 );

//INT nPageIndex, nPageCount = pRibbonNodeTabPageCollection->GetNodeCount();

//    for( nPageIndex = 0; nPageIndex < nPageCount; nPageIndex ++ )

//    {

//        CExtRibbonNodeTabPage * pRibbonNodeTabPage =

//            STATIC_DOWNCAST(

//                CExtRibbonNodeTabPage,

//                pRibbonNodeTabPageCollection->ElementAt( nPageIndex )

//                );

//        ASSERT_VALID( pRibbonNodeTabPage );

//        pRibbonNodeTabPage->ModifyFlags( __ECTN_TBB_HIDDEN );

//    } // for( nPageIndex = 0; nPageIndex < nPageCount; nPageIndex ++ )



CExtRibbonNodeRightButtonsCollection * pRibbonNodeRightButtonsCollection =

        _InitRibbon_RightButtonsCollection();

    m_pRibbonNode->InsertNode( NULL, pRibbonNodeRightButtonsCollection );

CExtRibbonNodeQuickAccessButtonsCollection * pRibbonNodeQuickAccessButtonsCollection =

        _InitRibbon_QuickAccessButtonsCollection();

    m_pRibbonNode->InsertNode( NULL, pRibbonNodeQuickAccessButtonsCollection );



CExtRibbonNodeFile * pRibbonNodeFile = _InitRibbon_FileMenu();

    m_pRibbonNode->InsertNode( NULL, pRibbonNodeFile );



    m_wndRibbonBar.SetButtons( m_pRibbonNode );

    VERIFY(

        m_wndRibbonBar.

            MenuInfoGetDefault()->

                AccelTableLoad( IDR_MAINFRAME )

        );

    VERIFY(

        m_wndRibbonBar.Ribbon_FileButtonGet() ->

            m_iconForLargeMode.m_bmpNormal.

                LoadBMP_Resource( MAKEINTRESOURCE( IDB_BITMAP_SMALL_ICON ) )

        );



}



CExtRibbonNodeFile * CMainFrame::_InitRibbon_FileMenu()

{

CExtRibbonNodeFile * pRibbonNodeFile = new CExtRibbonNodeFile;

    pRibbonNodeFile->CmdKeyTipSet( new CExtCustomizeCmdKeyTip( __EXT_MFC_SAFE_TCHAR( _T(’F’) ) ), false );

    pRibbonNodeFile->m_keyTipOptionsButton.KeyCodeAdd( DWORD(’T’) );

    pRibbonNodeFile->m_keyTipExitButton.KeyCodeAdd( DWORD(’X’) );

                            CExtCustomizeCmdScreenTip * pCmdScreenTip = new CExtCustomizeCmdScreenTip;

                            pCmdScreenTip->CaptionMainSet( _T("Application Button") );

                            pCmdScreenTip->TextMainSet( _T("Click here to open, save or print,\nand to see everything else you can\ndo with the document.") );

                            pCmdScreenTip->BmpMainGet().LoadBMP_Resource( MAKEINTRESOURCE(ID_FILE_DLB_TIP_IMAGE) );

                            pCmdScreenTip->BmpMainGet().Make32();

                            pCmdScreenTip->BmpMainGet().AlphaColor( RGB(255,0,255), RGB(0,0,0), 0 );

                            pRibbonNodeFile->CmdScreenTipAttach( pCmdScreenTip );



CExtRibbonNode * pNodeFileNew =

        new CExtRibbonNode(

            ID_FB_NEW,

            ID_FB_NEW,

            NULL,

            __ECTN_BIG_ACCENT_IN_MENU,

            NULL,

            _T("&New...")

            );

    pNodeFileNew->CmdKeyTipSet( new CExtCustomizeCmdKeyTip( __EXT_MFC_SAFE_TCHAR( _T(’N’) ) ), false );

    VERIFY(

        pNodeFileNew->m_iconBig.m_bmpNormal.LoadBMP_Resource(

            MAKEINTRESOURCE( ID_FB_NEW )

            )

        );

    pNodeFileNew->m_iconBig.m_bmpNormal.Make32();

    pNodeFileNew->m_iconBig.m_bmpNormal.AlphaColor( RGB(255,0,255), RGB(0,0,0), 0 );

                            pCmdScreenTip = new CExtCustomizeCmdScreenTip;

                            pCmdScreenTip->TextMainSet( _T("New") );

                            pNodeFileNew->CmdScreenTipAttach( pCmdScreenTip );

    pRibbonNodeFile->InsertNode( NULL, pNodeFileNew );



CExtRibbonNode * pNodeFileOpen =

        new CExtRibbonNode(

            ID_FB_OPEN,

            ID_FB_OPEN,

            NULL,

            __ECTN_BIG_ACCENT_IN_MENU,

            NULL,

            _T("&Open...")

            );

    pNodeFileOpen->CmdKeyTipSet( new CExtCustomizeCmdKeyTip( __EXT_MFC_SAFE_TCHAR( _T(’O’) ) ), false );

    VERIFY(

        pNodeFileOpen->m_iconBig.m_bmpNormal.LoadBMP_Resource(

            MAKEINTRESOURCE( ID_FB_OPEN )

            )

        );

    pNodeFileOpen->m_iconBig.m_bmpNormal.Make32();

    pNodeFileOpen->m_iconBig.m_bmpNormal.AlphaColor( RGB(255,0,255), RGB(0,0,0), 0 );

                            pCmdScreenTip = new CExtCustomizeCmdScreenTip;

                            pCmdScreenTip->TextMainSet( _T("Open") );

                            pNodeFileOpen->CmdScreenTipAttach( pCmdScreenTip );

    pRibbonNodeFile->InsertNode( NULL, pNodeFileOpen );



CExtRibbonNode * pNodeFileSave =

        new CExtRibbonNode(

            ID_FB_SAVE,

            ID_FB_SAVE,

            NULL,

            __ECTN_BIG_ACCENT_IN_MENU,

            NULL,

            _T("&Save")

            );

    pNodeFileSave->CmdKeyTipSet( new CExtCustomizeCmdKeyTip( __EXT_MFC_SAFE_TCHAR( _T(’S’) ) ), false );

    VERIFY(

        pNodeFileSave->m_iconBig.m_bmpNormal.LoadBMP_Resource(

            MAKEINTRESOURCE( ID_FB_SAVE )

            )

        );

    pNodeFileSave->m_iconBig.m_bmpNormal.Make32();

    pNodeFileSave->m_iconBig.m_bmpNormal.AlphaColor( RGB(255,0,255), RGB(0,0,0), 0 );

                            pCmdScreenTip = new CExtCustomizeCmdScreenTip;

                            pCmdScreenTip->TextMainSet( _T("Save") );

                            pNodeFileSave->CmdScreenTipAttach( pCmdScreenTip );

    pRibbonNodeFile->InsertNode( NULL, pNodeFileSave );



CExtRibbonNode * pNodeFileSaveAs =

        new CExtRibbonNode(

            ID_FB_SAVE_AS,

            ID_FB_SAVE_AS,

            NULL,

            __ECTN_BIG_ACCENT_IN_MENU|__ECTN_TBB_SEPARATED_DROPDOWN,

            NULL,

            _T("Save &As...")

            );

    pNodeFileSaveAs->CmdKeyTipSet( new CExtCustomizeCmdKeyTip( __EXT_MFC_SAFE_TCHAR( _T(’A’) ) ), false );

    pNodeFileSaveAs->CmdKeyTipSet( new CExtCustomizeCmdKeyTip( __EXT_MFC_SAFE_TCHAR( _T(’F’) ) ), false, false );

    pNodeFileSaveAs->SetTextMenuCaption( _T("Save As Other Format") );

    VERIFY(

        pNodeFileSaveAs->m_iconBig.m_bmpNormal.LoadBMP_Resource(

            MAKEINTRESOURCE( ID_FB_SAVE_AS )

            )

        );

    pNodeFileSaveAs->m_iconBig.m_bmpNormal.Make32();

    pNodeFileSaveAs->m_iconBig.m_bmpNormal.AlphaColor( RGB(255,0,255), RGB(0,0,0), 0 );

                            pCmdScreenTip = new CExtCustomizeCmdScreenTip;

                            pCmdScreenTip->TextMainSet( _T("Save As") );

                            pNodeFileSaveAs->CmdScreenTipAttach( pCmdScreenTip );

    pRibbonNodeFile->InsertNode( NULL, pNodeFileSaveAs );



                CExtRibbonNode * pNodeFileSaveAsFormat1 =

                    new CExtRibbonNode(

                        ID_FB_SAVE_AS_FROMAT_ICON,

                        ID_FB_SAVE_AS_FROMAT_ICON,

                        NULL,

                        __ECTN_BIG_ACCENT_IN_MENU|__ECTN_BOLD_IN_MENU,

                        NULL,

                        _T("Save Document As Format 1")

                        );

                pNodeFileSaveAsFormat1->CmdKeyTipSet( new CExtCustomizeCmdKeyTip( __EXT_MFC_SAFE_TCHAR( _T(’1’) ) ), false );

                pNodeFileSaveAsFormat1->SetTextMenuExtended(

                    _T("Save a copy of that will be fully compatible\nwith Format 1")

                    );

                VERIFY(

                    pNodeFileSaveAsFormat1->m_iconBig.m_bmpNormal.LoadBMP_Resource(

                        MAKEINTRESOURCE( ID_FB_SAVE_AS_FROMAT_ICON )

                        )

                    );

                pNodeFileSaveAsFormat1->m_iconBig.m_bmpNormal.Make32();

                pNodeFileSaveAsFormat1->m_iconBig.m_bmpNormal.AlphaColor( RGB(255,0,255), RGB(0,0,0), 0 );

                pNodeFileSaveAs->InsertNode( NULL, pNodeFileSaveAsFormat1 );



                CExtRibbonNode * pNodeFileSaveAsFormat2 =

                    new CExtRibbonNode(

                        ID_FB_SAVE_AS_FROMAT_ICON,

                        ID_FB_SAVE_AS_FROMAT_ICON,

                        NULL,

                        __ECTN_BIG_ACCENT_IN_MENU|__ECTN_BOLD_IN_MENU,

                        NULL,

                        _T("Save Document As Format 2")

                        );

                pNodeFileSaveAsFormat2->CmdKeyTipSet( new CExtCustomizeCmdKeyTip( __EXT_MFC_SAFE_TCHAR( _T(’2’) ) ), false );

                pNodeFileSaveAsFormat2->SetTextMenuExtended(

                    _T("Publish a copy of this document\nas Format 2")

                    );

                VERIFY(

                    pNodeFileSaveAsFormat2->m_iconBig.m_bmpNormal.LoadBMP_Resource(

                        MAKEINTRESOURCE( ID_FB_SAVE_AS_FROMAT_ICON )

                        )

                    );

                pNodeFileSaveAsFormat2->m_iconBig.m_bmpNormal.Make32();

                pNodeFileSaveAsFormat2->m_iconBig.m_bmpNormal.AlphaColor( RGB(255,0,255), RGB(0,0,0), 0 );

                pNodeFileSaveAs->InsertNode( NULL, pNodeFileSaveAsFormat2 );



                CExtRibbonNode * pNodeFileSaveAsFormat3 =

                    new CExtRibbonNode(

                        ID_FB_SAVE_AS_FROMAT_ICON,

                        ID_FB_SAVE_AS_FROMAT_ICON,

                        NULL,

                        __ECTN_BIG_ACCENT_IN_MENU|__ECTN_BOLD_IN_MENU,

                        NULL,

                        _T("Save Document As Format 3")

                        );

                pNodeFileSaveAsFormat3->CmdKeyTipSet( new CExtCustomizeCmdKeyTip( __EXT_MFC_SAFE_TCHAR( _T(’3’) ) ), false );

                pNodeFileSaveAsFormat3->SetTextMenuExtended(

                    _T("Save a copy of that will be fully compatible\nwith Format 3")

                    );

                VERIFY(

                    pNodeFileSaveAsFormat3->m_iconBig.m_bmpNormal.LoadBMP_Resource(

                        MAKEINTRESOURCE( ID_FB_SAVE_AS_FROMAT_ICON )

                        )

                    );

                pNodeFileSaveAsFormat3->m_iconBig.m_bmpNormal.Make32();

                pNodeFileSaveAsFormat3->m_iconBig.m_bmpNormal.AlphaColor( RGB(255,0,255), RGB(0,0,0), 0 );

                pNodeFileSaveAs->InsertNode( NULL, pNodeFileSaveAsFormat3 );



                CExtRibbonNode * pNodeFileSaveAsFormat4 =

                    new CExtRibbonNode(

                        ID_FB_SAVE_AS_FROMAT_ICON,

                        ID_FB_SAVE_AS_FROMAT_ICON,

                        NULL,

                        __ECTN_BIG_ACCENT_IN_MENU|__ECTN_BOLD_IN_MENU,

                        NULL,

                        _T("Save Document As Format 4")

                        );

                pNodeFileSaveAsFormat4->CmdKeyTipSet( new CExtCustomizeCmdKeyTip( __EXT_MFC_SAFE_TCHAR( _T(’4’) ) ), false );

                pNodeFileSaveAsFormat4->SetTextMenuExtended(

                    _T("Publish a copy of this document\nas Format 4")

                    );

                VERIFY(

                    pNodeFileSaveAsFormat4->m_iconBig.m_bmpNormal.LoadBMP_Resource(

                        MAKEINTRESOURCE( ID_FB_SAVE_AS_FROMAT_ICON )

                        )

                    );

                pNodeFileSaveAsFormat4->m_iconBig.m_bmpNormal.Make32();

                pNodeFileSaveAsFormat4->m_iconBig.m_bmpNormal.AlphaColor( RGB(255,0,255), RGB(0,0,0), 0 );

                pNodeFileSaveAs->InsertNode( NULL, pNodeFileSaveAsFormat4 );



CExtRibbonNode * pNodeFileFinish =

        new CExtRibbonNode(

            ID_FB_FINISH,

            ID_FB_FINISH,

            NULL,

            __ECTN_BIG_ACCENT_IN_MENU|__ECTN_GROUP_START,

            NULL,

            _T("&Finish")

            );

    pNodeFileFinish->CmdKeyTipSet( new CExtCustomizeCmdKeyTip( __EXT_MFC_SAFE_TCHAR( _T(’I’) ) ), false );

    pNodeFileFinish->SetTextMenuCaption( _T("Before You Share") );

    VERIFY(

        pNodeFileFinish->m_iconBig.m_bmpNormal.LoadBMP_Resource(

            MAKEINTRESOURCE( ID_FB_FINISH )

            )

        );

    pNodeFileFinish->m_iconBig.m_bmpNormal.Make32();

    pNodeFileFinish->m_iconBig.m_bmpNormal.AlphaColor( RGB(255,0,255), RGB(0,0,0), 0 );

    pRibbonNodeFile->InsertNode( NULL, pNodeFileFinish );



                CExtRibbonNode * pNodeFileFinishInspectDocument =

                    new CExtRibbonNode(

                        ID_FB_FINISH_INSPECT_DOCUMENT,

                        ID_FB_FINISH_INSPECT_DOCUMENT,

                        NULL,

                        __ECTN_BIG_ACCENT_IN_MENU|__ECTN_BOLD_IN_MENU,

                        NULL,

                        _T("&Inspect Document...")

                        );

                pNodeFileFinishInspectDocument->CmdKeyTipSet( new CExtCustomizeCmdKeyTip( __EXT_MFC_SAFE_TCHAR( _T(’I’) ) ), false );

                pNodeFileFinishInspectDocument->SetTextMenuExtended(

                    _T("Helps check the document for\ninapropriate or private information.")

                    );

                VERIFY(

                    pNodeFileFinishInspectDocument->m_iconBig.m_bmpNormal.LoadBMP_Resource(

                        MAKEINTRESOURCE( ID_FB_FINISH_INSPECT_DOCUMENT )

                        )

                    );

                pNodeFileFinishInspectDocument->m_iconBig.m_bmpNormal.Make32();

                pNodeFileFinishInspectDocument->m_iconBig.m_bmpNormal.AlphaColor( RGB(255,0,255), RGB(0,0,0), 0 );

                pNodeFileFinish->InsertNode( NULL, pNodeFileFinishInspectDocument );



                CExtRibbonNode * pNodeFileFinishRestrictPermission =

                    new CExtRibbonNode(

                        ID_FB_FINISH_RESTRICT_PERMISSION,

                        ID_FB_FINISH_RESTRICT_PERMISSION,

                        NULL,

                        __ECTN_BIG_ACCENT_IN_MENU|__ECTN_BOLD_IN_MENU,

                        NULL,

                        _T("Restrict &Permission")

                        );

                pNodeFileFinishRestrictPermission->CmdKeyTipSet( new CExtCustomizeCmdKeyTip( __EXT_MFC_SAFE_TCHAR( _T(’R’) ) ), false );

                pNodeFileFinishRestrictPermission->SetTextMenuExtended(

                    _T("Grant access to specific users by verifying\ntheir login credentials.")

                    );

                VERIFY(

                    pNodeFileFinishRestrictPermission->m_iconBig.m_bmpNormal.LoadBMP_Resource(

                        MAKEINTRESOURCE( ID_FB_FINISH_RESTRICT_PERMISSION )

                        )

                    );

                pNodeFileFinishRestrictPermission->m_iconBig.m_bmpNormal.Make32();

                pNodeFileFinishRestrictPermission->m_iconBig.m_bmpNormal.AlphaColor( RGB(255,0,255), RGB(0,0,0), 0 );

                pNodeFileFinish->InsertNode( NULL, pNodeFileFinishRestrictPermission );



                            CExtRibbonNode * pNodeFileFinishUnrestrictedAccess =

                                new CExtRibbonNode(

                                    ID_FB_FINISH_RESTRICT_PERMISSION_UNRESTRICTED_ACCESS,

                                    ID_FB_FINISH_RESTRICT_PERMISSION_UNRESTRICTED_ACCESS,

                                    NULL,

                                    0,

                                    NULL,

                                    _T("&Unrestricted Access")

                                    );

                            pNodeFileFinishUnrestrictedAccess->CmdKeyTipSet( new CExtCustomizeCmdKeyTip( __EXT_MFC_SAFE_TCHAR( _T(’U’) ) ), false );

                            pNodeFileFinishRestrictPermission->InsertNode( NULL, pNodeFileFinishUnrestrictedAccess );



                            CExtRibbonNode * pNodeFileFinishDoNotDistribute =

                                new CExtRibbonNode(

                                    ID_FB_FINISH_RESTRICT_PERMISSION_DO_NOT_DISTRIBUTE,

                                    ID_FB_FINISH_RESTRICT_PERMISSION_DO_NOT_DISTRIBUTE,

                                    NULL,

                                    0,

                                    NULL,

                                    _T("Do &Not Distribute...")

                                    );

                            pNodeFileFinishRestrictPermission->InsertNode( NULL, pNodeFileFinishDoNotDistribute );



                            CExtRibbonNode * pNodeFileFinishRestrictPermissionAs =

                                new CExtRibbonNode(

                                    ID_FB_FINISH_RESTRICT_PERMISSION_AS,

                                    ID_FB_FINISH_RESTRICT_PERMISSION_AS,

                                    NULL,

                                    __ECTN_GROUP_START,

                                    NULL,

                                    _T("&Restrict Permission As...")

                                    );

                            pNodeFileFinishRestrictPermissionAs->CmdKeyTipSet( new CExtCustomizeCmdKeyTip( __EXT_MFC_SAFE_TCHAR( _T(’R’) ) ), false );

                            pNodeFileFinishRestrictPermission->InsertNode( NULL, pNodeFileFinishRestrictPermissionAs );



                CExtRibbonNode * pNodeFileFinishAddDigitalSignature =

                    new CExtRibbonNode(

                        ID_FB_FINISH_ADD_DIGITAL_SIGNATURE,

                        ID_FB_FINISH_ADD_DIGITAL_SIGNATURE,

                        NULL,

                        __ECTN_BIG_ACCENT_IN_MENU|__ECTN_BOLD_IN_MENU,

                        NULL,

                        _T("Add a Digital &Signature...")

                        );

                pNodeFileFinishAddDigitalSignature->CmdKeyTipSet( new CExtCustomizeCmdKeyTip( __EXT_MFC_SAFE_TCHAR( _T(’S’) ) ), false );

                pNodeFileFinishAddDigitalSignature->SetTextMenuExtended(

                    _T("Add a signature that is not visible within\nthe content of the document.")

                    );

                VERIFY(

                    pNodeFileFinishAddDigitalSignature->m_iconBig.m_bmpNormal.LoadBMP_Resource(

                        MAKEINTRESOURCE( ID_FB_FINISH_ADD_DIGITAL_SIGNATURE )

                        )

                    );

                pNodeFileFinishAddDigitalSignature->m_iconBig.m_bmpNormal.Make32();

                pNodeFileFinishAddDigitalSignature->m_iconBig.m_bmpNormal.AlphaColor( RGB(255,0,255), RGB(0,0,0), 0 );

                pNodeFileFinish->InsertNode( NULL, pNodeFileFinishAddDigitalSignature );



                CExtRibbonNode * pNodeFileFinishCompatibilityChecker =

                    new CExtRibbonNode(

                        ID_FB_FINISH_COMPATIBILITY_CHECKER,

                        ID_FB_FINISH_COMPATIBILITY_CHECKER,

                        NULL,

                        __ECTN_BIG_ACCENT_IN_MENU|__ECTN_BOLD_IN_MENU,

                        NULL,

                        _T("&Compatibility Checker...")

                        );

                pNodeFileFinishCompatibilityChecker->CmdKeyTipSet( new CExtCustomizeCmdKeyTip( __EXT_MFC_SAFE_TCHAR( _T(’C’) ) ), false );

                pNodeFileFinishCompatibilityChecker->SetTextMenuExtended(

                    _T("Check the document for features\nunsupported by previous version.")

                    );

                VERIFY(

                    pNodeFileFinishCompatibilityChecker->m_iconBig.m_bmpNormal.LoadBMP_Resource(

                        MAKEINTRESOURCE( ID_FB_FINISH_COMPATIBILITY_CHECKER )

                        )

                    );

                pNodeFileFinishCompatibilityChecker->m_iconBig.m_bmpNormal.Make32();

                pNodeFileFinishCompatibilityChecker->m_iconBig.m_bmpNormal.AlphaColor( RGB(255,0,255), RGB(0,0,0), 0 );

                pNodeFileFinish->InsertNode( NULL, pNodeFileFinishCompatibilityChecker );



                CExtRibbonNode * pNodeFileFinishMarkAsFinal =

                    new CExtRibbonNode(

                        ID_FB_FINISH_MARK_AS_FINAL,

                        ID_FB_FINISH_MARK_AS_FINAL,

                        NULL,

                        __ECTN_BIG_ACCENT_IN_MENU|__ECTN_BOLD_IN_MENU,

                        NULL,

                        _T("Mark As &Final")

                        );

                pNodeFileFinishMarkAsFinal->CmdKeyTipSet( new CExtCustomizeCmdKeyTip( __EXT_MFC_SAFE_TCHAR( _T(’M’) ) ), false );

                pNodeFileFinishMarkAsFinal->SetTextMenuExtended(

                    _T("Let readers know your document is final\nand make it read only.")

                    );

                VERIFY(

                    pNodeFileFinishMarkAsFinal->m_iconBig.m_bmpNormal.LoadBMP_Resource(

                        MAKEINTRESOURCE( ID_FB_FINISH_MARK_AS_FINAL )

                        )

                    );

                pNodeFileFinishMarkAsFinal->m_iconBig.m_bmpNormal.Make32();

                pNodeFileFinishMarkAsFinal->m_iconBig.m_bmpNormal.AlphaColor( RGB(255,0,255), RGB(0,0,0), 0 );

                pNodeFileFinish->InsertNode( NULL, pNodeFileFinishMarkAsFinal );



CExtRibbonNode * pNodeFileShare =

        new CExtRibbonNode(

            ID_FB_SHARE,

            ID_FB_SHARE,

            NULL,

            __ECTN_BIG_ACCENT_IN_MENU,

            NULL,

            _T("S&hare")

            );

    pNodeFileShare->CmdKeyTipSet( new CExtCustomizeCmdKeyTip( __EXT_MFC_SAFE_TCHAR( _T(’H’) ) ), false );

    pNodeFileShare->SetTextMenuCaption( _T("Share Your Document") );

    VERIFY(

        pNodeFileShare->m_iconBig.m_bmpNormal.LoadBMP_Resource(

            MAKEINTRESOURCE( ID_FB_SHARE )

            )

        );

    pNodeFileShare->m_iconBig.m_bmpNormal.Make32();

    pNodeFileShare->m_iconBig.m_bmpNormal.AlphaColor( RGB(255,0,255), RGB(0,0,0), 0 );

    pRibbonNodeFile->InsertNode( NULL, pNodeFileShare );



                CExtRibbonNode * pNodeFileShareEmail =

                    new CExtRibbonNode(

                        ID_FB_SHARE_EMAIL,

                        ID_FB_SHARE_EMAIL,

                        NULL,

                        __ECTN_BIG_ACCENT_IN_MENU|__ECTN_BOLD_IN_MENU,

                        NULL,

                        _T("&Email...")

                        );

                pNodeFileShareEmail->CmdKeyTipSet( new CExtCustomizeCmdKeyTip( __EXT_MFC_SAFE_TCHAR( _T(’E’) ) ), false );

                pNodeFileShareEmail->SetTextMenuExtended(

                    _T("Email a copy of your document as an\nattachment.")

                    );

                VERIFY(

                    pNodeFileShareEmail->m_iconBig.m_bmpNormal.LoadBMP_Resource(

                        MAKEINTRESOURCE( ID_FB_SHARE_EMAIL )

                        )

                    );

                pNodeFileShareEmail->m_iconBig.m_bmpNormal.Make32();

                pNodeFileShareEmail->m_iconBig.m_bmpNormal.AlphaColor( RGB(255,0,255), RGB(0,0,0), 0 );

                pNodeFileShare->InsertNode( NULL, pNodeFileShareEmail );



                CExtRibbonNode * pNodeFileShareInternetFax =

                    new CExtRibbonNode(

                        ID_FB_SHARE_INET_FAX,

                        ID_FB_SHARE_INET_FAX,

                        NULL,

                        __ECTN_BIG_ACCENT_IN_MENU|__ECTN_BOLD_IN_MENU,

                        NULL,

                        _T("Internet Fa&x...")

                        );

                pNodeFileShareInternetFax->CmdKeyTipSet( new CExtCustomizeCmdKeyTip( __EXT_MFC_SAFE_TCHAR( _T(’F’) ) ), false );

                pNodeFileShareInternetFax->SetTextMenuExtended(

                    _T("Use an internet fax service to fax your\ndocument.")

                    );

                VERIFY(

                    pNodeFileShareInternetFax->m_iconBig.m_bmpNormal.LoadBMP_Resource(

                        MAKEINTRESOURCE( ID_FB_SHARE_INET_FAX )

                        )

                    );

                pNodeFileShareInternetFax->m_iconBig.m_bmpNormal.Make32();

                pNodeFileShareInternetFax->m_iconBig.m_bmpNormal.AlphaColor( RGB(255,0,255), RGB(0,0,0), 0 );

                pNodeFileShare->InsertNode( NULL, pNodeFileShareInternetFax );



                CExtRibbonNode * pNodeFileShareDocumentManagementServer =

                    new CExtRibbonNode(

                        ID_FB_SHARE_DMS,

                        ID_FB_SHARE_DMS,

                        NULL,

                        __ECTN_BIG_ACCENT_IN_MENU|__ECTN_BOLD_IN_MENU,

                        NULL,

                        _T("&Document Management Server...")

                        );

                pNodeFileShareDocumentManagementServer->CmdKeyTipSet( new CExtCustomizeCmdKeyTip( __EXT_MFC_SAFE_TCHAR( _T(’D’) ) ), false );

                pNodeFileShareDocumentManagementServer->SetTextMenuExtended(

                    _T("Share this document by saving it to an\ndocument management server.")

                    );

                VERIFY(

                    pNodeFileShareDocumentManagementServer->m_iconBig.m_bmpNormal.LoadBMP_Resource(

                        MAKEINTRESOURCE( ID_FB_SHARE_DMS )

                        )

                    );

                pNodeFileShareDocumentManagementServer->m_iconBig.m_bmpNormal.Make32();

                pNodeFileShareDocumentManagementServer->m_iconBig.m_bmpNormal.AlphaColor( RGB(255,0,255), RGB(0,0,0), 0 );

                pNodeFileShare->InsertNode( NULL, pNodeFileShareDocumentManagementServer );



                CExtRibbonNode * pNodeFileShareCreateDocumentWorkspace =

                    new CExtRibbonNode(

                        ID_FB_SHARE_CREATE_DOC_WKS,

                        ID_FB_SHARE_CREATE_DOC_WKS,

                        NULL,

                        __ECTN_BIG_ACCENT_IN_MENU|__ECTN_BOLD_IN_MENU,

                        NULL,

                        _T("&Create Document Workspace...")

                        );

                pNodeFileShareCreateDocumentWorkspace->CmdKeyTipSet( new CExtCustomizeCmdKeyTip( __EXT_MFC_SAFE_TCHAR( _T(’W’) ) ), false );

                pNodeFileShareCreateDocumentWorkspace->SetTextMenuExtended(

                    _T("Create new site of this document and\nkeep your local copy synchronized.")

                    );

                VERIFY(

                    pNodeFileShareCreateDocumentWorkspace->m_iconBig.m_bmpNormal.LoadBMP_Resource(

                        MAKEINTRESOURCE( ID_FB_SHARE_CREATE_DOC_WKS )

                        )

                    );

                pNodeFileShareCreateDocumentWorkspace->m_iconBig.m_bmpNormal.Make32();

                pNodeFileShareCreateDocumentWorkspace->m_iconBig.m_bmpNormal.AlphaColor( RGB(255,0,255), RGB(0,0,0), 0 );

                pNodeFileShare->InsertNode( NULL, pNodeFileShareCreateDocumentWorkspace );



CExtRibbonNode * pNodeFilePrint =

        new CExtRibbonNode(

            ID_FB_PRINT,

            ID_FB_PRINT,

            NULL,

            __ECTN_BIG_ACCENT_IN_MENU|__ECTN_TBB_SEPARATED_DROPDOWN,

            NULL,

            _T("&Print...")

            );

    pNodeFilePrint->CmdKeyTipSet( new CExtCustomizeCmdKeyTip( __EXT_MFC_SAFE_TCHAR( _T(’P’) ) ), false );

    pNodeFilePrint->CmdKeyTipSet( new CExtCustomizeCmdKeyTip( __EXT_MFC_SAFE_TCHAR( _T(’W’) ) ), false, false );

    pNodeFilePrint->SetTextMenuCaption( _T("Printing Your Document") );

    VERIFY(

        pNodeFilePrint->m_iconBig.m_bmpNormal.LoadBMP_Resource(

            MAKEINTRESOURCE( ID_FB_PRINT )

            )

        );

    pNodeFilePrint->m_iconBig.m_bmpNormal.Make32();

    pNodeFilePrint->m_iconBig.m_bmpNormal.AlphaColor( RGB(255,0,255), RGB(0,0,0), 0 );

    pRibbonNodeFile->InsertNode( NULL, pNodeFilePrint );



                CExtRibbonNode * pNodeFilePrintPrint =

                    new CExtRibbonNode(

                        ID_FB_PRINT,

                        ID_FB_PRINT,

                        NULL,

                        __ECTN_BIG_ACCENT_IN_MENU|__ECTN_BOLD_IN_MENU|__ECTN_BIG_ACCENT_IN_MENU,

                        NULL,

                        _T("&Quick Print")

                        );

                pNodeFilePrintPrint->CmdKeyTipSet( new CExtCustomizeCmdKeyTip( __EXT_MFC_SAFE_TCHAR( _T(’Q’) ) ), false );

                VERIFY(

                    pNodeFilePrintPrint->m_iconBig.m_bmpNormal.LoadBMP_Resource(

                        MAKEINTRESOURCE( ID_FB_PRINT )

                        )

                    );

                pNodeFilePrintPrint->m_iconBig.m_bmpNormal.Make32();

                pNodeFilePrintPrint->m_iconBig.m_bmpNormal.AlphaColor( RGB(255,0,255), RGB(0,0,0), 0 );

                pNodeFilePrint->InsertNode( NULL, pNodeFilePrintPrint );



                CExtRibbonNode * pNodeFilePringPreview =

                    new CExtRibbonNode(

                        ID_FB_PRINT_PREVIEW,

                        ID_FB_PRINT_PREVIEW,

                        NULL,

                        __ECTN_BIG_ACCENT_IN_MENU|__ECTN_BOLD_IN_MENU|__ECTN_BIG_ACCENT_IN_MENU,

                        NULL,

                        _T("Print Pre&view")

                        );

                pNodeFilePringPreview->CmdKeyTipSet( new CExtCustomizeCmdKeyTip( __EXT_MFC_SAFE_TCHAR( _T(’V’) ) ), false );

                VERIFY(

                    pNodeFilePringPreview->m_iconBig.m_bmpNormal.LoadBMP_Resource(

                        MAKEINTRESOURCE( ID_FB_PRINT_PREVIEW )

                        )

                    );

                pNodeFilePringPreview->m_iconBig.m_bmpNormal.Make32();

                pNodeFilePringPreview->m_iconBig.m_bmpNormal.AlphaColor( RGB(255,0,255), RGB(0,0,0), 0 );

                pNodeFilePrint->InsertNode( NULL, pNodeFilePringPreview );





CExtRibbonNode * pNodeFileClose =

        new CExtRibbonNode(

            ID_FB_CLOSE,

            ID_FB_CLOSE,

            NULL,

            __ECTN_BIG_ACCENT_IN_MENU|__ECTN_GROUP_START,

            NULL,

            _T("&Close")

            );

    pNodeFileClose->CmdKeyTipSet( new CExtCustomizeCmdKeyTip( __EXT_MFC_SAFE_TCHAR( _T(’C’) ) ), false );

    VERIFY(

        pNodeFileClose->m_iconBig.m_bmpNormal.LoadBMP_Resource(

            MAKEINTRESOURCE( ID_FB_CLOSE )

            )

        );

    pNodeFileClose->m_iconBig.m_bmpNormal.Make32();

    pNodeFileClose->m_iconBig.m_bmpNormal.AlphaColor( RGB(255,0,255), RGB(0,0,0), 0 );

                            pCmdScreenTip = new CExtCustomizeCmdScreenTip;

                            pCmdScreenTip->TextMainSet( _T("Close") );

                            pNodeFileClose->CmdScreenTipAttach( pCmdScreenTip );

    pRibbonNodeFile->InsertNode( NULL, pNodeFileClose );



    return pRibbonNodeFile;

}



CExtRibbonNodeRightButtonsCollection * CMainFrame::_InitRibbon_RightButtonsCollection()

{

CExtRibbonNodeRightButtonsCollection * pRibbonNodeRightButtonsCollection =

        new CExtRibbonNodeRightButtonsCollection;



CExtRibbonNode * pNodeRTL =

        new CExtRibbonNode(

            ID_RTL,

            ID_RTL,

            NULL,

            0L,

            _T("RTL")

            );

    VERIFY(

        pNodeRTL->m_iconSmall.m_bmpNormal.LoadBMP_Resource(

            MAKEINTRESOURCE( IDB_RTL )

            )

        );

    pNodeRTL->m_iconSmall.m_bmpNormal.Make32( false );

    pNodeRTL->m_iconSmall.m_bmpNormal.AlphaColor( RGB(255,0,255), RGB(0,0,0), BYTE(0) );

    pRibbonNodeRightButtonsCollection->InsertNode(

        NULL,

        pNodeRTL

        );



CExtRibbonNode * pNodeAppAbout =

        new CExtRibbonNode(

            ID_APP_ABOUT,

            ID_APP_ABOUT,

            NULL,

            0L,

            _T("About")

            );

    VERIFY(

        pNodeAppAbout->m_iconSmall.m_bmpNormal.LoadBMP_Resource(

            MAKEINTRESOURCE( ID_APP_ABOUT_16x16 )

            )

        );

    pNodeAppAbout->m_iconSmall.m_bmpNormal.PreMultiplyRGBChannels( false );

                            CExtCustomizeCmdScreenTip * pCmdScreenTip = new CExtCustomizeCmdScreenTip;

                            pCmdScreenTip->TextMainSet( _T("About") );

                            pNodeAppAbout->CmdScreenTipAttach( pCmdScreenTip );

    pRibbonNodeRightButtonsCollection->InsertNode(

        NULL,

        pNodeAppAbout

        );



CExtRibbonNodeMdiRightButtons * pNodeMDI =

        new CExtRibbonNodeMdiRightButtons;

    pRibbonNodeRightButtonsCollection->InsertNode(

        NULL,

        pNodeMDI

        );



    return pRibbonNodeRightButtonsCollection;

}



CExtRibbonNodeQuickAccessButtonsCollection * CMainFrame::_InitRibbon_QuickAccessButtonsCollection()

{

CExtRibbonNodeQuickAccessButtonsCollection * pRibbonNodeQuickAccessButtonsCollection =

        new CExtRibbonNodeQuickAccessButtonsCollection;



CExtRibbonNode * pNodeQA_FileSave =

        new CExtRibbonNode(

            ID_QA_FILE_SAVE,

            ID_QA_FILE_SAVE,

            NULL,

            0L,

            _T("Save")

            );

    VERIFY(

        pNodeQA_FileSave->m_iconSmall.m_bmpNormal.LoadBMP_Resource(

            MAKEINTRESOURCE( ID_QA_FILE_SAVE )

            )

        );

    pNodeQA_FileSave->m_iconSmall.m_bmpNormal.Make32();

    pNodeQA_FileSave->m_iconSmall.m_bmpNormal.AlphaColor( RGB(255,0,255), RGB(0,0,0), 0 );

                            CExtCustomizeCmdScreenTip * pCmdScreenTip = new CExtCustomizeCmdScreenTip;

                            pCmdScreenTip->TextMainSet( _T("Save") );

                            pNodeQA_FileSave->CmdScreenTipAttach( pCmdScreenTip );

    pRibbonNodeQuickAccessButtonsCollection->InsertNode(

        NULL,

        pNodeQA_FileSave

        );



CExtRibbonNode * pNodeQA_EditUndo =

        new CExtRibbonNode(

            ID_QA_EDIT_UNDO,

            ID_QA_EDIT_UNDO,

            NULL,

            0L,

            _T("Undo")

            );

    VERIFY(

        pNodeQA_EditUndo->m_iconSmall.m_bmpNormal.LoadBMP_Resource(

            MAKEINTRESOURCE( ID_QA_EDIT_UNDO )

            )

        );

    pNodeQA_EditUndo->m_iconSmall.m_bmpNormal.Make32();

    pNodeQA_EditUndo->m_iconSmall.m_bmpNormal.AlphaColor( RGB(255,0,255), RGB(0,0,0), 0 );

                            pCmdScreenTip = new CExtCustomizeCmdScreenTip;

                            pCmdScreenTip->TextMainSet( _T("Undo") );

                            pNodeQA_EditUndo->CmdScreenTipAttach( pCmdScreenTip );

    pRibbonNodeQuickAccessButtonsCollection->InsertNode(

        NULL,

        pNodeQA_EditUndo

        );



CExtRibbonNode * pNodeQA_EditRedo =

        new CExtRibbonNode(

            ID_QA_EDIT_REDO,

            ID_QA_EDIT_REDO,

            NULL,

            0L,

            _T("Redo")

            );

    VERIFY(

        pNodeQA_EditRedo->m_iconSmall.m_bmpNormal.LoadBMP_Resource(

            MAKEINTRESOURCE( ID_QA_EDIT_REDO )

            )

        );

    pNodeQA_EditRedo->m_iconSmall.m_bmpNormal.Make32();

    pNodeQA_EditRedo->m_iconSmall.m_bmpNormal.AlphaColor( RGB(255,0,255), RGB(0,0,0), 0 );

                            pCmdScreenTip = new CExtCustomizeCmdScreenTip;

                            pCmdScreenTip->TextMainSet( _T("Redo") );

                            pNodeQA_EditRedo->CmdScreenTipAttach( pCmdScreenTip );

    pRibbonNodeQuickAccessButtonsCollection->InsertNode(

        NULL,

        pNodeQA_EditRedo

        );



CExtRibbonNode * pNodeQA_FilePrint =

        new CExtRibbonNode(

            ID_QA_FILE_PRINT,

            ID_QA_FILE_PRINT,

            NULL,

            0L,

            _T("Print")

            );

    VERIFY(

        pNodeQA_FilePrint->m_iconSmall.m_bmpNormal.LoadBMP_Resource(

            MAKEINTRESOURCE( ID_QA_FILE_PRINT )

            )

        );

    pNodeQA_FilePrint->m_iconSmall.m_bmpNormal.Make32();

    pNodeQA_FilePrint->m_iconSmall.m_bmpNormal.AlphaColor( RGB(255,0,255), RGB(0,0,0), 0 );

                            pCmdScreenTip = new CExtCustomizeCmdScreenTip;

                            pCmdScreenTip->TextMainSet( _T("Print") );

                            pNodeQA_FilePrint->CmdScreenTipAttach( pCmdScreenTip );

    pRibbonNodeQuickAccessButtonsCollection->InsertNode(

        NULL,

        pNodeQA_FilePrint

        );



CExtRibbonNode * pNodeQA_AddDigitalSignature =

        new CExtRibbonNode(

            ID_QA_ADD_DIGITAL_SIGNATURE,

            ID_QA_ADD_DIGITAL_SIGNATURE,

            NULL,

            0L,

            _T("Add a Digital Signature")

            );

    VERIFY(

        pNodeQA_AddDigitalSignature->m_iconSmall.m_bmpNormal.LoadBMP_Resource(

            MAKEINTRESOURCE( ID_QA_ADD_DIGITAL_SIGNATURE )

            )

        );

    pNodeQA_AddDigitalSignature->m_iconSmall.m_bmpNormal.Make32();

    pNodeQA_AddDigitalSignature->m_iconSmall.m_bmpNormal.AlphaColor( RGB(255,0,255), RGB(0,0,0), 0 );

                            pCmdScreenTip = new CExtCustomizeCmdScreenTip;

                            pCmdScreenTip->TextMainSet( _T("Add digital signature") );

                            pNodeQA_AddDigitalSignature->CmdScreenTipAttach( pCmdScreenTip );

    pRibbonNodeQuickAccessButtonsCollection->InsertNode(

        NULL,

        pNodeQA_AddDigitalSignature

        );



    return pRibbonNodeQuickAccessButtonsCollection;

}



CExtRibbonNode * CMainFrame::_InitRibbonPage_Test()

{

CExtRibbonNodeTabPage * pRibbonNodeTabPage = new CExtRibbonNodeTabPage( 0L, NULL, _T("Test") );

    pRibbonNodeTabPage->CmdKeyTipSet( new CExtCustomizeCmdKeyTip( __EXT_MFC_SAFE_TCHAR( _T(’T’) ) ), false );

    pRibbonNodeTabPage->InsertNode( NULL, _InitRibbonNode_Test_Test() );

    return pRibbonNodeTabPage;

}



static bool

SetRibbonBMP(CExtBitmap &bmp, UINT id)

{

    if (!bmp.LoadBMP_Resource(MAKEINTRESOURCE(id)))

    {

        TRACE("SetRibbonBMP: Can’t find bitmap resource id %d\n", id);

        return false;

    }

    bmp.Make32();

    bmp.AlphaColor(RGB(255,0,255), RGB(0,0,0), 0);

    return true;

}



static void

SetRibbonTips(CExtCustomizeCmdTreeNode *node, const TCHAR *keyTip,

              CExtBitmap &bmp,

              const TCHAR *tipTitle = NULL,

              const TCHAR *tipText = NULL,

              UINT bmpId2 = 0,

              const TCHAR *tipText2 = NULL,

              bool isDropDown = false)

{

    if (keyTip != NULL)

        node->CmdKeyTipSet(new CExtCustomizeCmdKeyTip(

                __EXT_MFC_SAFE_TCHAR(keyTip)), false, !isDropDown);

    if (tipTitle == NULL && tipText == NULL)

        return;

    CExtCustomizeCmdScreenTip *tip = new CExtCustomizeCmdScreenTip;

    tip->BmpMainGet() = bmp;

    if (tipTitle != NULL)

        tip->CaptionMainSet(tipTitle);

    if (tipText != NULL)

    {

        tip->TextMainSet(tipText);

        if (tipText2 != NULL)

        {

            tip->CaptionSecondarySet(tipText2);

            if (bmpId2 != 0)

            {

                tip->BmpSecondaryGet().LoadBMP_Resource(

                    MAKEINTRESOURCE(bmpId2));

                tip->BmpSecondaryGet().PreMultiplyRGBChannels(false);

            }

        }

    }

    node->CmdScreenTipAttach(tip, !isDropDown);

}



static void

SetRibbonTips(CExtCustomizeCmdTreeNode *node, const TCHAR *keyTip,

              UINT bmpId = 0,

              const TCHAR *tipTitle = NULL,

              const TCHAR *tipText = NULL,

              UINT bmpId2 = 0,

              const TCHAR *tipText2 = NULL,

              bool isDropDown = false)

{

    if (keyTip != NULL)

        node->CmdKeyTipSet(new CExtCustomizeCmdKeyTip(

                __EXT_MFC_SAFE_TCHAR(keyTip)), false, !isDropDown);

    if (tipTitle == NULL && tipText == NULL)

        return;

    CExtCustomizeCmdScreenTip *tip = new CExtCustomizeCmdScreenTip;

    if (bmpId != 0)

        SetRibbonBMP(tip->BmpMainGet(), bmpId);

    if (tipTitle != NULL)

        tip->CaptionMainSet(tipTitle);

    if (tipText != NULL)

    {

        tip->TextMainSet(tipText);

        if (tipText2 != NULL)

        {

            tip->CaptionSecondarySet(tipText2);

            if (bmpId2 != 0)

            {

                tip->BmpSecondaryGet().LoadBMP_Resource(

                    MAKEINTRESOURCE(bmpId2));

                tip->BmpSecondaryGet().PreMultiplyRGBChannels(false);

            }

        }

    }

    node->CmdScreenTipAttach(tip, !isDropDown);

}



void

AddRibbonDropDownItem(CExtRibbonNode *parent, const TCHAR *label,

                      const TCHAR *keyTip, UINT id, UINT bmpId = 0)

{

    CExtCmdIcon icon, *iconP = NULL;

#ifdef TRY_RIBBON_NODES_IN_MENU

    // Attempting to use a CExtRibbonNode instead creates the items in the menu

    // properly, but somehow removes both the icon and text from the parent

    // button!

    CExtRibbonNode *node =

        new CExtRibbonNode(id, id, NULL, 0, label, label);

    SetRibbonBMP(node->m_iconBig.m_bmpNormal, bmpId);

    SetRibbonBMP(node->m_iconSmall.m_bmpNormal, id);

#else

    if (bmpId != 0 && SetRibbonBMP(icon.m_bmpNormal, bmpId))

        iconP = &icon;

    CExtCustomizeCmdTreeNode *node =

        new CExtCustomizeCmdTreeNode(id, id, NULL, 0, label, label, NULL, 0,

                                     iconP);

#endif // TRY_RIBBON_NODES_IN_MENU

    SetRibbonTips(node, keyTip, bmpId, label, _T("More text could go here"));

    parent->InsertNode(NULL, node);

}



CExtRibbonNode * CMainFrame::_InitRibbonNode_Test_Test()

{

    CExtRibbonNodeGroup * group =

        new CExtRibbonNodeGroup( ID_RIBBON_PAGE_TEST );

    SetRibbonTips(group, _T(""), ID_COVER_PAGE_LARGE, _T("Blah"), _T("Blah blah"));

    SetRibbonBMP(group->m_iconBig.m_bmpNormal, ID_COVER_PAGE_LARGE);

    SetRibbonBMP(group->m_iconSmall.m_bmpNormal, ID_COVER_PAGE_SMALL);

    CExtCustomizeCmdScreenTip * pCmdScreenTip = new CExtCustomizeCmdScreenTip;

    pCmdScreenTip->TextMainSet( _T("Test") );

    group->CmdScreenTipAttach( pCmdScreenTip );

    group->SetTextInToolbar( _T("Test") );



#ifdef USE_SAME_IDS_FOR_CMD_AND_BMP

    UINT cmdId = ID_COVER_PAGE_LARGE;

    UINT cmdId2 = ID_BLANK_PAGE_LARGE;

    UINT cmdId3 = ID_PAGE_BREAK_LARGE;

#else

    UINT cmdId = ID_COVER_PAGE_SMALL;

    UINT cmdId2 = ID_BLANK_PAGE_SMALL;

    UINT cmdId3 = ID_PAGE_BREAK_SMALL;

#endif // USE_SAME_IDS_FOR_CMD_AND_BMP

#ifdef SHOW_ICONS_IN_MENU

    UINT bmpId = ID_COVER_PAGE_LARGE;

    UINT bmpId2 = ID_BLANK_PAGE_LARGE;

    UINT bmpId3 = ID_PAGE_BREAK_LARGE;

#else

    UINT bmpId = 0;

    UINT bmpId2 = 0;

    UINT bmpId3 = 0;

#endif // SHOW_ICONS_IN_MENU

    CExtRibbonNode * node =

        new CExtRibbonNode( cmdId, cmdId, NULL, 0, _T("Test") );

    //node->RibbonILE_RuleArrayGet().RemoveAll();

    SetRibbonBMP(node->m_iconBig.m_bmpNormal, ID_COVER_PAGE_LARGE);

    SetRibbonBMP(node->m_iconSmall.m_bmpNormal, ID_COVER_PAGE_SMALL);



    SetRibbonTips(node, _T(""), ID_COVER_PAGE_LARGE, _T("Test"), _T("Blah blah"));

    SetRibbonTips(node, _T(""), ID_COVER_PAGE_LARGE, _T("Drop"), _T("Drop down"), 0, NULL, true);



    group->InsertNode(NULL, node);



#ifdef USE_DROP_DOWN

#ifdef USE_AUTO_CHANGE

    node->ModifyFlags(__ECTN_TBB_SEPARATED_DROPDOWN | __ECTN_TBB_AUTOCHANGE_ID);

#else

    node->ModifyFlags(__ECTN_TBB_SEPARATED_DROPDOWN);

#endif // USE_AUTO_CHANGE



    AddRibbonDropDownItem(node, _T("Item 1"), _T(""), cmdId, bmpId);

    AddRibbonDropDownItem(node, _T("Item 2"), _T(""), cmdId2, bmpId2);

    AddRibbonDropDownItem(node, _T("Item 3"), _T(""), cmdId3, bmpId3);

#endif // NO_DROP_DOWN

    return group;

}

Robert Webb Sep 16, 2008 - 6:42 PM

> The ribbon bar buttons should contain text which are not changed via menu

> actions. Changing the button’s text can change entire ribbon’s layout of

> buttons and even make some ribbon groups collapsed. This means the split

> buttons with auto-changed command identifier should be without text.



Yes it should cause a rearrangement. However I don’t see why that’s a problem. Ribbon bars are specifically designed to do this sort of rearrangement, so what’s the problem? If the text changes, the ribbon bar should rearrange. I don’t mind that. But I do need the text to match the menu item chosen.



Any tips on how I can make this happen with the current Prof-UIS release? There seem to be a few issues:



(1) How do I catch the menu selection event?



(2) Once caught I can call SetTextInToolbar(). Will that cause the ribbon bar to rearrange if called on-the-fly? Or do I need to force a rearrangement somehow?



(3) The next problem though is that even when text is set Prof-UIS won’t display it on an auto-change drop-down item. How would I force that to happen? Can you point me to the place in the Prof-UIS library code where the text is drawn?



(4) Finally, if the menu is made from CExtRibbonNodes rather than CExtCustomizeCmdTreeNodes, even the icon won’t appear in the ribbon bar. Just a blank button with no icon and no text. Why is this? How do I get around it? I want to do it this way so that the items have large and small icons which can both be inherited by the parent drop-down button, and used as appropriate. Again, I need to override the auto-behaviour myself I think to do this (and inherit tooltips as well).



> The inheritable ribbon tip feature is not implemented yet. Thank you for

> reporting us this issue. We added this to our to-do list.



Thanks. We have a deadline soon though. I’m happy to impliment this myself for now, but need to know how to override a few things as per above.



Thanks,

Rob.

Technical Support Sep 17, 2008 - 5:58 AM

Here are the answers to your questions,

1) You should handle a CExtPopupBaseWnd::g_nMsgTranslateMouseClickEvent registered message in your main frame window so that you can catch mouse click events during menu item tacking. The WPARAM parameter is a pointer to the CExtPopupBaseWnd::TranslateMouseClickEventData_t data structure. If your method handles the mouse click event, it should set the CExtPopupBaseWnd::TranslateMouseClickEventData_t::m_bMessageHandled property to true and CExtPopupBaseWnd::TranslateMouseClickEventData_t::m_bNoEat property to false. Of course, you will need to hit-test the menu item using the CExtPopupMenuWnd::_HitTest() method and detect whether it’s disabled using the CExtPopupMenuWnd::ItemEnabledGet() method.

2) You should update the ribbon bar’s layout using the CExtRibbonPage::Ribbon_UpdateLayout() method.

3) This is not supported yet. We need to do some tricky changes in ribbon’s code to make this possible.

4) Currently the ribbon nodes should be used for in-ribbon elements only and command tree nodes should be used for popup menu items. The large/small icon inheritance is also require improvements in Prof-UIS code.

We took a closer look at the Microsoft Office 2007 applications again. It looks like split buttons never change the main part of button there. We suppose such auto-change-able buttons are replaced with galleries.

Robert Webb Sep 18, 2008 - 3:29 AM

Thanks for the answers, I’ll try them out.



3) This is not supported yet. We need to do some tricky changes in ribbon’s code to make this possible.
Surely it’s not far from working. Did you try the different cases in my test program? Change the TEST_NUMBER #define to other numbers, as described at the top. In particular, look at case 2. This shows that the text can indeed auto-change and is displayed, but only when no icons are used. I tried different length labels in the drop-down, and the ribbon bar doesn’t rearrange accordingly, but I should be able to catch the event and force the update. Does Prof-UIS core code explicitly prevent the label from appearing? Or is it a side effect of something else? If you could point me at the part in the code where the label is drawn I may be able try changing it.
4) Currently the ribbon nodes should be used for in-ribbon elements only and command tree nodes should
be used for popup menu items.





They seem to work fine on the menu itself. The only side effect is that the parent button won’t show an icon or text at all (whether or not it’s an auto-change drop-down). How is it that the icon/text isn’t drawn? Again, is this something explicitly done by Prof-UIS, or some sort of side effect?



We took a closer look at the Microsoft Office 2007 applications again. It looks like split
buttons never change the main part of button there. We suppose such auto-change-able buttons
are replaced with galleries.





Is there a way I could use a gallery instead? Can I make a gallery appear like a simple menu, preferably with large icons?



Thanks,

Rob.

Robert Webb Sep 23, 2008 - 3:18 AM

I’ve managed to get all this mostly working, but much trickiness was required to get it right.  Here’s what I did:

- Used a new unique ID for drop-down button.  Anytime the button shares an ID with one of the menu items things break.

- Handled CExtPopupBaseWnd::g_nMsgTranslateMouseClickEvent as you suggested.  However I didn’t set m_bMessageHandled to true nor m_bNoEat to false, as this stopped the popup from closing, and all seems to work if I just leave those values as is.  I also didn’t call ItemEnabledGet(), as this caused a failed assertion.

- I cast wParam to CExtPopupBaseWnd::TranslateMouseClickEventData_t.  This class has a m_nFlags member.  Took me a while to figure out what symbolic constants this used, but I eventually figured out it’s not flags at all, but rather a Windows message such as WM_LBUTTONUP.  Why call it m_nFlags?

- I used _HitTest() as you suggested (why the "_" if it’s a public method?) to find the item clicked, which gave me access to the menu item node, and in turn its parent ribbon bar node, which is the drop-down button initially clicked.

- I copied the labels and tips from the menu item to the parent.  I also copied the large icon (I’m using large icons in the drop-down menu).  For the small icon I have a lookup table so I know which resource to use based on the large icon ID.

- Copied the effective command from the menu item to the basic command of the parent, leaving the parent’s effective ID unchanged.  See explanation below for details.

- Called Ribbon_UpdateLayout() as you suggested to update the ribbon bar in case of label text changing size.  This wasn’t enough though and I also needed to call InvalidateRect(NULL) and UpdateWindow().



Also needed a method to handle the drop-down button’s new event.  The problem here however is that I need to know which menu item was last selected.  The only way I could get it all to work was for the menu-item handler to change the basic ID to the desired command without changing the effective ID.  Prof-UIS doesn’t give you a direct way to do this.  SetCmdID(...true) changes the effective ID only, while SetCmdID(...false) changes both.  So I needed to call it twice: once to set both, and again to set just the effective ID back again.  Then I can use SearchNodeElement() in the drop-down button handler to find the relevant button via the constant effective ID, then get the basic ID from that node, which represents the command ID that should actually be performed.



Weird: Changing the basic and effective IDs for a ribbon button doesn’t effect which handler is used for it, as defined by ON_COMMAND(), even though the ID no longer matches.  What’s happening here?



Remaining problems:

- If the drop-down is put on the quick-access bar, things don’t keep in sync.


We took a closer look at the Microsoft Office 2007 applications again. It looks like split buttons never
change the main part of button there.



Maybe, but no reason it shouldn’t be allowed.  It is a little odd when the change in text size causes the buttons to rearrange and switch between large and small, but it makes sense.  Alternative would be to always allow enough space for the longest menu label.

Technical Support Sep 24, 2008 - 5:07 AM

We are sorry for the delay with this reply. All the Prof-UIS notifications related to re-translated mouse events provide mouse event flags in appropriated data structures "as is". But we suspect some mouse flags can be really absent because mouse event is re-translated from thread hook procedure - not from window procedure. The methods starting from "_" character are internal Prof-UIS methods. They are not documented and we are advising to use them very rarely and only in case of advanced coding tasks like you requested us. The "_" character allows us to see all the internal class methods in the Class View separated from the other methods. We also using inversion based method naming (ItemTextGet and ItemTextSet instead of GetItemText and GetItemText) what places similar methods near each other in the class method list displayed in Class View. You also worte:

Weird: Changing the basic and effective IDs for a ribbon button doesn’t effect which handler is used for it, as defined by ON_COMMAND(), even though the ID no longer matches. What’s happening here?

We don’t understand the problem. Of course, if you have changed button’s identifier, then it sends command messages with the new identifier.

The buttons inside the quick access toolbar are working exactly same as other buttons. The quick access toolbar is not a standalone control and even not window. This is several ribbon buttons placed near each other on the surface of the ribbon bar control. Besides the ribbon bar is based on the CExtCustomizeSite class which manages command tree nodes and appropriated toolbar buttons and menu items in customizable toolbars/menus and ribbon controls. The customize site does automatic synchronization of several types of toolbar/menu/ribbon items. For instance text values in text fields and combo fields are synchronized. The effective command identifiers of split buttons are not synchronized between several copies of the same button. Is that what want to do?



Robert Webb Sep 25, 2008 - 4:20 AM

 


Weird: Changing the basic and effective IDs for a ribbon button doesn’t effect which handler is used for it, as defined by ON_COMMAND(), even though the ID no longer matches. What’s happening here?

We don’t understand the problem. Of course, if you have changed button’s identifier, then it sends command messages with the new identifier.

No, that’s what I’m saying didn’t happen.  I could change the effective and basic IDs, but the ON_COMMAND() for the original ID was still called, not for the new ID.  Anyway, it’s not important for me as it isn’t causing a problem, I just thought it was odd.


The buttons inside the quick access toolbar are working exactly same as other buttons. The quick access toolbar is not a standalone control and even not window. This is several ribbon buttons placed near each other on the surface of the ribbon bar control. Besides the ribbon bar is based on the CExtCustomizeSite class which manages command tree nodes and appropriated toolbar buttons and menu items in customizable toolbars/menus and ribbon controls. The customize site does automatic synchronization of several types of toolbar/menu/ribbon items. For instance text values in text fields and combo fields are synchronized. The effective command identifiers of split buttons are not synchronized between several copies of the same button. Is that what want to do?

 


When a drop-down menu item is selected, I find the parent button (the drop-down button) and alter its large and small icons, its label, its tip, and its basic ID (but not effective).  If the button appears on the quick-access, then only the drop-down used is updated, not the other copy.  That is, if I selected from the QA drop-down, then only that button is altered.  If I select from the original drop-down, then only that button is altered.  The other button retains the old icons, text and tips (but does use the new ID).  I guess I need to find all copies of buttons with the same effective ID somehow and update all of them.


Rob.

Technical Support Sep 26, 2008 - 12:25 PM

Yes, the quick access toolbar area is a collection of cloned copies of both nodes and toolbar button objects. To find all the button instances you should use the ribbon bar as toolbar. The CExtToolControlBar::GetButtonsCount() and CExtToolControlBar::GetButtons() methods allow you to enumerate all the buttons linearly without ribbon hierarchy and get pointer to each CExtBarButton() object for further changes.

Robert Webb Oct 29, 2008 - 12:52 AM

I tried your idea of using CExtToolControlBar::GetButtonsCount() and CExtToolControlBar::GetButton().  However, it only iterates over buttons that are currently visible, ie only ones on the current ribbon page.  If I use a quick access drop-down from another page, my update code won’t find the matching drop-down on the ribbon bar.


Do I need to do something recursive to iterate over all ribbon nodes?  SearchNodeElement() looks promising, but will only find one match.


Thanks,

Rob.

Technical Support Oct 29, 2008 - 2:02 PM

The command tree contains nodes which describe the entire ribbon bar structure. The ribbon bar contains toolbar button objects only for displayed nodes: tab buttons, quick access toolbar buttons, file button, buttons at right side of tabs and all the buttons on the selected tab page. If user selects other tab page, then current set of buttons become destroyed and new buttons for selected tab page are created. So, you code is unable to access toolbar buttons which are not displayed in the ribbon bar. We do not see any problems with this design. If some button is not found, then there is nothing to change.


Robert Webb Oct 29, 2008 - 5:41 PM

There’s nothing wrong with the design, but for my purposes I need to iterate over all ribbon controls, even on pages not currently visible.  That way I can change their icons appropriately so that when they do become visible they are showing the right icon.


I have got this working though by recursing from the ribbon root node down through all child nodes, looking for matching IDs.


Thanks,


Rob.

Technical Support Sep 16, 2008 - 9:44 AM

The ribbon bar buttons should contain text which are not changed via menu actions. Changing the button’s text can change entire ribbon’s layout of buttons and even make some ribbon groups collapsed. This means the split buttons with auto-changed command identifier should be without text.

The inheritable ribbon tip feature is not implemented yet. Thank you for reporting us this issue. We added this to our to-do list.