473,406 Members | 2,336 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 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 !=
SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE)
{
Application.DoEvents();
}
// Print the page - prompt user
ie.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRINT,
OLECMDEXECOPT.OLECMDEXECOPT_PROMPTUSER, ref o, ref o);

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 5268

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: jgctr4 | last post by:
I'm trying to print an HTML file using AxWebBrowser.ExecWB but it it gives a run time error "Trying to revoke a drop target that has not been registered". Does anyone have any suggestions? ...
1
by: Hasani | last post by:
right now, for printing HTML in .net I use a AxBrowser and I do ExecWB(SHDocVw.OLECMDID.OLECMDID_PRINT, SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER) I then call Application.DoEvents() in...
1
by: Curtis Justus | last post by:
Hi, My back is against the wall and I've tried to figure out something to do. Here is my scenario: I have an automated process running in a service that generates HTML files. Each resulting...
4
by: Suzanka | last post by:
Hello, I have an application written in C# on visual studio .NET. It is a web aplication. The application consists of many different forms, that users occassionaly want to print out for filing....
0
by: Curtis Justus | last post by:
Hi, I need to have the ability to take HTML files and print them out to a printer (each document may have to be sent to a different printer). This needs to be done without user interaction...
1
by: eskildb | last post by:
First, please be gently. I am fairly new to the programming world (1.5 years with some expermentation prior to). I have been working on a project that has to print HTML pages with graphics in a...
1
by: eskildb | last post by:
First, please be gently. I am fairly new to the programming world (1.5 years with some expermentation prior to). I have been working on a project that has to print HTML pages with graphics in a...
12
by: Alex Clark | last post by:
Greetings, (.NET 2.0, WinXP Pro/Server 2003, IE6 with latest service packs). I've decided to take advantage of the layout characteristics of HTML documents to simplify my printing tasks, but...
0
by: Andrew Meador | last post by:
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.