Results 1 to 5 of 5

Thread: Question about RTF control...

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2000
    Posts
    66

    Question Question about RTF control...

    Hello,

    When I change the SelStart property of my RTF control, I would like the line (depending on the selstart position) to be the first visible line (at the top of the visible part of my RTF).

    Is it possible and how can I do that ?
    Is there an option in the RTF control or should I use the SendMessage API ?...

    Thanks,
    Thierry

  2. #2
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765
    Do you want to move text, or just set the curser postion?

    Move Curser
    VB Code:
    1. 'moves it to the beginning
    2. RichTextbox1.selstart = 0

    Copy Text
    VB Code:
    1. Dim temp as String
    2. 'or use the clipboard
    3. temp = richtextbox1.seltext
    4. richtextbox1.selstart = 0
    5. richtextbox1.seltext = temp


    I haven't tested the Copy Text thingy, but it should work..
    Don't Rate my posts.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2000
    Posts
    66

    I want this :

    For example, if I want to go to page # 15 I get :

    imgKO.jpg

    But what I would like is :

    imgOK.jpg

    Thanks,
    Thierry
    Attached Images Attached Images  

  4. #4
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765
    Hmm... I don't know if thats possible... not without alot of work anyways. The RichTextbox doesn't divide text up into pages... so you would have to work out how many lines would fit on a page, and then tell it where a new page starts/ends...

    Then you could move between them... maybe...
    Don't Rate my posts.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Mar 2000
    Posts
    66

    I get the solution...

    I aggre with you when you said that the RichTextbox doesn't divide text up into pages... but what I omitted to tell you is that the file that I load (created by another program) are supposed to fit a specific parameter which is a number of Lines_Per_Page.

    I wrote a function GetCharFromLine which call SendMessage API and it works fine when I specified a page number smaller than the current one.

    Then, to solve my problem when I specified a page number taller than the current page, I got the idea of setting the cursor (SelStart property) to the 'page specified + 1' then just after, setting the ursor to the 'page specified' and it works fine now !...

    ' cP is the current page
    ' nP is the page number that user ask for
    z = (((nP + 1) * Lines_Per_Page) - Lines_Per_Page)
    x = ((nP * Lines_Per_Page) - Lines_Per_Page)
    RTB.SelStart = GetCharFromLine(Text1, x)
    '
    ' if current page is smaller than page number specified
    '
    If cP < nP Then
    RTB.SelStart = GetCharFromLine(Text1, z) ' page + 1
    RTB.SelStart = GetCharFromLine(Text1, x) ' page specified
    End If

    RTB.SelLength = 1 ' just to see where the cursor is
    RTB.SetFocus




    ' returns the first character of line #
    Public Function GetCharFromLine(txtbox As RichTextBox, LineIndex As Long) As Long
    GetCharFromLine = SendMessage(txtbox.hwnd, EM_LINEINDEX, LineIndex, 0&)
    End Function


    Thanks again for your help,
    Thierry

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