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!

how to stop textbox from scrolling 1

Status
Not open for further replies.

BlackDice

Programmer
Mar 1, 2004
257
0
0
US
Does anyone know of a way to stop a textbox from scrolling if the user places the mouse in the textbox and drags the cursor? I have a textbox with a maxlength of 2 that displays "AM" or "PM". Even though the user can't put anything else in the textbox, it allows them to scroll the 'am' or 'pm' out of visibility. Thanks in advance

bdiamond
 
I put in my posting that I have that property set to '2' already, but it doesn't work. thanks anyway

bdiamond
 
I'm not sure if this would meet your needs but you could put

Return .F.

in the When event of the textbox.

Jim
 
It probably has to do with the font being a proportional font. If you change the width of the textbox to be wider, say 100, it will not scroll, but it won't look so good either. Changing the font to a Fixed spaced font (such as Courier new) should work without having to change the width, but don't know if that is an acceptable solution for you.

Mark
 
I just tried to do a 'return .f.' in the 'When' event, but that stops all input. thanks, though!!

bdiamond
 
Mark826, I gave you a star because that worked!! thanks!!

bdiamond
 
Mark826,

I'm curious why this seems to work. You said it was "probably" the reason as though you were drawing on something about the way that these fonts will affect VFP's behavior in this situation. Anything else you can add to this? I mean what was it that made you think of this solution?

boyd.gif

[sub]craig1442@mchsi.com[/sub][sup]
"Whom computers would destroy, they must first drive mad." - Anon​
[/sup]
 
Don't know what made me think of that solution. If you take a look at the maximum character width for these fonts it might give a better idea of what I think VFP is doing for this scrolling.

FONTMETRIC(7, "Arial",10) && Returns 35
FONTMETRIC(7, "Courier New",10) && Returns 9

A little test I just did was to create a form with a textbox in it, set the maxlength to 1, and changed the width around until no characters would scroll left. The widths of the textboxes where they stop scrolling are:
Change the maxlength to 1, Arial was 46, Courier 20
Change the maxlength to 2, Arial was 81, Courier 29
Change the maxlength to 3, Arial was 116, Courier 38

Both fonts increment by their maximum character width to where they stop scrolling. VFP probably calculates this # to make sure that if the width of the textbox will not handle the largest possible text, it needs to turn on the scrolling for that textbox?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top