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

Autosize an EditBox

Status
Not open for further replies.

TheWizard78

Programmer
Jun 28, 2004
18
CA
Hello World!

I have a little problem. I want to use an EditBox with (Top=0, Left=0, Width=400, ControlSource=var_cString).
If my variable "var_cString" has more characters than you can see in the editbox, I would like to autosize the Height, to be able to see the entire text.

I have tried with MEMLINES() but I don't have a fixed length for SET MEMOWIDTH, so it returns an invalid number of lines.

Note: I don't want use FIXEDSYS or COURIER fonts.

Can anyone help me please?

Robert
 
Robert,
Obviously you've always got some limits - no matter how big you make it, it's possible that the memo data will exceed the control size, and you are limited to the form / monitor size. Why not simply give the user a command button to expand the editbox (or shrink the font size) when they can't see all they want to? When the data is too big, they'll still have to use the scroll bar to see it all.

Rick
 
Thank you Rick

It's just because I don't want the user to click on anything, there are no extra space in my form to add a new button and I want that everything to be shown and setup automatically. All the space is already use to show some information. And all the editbox are enabled=.f. and Scrollbars=None

Just to put you in the context, there are 4 editbox with left 0. When I resize progmatically the first one, the top of the second one = the height of the first one. So they are all autosize and the last one use all the extra space until it reached the bottom of the form. It's not to much information that is in my editbox, but it's just because I want to maximize the height of my last editbox, so the 3 first one must be shorter but always showing the entire string

Thanks

Robert
 
Hello Robert.

If you have a copy of "1001 Things You Wanted to Know About VFP" ( ), there is an expanding edit box class in chapter 4:

The expanding edit box (Example: CH04.VCX::edtBase)

One of the shortcomings of the Visual FoxPro base class edit box is that it may be too small to allow the user to see all the text in the memo field being displayed. We can solve this problem easily enough by adding a few properties to our base class edit box and a couple of methods to shrink and expand it.

At first glance one may be tempted to automatically expand the edit box when it gets focus and shrink it again when it loses focus. However, on reflection you will probably agree this would not make a good interface design and would, at the least, be disconcerting for the end user. Therefore we have opted to allow the user to expand and shrink the edit box by creating a shortcut menu called from the edit box RightClick method. This menu also gives the user the ability to change the font of the text displayed in the edit box. (Your end users will appreciate the ability to ease the strain on their eyes by enlarging the font, especially when the memo fields to be edited are lengthy.)


Marcia G. Akins
 
Robert,

I appreciate that you want the edit box to expand automatically, without the user having to do anything. I hope Marcia's solution will meet your requirements.

Personally, I'm not convinved that this is the best user interface. I prefer to use a fixed-size edit box, with a custom zoom method. When the user chooses to zoom, they see a modal resizable form that contains a new edit box (and nothing else), which in turn is bound to the same memo field as the original one. If they re-size (or even maximise) this form, the edit box gets resized with it.

If you are concerned about the space needed for a button to launch the zoom process, you could always use a right-click menu or a keypress.

This solution works very well in my apps, and my users are generally pleased with it.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Thank you very much to all of you.

But my concern is that I don't want to maximize the editbox to the entire screen, because there are some other editbox that need to be show. I would like to have a property like IntegralHeight to strech vertically my editbox until the end of the text and keep the width that I have fix at the beginning. So with that modification, I will be able to put all my editbox on the form

Robert
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top