Out of Bounds exception on OpenPrinterDialog

This one has me baffled. I’ve had several users report an out of bounds exception on this line of code:

gPrinter = OpenPrinterDialog( gPrinterSetup, DialogInWnd )

gPrinter is a graphics object
DialogInWind is a window (which may sometimes be nil)

How does “Out of Bounds” apply here? There’s no array…

Exception msgs are not always completely accurate. IMHO, if you know that DialogInWnd may be nil, you should be testing for that before calling that line.

if gPrinter <> nil then gPrinter = OpenPrinterDialog( gPrinterSetup, DialogInWnd ) ....

Interesting. I thought that passing it a nil value for the window would have the same effect as not passing anything in that parameter. I’ll add code to handle both cases appropriately.


I think I’m correct here. You could pass it nil
gPrinter = OpenPrinterDialog( gPrinterSetup, Nil )
but you’re passing it a nil object which (I believe) is causing your problems.