Solved

Text box scrolling.

Posted on 2001-06-08
13
264 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

747 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

14 Experts available now in Live!

Get 1:1 Help Now