Solved

Print html document (C++Builder)

Posted on 2001-06-11
4
222 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month8 days, left to enroll

617 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