img/mfc2.jpg

CWinApp - przykład


Metoda OpenDocumentFile

BOOL CMyApp::InitInstance()
{
    // ...
    if (m_lpCmdLine[0] == '\0')
    {
          // Create a new (empty) document.
          OnFileNew();
    }
    else
    {
          // Open a file passed as the first command line parameter.
          OpenDocumentFile(m_lpCmdLine);
    }
  
    // ...
}

Obsługa komunikatów


BEGIN_MESSAGE_MAP(CMyApp, CWinApp)
    //{{AFX_MSG_MAP(CMyApp)
    ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
    ON_COMMAND(ID_FILE_NEW, OnMyFileNew)
    ON_COMMAND(ID_FILE_OPEN, OnMyFileOpen)
    ON_COMMAND(ID_FILE_PRINT_SETUP, OnMyFilePrintSetup)
    //}}AFX_MSG_MAP
END_MESSAGE_MAP()