Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Where it proceeds
Message
From
05/11/2005 15:52:36
Mike Yearwood
Toronto, Ontario, Canada
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01065687
Message ID:
01065764
Views:
23
>am I executing a form, from the menu and from another form how I can know, in the moment in that I execute it of where it proceeds?

Call this routine from the called form's load event and give it the name property of the called form. If it gives comes up empty, the form was called from the menu or command window. If it is not empty, that should be the name of the other form.

HTH
CalledByForm.PRG
LPARAMETERS m.tcCalledFormName
IF VARTYPE(m.tcCalledFormName)#"C"
  ERROR 11
ENDIF

LOCAL m.loActiveForm
IF TYPE("_SCREEN.ACTIVEFORM")="U"
  *Called from the command window.
  RETURN ""
ENDIF
m.loActiveForm = _SCREEN.ActiveForm
IF VARTYPE(m.loActiveForm)#"O"
  *Called from the menu.
  RETURN ""
ENDIF

LOCAL ARRAY laStack[1]
ASTACKINFO(laStack)
LOCAL m.llSuccess, m.lnX, m.lcActiveFormName, m.lcCallingFormName
m.llSuccess = .F.
m.lcActiveFormName = UPPER(ALLTRIM(m.loActiveForm.Name))
m.lcCallingFormName = ""
m.tcCalledFormName = UPPER(m.tcCalledFormName)
*Run backwards through the stack.
*Locate the passed form's name.
*Once that's found, locate the name
*of the form before that. If
*the last active form is the form
*before the passed form name, that
*is the calling form.
FOR m.lnX = ALEN(laStack,1) TO 1 STEP -1
  IF UPPER(laStack[m.lnX,3]) = m.tcCalledFormName+"."
    m.llSuccess = .T.
    EXIT
  ENDIF
ENDFOR

IF NOT m.llSuccess
  RETURN m.lcCallingFormName
ENDIF

LOCAL m.lnY
FOR m.lnY = m.lnX TO 1 STEP -1
  IF UPPER(laStack[m.lnY,3]) = m.lcActiveFormName+"."
    m.llSuccess = .T.
    EXIT
  ENDIF
ENDFOR m.lnY
IF m.llSuccess
  m.lcCallingFormName = m.lcActiveFormName
ENDIF
RETURN m.lcCallingFormName
Previous
Reply
Map
View

Click here to load this message in the networking platform