Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


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

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%
	AbortPrintFlag=True
	On Local Error Resume Next
	i = AbortDoc(Printer.hDC)
End Sub

Add this code to the print routine:

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

 

 

 

 

 


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

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date