Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scrolling a multilined textbox without scroll bars? 1

Status
Not open for further replies.

ironmunk

Technical User
Aug 21, 2001
51
CA
Can this be done? I have a text box that is multilined filled with text. I'd like to have 2 command button so the text can scroll up and down in the text box without the scroll bars showing up?

Possible?
 
Here some code for you. You will need a text1 text box and 2 command buttons named cmdUp and a cmdDown then drop this code in a new project.
Code:
Option Explicit

Private Declare Function SendMessageByVal Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, _
    ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Private Const EM_LINESCROLL = &HB6

Private Sub cmdDown_Click()
    LineScroll Text1, 0, 1
    Text1.SetFocus
End Sub

Private Sub cmdUp_Click()
    LineScroll Text1, 0, -1
    Text1.SetFocus
End Sub

' Positive values scroll left and up, negative values scroll right and down.
Sub LineScroll(tb As TextBox, ByVal HorizScroll As Long, ByVal VertScroll As Long)
    SendMessageByVal tb.hwnd, EM_LINESCROLL, HorizScroll, VertScroll
End Sub

Private Sub Form_Load()
    Dim iX As Long
    Dim iY As Long
    Dim str As String

        For iY = 0 To 75
            str = str & iY & ". "
            For iX = 65 To 90
                str = str & Chr$(iX)
            Next
            str = str & vbCrLf
        Next
    Text1.Text = str

End Sub

Hope this helps. If you choose to battle wits with the witless be prepared to lose.
[machinegun][hammer]
 
I received the following error msg.

Can't find DLL entry point sendmessageA in user32

any idea?
 
What OS are you using? If you choose to battle wits with the witless be prepared to lose.
[machinegun][hammer]
 
As a quick test try just using

Private Declare Function SendMessageByVal Lib "user32" Alias "SendMessage" (ByVal hwnd As Long, _
ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

instead. I will try to set things up on a 2000 platform and see what is going on. Let me know if the change works. If you choose to battle wits with the witless be prepared to lose.
[machinegun][hammer]
 
I copied the code right from the first post into a new project on a machine running 2000 and it worked fine. What verson is the User32.dll on your machine? (5.0.2195.2821). You may also have a corrupt dll. If you choose to battle wits with the witless be prepared to lose.
[machinegun][hammer]
 
It looks like the version I have is corrupt (5.0.2195.2831). How can I repair this?
 
I give you a start for this...this is cool. I was thinking about doing this as well...works great!!
 
dvannoy,

If you want to add the right and left buttons make sure you set the text boxes scroll property to include horizontal or they will not work, FYI. [spin]
If you choose to battle wits with the witless be prepared to lose.
[machinegun][hammer]
 
Thanks, right now the text will just drop to the next line...I use the text box as a small comment section so not very much data would be in there....but I will remember that for the future.. right now right to left is set to false..it's such a small box I just want them to scroll down..


Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top