?
Solved

Printing an HTML document

Posted on 1998-09-07
16
Medium Priority
?
400 Views
Last Modified: 2010-04-06
I have an HTML file in a IE activeX control under delphi3, and i'd like to know how to print it.
0
Comment
Question by:jpcs
[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
  • 7
  • 6
  • 2
  • +1
16 Comments
 
LVL 10

Expert Comment

by:viktornet
ID: 1338950
Isn't there any procedure like Control.Print; or Control.Something.Print;???
How about the idea printing it as a bitmap....get the DC(Device Context) of the control, and then use a method to draw it onto the printer's canvas..

Regards,
Viktor Ivanov
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1338951
Hi jpcs,

 printing should be possible like :

procedure THtmlPageEditorForm.ViewerPrint1Click(Sender: TObject);
var
  VI, VO : OleVariant;
  IECommand : IOleCommandTarget;
begin
 IECommand := Document as IOleCommandTarget;
 IECommand.Exec(nil, OLECMDID_PRINT, OLECMDEXEOPT_DONTPROMPTUSER, VI, VO);
end;

{from Delphi Informant}

find also help and example sources at http://www.hyperact.com

Zif.
0
 
LVL 1

Author Comment

by:jpcs
ID: 1338952
No, it didn't work.

Let me explain it better :
   I have a fom with 2 controls:

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 1

Author Comment

by:jpcs
ID: 1338953
Sorry, click the submit button by mistake.

Thanks ZifNab.

As i was saying :

I have 2 controls :
   print : bitbtn control
   preview : t_webbrowser_v1 (ie ActiveX control)


When i click the print button, it should print the htm file in preview window.

The code you sent me didn't work sisnce delphi didn't recognize this line : "IECommand : IOleCommandTarget; ". It said that  IOleCommandTarget is not a valid variable kind.


What can i do? (please, tell me the full code)


0
 
LVL 4

Expert Comment

by:d003303
ID: 1338954
Yo,
use this code. It also cleans up the references of the interfaces, the code Zif posted does not. Maybe someone should tell the people at the Delphi informant about this memory leak.

procedure TForm1.Button1Click(Sender: TObject);
var VarIn, VarOut   : OLEVariant;
    DocIDispatch    : IDispatch;
    DocOLECmdTarget : IOleCommandTarget;
begin
  VarIn := 0;
  VarOut := 0;
  DocIDispatch := WebBrowser1.Document;
  if failed(DocIDispatch.QueryInterface(IOleCommandTarget, DocOLECmdTarget))
   then Exit;
  DocIDispatch._Release;
  DocOLECmdTarget.Exec(nil, OLECMDID_PRINT, OLECMDEXECOPT_PROMPTUSER, VarIn, VarOut);
  DocOLECmdTarget._Release;
end;

Slash/d003303
0
 
LVL 4

Expert Comment

by:d003303
ID: 1338955
uh, I forgot, include ActiveX in your uses clause !
0
 
LVL 1

Author Comment

by:jpcs
ID: 1338956
Thanks d003303, but it didn't work.

I get the following error on line "DocOLECmdTarget.Exec(nil, OLECMDID_PRINT, OLECMDEXECOPT_PROMPTUSER, VarIn, VarOut);" : ERROR : imcopatible types : 'TGUID and POINTER.

The cursor is placed between nil and OLECMDID_PRINT.


What can I do?

0
 
LVL 4

Expert Comment

by:d003303
ID: 1338957
...seems that you didn't patched your Delphi. I use D3.02, there were several changes in the units. If you have D3 pro, open ActiveX.pas (in .\Delphi 3\source\RTL\WIN) and search for the IOleCommandTarget interface. if the declaration is NOT like this:

  IOleCommandTarget = interface(IUnknown)
    ['{b722bccb-4e68-101b-a2bc-00aa00404770}']
    function QueryStatus(CmdGroup: PGUID; cCmds: Cardinal;
      prgCmds: POleCmd; CmdText: POleCmdText): HResult; stdcall;
    function Exec(CmdGroup: PGUID; nCmdID, nCmdexecopt: DWORD;
      const vaIn: OleVariant; var vaOut: OleVariant): HResult; stdcall;
  end;

you will have to patch to make all your apps work properly.

Slash/d003303
0
 
LVL 1

Author Comment

by:jpcs
ID: 1338958
I're right. I havent't patched Delphi (I have Client / Server Version). Where can I get the patch? In Inprise, i only could get the release 2, but i need release 1. Is there any site in the web where it's availlable for download? If you need to contact me, My e-mail is jsantos98@usa.net

If this solves my problem, I'l give you the points.


Thanks

0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1338959
jpcs, you've to buy patch release 1.... sorry...
0
 
LVL 4

Expert Comment

by:d003303
ID: 1338960
right, Patch release 1 must be purchased from Inprise. Release 2 is available for free download at their site, BUT works ONLY with an already applied Patch Release 2 !

Slash/d003303
0
 
LVL 1

Author Comment

by:jpcs
ID: 1338961
I went to inprise site, but there is a little problem : I live in Portugal, and Inprise doesn't have any place here listed in there site in order to contact it.

Any sugestion?
0
 
LVL 4

Expert Comment

by:d003303
ID: 1338962
The contact in this case is:

INPRISE EMM
Robert-Bosch Strasse 11
63 225 Langen
Germany


Email: emm@corp.inprise.com
Phone: +49 6103 979 0
Fax: +49 6103 979 286
INPRISE Country Office

Slash/d003303
0
 
LVL 1

Author Comment

by:jpcs
ID: 1338963
Sorry for the delay Slash/d003303, but only today I could test it on Delphi 4, and... IT WORKS!!!! Thank you very much.

Please answer again to the question so I can give you the Points.

Just answer me another thing : How can I remove the text it prints in the header and footer? Example :

Header : "Page 1 of 1"
Footer : "file://f:\cdgest\data\list.html     20-9-1998"


Thanks


JPCS
0
 
LVL 4

Accepted Solution

by:
d003303 earned 280 total points
ID: 1338964
Yo,
glad it works now. For the page layout, go to the menu File->Page setup and change header and footer settings. They are stored for each user individually. To change them by code, look at the registry key
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\PageSetup
at the header/footer values.

Have fun,
Slash/d003303
0
 
LVL 1

Author Comment

by:jpcs
ID: 1338965
thanx
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

719 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