Solved

Printing an HTML document

Posted on 1998-09-07
16
390 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
  • 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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 70 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…

789 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