Solved

Text box scrolling.

Posted on 2001-06-08
13
270 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
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…

785 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