TEdit
Source: source/classes/edit.prg
Inherits from: TControl
TEdit wraps the standard Windows EDIT control, supporting both single-line and multi-line text editing. It features picture clause formatting, password mode, read-only mode, cue banners, character limits, and alignment options (left, right, center). TEdit is especially useful for multi-line text wherever TGet is too constrained.
Key DATA Members
| DATA | Type | Description |
|---|---|---|
bSetGet | Block | Code block to get/set the bound variable |
lReadOnly | Logical | When true, the edit text cannot be modified |
lPassword | Logical | Password mode (displays bullets instead of characters) |
lMultiLine | Logical | Multi-line edit mode with scrollbars |
nLimitChars | Numeric | Maximum number of characters allowed |
cPicture | Character | Picture clause for formatted display (e.g. "999.99") |
cCueText | Character | Watermark/cue banner text shown when empty |
bHScroll | Block | Code block evaluated on horizontal scroll events |
Methods
| Method | Description |
|---|---|
New( nRow, nCol, bSetGet, oWnd, nW, nH, lPixel, oFont, cPict, bChanged, bUpdate, bHScroll, lMultiLine, lReadOnly, lPassword, lRight, lCenter, lNumber, lUpper, lUpdate, bWhen, bValid, lLimitText, nLimitChars, cCueText ) | Create a new EDIT control |
ReDefine( nId, oWnd, bSetGet, ... ) | Redefine from a dialog resource |
SetSel( nStart, nEnd ) | Select a range of text characters |
SelectAll() | Select all text in the control |
SetLimitText( n ) | Set the maximum text length (EM_LIMITTEXT) |
SetCueBanner( lOnFocus, cText ) | Set the cue banner (watermark) text |
VarPut( uVal ) | Set the bound variable to a new value |
cText( uVal ) | Get or set the edit window text |
Value() | Return the current value from bSetGet |
Read() | Read text from the control into bSetGet |
Example: Multi-Line Edit Box
#include "FiveWin.ch"
function Main()
local oWnd, oEdit, cText := MemoRead( "notes.txt" )
DEFINE WINDOW oWnd TITLE "TEdit Demo" SIZE 600, 400
@ 10, 10 EDIT oEdit VAR cText ;
OF oWnd ;
SIZE 560, 340 ;
MULTILINE
ACTIVATE WINDOW oWnd CENTERED
return nil
Notes
- Use the
MULTILINEclause to create a multi-line edit box with vertical and horizontal scrollbars. TheES_WANTRETURNstyle is automatically applied in multi-line mode. - Password mode disables multi-line automatically. The
ES_PASSWORDstyle masks the input. - The
cPictureclause applies a picture mask. If the picture contains!, the uppercase style (ES_UPPERCASE) is added. - Cue banner text (watermark) appears inside the edit control when it is empty and does not have focus.