modal dialog box

B

Bill nguyen

I need to popup a tiny modal dialog box when a user clicks on the "Print"
button to force the user to wait for printing process to finish before
he/she can continue. The model dialog box should go away when the printing
is done.
Any sample code is greatly appreciated.


Bill
 
K

Ken Tucker [MVP]

Hi,

Doesnt the print document control throw one up for you which allows
you to cancel the print?

Ken
 
A

Armin Zingler

Bill nguyen said:
I need to popup a tiny modal dialog box when a user clicks on the
"Print" button to force the user to wait for printing process to
finish before he/she can continue. The model dialog box should go
away when the printing is done.
Any sample code is greatly appreciated.


You don't have to show it modally because the Print method does not return
before printing has finished:

dim f as new waitform

f.show
f.refresh
pd.print
f.close


We now have the problem of having an "unresponsive" Form. To avoid this, you
can only use multiple threads, because Print does lock the UI thread.

Version 1:
Print on a different thread. In this case, you can show a dialog box
modally. In addition, handle the PD's EndPrint event to close the modal Form
there.

Version 2:
Print on the same thread but show a dialog box modally (or modeless +
application.run) in a different thread.


Armin
 
H

Herfried K. Wagner [MVP]

Bill said:
I need to popup a tiny modal dialog box when a user clicks on the "Print"
button to force the user to wait for printing process to finish before
he/she can continue. The model dialog box should go away when the printing
is done.
Any sample code is greatly appreciated.

Take a look at the 'PrintDocument' object's 'PrintController' property.
 
B

Bill Nguyen

it's not about the printing process. I'm using CrystalReport
Document.PrintReport, not PrintDocument class.
I just want the user to stay off the form until the printing process is
done. If the printing process fails for some reason, the modal form should
go away.

Bill
 
A

Armin Zingler

Bill Nguyen said:
it's not about the printing process. I'm using CrystalReport
Document.PrintReport, not PrintDocument class.
I just want the user to stay off the form until the printing process
is done. If the printing process fails for some reason, the modal
form should go away.


Didn't know you're using CR.

IMO, it's not ok how CR works in this situation: PrintReport does not return
but you are still able to use your Forms. This can cause reentrance.
PrintReport or one of it's sub procedures internally processes messages
(like application.doevents), thus you are asking for a modal form, which is
understandable.

One solution is to show a modal Form, and in it's Activated event, start
PrintReport. You have to pass the reference to the CRViewer in this case.

Another solution is to print on a different thread, then show the modal
Form. When PrintReport has finished, close the modal Form.


Armin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top