Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / December 2007

Tip: Looking for answers? Try searching our database.

InfoPath Print MessageBox

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
stnfck - 07 Dec 2007 15:52 GMT
I am attempting to print out various infopath views using a print driver that
prints to an image via the folowing code:

                   Print(false);

                   //MessageBox.Show("Printing: "+infos[i].Name);
                   
                   bool canAccess = false;
                   while (!canAccess) {
                       try {
                           Bitmap tiff = new Bitmap(fileLocation); //
Errors here because the file doesnt exist
                           MemoryStream stream = new MemoryStream();
                           tiff.Save(stream,
System.Drawing.Imaging.ImageFormat.Tiff);
                           string image =
Convert.ToBase64String(stream.ToArray());
                           stream.Close();
                           tiff.Dispose();

                           xmlInfo += image;

                           canAccess = true;
                           File.Delete(fileLocation);
                       } catch (Exception e) {
                           System.Threading.Thread.Sleep(1000);          
                       }
                   }

Youll notice that I have a loop checking for when the image becomes
available so that I can bring it in as a string and append it to the xml
document for processing.

Here is the weird part, if I do it as it shows above it never creates the
image, it will just sit in that Thread loop forever becuase the Bitmap cannot
access the file.

BUT! If I uncomment that MessageBox that would just prompt before it does
anything it works perfectly.

I have tried sleeping right after the print to see if it just needed to take
some time. Doesnt Work.

I have tried printing on another thread, and that doesnt work.

So my question is, is does anyone know what MessageBox.Show is doing that
would let that process continue?

Thanks in advance!
JTMSDN - 07 Dec 2007 20:05 GMT
I ended up hooking into the Windows Dialog using SetWindowsHookEx to close
any messageboxes that displayed but this is a bit of a hack. Anyone know how
IO operations would hang a Print Thread, but how also making a call to
MessageBox in user32.dll would somehow seperate it enough to continue?

> I am attempting to print out various infopath views using a print driver that
> prints to an image via the folowing code:
[quoted text clipped - 45 lines]
>
> Thanks in advance!

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.