Solved

Printing an HTML document

Posted on 1998-09-07
16
386 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
 
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
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.

 
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

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

932 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

10 Experts available now in Live!

Get 1:1 Help Now