>Look at the TCppWebBrowser help for the ExecWB method. It allows you to
>pass in a command ID (one of which is for print) to execute browser
>commands.
Any further?
Thank you,
Luca
> >Look at the TCppWebBrowser help for the ExecWB method. It allows you to
> >pass in a command ID (one of which is for print) to execute browser
> >commands.
// // Shdocvw_tlb.h
CppWebBrowser1->ExecWB(Shdocvw_tlb::OLECMDID_PRINT,
Shdocvw_tlb::OLECMDEXECOPT_PROMPTUSER);
or
CppWebBrowser1->ExecWB(Shdocvw_tlb::OLECMDID_PRINT,
Shdocvw_tlb::OLECMDEXECOPT_DONTPROMPTUSER);
Hans.
// DO NOTHING
CppWebBrowser1->ExecWB(::OLECMDID_PRINT, ::OLECMDEXECOPT_DONTPROMPTUSER);
// FROM http://www.codeproject.com/miscctrl/wbp.asp
// PRINT A BLANK PAGE
// Verify the WebBrowser control is valid.
LPDISPATCH lpDispApp = CppWebBrowser1->Application;
if(lpDispApp)
{
// Get the HTMLDocument interface.
LPDISPATCH lpDispDoc = CppWebBrowser1->Document;
if (lpDispDoc != NULL)
{
// Get the IOleCommandTarget interface so that
// we can dispatch the command.
LPOLECOMMANDTARGET lpTarget = NULL;
if (SUCCEEDED(lpDispDoc->
QueryInterface(IID_IOleCommandTarget,
(LPVOID*) &lpTarget)))
{
// Execute the print preview command. The
// control will handle the print preview
// GUI.
// OLECMDID_PRINTPREVIEW is defined in
// "docobj.h".
lpTarget->Exec(NULL,
::OLECMDID_PRINTPREVIEW, 0, NULL, NULL);
lpTarget->Release();
}
lpDispDoc->Release();
}
lpDispApp->Release();
}
// ----------------------------------
// PRINT A BLANK PAGE
TPrinter* Prntr = Printer();
Prntr->BeginDoc();
CppWebBrowser1->PaintTo( Prntr->Handle, 0,0);
Prntr->EndDoc();
//------------------------
compiling the whole project at http://www.codeproject.com/miscctrl/wbp.asp with
Visual Studio 2003 it runs perfectly. Then I tried to create a DLL to import
functions capabilities to my borland application. Unfortunately I've got no
results :-(
Any help is REALLY appreciated
Luca
> I did find some other good pieces of code however they do not work >:(
Then use the code that I suggested.
Hans.
Luca
Ah... Strange. Here it works ok. What are the problems ?
Errormessages ?
Hans.
Using:
TVariant outvar;
CppWebBrowser1->ExecWB(OLECMDID_PRINT, 0, NULL, outvar);
I'd like to understand outvar's meaning but there is no documentation.
I'm using Borland C++ Builder 6 with service pack 4 on WindowsXP pro (with
latest updates).
I believe to a bug not in my code... >:(
What environment do you use?
thanks,
Luca
The Small example. All successfully work, but does not print footline(only headline). Why, I do not know. Where there is mistake?
Code:
void __fastcall TForm1::PrintButtonClick(TObject *Sender)
{
SAFEARRAYBOUND psabBounds[1];
SAFEARRAY *psaHeadFoot;
// Initialize header and footer parameters to send to ExecWB().
psabBounds[0].lLbound = 0;
psabBounds[0].cElements = 2;
psaHeadFoot = SafeArrayCreate(VT_VARIANT, 1, psabBounds);
VARIANT vHeadStr, vFootStr;
long rgIndices;
VariantInit(&vHeadStr);
VariantInit(&vFootStr);
// Argument 1: Header
vHeadStr.vt = VT_BSTR;
vHeadStr.bstrVal = SysAllocString(L"This is my header string.");
// Argument 2: Footer
vFootStr.vt = VT_BSTR;
vFootStr.bstrVal = SysAllocString(L"This is my footer string.");
rgIndices = 0;
SafeArrayPutElement(psaHeadFoot, &rgIndices, static_cast<void *>(&vHeadStr));
rgIndices = 1;
SafeArrayPutElement(psaHeadFoot, &rgIndices, static_cast<void *>(&vFootStr));
// SAFEARRAY must be passed ByRef or else MSHTML transforms it into NULL.
TVariant vArg;
VariantInit(&vArg);
vArg.vt = VT_ARRAY | VT_BYREF;
vArg.parray = psaHeadFoot;
WB->ExecWB(Shdocvw_tlb::OLECMDID_PRINT, Shdocvw_tlb::OLECMDEXECOPT_DONTPROMPTUSER, &vArg, NULL);
VariantClear(&vHeadStr);
VariantClear(&vFootStr);
if (psaHeadFoot) {
SafeArrayDestroy(psaHeadFoot);
}
}
luca
MSDN cut:
Microsoft Internet Explorer (Programming) versions 4.0, 4.01, 4.01 SP1, 4.01 SP2, 5, 5.01, 5.5
I tried following combinations:
Win98 + IE5, Win2000 + IE6 - prints...
Mark
"gizmo" <_gi...@mail.ru> wrote in message
news:4354b719$1...@newsgroups.borland.com...
OleInitialize(NULL);
CppWebBrowser1->ExecWB(Shdocvw_tlb::OLECMDID_PRINT,
Shdocvw_tlb::OLECMDEXECOPT_DONTPROMPTUSER, &vArg, NULL);
but no news...
luca
thank you all for your good suggestions
Luca
luca
ChDir( "z:/report/" );
CppWebBrowser1->Navigate("file://z:\\report\\report2.html");
---------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body>
<h1>This is a demonstration</h1>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="300" border="1">
<TR>
<TD></TD>
<TD>Studio dentistico: Dentisti sdentati</TD>
<TD></TD>
</TR>
<TR>
<TD></TD>
<TD><IMG style="WIDTH: 472px; HEIGHT: 256px" height="256" alt=""
src="bhteethl.jpg" width="472"
align="middle"></TD>
<TD></TD>
</TR>
<TR>
<TD></TD>
<TD>Paziente: Dante Storto</TD>
<TD></TD>
</TR>
</TABLE>
<P> </P>
</body>
</html>
What would ChDir() have to do with printing ?
> ChDir( "z:/report/" );
> CppWebBrowser1->Navigate("file://z:\\report\\report2.html");
Why would the contents of the html file have to do something with printing?
Hans.
>It never works with an html file from disk.
>It does not print. just update the page in CppWebBrowser1 control.
>Neither calling ChDir before.
>
>ChDir( "z:/report/" );
>CppWebBrowser1->Navigate("file://z:\\report\\report2.html");
What happens when you do proper forward slashes?
CppWebBrowser1->Navigate("file://z:/report/report2.html");
Alan Bellingham
--
ACCU Conference 2006 - 19-22 April, Randolph Hotel, Oxford, UK
Luca, you need to wait for the Document complete event after any call to
navigate!
void __fastcall TmainForm::CppWebBrowser1DocumentComplete(TObject *Sender,
LPDISPATCH pDisp, VARIANT *URL)
{
if (Printing)
{
CppWebBrowser1->ExecWB( Shdocvw_tlb::OLECMDID_PRINT,
Shdocvw_tlb::OLECMDEXECOPT_DONTPROMPTUSER);
}
}
--
Regards
Martin
CppWebBrowser1->Navigate(file://z:\\report\\report2.html);
while(CppWebBrowser1->Busy)
Application->ProcessMessages();
but now I know it is obviously wrong!
Thank you very and very much Martin.
Luca
Thank you,
Luca
Have a look at the keys in \\Software\\Microsoft\\Internet
Explorer\\PageSetup. I usually save these settings, apply what I need for my
app, then restore the old values.
--
Regards
Martin Rothschink
luca
>Have a look at the keys in \\Software\\Microsoft\\Internet
>Explorer\\PageSetup. I usually save these settings, apply what I need for my
>app, then restore the old values.
And if your user is running any other application - well, good luck to
them.
I really hope there's a better solution than this.
Yes, that may be a problem. Actually I do this after my user clicks on the
print button:
... OnPrintClick()
{
SaveOldRegSettings();
ApplyMySettings();
Print();
RestoreOldSettings();
}
So the chance for a collision of two apps is very small.
If anybody knows a better way, please let me know.
--
Regards
Martin Rothschink
No, these are per user global settings for Internet Explorer. The key is in
HKEY_CURRENT_USER. I don't know of any other way and it worked well for my
application.
--
Regards
Martin Rothschink
The first way:
Show the standard window of the dialogue, install the global hook, install their own parameters, move dialog off screen and print.
The second way:
PrintTemplates