Thursday, February 28, 2013
LockScreen Woes! - Beware!
Being a proponent of Clipper during my DOS xBase days, I massively use ScreenLock where it will lock the screen (do not show things as they happen) and where I can start creating boxes, labels, buttons (in the DOS style sense) and a whole lot of codes and suddenly when ScreenLock is released, pooop it suddenly appears as if it is like our form in VFP these days. That is very useful because if you don't lock the screen, you will see each line created slowly in front of your eyes (we have slower machines back then). That also speeds up drastically my exe back then.
So I was happy that when I jumped to VFP, they created a sort of the same thing, i.e., LockScreen property. So what does that Lockscreen do? VFP Help says these:
Determines whether a form batches all changes to property settings for its contained objects. Available at design time and run time.
True (.T.) - The form's contained objects reflect changes in property settings only when LockScreen is reset to false (.F.) rather than as soon as the changes are made.
False (.F.) - (Default) The form's contained objects reflect changes in property settings as soon as the changes are made.
Wow! Looks just like the same with ScreenLock. Darn, that is cool! I can make a lot of changes and show those changes only when it is released or value returned back to .F., i.e., Thisform.LockScreen = .F.
But is it really the same with VFP?
I had released ssUltimate 1 to subscribers and MK started immediately digging onto it (he is like my proofreader) and one thing he told me is when SwitchX or OptionSwitchX is clicked or spacebar pressed, that all my classes' titlebars seem to flicker. Immediately my mind goes to something that is doing something as well in the form from top to bottom and so there is only one thing on my mind that may be able to do that, i.e., LockScreen. I removed it and the flickering went away.
Why does that happen?
When you put a lock onto the screen and release it later, VFP will try to repaint the whole screen from top to bottom and all the visible objects of the current active form will be repainted as well. So does this results to a faster refresh? Unfortunately not!
Each of the objects in VFP has its own refresh property and it is faster to do that refresh on the specific objects you want changes to be reflected back. Than locking the screen and releasing it because what happens with that seemingly innocent property is it loops to all visible objects on the form and issues refresh one by one from top to bottom. And so the flickering on some cases especially when there is an image of PNG format.
While I can not entirely attribute bleeding effect of PNG format images to Lockscreen, it adds to that problem. PNG format, while cleaner and has a great transparency effect, is prone to flickering and bleeding when it gets repainted. And if you use Lockscreen, then whether you like it or not, your images will be among those that gets repainted when the lock is released.
Do you also experience trailing images? I mean your objects are drawn repeatedly as if being dragged down by mouse and previous images of itself are still seen on its previous locations? Then this might be also a side effect of lockscreen.
Is LockScreen therefore bad or does not result to a desired output?
In some cases, I believe Lockscreen remains useful especially if you are doing massive operations affecting a lot of objects in the form. We can lock the screen and refresh everything in one go. But if you will ask my advice, except with massive operations that will require repainting of majority of objects on the screen, then I would rather do a refresh on individual objects when needed than use LockScreen.