Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem cancelling form in init
Message
From
07/12/2001 08:48:11
Mark Hall
Independent Developer & Voip Specialist
Keston, Kent, United Kingdom
 
 
To
07/12/2001 08:29:48
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00591072
Message ID:
00591090
Views:
25
This message has been marked as a message which has helped to the initial question of the thread.
>I have run into a problem that I have never encountered before. Typically, if I want to cancel the instantiation of a form for whatever reason (based on conditions), I check for a condition in the form's init method, then if it fails, clear events (if it is a single form app) and return .f.. However, for some reason in my current small single form app, when I cancel events and return .f., the form closes, but I am returned to the vfp screen with no form. If I turn on the debugger, I am sitting at the read events command just below where I called my form, even if I issued a clear events before the return .f. in the form. Any ideas? I must have overlooked something here somehow.
>
>Code in main.prg calling form:
>
>*--Run Main Form
>DO FORM Rebuildall WITH llautorun, llforcedbf, llforceindex, llresult, llpolcall
>READ EVENTS
>IF llresult
> *--Return to calling program ok
> RETURN .T.
>ELSE
> *--Return to calling program with an error
> RETURN .F.
>ENDIF
>
>*--Code in form's init method
>*--Create the archive directory
>IF !DIRECTORY(thisform.bakdir)
> MKDIR (thisform.bakdir)
>ENDIF
>*--Verify its creation
>IF !DIRECTORY(thisform.bakdir)
> CLEAR EVENTS
> llresult=.f.
> RETURN llresult
>ENDIF
>
>
>Thanks for your help!
>Tracy


Hi Tracy,

I think the problem here is that the CLEAR EVENTS is actually being run before the READ EVENTS. Which means that it does nothing.

If your Form is Modal, then that is definetly the case, as execution of your main program will be suspended while your form runs.

As you do have single form app, then you could forget the READ EVENTS/CLEAR EVENTS altogether. Just DO FORM and the app will quit whenever you RELEASE your form.

Cetins suggestion will also do the trick.

Regards,
Mark
Regards
Mark

Microsoft VFP MCP
Menulib - OO Menus for VFP www.hidb.com/menulib
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform