Solved

Text box scrolling.

Posted on 2001-06-08
13
276 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 28

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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

735 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