ActiveX控件中的打印代码一直是运行正常,可今天为了修改ActiveX控件的版本,修改资源文件后,打印功能一直报错。
Debug后发现错误描述信息是:
<!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--> ERROR:Cannot find dialogtemplatewithIDD 0x7803 .错误的根源就是下述代码,原因是用于打印预览的对话框工具栏的资源无法找到,而这些资源是在afxprint.rc文件中的。
<!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--> #ifdef_DEBUG // dialogtemplatemustexistandbeinvisiblewithWS_CHILDset if ( ! _AfxCheckDialogTemplate(lpszTemplateName,TRUE)) { ASSERT(FALSE); // invaliddialogtemplatename PostNcDestroy(); // cleanupifCreatefailstoosoon return FALSE; } #endif // _DEBUG因此修改的方法也很简单,用“源代码文本编辑器”打开资源文件”XXX.rc”,在其中加入
<!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--> #include " l.chs//afxprint.rc "
参考资料
http://www.codeguru.com/forum/showthread.php?t=347195