Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.
These Database Events
fire when a view is modified in the View Designer.
PROCEDURE DBC_BeforeModifyView( cViewName )
PROCEDURE DBC_AfterModifyView( cViewName, lChanged )
Parameter |
Value |
Meaning |
cViewName |
Character |
The name of the view being modified. |
lChanged |
Logical |
Indicates whether the view was changed. |
Like other before-and-after pairs of events, you can prevent a view from being modified (the View Designer won’t appear) by returning .F. in the BeforeModifyView event, while the AfterModifyView event simply fires, notifying you that the view was modified and either changed or not.
As discussed in the “Database Events
” topic, there’s no way to tell what changes a user made, so if that’s important, you’ll have to save the current view structure in the BeforeModifyView event, or rely on metadata that saves that information somewhere, and then compare the saved information against the view structure in the AfterModifyView event.
* This goes in the stored procedures of a database.
PROCEDURE DBC_BeforeModifyView(cViewName)
WAIT WINDOW PROGRAM() + CHR(13) + ;
'cViewName: ' + cViewName
PROCEDURE DBC_AfterModifyView(cViewName, lChanged)
WAIT WINDOW PROGRAM() + CHR(13) + ;
'cViewName: ' + cViewName + CHR(13) + ;
'lChanged: ' + TRANSFORM(lChanged)
* End of stored procedures.
* Create a view, and then modify it.
OPEN DATABASE TestData
DBSETPROP(DBC(), 'Database', 'DBCEvents', .T.) && Turn on events
CREATE SQL VIEW TestView AS SELECT * FROM Customer
MODIFY VIEW TestView
BeforeCreateView, BeforeDropView, Create SQL View, Database Events, Modify View