Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
WhatsThisHelp
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Titre:
Divers
Thread ID:
00477098
Message ID:
00477143
Vues:
32
>I've created a sample form for "WhatsThisHelp". It works "In Screen" (Form.ShowWindow = 0) but not "As Top-Level Form" (Form.ShowWindow = 1). Any tips, tricks or workarounds to this problem or is it simply not possible?
>

First, if you really want it to be a Top-Level Form, ShowWindow should be set to 2. ShowWindow = 1 is "In Top-Level Form".

Second, all modal Forms want to belong to _SCREEN; you can emulate modal behavior by adding code something like this to your Form's LostFocus() method:
*  the control oFirstControl is a control on the form
thisform.oFirstControl.SetFocus()
NODEFAULT
I have code in my base control classes so that the controls update a pair of Form properties tracking Form object refs as they receive focus; I use these properties to determine the control that last received control within the Form:
*  In the GotFocus of each base class
IF TYPE('thisform.oLastGotFocus') = 'U'
   thisform.AddProperty('oLastGotFocus', NULL)
ENDIF
IF TYPE('thisform.oPriorGotFocus') = 'U'
   thisform.AddProperty('oPriorGotFocus', NULL)
ENDIF
thisform.oPriorGotFocus = thisform.oLastGotFocus
thisform.oLastGotFocus = this

* In the Release of the base Form class;  need to release the object refs
* so that the Controls can be fully released without leaving any dangling
* object refs to prevent Form deinstantiation
IF TYPE('thisform.oPriorGotFocus') # 'U'
   thisform.oPriorGotFocus = NULL
ENDIF
IF TYPE('thisform.oLastGotFocus') # 'U'
   thisform.oLastGotFocus = NULL
ENDIF
You can expand on these relatively easily, and change the LostFocus code in the pseudo-modal form to return control to the previous control by:
NODEFAULT
WITH thisform
   IF TYPE('.oLastGotFocus') = 'O' AND ! ISNULL(.oLastGotFocus)
      LOCAL oGotFocusRef
      oGotFocusRef = .oLastGotFocus     && Save Last ref to var and move
      .oLastGotFocus = .oPriorGotFocus  && Prior to Last to preserve the
      oGotFocusRef.SetFocus()           && Prior when Last GotFocus() fired
   ELSE
      *  No Last Control available so use first enabled and visible
      LOCAL nCtrlCnt
      FOR nCtrlCnt = 1 TO .ControlCount 
         IF .controls(nCtrlCnt).Enabled AND .controls(nCtrlCnt).Visible
            .controls(nCtrlCnt).SetFocus()
         ENDIF
      ENDFOR
      .Show()  && I can't figure out what to do, so just Show the Form
   ENDIF
ENDWITH
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform