Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Application Framework DoForm
Message
From
22/09/2005 12:43:05
 
 
To
22/09/2005 08:50:14
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 7
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01051754
Message ID:
01052043
Views:
11
You can either modify the doform method to accept an additional parameter and modify your doform() call to send values for the other parameters as well or create a 2nd method such as doformp() and copy and paste the code from doform into and modify it and call it instead. I gave an example below of modifying the doform method to accept a parameter to pass to the form. However, in your case, since you want to pass a parameter, if the form already is open you don't want to show it like the code does below but rather close it and reopen it passing the parameter so you should create a new method like doformp() to call instead and modify it meet your needs.

Such as:
*Example calling doform method
oApp.doform('myform',.f.,.f.,.f.,.f.,.f.,'my new value')


*oApp.doform() with modifications
LPARAMETERS tcFileName,tcClass,tlNoMultipleInstances,tlNoShow, tlGoMenu, tlNavToolbar, tcCharParam

ASSERT EMPTY(tcFileName) OR VARTYPE(tcFileName) = "C"
ASSERT EMPTY(tcClass) OR VARTYPE(tcClass) = "C"

LOCAL lcFileName,lcClass,lnCount, lcFormName,lnFormCount, loMediator, ;
      loForm, loFormMember, lNeedReActivateFormset, ;
      llFormSet,llEnabledFormFound
*&* VFP 5 framework cascade code also used: 
*&* LOCAL lnTop,lnLeft,loForm2,lcName

THIS.ClearLastError()

lcFileName=ALLTRIM(tcFileName)

lcClass=IIF(VARTYPE(tcClass)="C",LOWER(ALLTRIM(tcClass)),"")

IF EMPTY(lcClass)
   lcFileName = THIS.GetResourceFileName(lcFileName,".scx")
ELSE
   lcFileName = THIS.GetResourceFileName(lcFileName,".vcx")
ENDIF   

IF EMPTY(lcFileName)
   RETURN .F.
ENDIF   

lcFormName=IIF(EMPTY(lcClass),lcFileName,lcFileName+","+lcClass)
IF tlNoMultipleInstances
   FOR lnCount = 1 TO THIS.nFormCount
      IF THIS.aFormNames[lnCount]==lcFormName AND ;
         VARTYPE(THIS.aForms[lnCount])="O" 
         IF UPPER(THIS.aForms[lnCount].BaseClass)== "FORM" AND ;
            THIS.aForms[lnCount].WindowState = 1 && minimized
            THIS.aForms[lnCount].WindowState = 0
         ENDIF
         IF VARTYPE(THIS.oFrame) = "O"
            THIS.oFrame.Show()
         ENDIF
         THIS.aForms[lnCount].Show
         RETURN .F.
      ENDIF
   ENDFOR
ENDIF

* this is a hook, nothing in it
IF NOT THIS.BeforeDoForm(tcFileName,tcClass,tlNoMultipleInstances,tlNoShow, tlGoMenu, tlNavToolbar)
   RETURN .F
ENDIF

THIS.RefreshFormsCollection
THIS.nFormCount=THIS.nFormCount+1
DIMENSION THIS.aForms[THIS.nFormCount],THIS.aFormNames[THIS.nFormCount]
THIS.aFormNames[THIS.nFormCount]=lcFormName

IF VARTYPE(THIS.oFrame) = "O"
   THIS.oFrame.Show()
ENDIF

IF NOT EMPTY(lcClass)
   THIS.aForms[THIS.nFormCount] = ;
        THIS.Instantiate(lcClass, lcFileName)
ELSE
   IF !EMPTY(tcCharParam)
      DO FORM (lcFileName) NAME THIS.aForms[THIS.nFormCount] LINKED NOSHOW WITH tcCharParam
   ELSE
      DO FORM (lcFileName) NAME THIS.aForms[THIS.nFormCount] LINKED NOSHOW
   ENDIF
ENDIF

lnFormCount=THIS.nFormCount
THIS.RefreshFormsCollection

