Solved

ActiveX control or Javascript for Printing

Posted on 1997-12-01
2
374 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Chrome Developer Tools - more info on 401 (unauthorized) error? 6 68
remove border from element 5 49
Reinstall Putty Windows 7 5 44
Not seen Link button 5 0
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
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…

929 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