Home > Software engineering >  How to get the CWinApp: : OnFileOpen return values?
How to get the CWinApp: : OnFileOpen return values?

Time:09-23

In learning a MDI document program, found in the message map menu item in the "open file" event is mapped to the CWinApp: : OnFileOpen events, rather than the custom open the file, I think
ON_COMMAND (ID_FILE_OPEN CWinApp: : OnFileOpen)

In the source file but could not find CWinApp: : OnFileOpen return values,
Baidu found CWinApp: : OnFileOpen prototype in appdlg. CPP, set breakpoints, the program also tracking to ENSURE smoothly (m_pDocManager!=NULL);
M_pDocManager - & gt; OnFileOpen ();
By tracking process, come to cmdtarg CPP in AFX_STATIC BOOL AFXAPI _AfxDispatchCmdMsg function, should be distributed to news, tracking to (pTarget - & gt; * MMF. PfnCmd_v_v ()); break;
Don't know what this is, after baidu will know what is point to a function pointer, didn't understand, followed by some such as message routing, with just will go to "not loaded wuser32, PDB interface", finally still don't know how to get the file name is returned, it is strange that the program did not interrupt, a few button "jump out" tracking program executed properly, can see the child window has to load the specified file,
I just want to have a general understand actually in the middle of the process, the problem is CWinApp: : when OnFileOpen return values, how to deal with it?

CodePudding user response:

Add custom response function OnMyFileOpen

ON_COMMAND (ID_FILE_OPEN CMyWinApp: : OnMyFileOpen)

CodePudding user response:

I know you can add a custom process, I want to ask CWinApp: : when OnFileOpen return values, how to deal with it?

CodePudding user response:

CWinApp: : OnFileOpen has a very simple implementation of calling CWinApp: : DoPromptFileName followed by CWinApp: : OpenDocumentFile have the file or path name of the file to open. The CWinApp implementation routine DoPromptFileName brings up the standard FileOpen dialog and fills it with the file extensions obtained from the current document templates.

CodePudding user response:

PTarget - & gt; * MMF. PfnCmd_v_v) (a) well, is to call a function pointer, the pointer to OnFileOpen,
ON_COMMAND (ID_FILE_OPEN CWinApp: : OnFileOpen) essence is to ID_FILE_OPEN this command and CWinApp: : OnFileOpen associated

CodePudding user response:

By class CRecentFileList
Can be successfully opened the file name

CodePudding user response:

The
TheApp. M_pRecentFileList - & gt; M_arrNames [j].

CodePudding user response:

Want to open the file name, overloading App class OpenDocumentFile, incoming parameters is to open the file name of the

CDocument * CMyApp: : OpenDocumentFile (LPCTSTR lpszFileName)
{
//TODO: Add your specialized code here and/or call the base class

Return CWinApp: : OpenDocumentFile (lpszFileName);
}

CodePudding user response:

7 building positive solution, overloading App, OpenDocumentFile
  • Related