all groups > dotnet interop > january 2005 >
You're in the

dotnet interop

group:

Is is possible to use VT_ARRAY in ExecWB to print custom footer?



Is is possible to use VT_ARRAY in ExecWB to print custom footer? A Miller
1/29/2005 11:21:01 PM
dotnet interop: The documentation[1] for ExecWB with IDM_PRINT describes 3 forms of pvaIn.
The 3rd form is a VT_ARRAY, where the 1st two BSTR's specify a custom header
and footer. I have not been able to get this to work. The printed document
always uses the default header and footer.

For example,

Dim pvaIn(1) As Object
pvaIn(0) = "header"
pvaIn(1) = "footer"
Me.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRINT,
SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_PROMPTUSER, CType(pvaIn, Object), Nothing)

The document is printed, but with the default header and footer rather than
the custom ones I specified. I have also tried including the remaining 3
objects in the pvaIn VT_ARRAY, also with out success (prints, but not with
custom header and footer).

The generated interop for the WebBrowser control declares the pvaIn paramter
as an UnmanagedType.Struct...this is from Lutz' Reflector....

Sub ExecWB(<In> ByVal cmdID As OLECMDID, <In> ByVal cmdexecopt As
OLECMDEXECOPT, <In, MarshalAs(UnmanagedType.Struct)> ByRef Optional pvaIn As
Object, <In, Out, MarshalAs(UnmanagedType.Struct)> ByRef Optional pvaOut As
Object)

Whereas I think the object should be marshalled as a SAFEARRAY. Could this
be the problem? Is there a way to override the marshalling or contruct a
pvaIn that is marshalled correctly using the existing declarations?

[1]
http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/webbrowser/reference/ifaces/iwebbrowser2/iwebbrowser2.asp

--
Andy Miller
RE: Is is possible to use VT_ARRAY in ExecWB to print custom foote A Miller
1/30/2005 11:33:05 PM
Thank you Peter,

I will experiment with creating a C++ wrapper that I can P/Invoke.

Andy Miller
Structured Solutions

[quoted text, click to view]
RE: Is is possible to use VT_ARRAY in ExecWB to print custom footer? v-phuang NO[at]SPAM online.microsoft.com (
1/31/2005 6:11:46 AM
Hi Andy,

Based on my understanding, you want to know if it's possible to customize
the footer information when calling the Webbrowser control's ExecWB to
print from you VB.NET application. The footer information can be set in the
3rd parameter for ExecWB. The problem is this parameter is a Variant of
type VT_ARRAY. Its structure is described here:
http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/webbrows
er/reference/methods/execwb.asp

"If pvaIn is a VARIANT of type VT_ARRAY, pvaIn specifies a SAFEARRAY
containing (in the following order) a header BSTR, a footer BSTR, the
address of an IStream pointer for a Microsoft Outlook Express header
document, an alternate URL BSTR used for MSHTML in Outlook Express, and a
DWORD containing flags."

Unfortunately, this is not currently possible using only VB.NET or C#.

Technically, these languages do not support a syntax that would allow one
to create a parameter of type VARIANT (.vt = VT_BYREF|VT_VARIANT)
referencing a
VARIANT (.vt = VT_ARRAY|VT_VARIANT), i.e. a SAFEARRAY of VARIANT wrapped up
in a by-ref VARIANT. This is the mandatory type of the third parameter in
the method in question, whose IDL is shown below.
HRESULT ExecWB(
[in] OLECMDID cmdID,
[in] OLECMDEXECOPT cmdexecopt,
[in, optional] VARIANT* pvaIn,
[in, out, optional] VARIANT* pvaOut);

In general, your only option is to create an unmanaged (e.g. C++ or VB6)
wrapper library. And then call the C++ wrap library in .NET.
Here is a link about how to do print customized footer and header in C++.

How To Print Custom Headers and Footers for a WebBrowser Control
http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q267240


Hope this helps.

Best regards,

Perter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
RE: Is is possible to use VT_ARRAY in ExecWB to print custom foote v-phuang NO[at]SPAM online.microsoft.com (
2/1/2005 1:49:17 AM
Hi Andy,

You are welcome!
If you still have any concern, please feel free to post in the newsgroup.

Best regards,

Perter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
AddThis Social Bookmark Button