Knowledge Base Nr: 00101 mruliste.cpp - http://www.swe-kaiser.de

MFC: Liste der zuletzt geladenen Dateien (MRU) im file-menu verwenden.

  
//menu-eintrag ID_FILE_MRU_FILE1 in file/datei menu (attribute: grayed).
//mit ClassWizard OpenDocumentFile() für die Applikationsklasse überladen.
//darin irgendeine funktion aufrufen oder aktion ausführen.
//muss einen pointer auf das document zurückliefern.

class CClickcon3App : public CWinApp
{
public:
...
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CClickcon3App)
public:
...
virtual CDocument* OpenDocumentFile(LPCTSTR lpszFileName);
//}}AFX_VIRTUAL
...
};

/////////////////////////////////////////////////////////////////////////////
// CClickcon3App message handlers
...
CDocument* CClickcon3App::OpenDocumentFile(LPCTSTR lpszFileName)
{
CFrameWnd* pFrm = (CFrameWnd*)AfxGetMainWnd();
CClickcon3View* pView = (CClickcon3View*)pFrm->GetActiveView();

pView->DoListeStarten(lpszFileName); //oder pDoc->OnNewDocument() oder sonstiges

return pView->GetDocument(); //sonst klappts nicht - auch wenn das Document nicht genutzt wird!
}