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 General Discussion » Ribbonbar FileMenu Collapse All
Subject Author Date
Shailesh Nikam Jan 14, 2007 - 9:14 PM

Hi,
I have created ribbonbar bar control. Can you tell me how to show actual recent files list instead of aˆ?Recent Document Nameaˆ? from MDI application in this File Menu window(On click of button on left top corner of window).

Regards,
Shailesh

Shailesh Nikam Feb 6, 2007 - 1:16 AM

Hi,

Thanks a lot.
Using above code application is loading all recent files list in Application button of ribbonbar. But can you tell me how to write the code to open these recent files again.

Regards,
Shailesh

Shailesh Nikam Jan 15, 2007 - 10:44 PM

Hi,

I tried with above code but its giving me compilation error. Please find the attached source code and can you tell me why compiler is giving error use of undefined file ’CRecentFile’

I added InternalFriendlyWinApp class in my ribbonbar.h file and above recent file list code in OnRibbonGalleryInitContent function of ribbonbar.cpp

you can download sample source code from

http://www.wikiupload.com/download_page.php?id=53798

Regards,
Shailesh

Technical Support Jan 19, 2007 - 7:06 AM

We failed to download this file (it has a zero length). Would you check what’s wrong or send it to us by email?

Technical Support Jan 15, 2007 - 12:04 PM

The ribbon file button (also known as "application button" ) is kind of ribbon gallery button. To initialize the gallery content inside the ribbon file menu, you should override the CExtRibbonPage::OnRibbonGalleryInitContent() virtual method. You can use the CMyRibbonBar::OnRibbonGalleryInitContent() method from the RibbonBar sample as a guide.

The recent file list is stored in the CRecentFileList CWinApp::m_pRecentFileList property which is the protected property of the CWinApp class. So you will need simple trick to access it from any of your classes. First of all you should define this class somewhere in your project’s sources:

 
class __PROF_UIS_API InternalFriendlyWinApp : CWinApp
{
public:
    inline static InternalFriendlyWinApp * _GetFriendlyApp()
    {
        CWinApp * pApp = ::AfxGetApp();
        ASSERT( pApp != NULL );
        return (InternalFriendlyWinApp *)pApp;
    }
    CRecentFileList * _GetRecentFileList()
    {
        return m_pRecentFileList;
    }
};
Here is the code snippet based on the InternalFriendlyWinApp class that demonstrates how to extract correct document strings from the MFC application’s recent file list data:
CRecentFileList * pRecentFileList =
    InternalFriendlyWinApp::_GetFriendlyApp()->
        _GetRecentFileList();
if( pRecentFileList != NULL )
{
    int nRecentCount =
        pRecentFileList->GetSize();
    TCHAR sCurrDir[_MAX_PATH+1];
    ::memset(sCurrDir,0,sizeof(sCurrDir));
    ::GetCurrentDirectory(_MAX_PATH,sCurrDir);
    int nLenCurDir = (int)_tcslen(sCurrDir);
    for( int nItemIndex=0; nItemIndex<nRecentCount; nItemIndex++ )
    {
        CExtSafeString sDisplayName( _T("") );
        if(    !pRecentFileList->GetDisplayName(
                *((CString *)&sDisplayName),
                nItemIndex,
                sCurrDir,
                nLenCurDir,
                TRUE
                )
            )
            continue;
        ASSERT( !sDisplayName.IsEmpty() );
 
        . . .
 
    }
}