如何MDI程序刚出现时,不要生成子文档????
如何MDI程序刚出现时,不要生成子文档???? 问题点数:0、回复次数:6Top
1 楼laiyiling(陌生人[MVP])回复于 2004-10-02 15:59:25 得分 0
在程序的InitInstance中的ProcessShellCommand函数之前加入:
cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothingTop
2 楼nwpulipeng(☆→【★海阔天空★】)回复于 2004-10-03 19:01:54 得分 0
帮顶混分Top
3 楼cadinfo(无语清风)回复于 2004-10-03 19:07:14 得分 0
cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing
theapp InitInstance函数内部Top
4 楼TianChong(*︿_︿* ○Ооo○泡泡oо㊣VC高手群:2997669)回复于 2004-10-05 00:45:03 得分 0
本人一直在使用的方法:
修改CApp::InitInstance中调用ProcessShellCommand的那句,将参数cmdInfo中的成员变量m_nShellCommand去掉CCommandLineInfo::FileNew标志,使用其不新建文档,具体步骤如下:
在BOOL CMDINoChildApp::InitInstance()函数中的if(!ProcessShellCommand(cmdInfo))代码前增加如下代码:(其中CMDINoChildApp改为你自已的应用程序类,如YourApp)
if(cmdInfo.m_nShellCommand==CCommandLineInfo::FileNew) //这是新增的
cmdInfo.m_nShellCommand=CCommandLineInfo::FileNothing; //这是新增的
if(!ProcessShellCommand(cmdInfo)) //这是本来就有的
return FALSE; //这是本来就有的Top
5 楼jies()回复于 2004-10-05 21:53:09 得分 0
***App()中注释掉
// if (!ProcessShellCommand(cmdInfo))
// return FALSE;Top
6 楼nineclock(闭关中。。。)回复于 2004-10-05 23:55:07 得分 0
这个问题涉及到进程(程序)初始化时的启动参数的定制问题。大家都知道,在CWinApp的初始化函数InitInstance()中有这样两句初始化程序启动参数的两句:
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
请改为:
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
if (cmdInfo.m_nShellCommand==FileNew)
cmdInfo.m_nShellCommand=CCommandLineInfo::FileNothing; //不生成默认空白文档
m_nShellCommand可能的值还有:
FileNew FileOpen FilePrint FilePrintTo FileDDE FileNothing
而CCommandLineInfo类的主要成员有:
…………(对不起,太多,我就不列了,去MSDN“索引”用“CCommandLineInfo”看一下详情吧)
了解了这几点,你就能定制你的程序的启动参数了!
注:在程序外自动启动程序激活文档是默认行为,无需你定制Top




