我做的软件是给客户用的,客户不一定装word,我也试过用Notepad,但是效果不好,而且打不出图片。

解决方案 »

  1.   

    这个很简单,你需要响应IwebBrowser2 的事件。在OnDocumentComplete(...)的事件响应
    函数中调用你的打印命令,因为这个时候文件的内容才被完全的加载进IE。用CHtmlView是最简单的办法,你直接重载这个函数就行了。tnsw
      

  2.   

    IDM_PRINT Command ID--------------------------------------------------------------------------------Prints the current document using either the default print template or a custom print template.C++ InformationCommand group CGID_MSHTML (defined in mshtmhst.h)  
    Symbolic constant IDM_PRINT  
    User interface Optional. If this parameter is set to OLECMDEXECOPT_DODEFAULT or OLECMDEXECOPT_PROMPTUSER, the Print dialog box will be displayed. If this parameter is set to OLECMDEXECOPT_DONTPROMPTUSER, no dialog box will display and the document will be sent directly to the current printer. 
    IOleCommandTarget::Exec parameters pvaIn VARIANT of type VT_BSTR, VT_I2, or VT_ARRAY. 
    If pvaIn is a VARIANT of type VT_BSTR, pvaIn specifies the path to a custom print template.If pvaIn is a VARIANT of type VT_I2, pvaIn specifies a flag indicating whether the Print Dialog should be shown; any non-zero value shows the dialog.If pvaIn is a VARIANT of type VT_ARRAY, pvaIn specifies a SAFEARRAY containing (in the following order) a header BSTR, a footer BSTR, the address of an IStream pointer for a Microsoft Outlook Express header document, an alternate URL BSTR used for Microsoft's HTML parsing and rendering engine (MSHTML) in Outlook Express, and a DWORD containing flags.May be set to NULL to use the Microsoft® Internet Explorer default print template.
     
    pvaOut Set to NULL. 
     
    Header file mshtmcid.h  
    Applies to IHTMLDocument2::execCommand, IHTMLDocument2::queryCommandEnabled, IHTMLDocument2::queryCommandIndeterm, IHTMLDocument2::queryCommandState, IHTMLDocument2::queryCommandSupported, IHTMLDocument2::queryCommandValue, IOleCommandTarget::Exec, IOleCommandTarget::QueryStatus.  ResIf no template path is supplied, MSHTML will use the default print template.Minimum AvailabilityInternet Explorer 5.5 and later. 
    See AlsoIDM_PRINTPREVIEW, LayoutRect, DeviceRect, TemplatePrinter, HeaderFooter, dialogArguments