共用方式為


CWinApp::OnFileOpen

實作 ID_FILE_OPEN 命令。

afx_msg void OnFileOpen( );

備註

您必須將 ON_COMMAND( ID_FILE_OPEN, OnFileOpen ) 陳述式加入至 CWinApp 類別的訊息對應會啟用此成員函式。 如果已啟用,則此函式會處理 [開啟舊檔] 命令的執行。

如需預設行為的資訊和指引。如需如何覆寫這個成員函式,請參閱 Technical Note 22

範例

// The following message map, produced by the Application Wizard, binds  
// the File New, Open, and Print Setup menu commands to default 
// framework implementations of these commands.
BEGIN_MESSAGE_MAP(CStdApp, CWinApp)
   // Standard file based document commands
   ON_COMMAND(ID_FILE_NEW, &CWinApp::OnFileNew)
   ON_COMMAND(ID_FILE_OPEN, &CWinApp::OnFileOpen)
   // Standard print setup command
   ON_COMMAND(ID_FILE_PRINT_SETUP, &CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()
// The following message map illustrates how to rebind the 
// File New, Open and Print Setup menu commands to handlers that 
// you implement in your CWinApp-derived class.   
// Note, you can name the handler CCustomApp::OnFileNew instead of 
// CCustomApp::OnMyFileNew, and likewise for the other handlers, if desired.
BEGIN_MESSAGE_MAP(CCustomApp, CWinApp)
   ON_COMMAND(ID_FILE_NEW, &CCustomApp::OnMyFileNew)
   ON_COMMAND(ID_FILE_OPEN, &CCustomApp::OnMyFileOpen)
   ON_COMMAND(ID_FILE_PRINT_SETUP, &CCustomApp::OnMyFilePrintSetup)
END_MESSAGE_MAP()

需求

Header: afxwin.h

請參閱

參考

CWinApp 類別

階層架構圖表

CWinApp::OnFileNew