Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Obtaining the name of the top level form
Message
 
 
À
27/04/2000 15:21:10
James Marshall
SPAWAR Systems Center Charleston NCR
Washington, District de Colombia, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00364196
Message ID:
00364247
Vues:
18
James,

>Sergey et al,
>
>Tried it. Your suggestion worked fine. I'm still a step or two away from reaching the "Aha !!! zone", but I'm close..
>I'm running a frmTest within my TLform. The TL is named frmMain. In frmMain.Init, I put your ADDPROPERTY() code. I start the exe, running at a screen resolution of 1280x1024. In frmTest, I place the following:
>
>
>*my old, hard-coded way:
>messagebox("frmMain.Width is: " + STRfrmMain.Width))                                              &&  = 610
>
>*as Roi points out, they're there, hidden, but not what I want...:
>messagebox("_VFP.Width is: " + STR(_VFP.Width))                                                   &&  = 1016
>messagebox("_SCREEN.Width is: " + STR(_SCREEN.Width))                                     &&  = 1016
>
>*this works:
>messagebox("_SCREEN.oTLFName.Width is: " + STR(_SCREEN.oTLFName.Width))    &&  = 610

This works because you added property oTLFName to
_SCREEN object and assigned top level form object reference to it.

>
>*but this doesn't:
>messagebox("_SCREEN.frmMain.Width is: " + str(_SCREEN.frmMain.Width))               &&  = Unknown member

This doesn't work because _SCREEN object doesn't have property named frmMain.


>
>
>So, in summary,
>1. There is no VFP function (like PROGRAM(1)) to determine the TLF.
>2. I could build my own 'stack' with an array, but unless I'm using it for something else as well, there's not much point.
>3. I could call the form as DO form topform name oApp.topform linked, but I would still need to name all my apps TL forms the same.
>4. Using ADDPROPERTY() to the TL form is probably the way to go, I'll just have to add it to every new project's TLF.
>
>5. Possible AHA!, Since I'll probably have to create a formTL_dr class, to manage dynamic resize events anyway, I could probably add the additional property to the class? Hmmm.... Thanks again, everyone!
>
>
>>Hi James,
>>
>>_SCREEN should always be there, (although its probably hidden), so Sergey's idea should work.
>>
>>_screen.width is giving the screens width NOT your forms, if you want the form use _SCREEN.OTlfName.width
>>
>>hth
>>>Sergey,
>>>
>>>Thanks for your prompt reply. I'll try this out. But I thought _SCREEN was only available to apps designed with SHOWWINDOW=0 ?
>>>Also, if _SCREEN.width returned the incorrect value, wouldn't _SCREEN.OTlfName.width give me the same?
>>>Give me a sec, and I'll try it.
>>>
>>>>James,
>>>>
>>>>What about adding following code to the init of top level form?
>>>>
>>>>_SCREEN.AddProperty("oTFLName", THISFORM)
>>>>
>>>>After that you can reference it as _SCREEN.oTflName
>>>>
>>>>>Hope someone can help me here. I know enough to be dangerous, as they say. Here's my question:
>>>>>
>>>>>I'm taking my first stab at a top level form application, rather than the "In Screen (Default)" type. I'm playing around with dynamically resizing (the file examples and the Jan 99 issue of FoxproAdvisor were very helpful, thanks). I'm trying to find the right command for determining the name of the top level form, from within the application. I tried using _SCREEN, _VFP, and APPLICATION, but no joy. So far, I'm able to get it by using the following code:
>>>>>
>>>>>
>>>>>FOR EACH oForm IN APPLICATION.FORMS
>>>>>  IF oForm.ShowWindow = 2
>>>>>    oTLFName=oForm
>>>>>    EXIT
>>>>>  ENDIF
>>>>>ENDFOR
>>>>>
>>>>>IF TYPE("oTLFName")="O"
>>>>>   * I can now refer to it's properties, i.e., oTLFName.Height
>>>>>ELSE
>>>>>   * ShowWindow property is set to either 0 or 1
>>>>>ENDIF
>>>>>
>>>>>
>>>>>Is there a cleaner method of accessing TLF properties? I know that I could simply hard code the name, but I would like to create a class from this, if feasible. Thanks in advance...
--sb--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform