The first step is to create a subclass of the PagePanel. Although we want to change some of the functionality, we still want the majority of the functionality to remain intact, so it makes sense to create a subclass. No need to re-invent the wheel.
CanChange
Change
Open
The other event CanChange is the key to this modification. Ensure that the CanChange event returns a boolean value.
We also need two new private variables. These are an integer variable, called OldPageValue and a boolean variable called DoNotConfirm.
Well, now for the hard bit. Well, not really, this class only requires two routines, both of which are located in the event handlers.
First of all, we need to initialise everything. As normal, we do this in the Open event handler and is accomplished with just three lines of code:
Now for a slightly trickier piece of code, but still fairly simple:
if not DoNotConfirm Then
If the DoNotConfirm variable is set to False then proceed with this. If the variable is set to True, then we need to ignore this entire routine.
if RaiseEvent CanChange then
OldPageID=Value
RaiseEvent Change
Now, we call the new event handler. If the return value is True, then we want to change the page. As the page has actually already changed, we just store the new value of the PagePanel and then call the new Change event.else
DoNotConfirm=True
Value=OldPageID
DoNotConfirm=False
If the CanChange event returned False, then we need to return to the previous page. However, we do not want this Change event processing again, so we set the DoNotConfirm variable to True before setting the Value of the PagePanel back to the OldPageID. We also need to reset the DoNotConfirm variable back to False once the Value has been set.
No comments:
Post a Comment