Note: One of this article wants to solve is: How to do a new empty document when you double-click to start a MDI application (.exe); and double-click the MDI-related file (such as .txt) or by command line Specify the parameters to open the specified related files when the MDI application is started.
Regarding this problem, I have seen the instructions on Section 2.6 on the "MFC Classic Q & A": "How to prevent an MDI application from open a new (empty) document when starting? The method given by authors is:
CCOMMANDLINFO CMDINFO; cmdinfo.m_nshellcommand = ccommandlineinfo :: Filenothing; ParseCommandLine (cmdinfo);
According to the author's explanation, when the MDI application is associated with an extension, such as "txt" text, when double-click a text file, the program will automatically open the file. The author's explanation is this: "Change the default behavior from ccommandlineinfo :: filenew to CCommandlineInfo :: Filenothing, it still allows common command line analysis." I have been testing, and the above functions cannot be implemented under VC6. Tracking a source code, I found that the author's idea is good, but under VC6, MFC has made some restrictions, and the specific source code is as follows:
void CCommandLineInfo :: ParseLast (BOOL bLast) {if (bLast) {if (m_nShellCommand == FileNew && m_strFileName.IsEmpty ()!) m_nShellCommand = FileOpen;! m_bShowSplash = m_bRunEmbedded && m_bRunAutomated;!}}
Obviously MFC emphasizes that when the execution file name of the command line is not empty, it may be required to double-click a file, and the current m_nshellcommand == filenew must also be requested, such an additional premise. So I am this solution to the above problems:
CCommandLineInfo Cmdinfo; ParseCommandline (CMDInfo); if (cmdinfo.m_strfilename == ") CMDINFO.M_NSHELLCOMMAND = CCommandLineInfo :: Filenothing; This can be implemented when the MDI application is simply opened, and there is no new empty document; The file name of the command line is not empty, or double-click the file that specifies the extension to open the MDI, you can open the specified file. This code runs through XP SP2 VC6. Reprint, please indicate: vcfly.net