Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running VFP apps from within VFP App

Status
Not open for further replies.

Reggie1977

Programmer
Nov 10, 2003
7
IE
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?
 
Do you have the source code of the external app? If so, the easiest solution would be to remove the CLEAR EVENTS, and in its place put a call to whatever clean-up code the external app has available, and then issue RETURN.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
I've never had to do this, but you maybe can glean something useful from the attached code snippet.

Especially in the situation where you don't have access to the external applications source code.

Darrell

Code:
* 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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top