| When developing complicated components and windows setting the redraw can
become a problem. You run into problems when a higher level function calls a lower level
function and both needed to alter the redraw of the object. The lower level function is
not always called by a higher level function and so needs to alter the redraw property.
For example the higher level function switched off the redrawing of the window and
performs some processing without any problems. It then calls a lower level function which
also switches off the redraw. After the lower level function is complete it sets redraw
back to true and returns to the higher level function. The higher level functions
continues processing expecting the redraw to be switched off but it is not because the
lower level function has re-enabled it. To fix this problem you can add a weight to the
setredraw function. This software trick remembers how many times a function is called and
only unsets the real setting when an equal number of unsettings have been called.
Declare a protected instance variable:Integer ii_redraw. Then overload the
SetRedraw function where ab_setting is the single input argument of type Boolean:
IF ab_Setting THEN
ii_redraw --
IF ii_redraw <= 0 THEN
ii_redraw = 0
super::SetRedraw( TRUE )
RETURN 1
END IF
RETURN 0
ELSE
ii_redraw ++
IF ii_redraw = 1 THEN &
super::SetRedraw( FALSE )
END IF
RETURN 1
|