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

Preview Window Sizing

edited March 2002 in General
When I try to change the border icons on the preview window and then do a
WindowState := wsMaximized the preview window does not take into account the
height of the system task bar. Has anyone else seen this and is there an
easy fix?

What I'm doing is disabling the min/max buttons and leaving only the close
button on the title bar so they can close the window but not minimize or
maximize it.

David Looney

Comments

  • edited March 2002
    This is related to a problem with the way the set of Border Icons is handled
    when the form is created. One way to get around this is by sizing the
    preview window yourself in the OnResize callback for the form. Below is some
    sample come that will maximize the preview window, remove the minimize and
    maximize buttons, and resize it to fill the available desktop area.

    ----------------------------------------------------------------------------
    --------------

    procedure TForm1.ppReport1PreviewFormCreate(Sender: TObject);
    begin

    ppReport1.PreviewForm.WindowState := wsMaximized;

    TppViewer(ppReport1.PreviewForm.Viewer).ZoomSetting := zs100Percent;

    { we only want the close button }
    ppReport1.PreviewForm.BorderIcons := [biSystemMenu];

    { assign the resize event handler }
    ppReport1.PreviewForm.OnResize := FormResize;

    end;

    procedure TForm1.FormResize(Sender: TObject);
    var
    lRect: TRect;
    begin

    { system call to retrieve available desktop area }
    SystemParametersInfo(SPI_GETWORKAREA, 0, @lRect, 0);

    { set the size of the form to the available area }
    ppReport1.PreviewForm.Top := 0;
    ppReport1.PreviewForm.Left := 0;
    ppReport1.PreviewForm.Width := lRect.right - lRect.left;
    ppReport1.PreviewForm.Height := lRect.bottom - lRect.top;

    end;

    ----------------------------------------------------------------------------
    ---------------------------

    --
    Cheers,

    Alexander Kramnik
    Digital Metaphors

This discussion has been closed.