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

SetRoundMode(RmUp) causes erratic behaviour in RB Designer

edited June 2011 in End User
If the application sets roundmode to RmUp and then calls end user designer,
there is erratic behaviour in the end-user designer.
Steps to reproduce:
- Call SetRoundMode(rmup), then invoke end-user designer.
- Select an item and use Ctrl+arrow keys to move the item: Up and Left keys
does not work (Shift+arrow has the same behaviour).
- Try moving an item from header area to the footer area with mouse: it
can't be done and causes access violation.
Tested with Reportbuilder 12, Delphi2007
Akif

Comments

  • edited September 2012
    On 25/06/2011 21:27, Mehmet Akif wrote:

    I just lost half a day tearing my hair out before I discovered that we
    are calling SetRoundMode(rmup) in our application. The impact it had on
    TppDesigner in my case was to cause any report component to increase in
    height and width by 1 pixel each time it was moved. The cause was due to
    Round() being screwed up in

    function ppToMMThousandths(Value: Single; aUnits: TppUnitType; aResolution:
    TppResolutionType; aPrinter: TObject): Longint;
    var
    liDPI: Integer;
    begin

    case aUnits of

    utScreenPixels:
    Result := Round( ((Value / Screen.PixelsPerInch) / InchPerMM) *
    1000);

    ....
    end;

    Is there anything that can be done to either raise an Exception if
    Get8087CW doesn't return a satisfactory rounding mode for RB or to for
    RB to use a custom Round() function? I've really been put out by this today

    Thanks, Paul
  • edited September 2012
    I'm perplexed: doesn't it bother anyone at DM that if an app calls
    SetRoundMode(rmup) then it makes the Designer unusable? No comments at all?

  • edited September 2012
    Hi Paul,

    I apologize for the late response. Your post is a reply to a thread
    started over a year ago. These are occasionally difficult to track
    down. For future reference, please post a new thread for a quicker
    response.

    The Round routine is extensively used inside ReportBuilder and relies on
    the RoundMode being set to the default value of rmNearest.

    One way to work around this is to save the current round mode and change
    it to the default before showing the report.

    lSaveRoundMode := GetRoundMode;
    SetRoundMode(rmNearest);

    ppDesigner1.ShowModal;

    SetRoundMode(lSaveRoundMode);

    Another option would be to use another routine such as Ceil or Trunc to
    round up or down toward infinity.

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited September 2012
    Thanks for the reply Nico.

    Yes, I'm happy to implement any sort of workaround at my end and have
    already done so. But the point I was trying to make is that if RB is so
    depends on the default setting for RoundMode then I'd have thought that
    a check should be added to the RB code to test for this with an Assert()
    because the impact is so severe. And it might prevent other developers
    losing hours pulling their hair out trying to find out what is wrong :)

  • edited September 2012
    Hi Paul,

    Thanks, I understand your concern. We will look into perhaps finding an
    easy way to resolve this.

    Best Regards,

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