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 » Ribbon MRU example Collapse All
Subject Author Date
Dominik Braendlin Apr 28, 2010 - 8:45 AM

Dear Support,

I am starting to use ribbon for my MDI application. Could you please give an example on how to display the MRU „Recent File List“ in the very first drop down menu (from the left) of the ribbon bar.


The example given in RibbonBarMDI is not using real MRU content. I would like to get the same content as under ID_FILE_MRU_FILE1.



 


default:if( (pGalleryPopup->TrackFlagsGet()&TPMX_RIBBON_FILE_MENU) )"Recent Documents"), (HICON) NULL );for( nItemIndex = 0; nItemIndex < nItemCount; nItemIndex++ )" %d Recent Document Name"), nItemIndex + 1 );// 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

 

{

CExtToolBoxWnd::TOOLBOX_ITEM_DATA * pTBCI_GalleryGroup =

wndRG.ItemInsert( NULL, _T(

ASSERT( pTBCI_GalleryGroup != NULL );

INT nItemIndex, nItemCount = 5;

 

{

CExtSafeString str;

str.Format( _T(

CExtToolBoxWnd::TOOLBOX_ITEM_DATA * pTBCI_GalleryItem =

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

ASSERT( pTBCI_GalleryItem != NULL );

pTBCI_GalleryItem;

}



Thanks



Adrian

Technical Support May 3, 2010 - 8:23 AM

Unfortunately we don’t have such a test project. But we can explain you how to access the recent file list information stored inside MFC. First of all, you will need this C++ class for performing acrobatic tricks with MFC:

   class InternalFriendlyWinApp : CWinApp
            {
            public:
                        inline static InternalFriendlyWinApp * _GetFriendlyApp()
                        {
                                    CWinApp * pApp = ::AfxGetApp();
                                    ASSERT( pApp != NULL );
                                    return (InternalFriendlyWinApp *)pApp;
                        }
                        CRecentFileList * _GetRecentFileList()
                        {
                                    return m_pRecentFileList;
                        }
            }; // class InternalFriendlyWinApp
The following line of code returns the MFC’s recent file list information:
CRecentFileList * pRecentFileList = InternalFriendlyWinApp::_GetFriendlyApp()->_GetRecentFileList();

Please note, the returned pointer can be NULL if there are no recent files.
Then you can take a look at the source code of the CExtPopupMenuWnd::_BuildItems() internal method which performs the acrobatic tricks with the CRecentFileList object including the display name and relative path formatting.
The Office 2007 / 2010 recent file list is specific for the Office applications. It’s not needed for all the applications. That’s why we provide just a gallery inside ribbon file menu - not the recent file list viewer. Besides, MFC’s recent file list is single object and file list size is limited to 16 items. We have customers who support more lengthy recent file lists and multiple recent file lists.

Dominik Braendlin Apr 29, 2010 - 8:37 AM

Thank you for the example.

I am still wondering if you have an example that shows how to populate a recent file list with the MRU that is stored in the registry and that comes with every MFC SDI and MDI project.

Also how to use such a MRU item to load the specific file (e.g. 2007 Word or 2007 Excel) would be very helpful.

Adrian

Technical Support Apr 28, 2010 - 12:43 PM

The the very first drop down menu in your message is the ribbon file menu. The MRU are of it is the ribbon gallery. Each ribbon gallery element is the image - not text. Here is the sample project demonstrating how to initialize the ribbon gallery displayed by the ribbon file button:

http://www.prof-uis.com/download/forums/RibbonBar-Custom-Draw-File-Button-Gallery.zip

This sample application generates bitmaps containing text and the ribbon file button displays items which look like menu items with text - not like some graphic images.