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

Scrolling in Text Boxes & Movement Keys

Status
Not open for further replies.

mauricebaker

Programmer
Jan 2, 2005
3
0
0
GB
I have been having a few problems with Visual Basic 6 which I am sure
are obvious to the seasoned user but have eluded me. I should be most
grateful if someone could could help.

1. When entering text into a Text Box, you would think that there would be be an Event when SCROLLING takes place. I cannot find such an event in the textbooks. If the MaxLength is set, then this does not ensure that the whole of the available space can be used because characters are of differing widths even for the same font. This problem applies to single line and multiple line Text Boxes. How on earth can you use all the available space in a text box WITHOUT AUTOMATIC SCROLLING taking place?

2. How can you stop Tab Keys and arrow keys from causing unwanted effects such as changing the Focus when Text is being entered into a Text Box? I have managed to prevent the Tab Key changing the Focus by disabling TabSet in all Controls, but this is hardly satisfactory!
 
The problem here is related to the original design philosophy of VB, which was to hide away all the 'nastiness' of the Windows OS.

As a result they hid away all the messages and notifications that the OS sends around behind VB events, methods and properties. And whilst doing so they decided on which messages and notifications the various VB controls would allow the user to interact with.

The point being that the VB textbox control is VB's implementation of one of Windows standard controls, the edit control. And the edit control does indeed have a scroll event (in the shape of EN_HSCROLL and EN_VSCROLL notifications), but VB doesn't choose to expose them to you. You'll have to hook the control to get the notifications (a search in this forum should find plenty of examples of hooking and subclassing)

> How can you stop Tab Keys and arrow keys from causing unwanted effects

This is standard (documented) behaviour of an edit control. Want to insert a Tab? Use CTRL-TAB.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top