Solved

ActiveX control or Javascript for Printing

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

730 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