Solved

Scrolling a Textbox

Posted on 2000-04-25
8
277 Views
Last Modified: 2008-03-10
I have tried the scrollwindowex api function, but it doesn't work and i don't want to use a listbox for it.
0
Comment
Question by:frogman_j
8 Comments
 
LVL 28

Expert Comment

by:AzraSound
ID: 2748464
0
 
LVL 27

Accepted Solution

by:
Ark earned 100 total points
ID: 2749943
Do you want to scroll TextBox line-by-line or pixel-by-pixel?
If line-by-line, its simply:
Const EM_SCROLL = &HB5
Const SB_LINEDOWN = 1
Const SB_LINEUP = 0
Const SB_PAGEDOWN = 3
Const SB_PAGEUP = 2
Private Declare Function SendMessageByNum Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) As Long

Private Sub Command2_Click()
  Dim nRet As Long
  nRet = SendMessageByNum(Text1.hwnd, EM_SCROLL, SB_LINEDOWN, 0&)
End Sub

Pixel-by-pixel solution is a bit harder. I did this code for RichTextBox, but for ordinary TextBox it's the same:
http://www.freevbcode.com/ShowCode.Asp?ID=895

Cheers
0
 

Expert Comment

by:nicehumanbeing
ID: 2750269
try this : put a lotta text into the textbox. somewhere towards the end u add "FIND THIS"

put this into a command button


Text1.SelStart = InStr(1, Text1, "FIND THIS")
Text1.SelLength = 0
Text1.SetFocus
' be sure to put this setfocus line in


NOte : instead of the "FIND THIS TEXT" and the instring, u can simply add an average no of chars and repeat this in a timer to create a cute scroll effect.
Hope this solves ur problem .

ARK too has a nice solution for pixels...

0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

Author Comment

by:frogman_j
ID: 2757156
I used a modification of Ark's code, so put in an answer Ark!
0
 

Author Comment

by:frogman_j
ID: 2757158
never mind, Ark
0
 

Author Comment

by:frogman_j
ID: 2757164
Thanks for the bit of code. I looked at more of the SB_ constants and I can use it like I want now.
0
 

Author Comment

by:frogman_j
ID: 2757184
Just one more question. Is there a way to scroll to the bottom cleanly?
0
 
LVL 27

Expert Comment

by:Ark
ID: 2757262
Thanks for points, glad to help you!
About scrolling to bottom - it's simply - no API
Text1.SelStart = Len(Text1.Text)
Cheers
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question