Solved

Print html document (C++Builder)

Posted on 2001-06-11
4
214 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Need Delphi function to get Youtube video title 5 180
Delphi with SQL Natvie Client 15 73
Downloading email attachments 2 53
LAN or WAN ? 11 58
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
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: …

763 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

13 Experts available now in Live!

Get 1:1 Help Now