Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

DeviceType returns a string

edited August 2007 in General
DeviceType returns a string in the following code. Have I missed something?
The user always wants the portrait orientation on the screen; the print
orientation is selectable by the user.

procedure TFormRB.ppReportLabelBeforePrint(Sender: TObject);
begin
if IniRec.DoDebug then
begin
Logit(IniRec.DebugFile, '[ppReportLabelBeforePrint]DeviceType: ' +
ppReportLabel.DeviceType);
end;
if ppReportLabel.DeviceType = 'Screen' then
begin
ppReportLabel.PrinterSetup.Orientation := poPortrait;
ppReportLabel.PreviewFormSettings.ZoomSetting := zs100Percent;
end else
ppReportLabel.PrinterSetup.Orientation := FOrientation;
end;

Todd

Comments

  • edited August 2007
    Hi Todd,

    The Report.DeviceType property does not change, it remains set to what the
    user chooses before the report is printed. If you are trying to check to
    see if the user is printing to the printer, you need to check if the
    Report.PrinterDevice is nil. Take a look at the article below.

    ------------------------------------------
    Tech Tip: Detecting whether Report was
    Printed to the Printer
    ------------------------------------------

    The Report.AfterPrint event can be used to
    determine whether the report was printed
    to the printer (rather than preview, ...).


    Example:


    procedure TForm1.ppReport1AfterPrint(Sender: TObject);
    begin

    if (ppReport1.PrinterDevice <> nil) then
    ShowMessage('Report was printed to the printer');

    end;



    Note: If the user cancels the report while it
    is running, then the Report.OnCancel event will
    fire, followed by the Report.AfterPrint event.

    Example:

    procedure TForm1.ppReport1Cancel(Sender: TObject);
    begin
    ShowMessage('Printing cancelled by user');

    end;


    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited August 2007
    I forgot to add that the docs say that DeviceType returns an
    enumerated value and on my computer all works as expected, but on
    the client's computer when the DeviceType is Screen, the
    orientation remains the same as the orientation specified in the
    Printer orientation.

    Todd

  • edited August 2007
    Nico -

    My debug file shows that it is "Screen" when in the screen mode,
    and when the user selects to print, it returns "Print". However,
    let me check out the article.

    Todd

  • edited August 2007
    It is possible to use the enumerated types or the string that each
    enumerated type resolves to. You will notice that the DeviceType property
    is a String type.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.