Click here to Skip to main content
15,881,882 members
Home / Discussions / C#
   

C#

 
QuestionHow to Skin VC#.Net app? Pin
bug_aonz22-Aug-06 23:09
bug_aonz22-Aug-06 23:09 
AnswerRe: How to Skin VC#.Net app? Pin
Not Active23-Aug-06 1:07
mentorNot Active23-Aug-06 1:07 
QuestionFunky problem with reading multiline XML contents into a multiline textbox Pin
ThisIsMyUserName222-Aug-06 23:08
ThisIsMyUserName222-Aug-06 23:08 
AnswerRe: Funky problem with reading multiline XML contents into a multiline textbox Pin
benjymous22-Aug-06 23:30
benjymous22-Aug-06 23:30 
AnswerRe: Funky problem with reading multiline XML contents into a multiline textbox [modified] Pin
Guffa23-Aug-06 1:43
Guffa23-Aug-06 1:43 
GeneralRe: Funky problem with reading multiline XML contents into a multiline textbox Pin
ThisIsMyUserName223-Aug-06 14:17
ThisIsMyUserName223-Aug-06 14:17 
AnswerRe: Funky problem with reading multiline XML contents into a multiline textbox Pin
Guffa23-Aug-06 21:23
Guffa23-Aug-06 21:23 
QuestionPrinting from a WebBrowser control in a separate thread Pin
User 137680022-Aug-06 22:58
User 137680022-Aug-06 22:58 
Hi all,
I have a program that generates some HTML and then needs to automatically print it. This automatic printing occurs within a separate thread (timer) and for the life of me, I just can't get it working.

After a couple of days Googling around, I found a couple of things:
1) Attempting to do it calling IE (or the equivalent DLLs) isn't an option since it'll always pop up a print dialog box and there's nothing that can be done about that.
2) webBrowser1.Print() should work, but doesn't. It doesn't call an exception, it doesn't have any problems, but it also doesn't print. I'm assuming it's related to the fact that this is all in a separate thread from the timer.
3) If I attempt to be "messy" and just call a complete new thread that creates the webbrowser object, loads the HTML and print it, it gives an exception complaining it's not STA, even though I did set it that way.

So basically, I'm fairly stuck at this point. Here's the code I've tried so far minus the messy one, since that's definitely barking up the wrong tree I think. (note that the html is both in my webbrowser object or in the file - I'd love to not have to use the webbrowser object if I can get away with it)

/* //This way would be okay, except that it pops up a print dialog.<br />
 * <br />
 * Process proc = new Process();<br />
 * proc.StartInfo.FileName = szTempFolder + @"\Temp\Body.html";<br />
 * proc.StartInfo.UseShellExecute = true;<br />
 * proc.StartInfo.Verb = "print";<br />
 * proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;<br />
 * proc.Start();<br />
 * proc.WaitForExit();<br />
 */<br />
<br />
 /* //This doesn't work - maybe because of the thread?<br />
 * <br />
 * webBrowser1.Navigate(szTempFolder + @"\Temp\Body.html");<br />
 * webBrowser1.Print();<br />
 */<br />
<br />
 /* //This also doesn't work, and for no good reason that I know.<br />
 * <br />
 * ThreadStart threadDelegate = new ThreadStart(webBrowser1.Print);<br />
 * Thread thread = new Thread(threadDelegate);<br />
 * thread.SetApartmentState(ApartmentState.STA);<br />
 * thread.Start();<br />
 * thread.Join();<br />
 */<br />


Ben de Waal
QuestionRe: Printing from a WebBrowser control in a separate thread [modified] Pin
User 137680023-Aug-06 2:04
User 137680023-Aug-06 2:04 
QuestionRibbon Control Pin
seq-22-Aug-06 22:45
seq-22-Aug-06 22:45 
QuestionSchedule task Pin
minniemooo22-Aug-06 22:44
minniemooo22-Aug-06 22:44 
AnswerRe: Schedule task Pin
Colin Angus Mackay22-Aug-06 23:00
Colin Angus Mackay22-Aug-06 23:00 
GeneralRe: Schedule task Pin
minniemooo22-Aug-06 23:10
minniemooo22-Aug-06 23:10 
GeneralRe: Schedule task Pin
S. Senthil Kumar23-Aug-06 2:08
S. Senthil Kumar23-Aug-06 2:08 
QuestionrichTextBox Pin
sarojkumarjena22-Aug-06 22:40
sarojkumarjena22-Aug-06 22:40 
AnswerRe: richTextBox Pin
Gammaza22-Aug-06 22:48
Gammaza22-Aug-06 22:48 
GeneralRe: richTextBox Pin
sarojkumarjena22-Aug-06 23:08
sarojkumarjena22-Aug-06 23:08 
GeneralRe: richTextBox Pin
mav.northwind23-Aug-06 1:38
mav.northwind23-Aug-06 1:38 
QuestionBuilding a SqlConnection string during installation Pin
Gammaza22-Aug-06 22:33
Gammaza22-Aug-06 22:33 
AnswerRe: Building a SqlConnection string during installation Pin
Not Active23-Aug-06 1:11
mentorNot Active23-Aug-06 1:11 
GeneralRe: Building a SqlConnection string during installation Pin
Gammaza23-Aug-06 20:29
Gammaza23-Aug-06 20:29 
GeneralRe: Building a SqlConnection string during installation Pin
Not Active24-Aug-06 2:19
mentorNot Active24-Aug-06 2:19 
GeneralRe: Building a SqlConnection string during installation Pin
Gammaza5-Sep-06 2:38
Gammaza5-Sep-06 2:38 
GeneralRe: Building a SqlConnection string during installation Pin
Not Active5-Sep-06 7:42
mentorNot Active5-Sep-06 7:42 
Questiontop most modeless dialog Pin
s o v a n n22-Aug-06 22:11
s o v a n n22-Aug-06 22:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.