How to get scroll position for RichTextBox?

谁说我不能喝 提交于 2019-12-02 11:39:25

问题


I'm working in C#, Windows Forms application, and have a problem getting scroll position for RichTextBox with large amount of text.

I'm using this code:

  public class POINT
    {
        public  int x;
        public int y;

        public POINT()
        {
        }

        public POINT(int x, int y)
        {
            this.x = x;
            this.y = y;
        }
    }

SendMessage(this.Handle, EM_GETSCROLLPOS, 0, res)

But, when control contains large amount of text, resulting y offset is incorect because upper 16 bits of Y are always 0.

Is there any way to get scroll position larger than 16 bits?


回答1:


I thought it was about time to case this into an answer

GetPositionFromCharIndex(0)

Retrieves the location within the control at the specified character index

This will get the offset, of the character relative the the control



来源:https://stackoverflow.com/questions/9490182/how-to-get-scroll-position-for-richtextbox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!