Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: Visual Basic
Expertise: Advanced
Oct 29, 1998



Application Security Testing: An Integral Part of DevOps

Cancel a Pending Print Job

In the tip, "Please Stop Printing!" ["101 Tech Tips for VB Developers," Supplement to the August 1997 issue of VBPJ, page 13], the code works fine with one exception. If you use PrintManager, anything printed before you press the Abort button is sent to the printer. This code uses the Windows API AbortDoc to prevent this. Put a button named cCancel on the form and caption it "Abort Printing." Add this declaration to your program:

 Declare Function AbortDoc% Lib "GDI" ( _
	ByVal hDC As Integer)

Add this code to the cCancel button's Click event procedure:

 Sub cCancel_Click ()
	dim i%
	On Local Error Resume Next
	i = AbortDoc(Printer.hDC)
End Sub

Add this code to the print routine:

Do While ......
	Printer.Print ......
	If AbortPrintFlag then exit do
On Local Error resume next  
Dennis E.
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date