Article ID: | qOOP013 |
Date Revised: | July 22, 1997 |
Keywords: | pageframe, page, refresh, UIEnable, OOP |
Question: Why don't my pages show the current record?
Answer: When VFP does a form Refresh() only the topmost page of a pageframe refreshes to improve performance. To have each page refresh when it becomes the active page you can create an object that will handle it for you automatically:
**************************************************
*-- Class: pagerefresher (h:\vfp5app\ccontrol.vcx)
*-- ParentClass: cobject (h:\vfp5app\ccontrol.vcx)
*-- BaseClass: line
*-- This class is added to eage page of a cPageFrame object
* by the cPageFrame class. It's sole function is to refresh the
* page when it activates.
*
DEFINE CLASS pagerefresher AS cobject
Height = 1
Visible = .F.
Width = 1
Name = "pagerefresher"
PROCEDURE UIEnable
LPARAMETERS lEnable
if ( lEnable )
* cause the page to refresh
local llLockScreen
llLockScreen = thisform.LockScreen
thisform.LockScreen = .t.
this.parent.Refresh()
thisform.LockScreen = llLockScreen
endif
ENDPROC
ENDDEFINE
*
*-- EndDefine: pagerefresher
**************************************************
**************************************************
*-- Class: cobject (h:\vfp5app\ccontrol.vcx)
*-- ParentClass: line
*-- BaseClass: line
*-- This is an abstract lightweight class for the derivation of
* other general purpose classes.
*
DEFINE CLASS cobject AS line
Visible = .F.
Width = 17
Name = "cobject"
PROCEDURE Error
LPARAMETERS nError, cMethod, nLine
ObjError( this, nError, cMethod, nLine )
ENDPROC
*-- Placeholder Method for documentation
PROCEDURE documentation
ENDPROC
ENDDEFINE
*
*-- EndDefine: cobject
**************************************************
Assuming that you've created your own PageFrame subclass you can put this in its Init() method:
PROCEDURE Init
local i
set classlib to (this.ClassLibrary) additive
for i = 1 to this.PageCount
* add an object that is responsible for refreshing the page when each page activates
this.Pages[i].AddObject( "PageRefresher", "PageRefresher" )
endfor
ENDPROC