Highlighted
Absent Member.
Absent Member.
777 views

[archive] Multiline Entry Fields

[Migrated content. Thread originally posted on 28 June 2005]

Does anyone know of a helpful ratio to use to vary the vertical size of a multiline entry field according to the number of lines to be allowed?
0 Likes
5 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] Multiline Entry Fields

I'm sorry, I'm not really sure what you are asking?

Do you want to dynamically size an entry-field based on how many lines need to be edited?

A multiline entry-field which is set to display a certain number of lines will scroll vertically depending on the text that is enterred and also the MAX-TEXT value of the field.

If the value of the field can be up to 1000 characters in size and your entry-field is only 2 lines high, then it displays a 'window' on the portion of the 1000 characters that you are currently editing.

At least, that's what it does in the character-based version. Are you using the GUI version?
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Multiline Entry Fields

Thanks for the reply. What we want to do is scale the vertical size of the field to the number of lines to display. 1 1/2 to one doesn't seem to cover it. I guess the answere is that there isn't a precise answer in GUI environment.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Multiline Entry Fields

If I understand what you're asking, this is all dependent on the font used in the entry field and the cell size used in the window. You should be able to use W$TEXTSIZE to determine the proper height of the entry field.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Multiline Entry Fields

Hmm, entry fields base their size(width) and line height based upon the entry field's font. So, wouldn't simply dividing the text data size(or MAX-TEXT) by the size(width) of the entry-field give you the lines you need? This should work as long as you assign a FONT propery to the entry-field first.
It's not exactly precise for proportional fonts where alot of upper-case characters are used, but that should be rare.

If this doesn't work out then perhaps you could create a common routine where you pass in:


    - window handle
    - font handle(if you can inquire entry-field for font handle then no need to pass, I can't remember)
    - entry-field handle
    - data item size(use Format 8 of the SET verb to get the data item size dynamically)


Then, as Rob recommended, use W$TEXTSIZE passing window handle and font handle to get font width in window cell units.
Next, calculate the entry-field lines:

entry-field lines = data item size / (entry-field size(in cell units) / TEXTSIZE-BASE-X)

Next, modify the entry-field handle with the entry-field lines.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Multiline Entry Fields

Yes, but how many lines are taken up by the actual data depend on the use of CAPITALS within the data and the average size of the words used.

I knocked up the attached test program which seems to do the trick in a character-based environment. Sorry, I haven't got time to try it in GUI at the moment, but the theory should still work.

It's a bit 'clunky', but basically it works like this:
1) Display the ENTRY-FIELD containing the data you want to display, with an initial number of LINES. (NOTE: You must specify the NO-AUTOSEL style)
2) Modify the CURSOR setting of the field to be equal to your MAX-TEXT setting
3) ACCEPT the field BEFORE TIME ZERO to make the runtime position the cursor at the end of your data
4) INQUIRE on the field to get the value of the CURSOR-ROW setting.
5) MODIFY the field's LINES setting to be the same as the CURSOR-ROW

Let me know if this works for you.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.