参考示例,不知能否满足要求。
DECLARE LONG PostMessage IN User32 LONG, LONG, LONG, LONG
CREATE CURSOR tt (f1 C(4), f2 I)
FOR i = 1 TO 100
INSERT INTO tt VALUES (PADL(i, 4, "0"), i)
ENDFOR
GO TOP
of = CREATEOBJECT("form1")
of.show(1)
DEFINE CLASS form1 as Form
ADD OBJECT grid1 as _grid
ENDDEFINE
DEFINE CLASS _grid as grid
Visible = .T.
PROCEDURE init
BINDEVENT(thisform.hWnd, 0x401, this, "_BlankRows")
ENDPROC
PROCEDURE Scrolled(nDirection)
IF INLIST(nDirection, 1,3)
PostMessage(thisform.hWnd, 0x401, 0, 0)
ENDIF
ENDPROC
PROCEDURE MouseWheel(nDirection, nShift, nXCoord, nYCoord)
IF nDirection < 0
PostMessage(thisform.hWnd, 0x401, 0, 0)
ENDIF
ENDPROC
PROCEDURE AfterRowColChange(nColIndex)
IF this.RowColChange != 2
PostMessage(thisform.hWnd, 0x401, 0, 0)
ENDIF
ENDPROC
FUNCTION _SetCell(nRow, nCol, nRecno)
IF nRow <= nRecno
GO nRecno
this.SetFocus
this.ActivateCell(nRow, nCol)
DO WHILE RECNO() != nRecno
this.DoScroll(IIF(RECNO() < nRecno, 1, 0))
this.SetFocus
this.ActivateCell(nRow, nCol)
ENDDO
ENDIF
ENDFUNC
FUNCTION _BlankRows(hWnd, Msg, wParam, lParam)
LOCAL nRow, nCol, nX, nY, nWhere, nRelRow, nRelCol, nRecno
nCol = this.ActiveColumn
* 示例假设最底行第一格内的座标(nX, nY)(按实际情况确定或通过算计取得)
nX = 25
nY = this.top + this.height - 25
STORE 0 TO nWhere, nRelRow, nRelCol
this.GridHitTest(nX, nY, @nWhere, @nRelRow, @nRelCol)
IF nWhere==0 AND RECCOUNT()>=nRelRow
&& 空白行
thisform.LockScreen = .T.
this._SetCell(1, nCol, RECCOUNT()-nRelRow+1)
this.ActivateCell(nRelRow, nCol)
thisform.LockScreen = .F.
ENDIF
ENDPROC
ENDDEFINE