c++ - ProcessShellCommand OpenFile 在构造文档或视图类之前调用 OpenDocumentFile
问题描述
我有一个带有文档/视图架构的单文档 MFC 项目。在 CWinApp 派生类的源文件中,我们称它为 CMyApp,在 CMyApp::InitInstance 中有这部分初始化代码:
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line. Will return FALSE if
// app was launched with /RegServer, /Register, /Unregserver or /Unregister.
if (!ProcessShellCommand(cmdInfo))
return FALSE;
在我的 CMyApp 类中,我重写了 OpenDocumentFile 函数。然后我给调试器命令行一个完整的文件路径和名称。我在对 ProcessShellCommand 的调用中设置了一个中断,它具有文件名和 m_nShellCommand 到 OpenFile。ProcessShellCommand 首先按预期调用我已覆盖的 OpenDocumentFile 函数,但问题是尚未构造 CMyDocument 和 CMyView 类。如果 MFC 甚至还没有构建类,它如何期望我打开一个文档?我可以做到这一点并且它有效,但似乎我没有按预期做事。
CCommandLineInfo cmdInfo, cmdInfo2;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line. Will return FALSE if
// app was launched with /RegServer, /Register, /Unregserver or /Unregister.
if (!ProcessShellCommand(cmdInfo2))
return FALSE;
if (!ProcessShellCommand(cmdInfo))
return FALSE;
有更好的想法吗?
解决方案
推荐阅读
- ios - Flutter:Real Device 上的 iOS 测试不起作用,只是白屏
- python - Kv文件从调用它到本机python中输出不同的结果
- json - 如果 JSON 中存在值,则中断,但如果值为 null,则返回(kotlin)
- arrays - Java程序,数组程序
- python - 比较 2 个列表并打印差异
- python - ModuleNotFoundError:Ubuntu 中没有名为“win32api”的模块
- python - 在序列化 Django 中过滤数据
- c - 如何对 Cortex-M 架构的一些算法进行基准测试
- python - 随机模块中的数字是否有相同的机会出现或不出现?
- python - Plotly:悬停文本字段中的日期格式问题