TClientAnchor deltax and deltaY are reversed?

I am inserting an image in a TExcelFile and have used the code in the getting started demo as a starting point. It is not a show-stopper, but it appears to me that the deltax and deltaY parameters to TClientAnchor.Create are "back to front" i.e. the one(s) for X actually affect the Y-axis and vice-versa.



For example:

Following the comments in the create code section, if I insert an image in a single cell (that is much bigger than the cell) using the following, I expect it to fill the cell. However, what happens is that I get an image the same height as the row but only about a quarter of the width.



          e.DataFile.AddImage(PathToImage,

           TImageProperties_Create(

             TClientAnchor.Create(TFlxAnchorType.MoveAndDontResize, j, 0, k, 0, j, 1024, k, 255),

             PathToImage, 'Company Logo')



If I switch the end-point deltas around as below, then I get the cell being completely occupied:



             TClientAnchor.Create(TFlxAnchorType.MoveAndDontResize, j, 0, k, 0, j, 255, k, 1024),



It appears (to me) that the delta parameters are being wrongly interpreted or that the parameters need the X and Y labeling switched.





Hi,


Could it be that the order of the xml comments is confusing?  The methods you are calling is:



    class function Create(const aAnchorType: TFlxAnchorType; const aRow1: Int32; const aDy1: Int32; const aCol1: Int32; const aDx1: Int32; const aRow2: Int32; const aDy2: Int32; const aCol2: Int32; const aDx2: Int32): TClientAnchor; overload; static;


Note that the first parameter is Dy, then it comes Dx. This is because we always use row, col in FlexCel, that is (y, x) where the rows are Y and the cols are X. So if the first parameter is the Row1, then the second parameter should be DY1, as it is the offset for Row1.

Columns in Excel have more resolution than rows (most likely because standard rows are smaller than columns, so columns (or X) are measured with a 1/1024 precision, while rows (or Y) are measured in 1/255.

As the first parameter is Dy (1/255) and the second is Dx (1/1024) the correct call is as you wrote in second place:

TClientAnchor.Create(TFlxAnchorType.MoveAndDontResize, j(Row1 or Y1), 0 (Dy1), k(Col1 or X1), 0 (Dx1), j(Row2 or Y2), 255(Dy2),  k(Col2 or X2), 1024(Dx2))


I can see if might be confusing because the xml comments aren't in the same order:



   /// <param name="aAnchorType">How the image behaves when copying/inserting cells.</param>
    /// <param name="aCol1">First column of object</param>
    /// <param name="aDx1">Delta x of image, on 1/1024 of a cell.  0 means totally at the left, 512 on half of the cell, 1024 means at the left of next cell.</param>
    /// <param name="aRow1">First Row of object.</param>
    /// <param name="aDy1">Delta y of image on 1/255 of a cell. 0 means totally at the top, 128 on half of the cell, 255 means at the top of next cell.</param>
    /// <param name="aCol2">Last column of object.</param>
    /// <param name="aDx2">Delta x of image, on 1/1024 of a cell.  0 means totally at the left, 512 on half of the cell, 1024 means at the left of next cell.</param>
    /// <param name="aRow2">Last row of object.</param>
    /// <param name="aDy2">Delta y of image on 1/255 of a cell. 0 means totally at the top, 128 on half of the cell, 255 means at the top of next cell.</param>
 


That is, we first mention col1, dx1. But what matter is not the order of the comments, but the order in the declaration. Anyway, I'll see to order the comments so the follow the same order.

If there is something else going on please let me know, but I can't see anything wrong (except maybe the order of the comments)


As usual, you are correct. It was the order of the comments that tripped me up.

Thank you.