Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Repeated control refresh problem

Status
Not open for further replies.

aharrisreid

Programmer
Nov 17, 2000
312
GB

I am having a problem with form objects (especially a particular combobox) that repeatedly 'flash' when a form is being instantiated for the first time. Upon setting a breakpoint on the first line of the combo.refresh method I find it runs 4 times before the form 'settles'!

At the 1st break the call stack is...
Myform.Combo.refresh, BaseClassForm.refresh, MyForm.refresh

At the 2nd break the call stack is...
MyForm.Combo.refresh, MyForm.refresh

At the 3rd break the call stack is...
MyForm.combo.refresh

MyForm.refresh contains the code...
DODEFAULT() && calls baseclassform.refresh
other form-specific code

BaseClassForm.refresh contains the code...
DODEFAULT()
other generic form refresh code

MyForm.combo.refresh contains the code
DODEFAULT() && calls generic combo refresh code
other instance-specific refresh code

It appears as though the combo is refreshing at every level of a refresh call. How can I avoid this, yet still still make sure the generic default code runs at form and object level.

Any help would be appreciated.

Alan Harris-Reid

 
Alan,

Because you talk about the generic refresh code, I'm guessing that BaseClassForm is your form base class, directly sub-classed from the VFP base class?

If so, then you don't need to DODEFAULT() in the Refresh method because the VFP default behaviour happens even if you have code in a method.

DODEFAULT() is needed when you have added code to a method in a your base class and, when you sub-class it or use it on a form, you want something to happend in addition to the behaviour you coded into the base class.

So I think you should be able to remove some of the DODEFAULT() commands, which hopefully will stop some of the multiple refreshes.

If you have a FoxTalk subscription, there was an excellent article back in 1999 about DODEFAULT(). You can find it at
Another possibility is to use the form property LockScreen. Setting this to .T. freezes the form while the refresh(es)happen. Set it back to .F. after the refresh sequence has ended and the form appears correctly arranged. As you probably know, VFP is quite slow at repainting forms which may account for the flashing.

I hope some of that helps.

Stewart
 
StewartUk, thanks for the reply.

>I'm guessing that BaseClassForm is your form base class, > directly sub-classed from the VFP base class?

Not quite,
MyForm is based on MyMaintenanceFormClass
MyMaintenanceFormClass is subclassed from MyBaseFormClass
MyBaseFormClass is subclassed from the VFP native form class.

Each of the above levels has refresh code that must run in addition to refresh code in the parentclass, hence every refresh must include DODEFAULT(), except MyBaseFormClass, which calls the VFP native form.refresh automatically.

I placed a SUSPEND in MyForm.combo.refresh and it fired 3 times before the form 'settled'.


>So I think you should be able to remove some of the DODEFAULT() commands...<
For the reason mentioned above, I can't! Removing any DODEFAULT() at any level fails to run the refresh code of the parentclass.

What I need is some way of running the parentclass.refresh code without causing the from to refresh yet one more time for that level. I've tried NODEFAULT at the end of the refresh method at each level, but that makes no difference.

Any other ideas would be appreciated.

Regards,
Alan
 
Hi Alan,

Did you try Stewart's LockScreen suggestion? Set it .T. in the form's init and .F. at the end of the refresh sequence.

Regards,

Mike
 
mspratt, thanks for the reply.

>Did you try Stewart's LockScreen suggestion? Set it .T. in the form's init and .F. at the end of the refresh sequence.<

I did, and it works, but there is still a noticable display delay (although less than before) due to all the form and control refresh methods firing more than they should. I figured it was best to try and sort-out what was causing the problem before applying the 'bandage' which masked the problem.

I think I have cracked the problem by introducing NODEFAULT to the end of the refresh methods of the form and all parent form classes except the baseformclass, which by default automatically fires the native VFP form.refresh.

Regards,
Alan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top