Shiny Language Reference

Language Reference > User Interface > Memo Boxes


getmemoboxlinecount

int getmemoboxlinecount(int ID);

 

Returns the number of visual text lines in the memobox

The GETMEMOBOXLINECOUNT statement returns the number of visual lines in the memobox. Please read the following description carefully.

When using memoboxes on-screen they appear as multline edit controls. However the text data of a memobox control is actually stored as a single string, not as individual lines of text. This is necessary to allow dynamic formatting of the memobox. The size, shape, text bounding rect, font and other factors all affect the number of lines of text a memobox can display on screen at any one time. Each time Brass draws a memobox control it internally calculates how to chop up the text string into multiple lines so that it best fits the available display space. Because Brass allows non-fixed width fonts for the memobox control, a different number of characters may fit on each line. A row of 10 "W" characters takes up more pixel width than a row of 10 "I" characters.

The GETMEMOBOXLINECOUNT returns the number of lines Brass has calculated the current memobox contents must be chopped up into for them to fit correctly into the memobox. It does not return the number of visible lines of text - this can be calculated by dividing the height of the text bounding rectangle by the font height.

The line count calculation is performed by Brass internally when the text is drawn; using this function does not cause Brass to perform any lengthy calculations.

 

Parameters

ID

The control ID of the control you wish to retrieve the line count of

 

Return Value

The number of lines required to fit all of the memobox text into the memobox display

 

Example Code

// Create the memo box X: 10, Y:10 and sized 150*70
int iMemoBoxID = creatememobox(1, 10, 10, 150, 70);

// Set the memobox text to "Hello World"
setcaption(iMemoBoxID, "Hello World");

// Get the number of lines required to store the text
int iLines = getmemoboxlinecount(iMemoBoxID);