Solved

ActiveX control or Javascript for Printing

Posted on 1997-12-01
2
379 Views
Last Modified: 2013-12-25
I need a way to have a link within a fram trigger a print (of another frame) on the browser's printer. I don't think that there is a way to do this directly with HTML but am wondering if there is a simple way to do it using either an ActiveX control or a small Javascript.

This app is going into a controlled Intranet environment and will be running on IE3.


TIA
Marty
0
Comment
Question by:mravell
2 Comments
 
LVL 1

Accepted Solution

by:
lyon earned 250 total points
ID: 1855686
One of the reasons I love searches on Microsofts Technical Support Site... Here are two suggestions for getting the results you want. However they dont seem to address the multiple frame idea but with a little modification you should be able to get shift focus to the frame you want to print with the code then implement the print function with either a link or, as suggested here, a button:

What you need to do is call the GetDocument() method that returns an IDispatch*. Using the IDispatch*, call QueryInterface() on IID_IOleCommandTarget. With the object pointer returned, call Exec(NULL, OLECMDID_PRINT, 0, NULL,NULL).

Examples
1)
 void CAboutDlg::OnPrint()
   {
       CWnd* pWnd = GetFocus ();

       m_ctlWebBrowser.SetFocus ();
       // send Ctrl-P
       keybd_event (VK_CONTROL, 0, 0, 0);
       keybd_event ('P', 0, 0, 0);

       // set focus to control that previously had focus
       if (pWnd);
           pWnd->SetFocus ();
   }

2)

#include <docobj.h> -- This comes with the Internet Client SDK

   void CAboutDlg::OnPrint()
   {
       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();
   }

I have not tried this yet but it seems sound. Let me know how you make out

Regards
Lyon
0
 

Author Comment

by:mravell
ID: 1855687
Understood, I will see what kind of information I can dig up this evening and get you something either before 12am EST tomorrow or first thing in the morning. In the meantime try to get at least a downloadable copy of a SDK from either Sun or Microsoft. They have demos that will work fine for what we are trying to accomplish and I will see if I can produce a script instead.
Regards
Lyon
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
text on slider doesn't resize nicely 5 56
Show banners that are blocked by Ad Muncher 10 56
Form Processing in PHP 11 41
Select record with the most recent date 14 54
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

813 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now