Ticket Q311703
Visible to All Users

GetPixelPhysicalBounds - Get Document height in pixels

created 14 years ago

Hi, I'm trying to get the height of a RichEditDocument based on its contents.
I have found that RichEditControl has a method named GetPixelPhysicalBounds, which I think it may be helpful, but I cannot find any documentation about how to use it.
Any suggestions?
Thanks!
Christian Llanos

Comments (3)
Alessandro (DevExpress Support) 14 years ago

    Hello Christian,
    I believe that you can use the approach from the Content size ticket for this purpose. Please let us know whether this approach is appropriate for you.
    Thanks,
    Alessandro.

    CL CL
    Christian Llanos (CS) 14 years ago

      Hi Alessandro,
      I have reviewed that link and I'm not sure what approach should I take. It seems to me that the link you suggested is for Winforms, I'm currently working with WPF.
      What about GetPixelPhysicalBounds? what and how is this used for?
      Regards,
      Christian Llanos

      CL CL
      Christian Llanos (CS) 14 years ago

        I think I have found a possible solution:
        double height = 0.0;
        DevExpress.XtraRichEdit.DocumentLayoutUnit oldUnit = this.LayoutUnit;
        if (this.LayoutUnit != DevExpress.XtraRichEdit.DocumentLayoutUnit.Pixel) this.LayoutUnit = DevExpress.XtraRichEdit.DocumentLayoutUnit.Pixel;
        System.Drawing.Rectangle rect = this.GetLayoutLogicalBoundsFromPosition(this.Document.CreatePosition(this.Document.Range.End.ToInt() - 1));
        height = rect.Y + rect.Height;
        if (this.LayoutUnit != oldUnit) this.LayoutUnit = oldUnit;
        Regards,
        Christian Llanos

        Answers approved by DevExpress Support

        created 14 years ago (modified 11 years ago)

        Christian,
        Thank you for the update. Basically, the WinForms classes might be utilized in the WPF environment in exceptional cases. As for the GetPixelPhysicalBounds() method, I am afraid that it is used only internally. That is why this method is not described in our documentation. As an alternative, documented solution, I can only suggest that you use the RichEditControl.GetBoundsFromPosition Method as follows to accomplish a similar task:

        C#
        System.Drawing.Rectangle rect = richEditControl1.GetBoundsFromPosition(richEditControl1.Document.CreatePosition(richEditControl1.Document.Range.End.ToInt() - 1)); System.Drawing.Rectangle rectPix = DevExpress.XtraRichEdit.Utils.Units.DocumentsToPixels(rect, richEditControl1.DpiX, richEditControl1.DpiY); int height = rectPix.Bottom;

        Hopefully, you will find this information helpful.
        Thanks,
        Alessandro.

          Comments (2)

            Is this also possible for a XRRichTextEdit control? I'd like to be able to get the bounds for HTML content of a rich text edit that is able to grow vertically for a given width.

            DevExpress Support Team 10 years ago

              Hello Jules,

              To process your recent post more efficiently, I created a separate ticket on your behalf: How to get size of the HTML content displayed in XRRichText. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

              Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

              Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.