Solved

IWebBrowser and Printing

Posted on 1997-03-25
1
325 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

756 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