Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Opening and closing forms - Foxie is a bit too fast ...
Message
From
03/10/1997 15:42:14
 
 
To
03/10/1997 15:16:47
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
00053023
Message ID:
00053133
Views:
27
>>>>Hi Francois!
>>>>
>>>>You can save your form as class and use the following code:
>>>>
>>>>loForm=createobj([waitform])
>>>>loForm.Show()
>>>>=sqlexec(blah blah blah)
>>>>loForm.release()
>>>>
>>>>>In the first example
>>>>>
>>>>>do form MyPleaseWaitForm &&
>>>>>sqlexec(myconnection,"select * from ...)
>>>>>
>>>>>Fox does start the SQLEXEC command before completing FORM OPENING.
>>>>>The form is only completed once the SQLEXEC is finished ! not nice*
>>>
>>>
>>>Hi Vlad,
>>>
>>>I take your point. I tested it. But the problem still occurs if you use class instanciation rather than forms.
>>>
>>>From my experience what happens indeed when you do a FORM Show() :
>>>
>>> 1 - Fox shows the frame of the form (whether VCX or SCX)
>>> 2 - goes on with the rest of the fox code,
>>> 3 - in PARALLEL to step 2 goest its own way loading the controls.
>>>
>>>VFP uses that trick to improve form-rendering. You hardly notice it. When that code is pure VFP grammar, that generally works pretty fine.
>>>
>>>But in some situation line1 completion of code should be guaranteed before you step into line2.
>>>
>>>When that line2 is a blocking async SQLEXEC you need to resort to tricks if you want your UserPleaseWaitForm.show() to show before the async SQLEXEC is finished (not only the frame but all controls).
>>>
>>>I did insert =INKEY(1). I am really unsatisfied with the solution but sometimes turning fox around is the only way.
>>>
>>>If anyone ran into equivalent difficulties : fox being kind of too fast, i'd be glad to share experience!
>>>
>>>
>>>Regard
>>
>>I see two more solutions:
>>1. Run SQLExec from Form.Activate event.
>>2. Have MyPleaseWaitForm form available all time (hidden) and bring it up (very quickly) when it's necessary.
>
>Running from the .activate event would execute the code every time the form gains focus.
>The way I solvef this problem in the past was run the SQL from a timer set to go off .5 seconds after being set active. The code in the timer event turns itself off, so the code only runs once. (Edward helped me sort this out). Enable the timer from the init event.

Erik, you try to catch me. I always said that UT is dangerous place. To run code from Activate event just once, you could border it with some flag-property:
IF This.FirstActivateFlag=.T.
This.FirstActivateFlag=.F.
*** fire code here
ENDIF
BTW, I used this sometimes. You wouldn't believe me, but I had forms that passed through Init code without any reflections and I had to move it to Activate.
Edward Pikman
Independent Consultant
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform