Solved

Printing an HTML document

Posted on 1998-09-07
16
384 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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

758 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

18 Experts available now in Live!

Get 1:1 Help Now