WP5 equivalent of y_start, and [lin^].Height

  • Julian,

    How does code similar to this, in pre-V5, get rewritten in V5? I know there is no longer the line concept as such, but how does one determine the equivalent of y_start? What's the V5 analog to that?

    Code
    function DetermineTopValue : integer;
    var
       lin : PTLine;
    begin
       lin := WPRichText1.ActiveParagraph.line;
       Result := lin^.y_start + lin^.Height;
    end

    Oh, and I noticed you make a reference elsewhere recently to your adding a "line" concept back in, but since there are no longer pointers, I'm guessing the line in V5 will be quite a different construct than in pre-V5.

    diamond

    • Offizieller Beitrag

    Please use

    GetPointFromParLin to get the position 'on screen'

    or the 'intern' function which will also calculate the number of the page and the X,Y position the RTF-Resolution.

  • Hmm.... The need to determine the "y_start" is not based on a mouse click on screen, but rather as I'm constructing a document programmatically, and I need to know the y_start (or whatever the V5 equivalent of that is), on, say, some paragraph on the third page.

    Does the code you shared above help accomplish that?

    And with apologies, I'm not sure what you mean by "or the intern function which will also calculate the number of the page and the X,Y position the RTF-resolution". I'm sure I should follow that, but I don't! That sounds promising, but I'm not exactly (heck, not even kind of) sure how it relates to my need to determine the current y position of a given place within the document I'm creating programmatically.

    Thanks!

    diamond

    • Offizieller Beitrag

    Hi,


    -- and I need to know the y_start (or whatever the V5 equivalent of that is), on, say, some paragraph on the third page.

    Does the code you shared above help accomplish that?

    Yes:

    The 'intern' procedure is the procedure found in the RTF Engine:

    Memo.GetXYPositionAtRTF(
    FMemo.Cursor.RTFData,
    par,
    posinpar, PaintPageNr, Result.X, Result.Y) then

    Not that it uses 'posinpar' to identify the line

    I just posted the implementation GetPointFromParLin since it should make clear whats going on.

    I assume you will use the X and Y result right away.

    My using MulDiv(x, 1440, Memo.CurrentXPixelsPerInch) you get twips values.

    Julian

    • Offizieller Beitrag

    From Version 5.08.5 there will be new custom draw events which make it possible to draw borders around paragraphs, or group of paragraphs.

    You can also draw into the background of the paragraph to show the current paragraph with a flashing background.

    This events quite powerful since they also implement automatic stack logic. This is not just an event to draw to the canvas, it also offer the possibility to group paragraphs.

    See demo CustomParDraw

    Julian Ziersch