Reggie1977
Programmer
I have a VFP app from which I want to launch some other VFP apps. The problem is when a CLEAR EVENTS is issued from the external app it closes down the Main app. Has anyone any ideas how to resolve this?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
* Bracket the main "Read Event" with a "Do While" loop
PRIVATE pKeepAlive
pKeepAlive = .T.
* Simulate the "Main App"
LOCAL oMainApp
oMainApp = CREATEOBJECT("clsMainApp")
oMainApp.SHOW()
* Re-Issue "Read Events" until . . .
DO WHILE pKeepAlive
READ EVENTS
ENDDO
* The "Main App"
DEFINE CLASS clsMainApp AS FORM
DOCREATE = .T.
AUTOCENTER = .T.
CAPTION = '"Taming an external application which issues a "Clear events"'
CONTROLBOX = .F.
HEIGHT = 110
WIDTH = 390
* Initiates running the "External App"
ADD OBJECT cmdRunExternalApp AS COMMANDBUTTON WITH ;
AUTOSIZE = .T., ;
CAPTION = "Run External Application", ;
LEFT = 10, ;
TOP = 10
* Exits the "Main App"
ADD OBJECT cmdExit AS COMMANDBUTTON WITH ;
AUTOSIZE = .T., ;
CAPTION = "Exit Main Application", ;
LEFT = 10, ;
TOP = 50
* Display control to verify a "Read Event" is active
ADD OBJECT txtVerifyReadEvent AS TEXTBOX WITH ;
ALIGNMENT = 2, ;
FONTSIZE = 12, ;
LEFT = 2, ;
HEIGHT = 30, ;
TOP = THIS.HEIGHT - 26, ;
WIDTH = THIS.WIDTH - 4
* Timer to verify a "Read Events" is active *
ADD OBJECT oTimer AS clsTimer
* Form Method to run the external app
PROCEDURE RunExternalApp
DO ExternalApp
READ EVENTS
ENDPROC
* Deconstructor
PROCEDURE DESTROY
CLEAR EVENTS
pKeepAlive = .F. && External dependency
ENDPROC
* Button click to initiate running of the "External App"
PROCEDURE cmdRunExternalApp.CLICK
THISFORM.RunExternalApp()
ENDPROC
* Button click to initiate exiting of the "Main App"
PROCEDURE cmdExit.CLICK
THISFORM.RELEASE()
ENDPROC
ENDDEFINE
* Timer to verify a "Read Events" is active
DEFINE CLASS clsTimer AS TIMER
ENABLED = .T.
INTERVAL = 560
bFlip = .F.
PROCEDURE TIMER
THIS.bFlip = !THIS.bFlip
IF THIS.bFlip
THISFORM.txtVerifyReadEvent.VALUE = '"Read Event" firing!'
ELSE
THISFORM.txtVerifyReadEvent.VALUE = ""
ENDIF
ENDPROC
ENDDEFINE
* The "External App" which issues a "Clear Events"
PROCEDURE ExternalApp
MESSAGEBOX("External application running!",0,"Ba-Boom!")
CLEAR EVENTS
ENDPROC