VBCE.com - The Premier Website For Visual Basic/CE Developers

 

*Dev Corner

Sample Code
Controls
Workarounds
Tips & Tricks
Q & A
Forums

*Goodies
Downloads
Software
Bookstore


*General
Home
What's New
General Info
Misc. Info


*News Worthy
News
Articles
Editorials
KB Articles
Reviews
Awards

*Miscellaneous
Web Links
Partners
Search
Feedback
Advertising

<% On Error Resume Next SiteStats() %>

Sponsors


More...


Scroll That TextBox!
By webmaster@vbce.com

    The instrinsic TextBox control that VBCE provides has a bug (BUG: TextBox Does Not Scroll to the Caret Position Q181945) that causes it not to scroll to the caret position when the SelStart is set to a location that is out of the current view of the TextBox.

    This prevents the programmer from being able to do a number of things, the major one is incorporating a find method. What good is placing the caret at the bottom of a document and/or highlighting a word if the caret or the highlighted word is out of view?

    Fortunately, our little friend the Windows Message comes to the rescue once again. Sooner or later you'll need the functions of the VBCE.COM VBCEMiscUtility control, a control for use in VBCE, and this is just another one of those situations.

    By sending the TextBox an EM_SCROLLCARET message, the textbox will scroll so that the caret is in view. Simply place an instance of the VBCEMiscUtil control on your main form, paste the ScrollTextBox routine into your code somewhere, and then call it like this:

  'Scroll to end of textbox
  ScrollTextBox Text1

Public Sub ScrollTextBox(TBox)
  'EM_SCROLLCARET = &HB7
  'Works around the SelStart scrolling Bug
  'Scrolls the text box so that the
  'caret (cursor) is in view

  Call VBCEUtil1.SendMessageLong( _
     TBox.hwnd, &HB7, 0, 0)
End Sub

bug_word.jpg (1504 bytes)
bug_ant_1.gif (13248 bytes)
workaround.jpg (2931 bytes)

 

“When the bugs get tough,
the tough get coding!”



VBCE.com is DevX Winner!

Unless otherwise noted, all information on VBCE.com is Copyright 1998 - 2002
Windows, Windows CE, and Visual Basic are trademarks of the Microsoft Corporation.
VBCE.com is not responsible for content on external sites.
Send all feedback to webmaster@vbce.com
Webmasters - feel free to link to
VBCE.com - Premier Website for Visual Basic/CE Development

Buy Books!