Solved

Print html document (C++Builder)

Posted on 2001-06-11
4
218 Views
Last Modified: 2010-04-06
I know I am technically in the wrong group but there does not seem to be any C++Builder experts in the C++ Programming forum. Coming from a Delphi background to C++Builder very recently I think some Delphi experts may be able to help me.

I want to print a html document which the user does not have to see. In C++Builder 5.01 there is a component TCppWebBrowser that has a method ExecWB which makes it possible to print but I have having problems with it. I believe in Delphi the equivalent component is TWebBrowser.

Can anyone offer me any advice? If there are experts out there who can help I can provide mre information if required.

Thanks a lot,

Tom.
0
Comment
Question by:tomcorcoran
  • 2
4 Comments
 
LVL 17

Expert Comment

by:inthe
ID: 6178395
Hi,
this works ok in builder4:

void __fastcall TForm1::Button1Click(TObject *Sender)
{
TVariant i,o;
WebBrowser1->Navigate(WideString("www.yahoo.com"),&i,&o);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
TVariant i,o;
WebBrowser1->ExecWB(Shdocvw_tlb::OLECMDID_PRINT,Shdocvw_tlb::OLECMDEXECOPT_DONTPROMPTUSER, &i, &o);
}


set teh visible property of the browser to false if you dont want user to see it,and use the OLECMDEXECOPT_DONTPROMPTUSER flag so the printer doesnt prompt the user.

Regards Barry
0
 

Author Comment

by:tomcorcoran
ID: 6180202
Thanks a lot for the answer. The above is the code I have been having the problem with. If I run the above ot works. The problem is I want to run it all together, if I call the above OnClick events or the below in a single procedure it does not work but will work if the 2 steps are executed under seperate buttons. Put them under one or call the second OnClick from the first and it doesn't work! Am I going crazy?! Both steps work on their own without vIn or vOut too.

TVariant vIn;
TVariant vOut;
CppWebBrowser1->Navigate(WideString(sHTMLFile),&vIn,&vOut);
CppWebBrowser1->ExecWB(Shdocvw_tlb::OLECMDID_PRINT,
Shdocvw_tlb::OLECMDEXECOPT_DONTPROMPTUSER,&vIn,&vOut);

Does it work under one button for you?

Cheers, Tom.
0
 
LVL 8

Accepted Solution

by:
TOndrej earned 100 total points
ID: 6180592
Navigate sends request and returns; OnNavigateComplete event is called after the page has been loaded.

So you need to do something like this (pseudo-code):

clear flag;
navigate;
loop while flag not set; (in OnNavigateComplete set flag)
print;
0
 

Author Comment

by:tomcorcoran
ID: 6180674
Your comment lead to my solution, thank you! TcppWebBrowser has a OnDocumentComplete event which is where I moved the ExecWB printing command.

Cheers, Tom.
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

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…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
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 …

810 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