471,354 Members | 1,477 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,354 software developers and data experts.

IE Printing HTML file through ExecWB - print dialog comming up behindmy app - help!

I have implemented a printing scenario where an html file is
printed using the the following code:

public void PrintHtmlFile(string url)
RegistryKey IERegKey;
string header = null;
string footer = null;
object o = null;
InternetExplorerClass ie = null;
IWebBrowser wb = null;

// Get registry key for IE PageSetup and current values
for header and footer. If IE hasn't been
// through a print cycle, the PageSetup key will not
exist. Best thing to do is to run IE through
// at least one print job so the key will be set. With the
code below, the print will work, but the
// first printout will have headers and footers based on
default setting created on first print cycle.
// Once the registry key is in place - the following will
effectively hide the header and footer on
// printouts.
IERegKey = Registry.CurrentUser.OpenSubKey("software\
\Microsoft\\Internet Explorer\\PageSetup", true);
if (IERegKey != null)
footer = IERegKey.GetValue("footer", 0).ToString();
header = IERegKey.GetValue("header", 0).ToString();

// Set header and foot to blank
IERegKey.SetValue("footer", "");
IERegKey.SetValue("header", "");

// Create Internet Explorer instance - this (or the wb
object below) will fail if IE has not been through
// it's initial first run sequence.
ie = new InternetExplorerClass();

// Create web browser page - this (or the ie object above)
will fail if IE has not been through
// it's initial first run sequence.
wb = (IWebBrowserApp)ie;

//ie.Visible = true; // Shows the IE instance.

wb.Navigate(url, ref o, ref o, ref o, ref o);

// Wait for IE object to be ready - otherwise intermittant
errors occur when print is initiated.
while (ie.ReadyState !=
// Print the page - prompt user

if (IERegKey != null)
// Replace IE Page settings
IERegKey.SetValue("footer", footer);
IERegKey.SetValue("header", header);

This works pretty well. Anyway, when the user clicks the 'Print'
button on the application form, this sub is called with the full path
to the file passed via the URL parameter. The user then has a Print
Dialog box pop up letting them select the printer to print to. All
they have to do it click ok/print and it prints out. The problem is
that the print dialog box is coming up behind the application. How can
I make the dialog box come up on top of the application?

Thanks in advance!
Jul 16 '08 #1
0 5052

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Hasani | last post: by
1 post views Thread by Curtis Justus | last post: by
reply views Thread by Curtis Justus | last post: by
1 post views Thread by eskildb | last post: by
1 post views Thread by eskildb | last post: by
12 posts views Thread by Alex Clark | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.