by RiazKhan » Thu Aug 22, 2024 4:40 pm
Hi Antonio, Thank you for your prompt response as always...
Upon KeyPress [Enter] a function is called and each column is editable, HEditCol() is called to get input from user...
The function called to edit column is HEditCol()
Example of Input/editing of Column 3
xDesc is the Input Variable / Size of xDesc is Space(55)
nItem is the Row number
HEditCol(3,@xDesc,"@!",,0,16776960,,,{W_21EC(nItem,2),oBrowse,355,.F.,0,aAcc_Desc})
*---------------------------------------------------------------------------*
FUNCTION HEditCol( nCol, uVar, cPicture, bValid, nClrFore, nClrBack,aItems, bAction, aVarArry )
*---------------------------------------------------------------------------*
LOCAL oDlg, oGet, oFont, oBtn, oBtnAction
LOCAL nWidth,cVar,oBrw,iHelp,WHlp
LOCAL uTemp,aDim,lOk,cHType
LOCAL x,tRtn,DispDesc:=.F.,aDArray:={},aTmpArray:={}
cVar := aVarArry[1]
oBrw := aVarArry[2]
nWidth := aVarArry[3]
iHelp := aVarArry[4]
WHlp := aVarArry[5]
If Len(aVarArry) = 6
aTmpArray := aVarArry[6]
For x = 1 To Len(aTmpArray)
If Empty(aTmpArray[x])
aDel(aTmpArray[x])
Loop
Endif
If aScan(aDArray, aTmpArray[x]) = 0
aAdd(aDArray , aTmpArray[x])
Endif
Next x
DispDesc := If(Len(aDArray)#0,.T.,.F.)
Endif
uTemp := tRtn := uVar
aDim := aBrwPosRect( oBrw:hWnd, oBrw:nRowPos, oBrw:aColSizes, oBrw:nColPos, nCol,;
If( oBrw:oFont != nil, oBrw:oFont:hFont, 0 ) )
aDim[1]:= aDim[ 1 ] + 1
lOk := .f.
cHType := ValType( uVar )
IF oBrw:lCellStyle .And. nCol != oBrw:nColAct
oBrw:nColAct := nCol
If oBrw:oHScroll != nil
oBrw:oHScroll:SetPos(nCol)
Endif
oBrw:Refresh(.F.)
ENDIF
DEFINE DIALOG oDlg FROM aDim[ 1 ], aDim[ 2 ] TO aDim[ 3 ], aDim[ 4 ] ;
STYLE nOR( WS_VISIBLE, WS_POPUP ) PIXEL
IF oBrw:oFont != nil
oFont := TFont():New( oBrw:oFont:cFaceName, oBrw:oFont:nWidth,;
oBrw:oFont:nHeight, .F., oBrw:oFont:lBold )
Endif
@0,0 GET oGet VAR uVar ;
SIZE aDim[ 4 ] - aDim[ 2 ] - If( bAction != nil, 12, 0 ),;
aDim[ 3 ] - aDim[ 1 ] OF oDlg ;
FONT oFont COLOR nClrFore, nClrBack
oGet:oFont := oBrw:oFont
oGet:oGet:Picture := cPicture
oGet:bKeyDown := {|nKey| If(nKey=115,;
( uVar := If(DispDesc,(DispDesc(aDArray,tRtn)),cVar),;
oGet:Refresh(),oGet:SetFocus(.T.)), ;
If(iHelp,If(nKey=114,(uVar:=W_21A1(uVar,WHlp), ;
oGet:Refresh(),oGet:SetFocus() ),),);
)}
If bAction != NIL
@0,0 BUTTON oBtnAction PROMPT "" OF oDlg SIZE 12, 12
oBtnAction:bAction := {|| oGet:VarPut( Eval(bAction,uVar) ),;
oDlg:End(), lOk := .T. }
ENDIF
*
oGet:bValid := bValid
*
@10,0 BUTTON oBtn PROMPT "" ACTION (oDlg:End(), lOk:=.T. ) OF oDlg
oBtn:nStyle := nOr( WS_CHILD, WS_VISIBLE, BS_DEFPUSHBUTTON )
ACTIVATE DIALOG oDlg ;
ON INIT (DlgAdjust(oDlg,oGet,oBtnAction,aDim,cHType), ;
If(iHelp,GetBitMap(oGet,1,WHlp,nWidth,"16_F3"),))
IF !lOk
uVar := uTemp
ENDIF
RETURN lOk