![]() |
| | #1 |
| Registered User Join Date: Oct 2007 Location: USA
Posts: 2
| ... but I have a working program with a problem. Here's the code in question : Code: private void button2_Click(object sender, System.EventArgs e)
{
string[] frmdata = textBox1.Lines; //Incoming numbers, each number is a different form to print.
string[] valid = new String[textBox1.Lines.Length]; //Make an array to use as a check.
int cnt = 0;
Regex nMatch =new Regex("^[0-9]{5,}$"); //Each line should be 5 digits.
object bleh = System.Reflection.Missing.Value; //A junk value - used later as a filler for variables that are not used.
foreach (string frmElem in frmdata) {
if ((nMatch.IsMatch(frmElem)))
{ //Is the current line a good result?
valid[cnt] = frmElem; //Yeah, add to the check array.
}
else
{
valid[cnt] = "XXXXX:" + frmElem; //No doh! Change it to the flag-value
}
cnt++;
}
for (int x = 0;x < valid.Length;x++)
{
axBrowse1.BringToFront(); //Use the browser to view the HTML forms.
valid[x] = @"c:\forms\" + valid[x] + ".html"; //Modify the checked value to a local address.
try
{
axBrowse1.Navigate(valid[x],ref bleh,ref bleh,ref bleh,ref bleh); //Load
mshtml.IHTMLDocument2 doc = (mshtml.IHTMLDocument2) axBrowse1.Document;
while(axBrowse1.ReadyState != SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE)
{ //While the form's not loaded, just do whatever the program needs to do .
Application.DoEvents();
}
axBrowse1.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRINT,
SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER,
ref bleh, ref bleh); //It's done loading the form. Print it to the default printer.
System.Threading.Thread.Sleep(1100);
//1.1 sec pause for the job to finish?? It helped out-of-order somewhat, but there are still problems.
}
catch
{
valid[x] = "XXXXX: ERROR: " + valid[x] + " was not found.";
// Note all errors for later. A list of valid and invalid prints is saved to print a job report later on.
}
}
I'm printing a number of sequential HTML files, each file as a separate print job. The code is passed those files as frmdata. Everything prints fine. But, everything doesn't print in order. I'd expect the doevents() to clean up and flush + my thread-sleep ... so everything comes out in order ... but the spooler just doesn't do it for some reason. Is there something I should be doing to force-send to the spooler so things come in order? Also, on occasion ... a print from the end of the list might come out first (huh??!!) So that's a bonus right there. It's not a big deal - as this program saves a good half hour of work daily, but, we could save another 5 minutes if I could figure out how to get everything printed in order. Any ideas? What is it that I'm just missing/overlooking? My normal job size is 30-50 separate documents, some of them multiple pages. Last edited by kasemo; 10-25-2007 at 05:12 PM. |
| kasemo is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Number Guessing | blacknapalm | C Programming | 2 | 10-01-2008 01:48 AM |
| Random number + guessing game trouble | Ravens'sWrath | C Programming | 16 | 05-08-2007 03:33 AM |
| Stone Age Rumble | KONI | Contests Board | 30 | 04-02-2007 09:53 PM |
| newbie needs help with creating html table | Dylancougar | C Programming | 4 | 10-31-2005 09:13 PM |
| reading a text file printing line number | bazzano | C Programming | 4 | 09-16-2005 10:31 AM |