CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 1999
    Posts
    102

    how to get range of visible lines in rtb?

    Hi,
    I am writing an app, were the user can insert a string any where in an already text filled rtb.
    But, if the the text is longer then can be shown at onece, than after the insretion the current line will jump to the top of the visible part of the rtb (since i am doing this: first_half_text & added_string & second_half_text).
    my question is - is there a way to restores the rtb to show the same range of lines as before the adding of the string?

    Thanks
    Dani


  2. #2
    Join Date
    May 1999
    Location
    Omika, Japan
    Posts
    729

    Re: how to get range of visible lines in rtb?

    For this you will have to forego the "selected" look of the replaced string.

    If API way is ok , then get the caret position before addiging, then add, then set the caret position back to the same point ( at which time your selection/highlite will vanish) and issue a em_setscroll message, to scroll the caret into view. But i dont know how to show exactly the same no. of lines as before!!. There is a message to get the top-visible line, EM_GETFIRSTVISIBLELine, but there is no equivalent, SET !!, so even if you get the position and save it before additing i dont know how it can be set back.

    RK

  3. #3
    Join Date
    Sep 1999
    Posts
    102

    Re: how to get range of visible lines in rtb?

    Ravi,
    Well, for the benefit of others that might read this post, i just wanted to let you know - how your sugestion helped me solve the problem:
    I indid used the EM_GETFIRSTVISIBLELINE in order to get the first visble line.
    (mind you - i did not change nothing about the method of pasting the added text!)
    Then, in order to restore the visible range of the text afetr the adding of the string, i just added three lines:
    FirstLineStart = GetCharFromLine(rtfText, FirstLine)
    gets the starting char position of the first visible line -
    rtftext.selstart = FirstLineStart
    this will scorll the text to the same position as before the adding of the staring.
    and last - restored the selstart that was before the hole thing.
    Thas it.
    Thanks Ravi.
    All the best
    Dani


  4. #4
    Join Date
    May 1999
    Location
    Omika, Japan
    Posts
    729

    Re: how to get range of visible lines in rtb?

    Good try, and nice way to do it. When i answered your question, i didn't think abt it.
    One question: Doesn't the (edit) cursor jump around, causing some annoyance? Or does it look smooth?

    RK

  5. #5
    Join Date
    Sep 1999
    Posts
    102

    Re: how to get range of visible lines in rtb?

    Well, the answer is - yes and no.
    The cursor will not blink, but since i use mid function to select the parts of text to be joined, a selection accurs. so for an instance, the the hole selected text will be highlighted.
    For my surprize, when using .textRTF - it all works much smoother and faster.
    But all in all, it is ok, specialy - since the text returs to its original position - so the user doesnt have to search for the changes.
    All the best
    Dani.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured