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

Advice Sought re exception

edited February 2013 in End User
Hi

I have made a change somewhere which has radically upset the Report Builder
End User Reporting function and I am at a loss to understand what I have
done, I would appreciate any suggestions you may care to give to resolve my
issue.

Environment = Report Builder 14.07, Delphi 2007, windows 8

Using the report explorer has worked fine for many years, if I right click
on a report it opens in the designer, I can tab through data, design and
preview OK but when I go to run the report by double clicking on the report
90% of the time the report now fails with a 'Stack Overflow' message - I
then get the CPU display but I do not know what these mean or how to
interpret these to help me.

If I open the report in an older build of my application then the report
opens fine, it only fails with the newer builds I have done.

Also when I run reports by loading from the .rtm template then too I get
errors.

Everything is working OK on the 14.07, Delphi XE version.

I tried up dating to 14.08 but this had no effect.

Sorry for the 'vague' description of the problem - if you have any
suggestions as to how I can debug the problem to get a better understanding
of where the problem lies I would appreciate any suggestions.

Thanks in advance.

Philip L Jackson

Comments

  • edited February 2013
    Hi

    env = Delphi 2007/RB 14.08 + 14.07/Windows 8

    The problem seems to be with the setting...

    User Interface > Preview Form Settings > Window State.

    If the report is set to wsNormal the report is generated OK

    If the report is set to wsMaximised then the application generates a very
    violent exception and terminates without any diagnostic or other information
    (I am using Eureka Log for my error trapping).

    To try and reproduce the issue I have made a small test project by copying
    all the necessary components from my main application. However both
    wsNormal/wsMaximised work exactly as expected when I run the same reports
    which fail in my main application. So it cannot be a Delphi/RB/Windows
    issue.

    Builds of my main application before Christmas worked OK, the issue seems to
    be with any builds made in January. I have reviewed the changes I made to
    the application in January, there were only 3 and none of them involved
    anything to do with screen sizes, + the move to 14.08 the other day, so I am
    at a total loss as to what has changed and why I am now getting these
    errors.

    I would appreciate any advice you can offer.

    Regards

    Philip L Jackson
















  • edited February 2013
    Philip L Jackson wrote:


    Hello Philip,

    we had similar problems ... until we've checked that the
    report.ModalPreview property has not worked in prior versions with same
    functionality. After setting report.ModalPreview:=true; now everything
    is working fine.

    It's possible that this is the difference between your normal project
    and test project?

    --
    --
    Yusuf Zorlu

    MicrotronX Hard- & Software Consulting
    http://www.microtronx.com
  • edited February 2013
    Hi Philip,

    We have not seen this behavior before. Try setting your library path to
    RBuilder\Source and breaking on the exception you receive. This could
    shed some light on where the actual problem is occurring.

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited February 2013
    Hi

    Thanks for your reply - I have checked both applications and ModalPreview
    property is set to TRUE in both applications.

    However as an alternative to your suggestion I tried ModalPreview=FALSE and
    the application worked OK.

    I have spent many hours with finder on F7 stepping through the code to try
    and locate why "FPreviewForm.Showmodal;" fails with the error and
    "FPreviewForm.Show;" works great.

    Unfortunately I have over 1000 users with 100+ reports each and I could not
    face the torrent of phone calls I would face if I had to release my
    application with the instruction that they have to open each form in turn
    and change the settings.

    I will continue with the conversation with Digital M.

    Regards

    Philip L Jackson








  • edited February 2013
    Hi

    Please see Yusuf Zorlu's comments below + my response.

    The error occurs in ppProd at line FPreviewForm.Showmodal;

    I have tried tracing in further but I have spent many hours now seeing
    ppTB2Hook function CallWndProcHook being repeated but I cannot work out
    what section of code runs after this or indeed if the error is in one of the
    function calls.

    I have made about 4hrs of video trying to catch the point where the error
    occurs but to no avail.

    As I said to Yusuf I could not face telling all my users to reset all their
    reports to set the size to wsNormal or to change the preview form settings.

    Do you have any further ideas, suggestions?

    Yours in desperation.

    Philip L Jackson










    {display the form}
    if FModalPreview then
    begin
    FPreviewForm.ppOnActivate := PreviewFormActivateEvent;

    try
    FPreviewForm.Showmodal;

    if FModalException <> nil then
    raise FModalException;

    finally
    FModalException := nil;
    end;
    end

    else
    begin
    FPreviewForm.Show;

    PrintToDevices;
    end;




  • edited February 2013
    Hi Philip,

    This is an issue we will need to be able to recreate here in order to
    track down. I have tried running our end-user demo and did not receive
    the behavior you describe. Perhaps you can use that demo as a starting
    point to recreate the error on your machine, then send us a description
    on how to recreate it here.

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited February 2013
    Hi Nico

    You have just asked the $64,000 question. I have a small end user demo
    built with the same D2007, Advantage, Report Builder, and Windows 8 and it
    works faultlessly. There must be something that is upsetting one of the
    preview settings somewhere in my main application but where is the question.

    Regarding ppProd.pas, I have found that if I call

    FPreviewForm.Show;
    PrintToDevices;

    in lieu of

    FPreviewForm.Showmodal;


    in the code below then everything works fine.

    I have compiled my application with the D2007 options folder set to
    RBuilder\Source and copied the dcu to RBuilder\Lib and then modified the
    options folder to be back to RBuilder\Lib.

    Could you please advise if you can see any reason why I do not go forward
    with this solution?

    Best Wishes

    Philip L Jackson



    ppProd.pas......

    {display the form}
    if FModalPreview then
    begin
    FPreviewForm.ppOnActivate := PreviewFormActivateEvent;

    try
    // FPreviewForm.Showmodal; //removed 07/02/13 by PLJ
    FPreviewForm.Show; //added 07/02/13 by PLJ
    PrintToDevices; //added 07/02/13 by PLJ
    if FModalException <> nil then
    raise FModalException;

    finally
    FModalException := nil;
    end;
    end

    else
    begin
    FPreviewForm.Show;

    PrintToDevices;
    end;

  • edited February 2013
    Hi Philip,

    I'm a bit unclear about your solution. Are you altering the RB source?

    This is definitely not something we would recommend as it could have
    other unintended effects as well as turn into a maintenance issue when
    applying new updates.

    Have you tried setting the Report.ModalPreview property to False? This
    should give you the same effect.

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited February 2013

    As a test, you might try setting PreviewFormSettings.SinglePageOnly to True.
    That will use the old single page preview, that does not have the background
    thread generation for the scrollable pages.

    For Modal preview, PrintToDevices is called via an event-handler for the
    preview form's OnActivate event. Below is the relevant code. You might try
    putting a break point in the PreviewFormActivateEvent to determine whether
    the error occurs before or after that point.

    You could also try implementing the OnPreviewCreate event to assign the
    Report.PreviewForm.PopupParent. See the Delphi help for TForm.PopupParent
    and PopupMode. The PopupParent property enables you to specify the parent
    window of a modal form. If your application has multiple layered forms,
    perhaps this would help.


    In TppProducer.PrintToScreen,

    if FModalPreview then
    begin
    FPreviewForm.ppOnActivate := PreviewFormActivateEvent;

    try
    FPreviewForm.Showmodal;


    And then in TppProducer.PreviewFormActivateEvent

    if DeviceType = dtScreen then
    try
    PrintToDevices;


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

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited February 2013
    Hi

    You are correct - I am modifying RB Source and I am not happy about it but
    this is the only way I can get the reports to run when they have a modal =
    TRUE and the size set to wsMaximized.

    My customers have many 1000's of reports and I would not like to have to go
    through an exercise in changing all their report templates.

    ModalPreview = FALSE works fine with the size set to wsMaximized..

    Regards

    Philip L Jackson



  • edited February 2013
    Thanks for taking time to give me a detail reply

    1. PreviewFormSettings.SinglePageOnly is set to True

    2. The error occurs at FPreviewForm.Showmodal; but where within this
    command I cannot see. The PreviewFormActivateEvent; does not appear to
    generate the error.

    3. I have tried setting the TForm.PopupParent to pmAuto but this does not
    appear to have any effect.

    I am still running with the modified RB Source to Nico's horror in the
    previous news message.

    What is frustrating/confusing me is why can I get no further with the
    debugging information after FPreviewForm.Showmodal;?

    Regards

    Philip L Jackson



  • edited February 2013
    Hi Philip,

    Though this is more of a bandage for the problem, you should not have to
    change every report your users load. You could simply add code to alter
    the ModalPreview property after a template/report is loaded and before
    it is printed/previewed.

    It appears if we really want to get to the bottom of this issue you will
    need to begin removing sections from your main application to try to
    isolate the issue. Start by removing all event handlers dealing with
    the report. Then move to data access. Once you are able to load a
    report without errors, periodically begin adding features back to find
    the culprit.

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited February 2013

    In regards to number 3 I think you are referring to Form.PopupMode, which is
    a different but related property to Form.PopupParent. Try setting the
    PopupParent to the specific Form that should be the parent (underlying) form
    of the ShowModal form. See the Delphi help for details on these two
    properties.

    TForm.ShowModal is essentially a loop, below is the relevant bit from
    TCustomForm.ShowModal (Forms.pas). Using a visual debugger you cannot really
    trace into it, because doing so interrupts the windows message and so you
    just kind of go nowhere. This is a case where you either have to put break
    points elsewhere - such as the OnActivate event-handler or PrintToDevices
    or perhaps use a tool like CodeSite to log debug info. Logging debug info
    has the advantage over the visual debugger in that it does not alter the
    windows message processing behavior.

    try
    Show;
    try
    SendMessage(Handle, CM_ACTIVATE, 0, 0);
    ModalResult := 0;
    repeat
    Application.HandleMessage;
    if Application.Terminated then ModalResult := mrCancel else
    if ModalResult <> 0 then CloseModal;
    until ModalResult <> 0;
    Result := ModalResult;
    SendMessage(Handle, CM_DEACTIVATE, 0, 0);
    if GetActiveWindow <> Handle then ActiveWindow := 0;
    finally
    Hide;
    end;
    finally



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

    "Philip L Jackson" wrote in message news:51179a08$1@mail....

    Thanks for taking time to give me a detail reply

    1. PreviewFormSettings.SinglePageOnly is set to True

    2. The error occurs at FPreviewForm.Showmodal; but where within this
    command I cannot see. The PreviewFormActivateEvent; does not appear to
    generate the error.

    3. I have tried setting the TForm.PopupParent to pmAuto but this does not
    appear to have any effect.

    I am still running with the modified RB Source to Nico's horror in the
    previous news message.

    What is frustrating/confusing me is why can I get no further with the
    debugging information after FPreviewForm.Showmodal;?

    Regards

    Philip L Jackson




    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited February 2013
    Hi

    Thanks for your and Nard's time on this issue.

    I have not been able to get to the bottom of this but I have added the
    following to my report component and all now seems OK, except that the user
    has to maximise the report themselves.

    Best Wishes

    Philip L Jackson



    procedure TMainDataModule.ppReport1InitializeParameters(Sender: TObject;
    var aCancel: Boolean);
    begin
    ppReport1.PreviewFormSettings.windowState := wsNormal;
    ppReport1.PreviewFormSettings.ZoomSetting := zs100Percent;
    ppReport1.PreviewFormSettings.ZoomPercentage := 100;
    end;

This discussion has been closed.