IF THIS.nFormCount>=lnFormCount
   * success so far, 
   * let's enable and position the new object(s)
   * and then show it/them if we're supposed to:

   loForm = THIS.aForms[THIS.nFormCount] 
   llFormSet = (UPPER(loForm.BaseClass) == "FORMSET")      

   IF llFormSet

      FOR EACH loFormMember IN loForm.Forms 
         IF UPPER(loFormMember.BaseClass) == "FORM" 
            * skip toolbars         
            loMediator = THIS.GetFormMediatorRef(loFormMember)
            * don't force until we know about all forms
            * in set; see note below
            IF VARTYPE(loMediator) = "O"
               loMediator.LoadApp(THIS.cReference)
               loMediator.lGoMenu = tlGoMenu
               loMediator.lNavToolbar = tlNavToolbar
               llEnabledFormFound = .T.
            ENDIF

         ENDIF
      ENDFOR         

   ELSE

      loMediator = THIS.GetFormMediatorRef(THIS.aForms[THIS.nFormCount], ;
                                           THIS.lEnableFormsAtRunTime)
      * second param will force creation
      * if lEnableFormsAtRuntime is on
      IF VARTYPE(loMediator) = "O"
         loMediator.LoadApp(THIS.cReference)
         loMediator.lGoMenu = tlGoMenu
         loMediator.lNavToolbar = tlNavToolbar
      ENDIF
   ENDIF

   * if any forms in the formset are enabled,
   * some may have been left un-enabled by
   * intent, so that they don't get icon or whatever.
   * So if even one form in the formset is enabled
   * we won't dynamically enable the rest.   That's
   * why the below FOR/ENDFOR has to be done separately
   * from the above attempt to load mediators in a formset:

   IF llFormSet AND ;
      (NOT llEnabledFormFound) AND ;
      THIS.lEnableFormsAtRunTime

      THIS.ClearLastError()

      FOR EACH loFormMember IN loForm.Forms 
         IF UPPER(loFormMember.BaseClass) == "FORM"
            loMediator = THIS.CreateFormMediator(loFormMember)
            IF VARTYPE(loMediator) = "O"
               loMediator.LoadApp(THIS.cReference)
               loMediator.lGoMenu = tlGoMenu
               loMediator.lNavToolbar = tlNavToolbar
            ENDIF
         ENDIF
      ENDFOR         

   ENDIF

   IF NOT tlNoShow
      IF VARTYPE(THIS.oFrame) # "O"
         IF llFormSet
            * there is something screwy about
            * formsets when some forms may be showwindow 0
            * and others 1, even in _SCREEN, so it's
            * best to show each form separately:
            FOR EACH loFormMember IN loForm.Forms
              loFormMember.Show()
            ENDFOR
         ELSE
            loForm.Show()
         ENDIF
      ELSE
         * seems as though if even one form in
         * the formset is ShowWindow = 0,
         * then all forms must be brought into the top form
         IF llFormSet
            FOR EACH loFormMember IN loForm.Forms
               IF loFormMember.ShowWindow = 0
                 lNeedReActivateFormset = .T.
                 EXIT
               ENDIF
            ENDFOR
            FOR EACH loFormMember IN loForm.Forms
               IF lNeedReActivateFormset
                  THIS.ActivateFormInFrame(loFormMember)
               ELSE
                  loFormMember.Show()         
               ENDIF
            ENDFOR
         ELSE
            IF loForm.ShowWindow = 0
               THIS.ActivateFormInFrame(loForm)
            ELSE
               loForm.Show()
            ENDIF
         ENDIF
      ENDIF
   ENDIF

   IF THIS.lCascadeForms AND NOT llFormSet
      THIS.CascadeAll(loForm.Name)
      *&* this is where VFP framework used THIS.nPixelOffset,
      *&* all that code removed but the property might still
      *&* be useful somewhere
   ENDIF      

ENDIF

RETURN (THIS.IsErrorFree())
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform