The default text limit of an entry field is 32 characters. An application can set a non-default size when creating an entry field by setting the cchEditLimit member of an ENTRYFDATA structure and supplying a pointer to the structure as the pCtlData parameter to WinCreateWindow.
The following code fragment creates an entry field with a text limit of 12 characters:
HWND hwndEntryField2;
HWND hwndClient;
ENTRYFDATA efd;
LONG xPos = 50,
yPos = 50;
LONG xWidth = -1,
yHeight = -1; /* Must be -1 for ES_AUTOSIZE */
/* Initialize the ENTRYFDATA structure */
efd.cb = sizeof(ENTRYFDATA);
efd.cchEditLimit = 12;
efd.ichMinSel = 0;
efd.ichMaxSel = 0;
/* Create the entry field */
hwndEntryField2 = WinCreateWindow(
hwndClient, /* Parent-window handle */
WC_ENTRYFIELD, /* Window class */
"projects.xls", /* No initial text */
WS_VISIBLE | /* Visible when created */
ES_MARGIN | /* Create a border */
ES_AUTOSCROLL | /* Scroll text */
ES_AUTOSIZE, /* System sets the size */
xPos, yPos, /* x and y positions */
xWidth, yHeight, /* Width and height */
hwndClient, /* Owner-window handle */
HWND_TOP, /* Z-order position */
0, /* Window identifier */
&efd, /* Control data */
NULL); /* No pres. parameters */
To expand or reduce the text limit after creating the entry field, an application can send an EM_SETTEXTLIMIT message specifying a new maximum text limit for the entry field. The following code fragment increases to 20 characters the text limit of the entry field created in the previous example:
WinSendMsg(hwndEntryField2, EM_SETTEXTLIMIT, (MPARAM)20, (MPARAM)0);