Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Move code from Refresh method to CustomRefresh()
Message
From
08/09/2018 16:40:56
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
01661889
Message ID:
01661908
Views:
39
>>>Hi,
>>>
>>>I have a general question about the following situation. Just to see if anybody thinks it is a good or a bad practice. Or sees any gotchas with this approach.
>>>
>>>I have a textbox class that shows the value of the ID (unique field) from a lookup (parent) table, based on the PK value in the child table. The code that uses the Seek() the lookup (parent) table and sets the value of the ID (or unique field) is in the Refresh method of this textbox. This approach works. But ... The Refresh of the textbox fires quite often. Any time another window/form is open and then the focus is returned back to this form, the Refresh fires. I would like to reduce the calls to the Refresh field.
>>>
>>>So, my approach, is to create a custom refresh method (e.g. CustomRefresh), move the code from the Refresh to the CustomRefresh. Then call the textbox CustomRefresh from a method of a form, whenever a record moves. Therefore, the code in CustomRefresh will not be fired unnecessarily often but only when is necessary, when record pointer moves.
>>>
>>>Does the above seem like a reasonable approach?
>>
>>I wonder why the refresh happens so often, it looks like a problem that should be resolved on a higher level if possible. Refresh should only happen when you call loForm.Show(), and for the rest only if you call THISFORM.Refresh() on purpose, which should not be needed very often. Refresh is only necessary to call if the data that relates to the controlsource of an object has been changed and needs to be updated on these controls. There is no other purpose for refresh.
>>
>>Any other call to refresh is problematic. I once inherited a program that called THISFORM.Refresh in the forms Activate() method, a very bad practice, which made debugging any refresh related code impossible, because whenever you have the debugger active and then try to get back to the form, the activate would again call Refresh(). And that for no other purpose than to annoy the programmer.
>
>Doesn't form Refresh and Refresh of all controls on the form fire when the form goes into focus? And if the previous is true, then any time another form is closed and the focus goes back to the "initial" form, the Refresh fire. Is this correct?


According to my knowledge refresh is not fired when the form gets activated. It would be a disaster if that were true.
Christian Isberner
Software Consultant
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform