Link to home
Start Free TrialLog in
Avatar of uffa
uffa

asked on

printer setup dialog

..hi guys,
using the printer setup dialog with Delphi 1, I am able to get some selections that I make, like Printer.Orientation.
How can I get (read) the Paper Size and Paper Source selected from the dialog form ?

Thanks
Avatar of uffa
uffa

ASKER

Adjusted points to 50
Again, this is by Raymond (RWilson) as far as nobody commented this q
Perhaps it helps

Here's a sample that changes the paper bin on the fly:

                    procedure TForm1.Button1Click(Sender: TObject);var
                      ADevice, ADriver, APort: array [0..255] of char;  ADeviceMode:
                    THandle;
                      DevMode: PDevMode;begin    with Printer do begin
                          GetPrinter(ADevice,ADriver,APort,ADeviceMode);
                          SetPrinter(ADevice,ADriver,APort,0);
                          GetPrinter(ADevice,ADriver,APort,ADeviceMode);
                          DevMode := GlobalLock(ADeviceMode);
                          if not Assigned(DevMode) then ShowMessage('Can''t set printer.')
                          else begin        with DevMode^ do begin
                              {Put any other settings you want here}
                              dmDefaultSource := DMBIN_UPPER;
                             {these codes are listed in "Windows.pas"}        end;
                            GlobalUnlock(ADeviceMode);
                            SetPrinter(ADevice,ADriver,APort,ADeviceMode);      end;    end;

                        Printer.BeginDoc;
                        Printer.Canvas.TextOut(50,50,'This page is printing from the UPPER
                    PAPER TRAY.');
                        with DevMode^ do begin      {Put any other settings you want
                    here}
                          dmDefaultSource := DMBIN_LOWER;
                         {these codes are listed in "Windows.pas"}    end;
                        Printer.NewPageDC(DevMode);
                        Printer.Canvas.TextOut(50,50,'This page is printing from the LOWER
                    PAPER TRAY.');
                        Printer.EndDoc;end;


                    Here's the TDevMode structure with all the things you can change like
                    this:

                      _devicemodeA = packed record
                        dmDeviceName: array[0..CCHDEVICENAME - 1] of AnsiChar;
                        dmSpecVersion: Word;
                        dmDriverVersion: Word;
                        dmSize: Word;
                        dmDriverExtra: Word;
                        dmFields: DWORD;
                        dmOrientation: SHORT;
                        dmPaperSize: SHORT;
                        dmPaperLength: SHORT;
                        dmPaperWidth: SHORT;
                        dmScale: SHORT;
                        dmCopies: SHORT;
                        dmDefaultSource: SHORT;
                        dmPrintQuality: SHORT;
                        dmColor: SHORT;
                        dmDuplex: SHORT;
                        dmYResolution: SHORT;
                        dmTTOption: SHORT;
                        dmCollate: SHORT;
                        dmFormName: array[0..CCHFORMNAME - 1] of AnsiChar;
                        dmLogPixels: Word;
                        dmBitsPerPel: DWORD;
                        dmPelsWidth: DWORD;
                        dmPelsHeight: DWORD;
                        dmDisplayFlags: DWORD;
                        dmDisplayFrequency: DWORD;
                        dmICMMethod: DWORD;
                        dmICMIntent: DWORD;
                        dmMediaType: DWORD;
                        dmDitherType: DWORD;
                        dmICCManufacturer: DWORD;
                        dmICCModel: DWORD;
                        dmPanningWidth: DWORD;
                        dmPanningHeight: DWORD;
                      end;
Indi
Oops, Delphi 1 , long time ago...
Avatar of uffa

ASKER

.thanks, but I need to do exactly the contrary.  I need to read these setting information from the PrinterDialog form. In particular Paper Source and Size. (dmDefaultSource, dmPaperSize)

thanks anyway.
ASKER CERTIFIED SOLUTION
Avatar of Indefrei
Indefrei

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of uffa

ASKER

.I read my setings in an .EXE program and save them.  Then when I have to print I use the first code segment that Indi posted in order to set back my values previously saved but it seems like when I try to set my values Delphi maybe creates a second printer object so I still print with the default values.  When I print, therefore setting back the printer values, I'm using a DLL.
I guess there is something wrong in my code, maybe I should pass the printer THandle from the EXE to the DLL just to make sure I'm modifing the same printer object.  I think GetPrinter() should give me the same printer all the times, I have to take a closer look to my code.  

  Thank you for now.