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

Shape - stRoundRect

edited March 2003 in General
I need to change the radius of the Round Rectangle. How to do ? If I use
a Rect that is a little bigger, then the radius of the edges is to
great. Is it possible to change that ?


thanks


Klaus Astner

Comments

  • edited March 2003
    As I see by looking at the source code from the TppShape object (RB version
    6.03), the radius is not published in any way but is calculated in the
    CalcDimensions method.

    {determine length of the shortest side, use for circles, squares and corner
    rounding}
    if (liWidth < liHeight) then
    liSide := liWidth
    else
    liSide := liHeight;

    ...

    aXCornerRound := liSide div 4;
    aYCornerRound := liSide div 4;


    So one way would be to create a new component from TppShape, add the radius
    property and set the aXCornerRound and aYCornerRound to the desired value.

    But maybe the DM folks will find some magical solution that will require
    less work.

    Cheers

    Daniel
  • edited March 2003
    The UI doesn't support this, but it is implemented on the TppShape. The
    TppDrawShape draw command also supports it. Hook the component's
    OnDrawCommandCreate event up to accomplish this without having to code a new
    TmyShape component:

    procedure TForm1.ppShape1DrawCommandCreate(Sender, aDrawCommand: TObject);
    begin
    TppDrawShape(aDrawCommand).XCornerRound := 25400; {1 inch in microns}
    TppDrawShape(aDrawCommand).YCornerRound := 25400;
    end;

    Otherwise, it is time to code a custom component. It is easy to do this, and
    actually, I just coded it for you:) Here is an example of creating a new
    shape (the yellow L shaped icon in the designer) that supports corner
    rounding in a simple dialog launched from the popup menu. You may want to
    add initialization to the dialog, as this is just a complete minimal example
    showing the technique. You may also want to replace the TppShape with this
    one, by unregistering the TppShape and using the same image as the TppShape
    on your TmyShape.

    http://www.digital-metaphors.com/tips/SetShapeCornerRound.zip

    Cheers,

    Jim Bennett
    Digital Metaphors


This discussion has been closed.