Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
App Object Framework Thoughts?
Message
De
14/03/2001 15:36:15
Charlie Schreiner
Myers and Stauffer Consulting
Topeka, Kansas, États-Unis
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Divers
Thread ID:
00484876
Message ID:
00485041
Vues:
10
Hi Steve, Larry,
I agree with Larry's message, but... I like using a form as the ThisApp object. (I think I stole the ThisApp moniker from Craig Berntson.)
There are several advantages to a form.
1. You can use the Fred Taylor Resize idea with no fuss.
2. You don't need form destroy messaging. What I mean is this: whenever a form comes up, there must be a message sent to refresh things like toolbars, menus, etc. so things look right with the form that has the focus. When a form is released, you don't need to do anything, because another form Activate()s, and the ThisApp.Refresh should adjust things to look right. But when the last form releases, what can we do to get the menus and toolbars refreshed? If the app is a big AlwaysOnBottom form, it gets focus, and it's Activate works just like any other form. (Well, almost) In ThisApp.Activate I ask the form handler if there is any other form to switch to, and if not, do the normal ThisApp.Refresh().
The FormHandler, MenuHandler, ToolbarHandler, ErrorHandler, AppTimer, etc. are simply dropped on the App object.
My Main prg looks like this:
_SCREEN.AddProperty("Development", NOT VERSION(2) = 0)	
* Or force it here.
* _SCREEN.Development = .T. && Normal for running from VFP Command Window.
* _SCREEN.Development = .F. && Normal for Runtime and testing as if in Runtime.
* For Testing....Development does NO ERROR method and NO READ EVENTS
* Run you App Form here. 
DO FORM MyApp
IF NOT _SCREEN.Development AND VARTYPE(m.ThisApp) = "O"
  * This puts the application in the call stack and allows us to put 
  * all the general Error handling code in the Error method of the ReadEvents
  * object that gets created in the ReadEvents method.
  ThisApp.ReadEvents()		
  RELEASE ThisApp  && This releases the variable and causes the destroy to run.
ENDIF
RETURN
* snipped from the App Form's Load.
IF VARTYPE(m.ThisApp) = "U"
   PUBLIC ThisApp
ENDIF
ThisApp = This	&& Public variable to access the Application object.
* You can do a PRIVATE ThisApp in the Main.PRG if desired.
The App object should not become a blob. The Form's only messaging to the App is to tell it to Refresh, and a return a few global properties.
ThisApp.GetProperties("RememberSomeFact", "SomeForm")
Here are a few methods that are hopefully self documenting. The application object may use other object to do it's work (composition), but you use a consistent interface to interact with it.
.Launch("MyForm") or .Launch("MyForm", "ClassLib")
.FormAction("Save") or .FormAction("MoveNext")
This makes menus and toolbars easier to construct.
That's my .02
Charlie
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform