Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Shutdown an application from a modal form
Message
De
25/03/2003 14:17:09
Charlie Schreiner
Myers and Stauffer Consulting
Topeka, Kansas, États-Unis
 
 
À
25/03/2003 13:26:31
Information générale
Forum:
Visual FoxPro
Catégorie:
CodeMine
Divers
Thread ID:
00769828
Message ID:
00769867
Vues:
26
This message has been marked as a message which has helped to the initial question of the thread.
Hi Steve,
Here's what I do. Obviously, your code will be different, but the point is--to use a timer to allow the modal form to run its course, then finish releasing the app.
PROCEDURE Release(Force)
oModalForm = This.GetModalForm()
IF NOT ISNULL(m.oModalForm)     && If there is a Modal form up, Close it.
   oModalForm.Close()           && Make sure each modal form has Close()
   This.ShutDownApp = .T.       && that can kill the form and not spawn another wait state.
ENDIF               
Force = This.ReleaseType = 1 OR m.Force
IF This.CallStackReleased OR VARTYPE(ThisApp) <> "O" && OR This.ReleaseType = 1
   IF m.FromQueryUnload
      RetVal = .T.   && This release method was called from the QueryUnload.
   ELSE              && Program has just called the THISFORM.Release().
      RetVal = THIS.QueryUnload(m.Force, .T.)	&& See if it's OK to leave.
   ENDIF
   * Release in reverse order, so the error handler is last.
   IF m.RetVal
      IF NOT ISNULL(This.oRules)
         This.oRules.Release()
      ENDIF
      FOR x = THIS.ControlCount TO 1 STEP -1
         This.RemoveObject(THIS.Controls[m.x].Name)
      ENDFOR
      ON SHUTDOWN
      RELEASE ThisApp
   ELSE
      This.CallStackReleased = .F.
      This.ShutDownApp = .F.
      NODEFAULT
   ENDIF
ELSE
      NODEFAULT   && Don't Clear the App now. Set a 
                  && timer and allow its Event to call
                  && the Release again.
      IF NOT VARTYPE(This.AppReleaseTimer) = "O" 
         This.NewObject("AppReleaseTimer", "GenericTimer", "Handler.VCX")
      ENDIF
      This.AppReleaseTimer.Do("ThisApp", ;
         "Release("+ TRANSFORM(m.Force) + ", " ;
                   + TRANSFORM(m.FromQueryUnload) + ", " ;
                   + TRANSFORM(m.FromOnShutDown) + ", " ;
                   + ".T.)", 100)
      This.CallStackReleased = .T.
ENDIF
RETURN m.RetVal
The application object is in fact a form, and the Generic Timer class simply does a specified command after a certain amount of time has passed.

>I would like to be able to shutdown my application from a modal form. I have tried various scenarios with no luck.
>
>m.goapp.shutdown() will not close the application as long as a modal form is open.
>
>I created a new method of appapplication that closes the forms before executing the shutdown(), well the forms close but the app doesnt shut down.
>
>I dont really understand why, but i seem to hit this same roadblock every way I turn.
>
>On the modal form I have a command button,
>mybutton.click:
>m.goapp.zShutdown
>
>(I also tried thisform.oapp. )
>
>where appapplication.zShutdown() is:
>IF this.ostatemanager.closeallforms()
> this.shutdown()
>endif
>
>This scenario does not shutdown the application. Oddly, this.shutdown() returns .t., just as if it did shutdown correctly. When I go to close after that, I get the dreaded "can not quit foxpro" error.
Charlie
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform