Textbox Scrollbar Help

Lumus
05-26-2002, 08:07 PM
Is it possible to change the colour of a textbox's scrollbars? Is it also possible to make the scrollbars appear and dissappear when the text is longer than the box? Finally, how do I get a centre of a textbox to follow the mouse? (Eg. So a user can redesign the interface if they want to by clicking and dragging)

John
05-26-2002, 08:21 PM
Subclassing might help but The Hand would know better
To change the properties of the scroll bars you need to re-create the window using CreateWindowEx
hmm...


HTH,
Orbity

Agent
05-26-2002, 08:27 PM
Originally posted by Lumus
(Eg. So a user can redesign the interface if they want to by clicking and dragging)

I think your talking about resizing the form, and then
the textbox resizes?
Option Explicit

' You can change the numbers and if you like
' and in this example I used the textbox name
' 'Text1'. You change that to whatever your
' box is called.

Private Sub Form_Resize()

With Me

' Move/set the textbox's left, top, width, and height...
Text1.Move .Left + 10, .Top + 10, .ScaleWidth - 10, .ScaleHeight - 10

End With

End Sub

John
05-26-2002, 08:54 PM
I thought he meant letting the user move the text box around on the form. :-\

If this is right then:
I worked up this little example to show how you could do it with the arrow keys. I would suggest using something like GetAsyncKeyState to check for control instead of shift like this app does, because using shift will interfere with the normal operation of the text box.

This is just to get you started.

HTH,
Orbity

John
05-27-2002, 04:26 PM
Here is how to do it with the mouse:
Option Explicit

Private Sub Text1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 And Shift = 1 Then
Text1.Move Text1.Left + X - (Text1.Width / 2), Text1.Top + Y - (Text1.Height / 2)
Form1.Refresh
End If
End Sub

Just paste this into a blank project with 1 text box named Text1 and then press and hold shift while holding down the right mouse button and move the mouse around.

HTH,
Orbity

Lumus
05-28-2002, 01:08 AM
Thanks heaps. Can this be applied to any object that has a MouseMove property?

Banjo
05-28-2002, 03:22 AM
Yes, you need the MouseMove event.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum