Defining a Printer Driver

BlitzMax Forums/Brucey's Modules/Defining a Printer Driver

Glenn Dodd(Posted 2009) [#1]
If i use WXMax how do i define a printer or printer driver so the print dialog doesn't come up each time i print something?
Please Note:
The specific printer will never be the default printer on windows.

Regards
Glenn


DavidDC(Posted 2009) [#2]
This is something I've never perfected. The best I've currently got is that each session the user OK's the printer dialog once (with the printer they need already highlighted for them) and all subsequent prints are dialog-less.

What I'm doing is keeping a (global) copy of the PrintData, PageSetup and PrintDialogData after it has been setup once. I imagine you could dump this data to disk on cleanup and reload on startup, but I'm just using a global for the time being. Be interested if you can that aspect going!

Once you have your valid data structures filled, call TPrinter.Print with a false for the prompt dialog argument.

I'll include my wrapper for reference as to what I'm doing, (as opposed to correct practice!). Don't expect it to compile though as it will be missing dependencies.


I call the above using something like this for my POS receipt printouts:
'	If the user has switched the printers to something else (by printing out another document) then force a fresh config
	If TPrinter.PrintData And TPrinter.PrintData.GetPrinterName() <> Settings.s_POSReceiptPrinterName Then TPrinter.Cleanup()
					
	Local printer:TSalePrinter = TSalePrinter(New TSalePrinter.CreateGadget(Self,,Settings.POSReceiptCanvasRect,,Settings.POSReceiptMargins,wxPAPER_A4,,False,,wxPRINTBIN_AUTO, Settings.s_POSReceiptPrinterName))
				
	'	And throw the sale list at the printer
	'	Passing false requests that we remember this printer for next time			
	If printer Then printer.PrintSale(POSTableViewDialogPanel.GetSaleItemList(),False)

TSalePrinter is an extension of TPrinter. Hope that helps!


Glenn Dodd(Posted 2009) [#3]
Many thanks David.
It looks very useful. I need to prototype the concept to my work to prove the point and this will help me immensely.

Cheers
Glenn