How to display the margins as dotted lines?

  • Hello!

    In Full Layout Mode, how can I activate margin display,
    I mean the margins as dotted lines like in Word.
    I didn't find a property for this at TWPRichText.
    I also didn't find an event or anything else where I could do this.

    Thanx in advance,
    E. Hess

  • Thank you, but I don't get it. Do you have a Demo for me?
    There are several problems which I cannot solve:
    - reflect the size and the margins of the current page
    - actual zoom mode
    - In preview window (text not editable) , I should not see this margins.

    I saw in the sources, that TWPPaintModes has the flag wppShowMargins.
    Why don't you simply made it a public flag, which can be set at TWPRichtText? Sure, we would need some more Flags for the Preview window, and and which LayoutMode to show the margins.
    Wouldn't this be a nice enhancement for the next version?

    Thank you in advance,
    E. Hess

  • Ah, WaterM3 demo.

    WPLetterhead.PaintPageOnCanvas(0,
    0, 0, 0, 0, toCanvas, [wppShowMargins],
    XRes, YRes, -1, -1, [wpNoViewPortAPI]);

    Is it ok to use function PaintPageOnCanvas (with wppShowMargins)?

    Nevertheless, the feature-wish from my proevious posting remains ;-)

    Regards,
    E. Hess

  • Hmm, didn't work: "ghost" images (doubled texts) were displayed.
    So, first I used WP.Memo.PaintRTFPage instead, but no change.

    Now, I set some more PaintMode flags, and now it seems to be ok.
    The paintMode flags I used are:
    wppShowMargins
    wppNoImages
    wppNoTextAtAll
    wppNoParShading
    wppNoParLines
    wppNoHeaderFooter
    wppNoWatermarks
    wppNoPageBackground

    Is this ok, or should I use any other PaintMode flags?
    Is it generally ok to use this method to display the margins?

    And again:
    Nevertheless, the "official" feature-wish from my proevious posting remains ;-)

    Regards,
    E. Hess

  • Did not work :-( "Ghost" bands appeared.
    So, I watched the sources and realized the following in the Watermark event (C++ code):

    if (PaintMode.Contains( wppInPaintDesktop )) {
    if ((RTFEngine->LayoutMode == wplayLayout) ||
    (RTFEngine->LayoutMode == wplayFullLayout) ||
    (RTFEngine->LayoutMode == wpDualPageView)) {

    Wprtedefs::TWPVirtPage *vp = NULL;
    TWPRTFEnginePaintPages pp;
    TRect textr;

    if (RTFEngine->GetPaintPage( PaintPageNr, pp, vp)) {

    textr = PageRect;
    textr.Left = textr.Left + Wprtedefs::MulDiv( pp.MarginLeft, XRes, WPScreenPixelsPerInch );
    textr.Right = textr.Right - Wprtedefs::MulDiv( pp.MarginRight, XRes, WPScreenPixelsPerInch );
    textr.Top = textr.Top + Wprtedefs::MulDiv( pp.MarginTop, YRes, WPScreenPixelsPerInch );
    textr.Bottom = textr.Bottom - Wprtedefs::MulDiv( pp.MarginBottom, YRes, WPScreenPixelsPerInch );

    toCanvas->Pen->Width = 1;
    toCanvas->Pen->Color = clSilver;
    toCanvas->Pen->Style = psSolid; // psDot

    if (!pp.Modes.Contains( wpNoXMargins )) {
    if (pp.MarginLeft > 0) {
    toCanvas->MoveTo( textr.Left, textr.Top );
    toCanvas->LineTo( textr.Left, textr.Bottom );
    }
    if (pp.MarginRight > 0) {
    toCanvas->MoveTo( textr.Right, textr.Top );
    toCanvas->LineTo( textr.Right, textr.Bottom );
    }
    }
    if (!pp.Modes.Contains( wpNoYMargins )) {
    if (pp.MarginTop > 0) {
    toCanvas->MoveTo( textr.Left, textr.Top );
    toCanvas->LineTo( textr.Right, textr.Top );
    }
    if (pp.MarginBottom > 0) {
    toCanvas->MoveTo( textr.Left, textr.Bottom );
    toCanvas->LineTo( textr.Right, textr.Bottom );
    }
    }
    }
    }
    }

    This seems to work now.

    Unfortunately, the margins now are also shown in the preview window.
    But for the moment I can live with it.

    Regards,
    E. Hess

    • Offizieller Beitrag

    Hi,

    What I had in mind was the use of the OnPaintWatermark event in this way:

    Yes, I will add a viewoption - but the above gives you more control.

    Julian

  • Ok, thanx for the ViewOption.

    I didn't test your example above. But is it sure, that changing page adjustments (e.g. new section with new paper format etc.) are correctly reflected ?
    If yes, then I should again read the documentation... :-)

    Regards,
    E. Hess

    • Offizieller Beitrag

    That was a simplified example

    uses the 'current page' properties