Start Edit - GRID SENDMSG() Function 31

Syntax

TF$=SENDMSG(sysgui,id,31,mode,edit_params${,context{,ERR=lineref}})

Description

For BBj-specific information, see Start Edit - GRID SENDMSG() Function 31 BBj.

This function starts editing mode in the specified cell.

Parameter

Description

sysgui

SYSGUI channel.

id

Grid control ID.

31

Number of this SENDMSG() function.

mode

Always zero (prior to Rev. 2.22). Input mode (Visual PRO/5 Rev. 2.22 and 3.01 and later only)

0 Use INPUTN mode if the mask (or default mask, as set by Set Edit Mask - SENDMSG() Function 79 if the mask is not specified) contains the pound (#) character. Otherwise, use INPUTE mode.

1 Always use INPUTE mode.

2 Always use INPUTN mode.

edit_params$

Templated string with parameters that control how the function operates.

The structure of edit_params$ is flexible.

Note that when a grid control is in edit cell mode, keystrokes such as arrow keys, function keys, and Enter are not processed by the grid. If the application is to respond to these keys, they must be trapped. This is accomplished by checking for the EDITKEY Notify event (Notify code 6).

The complete string may be defined with this template:

mask:c(1*=0),restore:c(1*=0),initstr:c(1*=0),key:u(2),col:u(2),row:u(4)

(In Visual PRO/5 Rev. 2.22 and 3.01 and later only, the following is the complete template:)

mask:c(1*=0),restore:c(1*=0),initstr:c(1*=0),key:u(2),col:u(2),row:u(4),irules:c(1)

Either of these three shorter templates may also be used:

initstr:c(1*=0),key:u(2),col:u(2),row:u(4)
mask:c(1*=0),restore:c(1*=0),key:u(2),col:u(2),row:u(4)
mask:c(1*=0),restore:c(1*=0),initstr:c(1*=0),key:u(2),col:u(2),row:u:(4)

Each of the fields is described below:

Templated String Field

Description

MASK

Null-terminated mask string to use for editing. Valid mask characters are the same as those used by the INPUTE control. This mask overrides any masks specified by Set Edit Mask - GRID SENDMSG() Function 79 or Set Up Grid - ENDMSG() Function 30.

RESTORE$

Null-terminated restore string that can be used to restore the field during editing when the user presses Esc or Ctrl+R. If no string is specified, the initial value in the cell is the restore value.

INITSTR$

Null-terminated string with the initial value to be placed into the cell when entering edit mode. If an initial string is specified for a cell in a data-aware grid, the initial string specified in the function appears in the cell instead of the data in the record.

KEY

Integer that specifies the key code. This parameter is useful if editing mode was started in response to a KEYBOARD Notify event (Notify code 12). Entering the key value sent in the KEYBOARD message will cause it to be added to the edit control. To avoid sending a key value to the edit control, use 0 for this parameter.

COLUMN

Number of column in which to begin editing. Note that column numbering is zero-based.

ROW

Number of row in which to begin editing.

IRULES

INPUTN input rules flags, as described in the 'INPUTN' mnemonic section. (Visual PRO/5 Rev. 2.22 and 3.01 and later only)

Using a template that does not contain the irules field causes the flags to be obtained from the "!IRULES" STBL global variable. If the global variable is not defined, zero is used as a default. This parameter is ignored if INPUTE editing is selected.

Note that row numbering is zero-based. The return value is a one-byte string that indicates the success or failure of an operation; $01$ indicates success; $00$ indicates failure.

Example

This example shows the use of SENDMSG() Function 31 in response to a mouse left button click (Notify event 14). When the mouse click is detected, the program enters edit mode. When edit mode is ended by clicking on another cell, the edited data is stored in an array.

sysgui=unt
open (sysgui)"X0"
dim event$:tmpl(sysgui); event=len(event$)
dim generic$:noticetpl(0,0)
dim edit_param$:"initstr:c(1*=0),key:u(2),col:u(2),row:u(4)"
dim grid$:tmpl(sysgui,ind=1)
dim grid_data$[2,2]
print (sysgui)'window'(50,50,200,150,"Grid Sample",$00010003$,$$)
print (sysgui)'grid'(100,20,20,160,120,$9040$,3,3,3)
result$=sendmsg(sysgui,100,68,150/4,$$); rem row height
result$=sendmsg(sysgui,100,57,0,$$); rem turn off color change highlighting
dim grid$:tmpl(sysgui,ind=1)
grid$=sendmsg(sysgui,100,20,0,$$)
rem grid.style=1
counter=0
for col=0 to 2
result$=sendmsg(sysgui,100,36,col,chr(45)); rem column width
for row=0 to 2
grid.col=col,grid.row=row
grid.buf$=str(counter)
tf$=sendmsg(sysgui,100,54,0,grid$)
grid_data$[col,row]=str(counter)
counter=counter+1
next row
next col
repeat
read record(sysgui,len=event)event$
print event.code$,event.id,event.flags,event.x,event.y
if event.code$="N" then
: generic$=notice(sysgui,event.x);
: dim notice$:noticetpl(generic.objtype,event.flags);
: notice$=generic$
rem Query the cell after exiting edit mode
if event.code$="N" and notice.code=7 then
: grid_data$[notice.col,notice.row]=sendmsg(sysgui,100,34,0,$$)
rem Enter edit mode after a click of the left mouse button
if event.code$="N" and notice.code=14 and notice.lparam=1 then
: edit_param.row=notice.row,edit_param.col=notice.col;
: tf$=sendmsg(sysgui,100,31,0,edit_param$)
rem Redraw a cell in response to Notify event 23
if event.code$="N" and notice.code=23 then
: grid.col=notice.col,grid.row=notice.row;
: grid.buf$=grid_data$[notice.col,notice.row];
: tf$=sendmsg(sysgui,100,54,0,grid$)
rem Redraw range of cells in response to Notify event 22
if event.code$="N" and notice.code=22 then
: for row=notice.toprow to notice.botrow;
: grid.row=row;
: for col=notice.leftcol to notice.rightcol;
: grid.col=col;
: grid.buf$=grid_data$[col,row];
: result$=sendmsg(sysgui,100,54,0,grid$);
: next col;
: next row
until event.code$="X"
release

See Also

Interface CommonGrid::startEdit