Results 1 to 4 of 4

Thread: [RESOLVED] positioning within the Rich Text Box (RTB)

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    169

    Resolved [RESOLVED] positioning within the Rich Text Box (RTB)

    When using the rtb.Find method, is places the insertion point at the beginning of the matched text. However, it just pulls this matched text into view. Leaving it at the bottom of the rtb control, instead of positioning/ scrolling the found text to the top so that the text below it is also in view.


    Is there anyway to force a repositioning/scroll after the text is found, or somehow ensure that the matched text is placed at the top?
    Last edited by vb_lover; May 1st, 2006 at 01:47 PM.

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,175

    Re: positioning within the Rich Text Box (RTB)

    VB Code:
    1. Option Explicit
    2. Private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal _
    3.                                          wParam As Long, lParam As Long) As Long
    4. Private Const EM_LINESCROLL = &HB6
    5. Private Const EM_GETFIRSTVISIBLELINE = &HCE
    6.  
    7. Private Sub Command1_Click()
    8.    
    9.     Dim lng1stVisible As Long
    10.     Dim lngLineWithWord As Long
    11.    
    12.    
    13.     With RichTextBox1
    14.         .Find "the word you want"
    15.  
    16.         ' Get the line number that contains the word
    17.         lngLineWithWord = .GetLineFromChar(.SelStart)
    18.  
    19.         ' Get the line number of the 1st visible line
    20.         lng1stVisible = SendMessageLong(.hwnd, EM_GETFIRSTVISIBLELINE, 0&, 0&)
    21.        
    22.         ' Scroll
    23.         SendMessageLong .hwnd, EM_LINESCROLL, 0, ByVal lngLineWithWord - lng1stVisible
    24.     End With
    25.  
    26. End Sub

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    169

    Arrow Re: positioning within the Rich Text Box (RTB)

    Ohhhhh YEAaaaaaaaaaaa....

    Many Thanks Marty


    Yikes...18 thousand posts...

    And since you were so quick with the EM_'s maybe you are familiar with the statusbar and tooltip messaging

    i dont suppose you saw my other post about obtaining the window handle of the tooltips for a STATUSBAR did you?
    Last edited by vb_lover; May 1st, 2006 at 07:50 PM.

  4. #4

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