CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1

    Textbox manipulation with a Scrollbar

    I need to manipulate the contents of a textbox so that the last value can always been seen. How can I do this and do I need scrollbars to achieve this. Thanks.


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

    Re: Textbox manipulation with a Scrollbar

    By "last value" you mean the last section of text , right?

    There are a couple of Edit-box messages to do this kind of stuff. Check which suits you.

    For ex. if you want to scroll the Caret position into view

    ' in declarations :
    Const EM_SCROLLCARET = &HB7&
    Const EM_SCROLL = &HB5&
    Const EM_GETLINECOUNT = &HBA&
    Const EM_LINESCROLL = &HB6&

    private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
    (byval hwnd as Long, byval wMsg as Long, _
    byval wParam as Long, lParam as Any) as Long

    '
    private Sub Text2_GotFocus()
    ' to scroll the caret into view:
    SendMessage Text2.hwnd, EM_SCROLLCARET, 0, byval &H0&
    ' to show the last line, irrespective of the Caret position:
    ' SendMessage Text2.hwnd, EM_LINESCROLL, SendMessage(Text2.hwnd, EM_GETLINECOUNT, 0, 0), 0
    End Sub




    Be warned: that using it in _GotFocus like in this example would be a little funny to scroll to end each time!, it is not the right place...

    If you set the Multiple=True and ScrollBars = 2 (Vertical) would be nice for that example.

    RK

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