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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiline property of TextBox

Status
Not open for further replies.

RohanP

Programmer
Mar 6, 2002
50
IN
Is there a API which will set the VBTextBox's Multiline Property at run-time?? ______________________________
- Regards Rohan (India,Mumbai)
 
From MSDN:

By using the Microsoft Windows® application programming interface (API) SetScrollRange function, you can add code to your Visual Basic application that will allow you to create a work-around solution. This enables you to change the Text Box's appearance from single to multiline at run time.

The SetScrollRange function lets you set the minimum and maximum indicator positions of a scroll bar. To use this function, add the following Declare statement to the General Declarations section of your form (note that the Declare statement must be typed as a single line of code):

Private Declare Sub SetScrollRange Lib "User" (ByVal hWnd As Integer, ByVal nBar
As Integer, ByVal nMinPos As Integer, ByVal nMaxPos As Integer, ByVal
bRedraw As Integer)

 
How to use this sub???

I am getting Olverflow error on passing these values..

SetScrollRange (Text1.hWnd, 1, 1,10, 1)

Pls Help..

______________________________
- Regards Rohan (India,Mumbai)
 
Hmm...
Mistake in MSDN?!
should be: not ''USER'', but ''USER32''
Private Declare Sub SetScrollRange Lib "User32" (ByVal hWnd As Integer, ByVal nBar
As Integer, ByVal nMinPos As Integer, ByVal nMaxPos As Integer, ByVal
bRedraw As Integer)



 
I am trying to pass the TextBox's hWnd propety as the first parameter. The Value hWnd is returning is over 300000.

So I am getting the OverFlow Error. How should I do abt it? ______________________________
- Regards Rohan (India,Mumbai)
 
Not a mistake in MSDN as such, more a fact that MSDN has historical articles. The one quoted actually referes to VB3 and 16-bit windows. In summary, refernces to integer should be replaced with references to Longs
 
SetScrollRange Text1.hWnd, 1, 1, 10, 1

is what I tried, but this procedure is just setting the vertical Scroll Bar to the Text Box & not making it multiline. I want the TextBox changing from Singleline to Multiline at Run-Time. ______________________________
- Regards Rohan (India,Mumbai)
 
Yeh, realy this function create "create a work-around solution"
You will need to change style:
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
offset is: GWL_STYLE = (-16)
new style is: ES_MULTILINE (&H4&)
like SetWindowLong obj.hwnd, GWL_STYLE, new_style
 
Even this SetWindowLong is not helping..
it is not setting the text box to Multiline at run-time ______________________________
- Regards Rohan (India,Mumbai)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top