PDA

Ver la Versión Completa : Elección de la bandeja de impresión


sur-se
14-05-2007, 14:11:24
Hola.
Con el código siguiente puedo elegir la bandeja de impresión:

with Printer do
begin
Getprinter(ADevice, ADriver, APort, ADeviceMode);
DevMode := GlobalLock(ADeviceMode);
// Le indicamos la bandeja por la que queremos sacar el informe.
DevMode.dmDefaultSource := <Bandeja>;
end;


El problema está en como saber que número de le corresponde a cada una de las bandejas de cada impresora. El código siguiente me dice que bandejas tiene la impresora actualmente seleccionada, pero no sé a que valor debo asignar a la propiedad anteriormente indicada (dmDefaultSource). Incluso he probado a hacer múltiples pruebas con números y no he conseguido encontrar la que le corresponde, imprimiendo la impresora por donde quiere.


procedure TMainForm.GetBinNames;
var
BinNames: Pointer;
i: integer;
begin
{$R-} // Range checking must be turned off here.
// First determine how many bin names are available.
Rslt := DeviceCapabilitiesA(Device, Port, DC_BINNAMES, nil, nil);
if Rslt > 0 then
begin
{ Each bin name is 24 bytes long. Therefore, allocate Rslt*24 bytes to hold
the bin names. }
GetMem(BinNames, Rslt*24);
try
// Now retrieve the bin names in the allocated block of memory.
if DeviceCapabilitiesA(Device, Port, DC_BINNAMES, BinNames, nil) = -1 then
raise Exception.Create('DevCap Error');
//{ Add the information to the appropriate list box.
AddListViewItem('BIN NAMES', EmptyStr, lvGeneralData);
for i := 0 to Rslt - 1 do
begin
AddListViewItem(Format(' Bin Name %d', [i]),
StrPas(TBinNames(BinNames^)[i]), lvGeneralData);
end;
finally
FreeMem(BinNames, Rslt*24);
end;
end;
{$R+} // Turn range checking back on.
end;


¿Alguien sabe como determinar la correspondencia entre una y otra?
Un saludo.