Solved

IWebBrowser and Printing

Posted on 1997-03-25
1
331 Views
Last Modified: 2013-12-03
Assuming I have managed to embed a WebBrowser control from the ActiveX SDK client window that I have created, how can I instruct it to print its content?
0
Comment
Question by:xen15
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 2

Accepted Solution

by:
kolarb earned 200 total points
ID: 1334216
How do I print from the WebBrowser control?Although the WebBrowser control does
not support a print method, you can print its contents using one of two ways:
•Set focus to the Web Browser Control and send a key combination of Ctrl-P, or
•Call the GetDocument() method, which returns an *IDispatch. Using thisIDispatch

pointer, call QueryInterface() on IID_IOleCommandTarget. With the object pointer

returned, call Exec (NULL, OLECMDID_PRINT, 0, NULL,NULL):     LPDISPATCH
lpDispatch = NULL;    LPOLECOMMANDTARGET lpOleCommandTarget = NULL;    
lpDispatch = m_ctlWebBrowser.GetDocument();    ASSERT(lpDispatch);    
lpDispatch->QueryInterface(IID_IOleCommandTarget,(void**)&lpOleCommandTarget);  

 ASSERT(lpOleCommandTarget);    lpDispatch->Release();    // print contents of
web browser control    lpOleCommandTarget->Exec(NULL, OLECMDID_PRINT, 0,
NULL,NULL);    lpOleCommandTarget->Release();
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question