Richard,
Here's a recommendation for your question regarding Grids and the WriteBuffer method. The hurdle you need to overcome involves determining the true active control when a grid has focus. By default, VFP returns the name of the grid as the ActiveControl.
To determine the TRUE active control, add a new method to CBaseForm called TrueActiveControl. Place the following code in this new method:
*********************************************
LOCAL loControl
IF TYPE("_SCREEN.ActiveForm.ActiveControl") = "O"
*--- Store an object reference to the
*--- real ActiveControl loControl
loControl = _Screen.ActiveForm.ActiveControl
IF UPPER(ALLTRIM(loControl.BaseClass)) = "GRID"
*--- Object reference to the control
*--- in the grid column:
LOCAL lcJunk
lcJunk = "loControl.Columns(loControl.ActiveColumn)." + ;
loControl.Columns(loControl.ActiveColumn).CurrentControl
loControl = &lcJunk
ENDIF
ELSE
*--- Store a dummy object reference to loControl
loControl = CREATEOBJECT("custom")
loControl = .NULL.
ENDIF
RETURN loControl
**********************************
Next, change CBizObjForm.WriteBuffer() to the following code to make use of the new TrueActiveControl method:
==================================
LOCAL llRetval, loActiveControl
llRetVal = .T.
loActiveControl = ThisForm.TrueActiveControl()
IF NOT EMPTY(ALIAS()) AND ;
CURSORGETPROP('Buffering') != 1 AND GETFLDSTATE(0) % 2 = 1 ;
AND TYPE("loActiveControl") == "O"
IF TYPE("loActiveControl.ControlSource") <> "U" AND ;
!EMPTY(loActiveControl.ControlSource)
IF EVAL(loActiveControl.ControlSource) <> loActiveControl.Value
REPLACE (loActiveControl.ControlSource) WITH loActiveControl.Value
*-- We rely on the fact that we revert the field's value
*-- before this next line of code.
llRetVal = (TRIM(EVAL(loActiveControl.ControlSource));
= TRIM(loActiveControl.Value))
ENDIF
ENDIF
ENDIF
RETURN llRetVal
======================================================
Let me know how this works for you.
Regards,
Kevin McNeish
Oak Leaf Enterprises Solution Design, Inc.
www.oakleafsd.com
Kevin McNeish
Eight-Time .NET MVP
VFP and iOS Author, Speaker & Trainer
Oak Leaf Enterprises, Inc.
Chief Architect, MM Framework
http://www.oakleafsd.com