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

AV when selecting pageStyle band - remedy included

edited May 2012 in General
When we add the pageStyle band to a report in the designer at runtime,
then a DesignLayer is automatically added for this band.

But when we afterwards select the PageStyle band, we get an Access
Violation because the GetDefaultpagelayer function of the PageStyleBand
returned nil. We have solved this by changing the "Count -2" startvalue
of the for statement to "Count -1".

I'm not very sure that this will nog introduce other problems, but it
solved our AV problem.




function TppDesignLayers.GetDefaultPageLayer: TppDesignLayer;
var
liIndex: Integer;
lLayer: TppDesignLayer;
begin

Result := nil;

// get last page layer
for liIndex := Count - 1 downto 0 do
begin

lLayer := GetItemForIndex(liIndex);

if lLayer.LayerType = ltPage then
Result := lLayer;

if Result <> nil then
Exit;

end;

end;

Comments

  • edited May 2012
    I tried a simple test at Delphi design-time and also at run-time. I select
    the Report | PageStyle menu option and then page style and page layer are
    created. I can then select either the Foreground layer or the PageLayer.

    Please provide exact steps to reproduce the issue or create a simple example
    that we can build and run here in the debugger and send to support@ in zip
    format.

    The last design layer, (Count-1), should always be the Foreground. In the
    simple case when you have two design layers, the PageLayer should be 0 and
    Foreground 1.

    -
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited May 2012
    Some more info:

    It seems that one of our users has made the impossible possible (as
    users tend to do LOL). In his Report Design, DesignLayer[0] is
    ForeGround1, and DesignLayer[1] is PageLayer1.

    If I add the PageStyle band to my own report, then DesignLayer[0] is
    Pagelayer1 and DesignLayer[1] is Foreground1.

    Of course with this order of the pagelayers, GetDefaultPageLayer cannot
    find the correct layer if it only looks at DesignLayer[0] ...

    gr
    Bas

    Op 29-5-2012 21:55, Nard Moseley (Digital Metaphors) schreef:
  • edited May 2012
    In a prior release I think there was a bug that allowed the PageStyle to be
    in front. To fix the report, select the PagesStyle node in the report tree.
    Use the object inspector to set the OrderIndex property to 0.

    -
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited June 2012
    When i try to change the OrderIndex of PageStyle to 0, it changes back
    to 1 when I press Enter. It looks like the OrderIndex cannot be changed
    by hand...

    gr
    Bas


    Op 30-5-2012 18:07, Nard Moseley (Digital Metaphors) schreef:
  • edited June 2012
    A customer emailed an example report to support@ that was saved with the
    incorrect order. I created a patch for RB 14.05 that will fix the designer
    layer order - when the report loads - forcing the foreground to be the last
    layer. Please send an email to support@ and request the patch.


    -
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
This discussion has been closed.