Solved

Text box scrolling.

Posted on 2001-06-08
13
267 Views
Last Modified: 2010-05-02
I have a textbox.. i would like to have multiline...
but not the wrapping effect.

how do you enable multiline.. without the wrap.

The issue is i want to display contents in the textbox...
but only the first few characters..unless the user makes the form bigger.. then the textbox will get biigger and they can see more..


thanks.

<no i dont want to put each line into a listbox.. i know this would give the same results.. but i dont want to go down that route as it is slow to build.>
0
Comment
Question by:TheAnswerMan
13 Comments
 
LVL 5

Expert Comment

by:AndrewDev
ID: 6169478
This Text Box Enhancement might do a little of what you want
http://www.freevbcode.com/ShowCode.Asp?ID=2732

Regards
Andrew
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 6169648
It sounds like what you want is property ScrollBar = 1 '- Horizontal'
0
 
LVL 27

Expert Comment

by:Ark
ID: 6169693
Private Type RECT
   Left As Long
   Top As Long
   Right As Long
   Bottom As Long
End Type
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 Const EM_SETRECT = &HB3
Private Const EM_GETRECT = &HB2

Private Sub Form_Load()
  Dim rc As RECT
  SendMessage Text1.hWnd, EM_GETRECT, 0, rc
  rc.Right = rc.Right * 2 ' or more if you want, up to screen size
  SendMessage Text1.hWnd, EM_SETRECT, 0, rc
  Text1 = "Any long string you want"
End Sub

Cheers
0
 
LVL 5

Accepted Solution

by:
gwgaw earned 50 total points
ID: 6170021
Ark has the right approach.

However you will have to set rc.left and rc.top to 0 and
rc.bottom to rc.bottom + 6.

This is because Windows will automatically set the left and
top to 1 more than you specify for the carret width and
height, which is usually 1 pixel wide and 2 pixels more
than the height of the text. Then Windows will recaculate
the bottom for the same reason.

Debug.print rc's values in the form load event after
getting rc and put a
"SendMessage Text1.hWnd, EM_GETRECT,  0, rc" in the
textbox change event and debug.print rc's values and
you'll see what i mean.
0
 
LVL 3

Author Comment

by:TheAnswerMan
ID: 6177533
--adding the scrollbar does not stop the wrapping of the text.
0
 
LVL 3

Author Comment

by:TheAnswerMan
ID: 6177616
OK.  This great.. it works.. I have to set the control width like this first..

Text1.Width = Me.ScaleWidth - Text1.Left - 120

''otherwise the control never resizes..


What is it that that  
"SendMessage Text1.hWnd, EM_SETRECT, 0, rc"

does?

Is there some internal rectangle in the textbox.. and  the text is actually drawn in that.?  and this sets it to be a wider number??
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 3

Author Comment

by:TheAnswerMan
ID: 6177617
OK.  This great.. it works.. I have to set the control width like this first..

Text1.Width = Me.ScaleWidth - Text1.Left - 120

''otherwise the control never resizes..


What is it that that  
"SendMessage Text1.hWnd, EM_SETRECT, 0, rc"

does?

Is there some internal rectangle in the textbox.. and  the text is actually drawn in that.?  and this sets it to be a wider number??
0
 
LVL 3

Author Comment

by:TheAnswerMan
ID: 6177727
OK.  This great.. it works.. I have to set the control width like this first..

Text1.Width = Me.ScaleWidth - Text1.Left - 120

''otherwise the control never resizes..


What is it that that  
"SendMessage Text1.hWnd, EM_SETRECT, 0, rc"

does?

Is there some internal rectangle in the textbox.. and  the text is actually drawn in that.?  and this sets it to be a wider number??
0
 
LVL 3

Author Comment

by:TheAnswerMan
ID: 6177748
Hmmm actually. I went back and add Both scroll bars..

and it got the desired effect.

<I had originally added Vertical bar.. not desired effect>

So this is the simplest..

but i like the concept of the Inner Rect modification..
so i dont have to have the scrollbar if I dont want it.

so will go with that as the answer.  Can I go 50-50 on the credit??
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 6178106
If the inner box is what you liked, award the points there.  If you like both, you can go to the Customer Support section and post a zero-point question asking that the points be split between two experts...just reference the question ID (http://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20132248) and the two experts who should receive the points.
0
 
LVL 3

Author Comment

by:TheAnswerMan
ID: 6181783
ahh effit.

i'll just give credit to both.

i'll post another questrion just for rspahitz
0
 
LVL 3

Author Comment

by:TheAnswerMan
ID: 6181791
ahh effit.

i'll just give credit to both.

i'll post another questrion just for rspahitz
0
 
LVL 3

Author Comment

by:TheAnswerMan
ID: 6182015
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now