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
Solved

ActiveX control or Javascript for Printing

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Redirect Website for Mobile Devises 9 133
Select only the top record in a left join 13 45
Fulfillment API php code sample 1 58
asp Google Map 2 32
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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…

860 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