Q&A

  • 프린터 트레이 선택하는 방법좀....
기본프린터로 설정되어있는 프린터의 트레이를 선택하는 방법을 알고싶습니다. 원하는 트레이의 종이에 자동으로 인쇄를 하고 싶은데 잘 모르겠습니다..
1  COMMENTS
  • Profile
    오익환 2004.12.09 22:53


    http://www.efg2.com/Lab/Library/UseNet/1999/1102.txt 에서가져왔습니다.


    procedure ChangePrinterBin(ToBin: Integer);
    var
      ADevice, ADriver, APort: array [0..255] of Char;
      DeviceHandle: THandle;
      DevMode: PDeviceMode; // A Pointer to a TDeviceMode structure
    begin
      { First obtain a handle to the TPrinter's DeviceMode structure }
      Printer.GetPrinter(ADevice, ADriver, APort, DeviceHandle);
      { If DeviceHandle is still 0, then the driver was not loaded. Set
        the printer index to force the printer driver to load making the
        handle available }
      if DeviceHandle = 0 then
      begin
        Printer.PrinterIndex := Printer.PrinterIndex;
        Printer.GetPrinter(ADevice, ADriver, APort, DeviceHandle);
      end;
      { If DeviceHandle is still 0, then an error has occurred. Otherwise,
        use GlobalLock() to get a pointer to the TDeviceMode structure }
      if DeviceHandle = 0 then
        Raise Exception.Create('Could Not Initialize TDeviceMode
    structure')
      else
        DevMode := GlobalLock(DeviceHandle);

        with DevMode^ do
        begin
          dmFields := DM_DEFAULTSOURCE;
          dmDefaultSource := ToBin;
        end;

      if not DeviceHandle = 0 then
        GlobalUnlock(DeviceHandle);
    end;