From: Peter Below (TeamB) <100113.1101@compuXXserve.com> Subject: Re: TPrinter and Bin selection Date: 10 Jan 2000 00:00:00 GMT Message-ID: Content-Transfer-Encoding: 8bit References: <85d86i$2gs10@bornews.borland.com> Content-Type: text/plain; charset=iso-8859-1 Organization: TeamB Mime-Version: 1.0 Reply-To: 100113.1101@compuXXserve.com Newsgroups: borland.public.delphi.objectpascal In article <85d86i$2gs10@bornews.borland.com>, Farley Carter wrote: > I have an application that uses TPrinter to do its printing. > I now have a need to programtically select the outpin bin on the > printer. > I am using the following code to set the bin before calling BeginDoc. > Yet it does not seem to do what I would like it to do. Any ideas what > I am doing wrong? > if (DevMode^.dmFields and dm_defaultsource) = dm_defaultsource then > begin > DevMode^.dmFields := DevMode^.dmFields or dm_defaultsource; > DevMode^.dmDefaultSource := (DevMode^.dmDefaultSource and 256) or > cBinTranslate[FBin]; > end; Why are you using this tortuous construct? Simply set the two fields DevMode^.dmFields := DevMode^.dmFields or dm_defaultsource; DevMode^.dmDefaultSource := cBinTranslate[FBin]; You may also want to change the start of the routine to Printer.GetPrinter(FDevice, FDriver, FPort, DeviceMode); Printer.SetPrinter(FDevice, FDriver, FPort, 0); Printer.GetPrinter(FDevice, FDriver, FPort, DeviceMode); This forces a reload of the devmode, which is sometimes necessary to get the printer object to behave. And finally: pointers are your enemy, they byte . Avoid them if you can and in this case it is easy to do so. Declare your variables as FDevice, FDriver, FPort : array [0..128] of char; Get rid of the GetMem/FreeMem statements. Oh, bin numbers: i suggest you use the DMBIN_* symbolic constants defined in the Windows unit instead of plain numbers in your cBinTranslate definition. Peter Below (TeamB) 100113.1101@compuserve.com) No e-mail responses, please, unless explicitly requested! Sent using Virtual Access 5.00 - download your freeware copy now http://www.atlantic-coast.com/downloads/vasetup.exe