%re - Multiline Edit Box

Purpose

To create an multi-line edit box and display a character variable (i.e. a string).

Syntax

winio@('%N.Mre[options]', buffer)
winio@('%~N.Mre[options]', buffer, grey_ctrl)
character(*) buffer     (input/output)
integer grey_ctrl       (input)

Modifiers

Grave accent (`) - makes the control read-only (scroll bars are disabled).

Caret (^) - the call-back is called when a change is made.

Question mark (?) - a help string is supplied.

Tilde (~) - adds a variable that controls the grey (enable/disable) state.

Description

This control is similar to %rs (Edit String) but is multi-line. It has a buffer limit of 32K characters. Buffers larger than 32K may be used but will not automatically be updated when changes are made and require an explicit call to GetEditText@ (see below) in order to update the buffer..

N represents the width of the box in average characters. M represents the depth which should not be less than 2.

buffer is a character string for the text (maximum of 32*1024 characters). If buffer has zero length (e.g. winio@("%30.20re","")) then the control uses its own buffer. The content of this buffer can be retrieved by calling GetEditText@ (see below)

%re uses the standard Microsoft edit control which responds directly to the accelerator keys Ctrl+C, Ctrl+V, Ctrl+X and Ctrl+Z (for a single undo). It also has its own standard pop-up menu. Standard callbacks "EDIT_FILE_OPEN", "EDIT_FILE_SAVE", "EDIT_FILE_SAVE_AS" and "EDIT_UNDO" have been added analogous to the existing standard callbacks for %eb (Edit Box). These are in addition to the existing "CUT", "COPY" and "PASTE".

The following options are available:

UPPERCASE

Alphabetical characters (a . . z) are converted to upper case and displayed and stored as upper case.

LOWERCASE

Alphabetical characters (A . . Z) are converted to lower case and displayed and stored as lower case.

CENTRE_TEXT

Text is always centred on every line.

RIGHT_TEXT

Text is right justified on every line (the default is left justified text).

NO_HSCROLL

The text will not scroll to the right past the end of the window. The text will auto wrap.

NO_VSCROLL

The text will not scroll beyond the bottom of the window.

HSCROLLBAR

A horizontal scroll bar is added - do not use with NO_HSCROLL.

VSCROLLBAR

A vertical scroll bar is added - do not use with NO_VSCROLL.

KEEP_FOCUS

When the user tabs between windows, normally the focus will be lost, however with KEEP_FOCUS the selected text will remain selected.

NO_ADDITIONAL_DEPTH

Removes the standard spacing between this control and the next line.

The following functions may be used with this enhanced control. These functions take an INTEGER(7) value HWND, typically obtained via %lc (Handle of Last Control). If HWND is zero (0_7) then the control that has the current focus is used.

INTEGER FUNCTION GetEditText@(HWND, BUFFER, SIZE)
CHARACTER(*) BUFFER
INTEGER SIZE
Gets the contents of the control. Returns zero if the HWND is not valid or the buffer is not large enough. SIZE is the size of the buffer. Edit controls are limited to a maximum of 32K characters.

INTEGER FUNCTION OpenEditFile@(HWND, FILENAME)
CHARACTER(*) FILENAME
Opens and reads the text file into the control and associates the control with this FILENAME. Return zero if the HWND is not valid or the file cannot be opened and read. This function can be used in a callback associated with the "FILE_OPENR" standard callback and the %ft (Filter for File Dialog) format code for file "filters".

INTEGER FUNCTION EditFileSave@(HWND)
The function uses the file name associated with the control if it has one, otherwise it opens a standard "Open file" dialog and creates the file association. No action is taken if an association exists and the text has not changed. Returns zero if the HWND is not valid or the file cannot be saved. File "filters" can be provided via the %ft (Filter for File Dialog) format code.

INTEGER FUNCTION EditFileSaveAs@(HWND)
The function opens a standard "Open file" dialog to get a full path for a file and then saves it, creating a new file association for the control. Returns zero if the HWND is not valid or the file cannot be saved. File "filters" can be provided via the %ft (Filter for File Dialog) format code.

INTEGER FUNCTION EditFileClosePrompt@(HWND, CAPTION, MESSAGE)
CHARACTER(*) CAPTION,MESSAGE
Used when closing the control's window (e.g. within a %cc (Control Closure) callback). If the text has changed since the last "save" operation then a dialog is presented prompting for a save before closing. The possible responses are Yes, No and Cancel. CAPTION is the title for the prompting dialog and MESSAGE is its message. If %s is used within this MESSAGE string then %s is replaced by the short name of the associated file if there is one. The function returns zero for "No" and for "Yes" when the save is successful. This return value can be used directly as the return value of a %cc (Control Closure) callback.

INTEGER FUNCTION EditFileModified@(HWND)
Returns 1 if the text has been changed since the last save operation, otherwise it returns zero.

Notes

The %rs (Edit String) PASSWORD option is not available with %re. %re can take a pivot (%pv (Pivot)). %co can be used with %re (Multiline Edit Box).

See also

%rs (Edit String), %eb (Edit Box), %co (Options for Edit)


 

 

 

Basket
Empty
 
Copyright © 1999-2024 Silverfrost Limited