Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Deploying
Message
From
15/09/2004 07:45:40
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
14/09/2004 13:47:02
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Title:
Miscellaneous
Thread ID:
00941917
Message ID:
00942315
Views:
14
>Yes you read me like a book, I've taken all the read events out except in my Main.prg, but still not moving to next form:
>this is what the main.prg looks like
>DO FORM c:\dsm\master.scx
>READ events
>with a command button on the form that reads:
>clear events
>thisform.release
>
>As I click the first form I want to go into I have this:
>DO FORM c:\dsm\balances.scx
>and a command button that reads:
>DO FORM c:\dsm\master.scx
>thisform.Release
>CLEAR events
>
>Thanks for your patiences and help

As I understand master.scx is kind of menu form. Other forms are called from it (and let only one called form at a time on screen?). When called form closes master.scx would show up. Hope I understood it well and assuming one called form at a time only:

*Main.prg (have a main.prg as main entry point even if it'd contain a single line-in future you might want to add code lines)
do form master
read events

messagebox("Exiting application. Have a good day") && Just to show when this line executes
*Master.scx
* Buttons for other forms cmdFrm1, cmdFrm2 ... and one 'Exit' button that would end app
* A button calling another form - say cmdFrm1
*cmdFrm1.click
thisform.hide && If you don't want it to visible when called on screen
do form balances
thisform.show
*Master.scx - Unload 
* (having clear events in unload provides a more generic way for different types of closing) 
clear events
*Exit button - or you might not have this button at all (Window's own X button would do)
thisform.release
In this scenario called forms are modal (windowtype=1). No clear events code in them.

A simple one form at a time style application.

If however you wanted called forms as modeless than code would slightly change:
* A button calling another form - say cmdFrm1
*cmdFrm1.click
* Pass master's ref so called form controls hiding-showing
* Note: This is not the only way. Just an easy way.
do form balances with thisform && All forms would be called like this
We need to change things in called forms then.
A called form (add custom property oCaller to keep ref):
*Init
lparameters toCallerForm
this.oCaller = toCallerForm
this.oCaller.Hide && Hide master if you don't want it to be visible, switchable

*Unload
this.oCaller.Show && Show master back
Now since all buttons in master would call the forms with similar skeleton code you might take it a step further and create a custom LaunchForm method in master.
*Master.scx - LaunchForm (with modal type scenario)
lparameters tcFormNameToCall
this.Hide
do form (tcFormNameToCall)
this.show
And buttons' code callign forms change to:
*cmdFrm1 - button calling balance
thisform.LaunchForm('Balance')
In the same manner called forms would have similar codes (for modal ones nothing really) so it's a good idea to create a form class for called forms and have common properties (like oCaller)and code (like init and unload) in that. Actually as a principle you should start with your classes instead of baseclasses but for a small app it might not worth to take time for conversion (and forget I said this but you can change your form class later too).

And finally why do you call your forms like:

do form c:\dsm\master.scx

and not just:
do form master.scx

It might help you in IDE but in an EXE forms are already 'embedded' in executable and path has no meaning. To workaround this to be consistent both in IDE and exe you might create all of your projects with a common folder skeleton.ie:
ProjectsFolder
ProjectsFolder\CommonLibs && Classes,FLL etc lib files common to all projects
ProjectsFolder\CommonProgs && Prg common to all projects
...
ProjectsFolder\SomeProject
ProjectsFolder\SomeProject\Libs && App specisific lib files
ProjectsFolder\SomeProject\Data && App specisific data files
ProjectsFolder\SomeProject\Reports && App specisific report files
ProjectsFolder\SomeProject\Menus && App specisific menu files
ProjectsFolder\SomeProject\Progs && App specisific prg files
ProjectsFolder\SomeProject\Include && App specisific header files
ProjectsFolder\SomeProject\Forms && App specisific form files

Then a single set path (search path in tools\options) would make it possible to test it both in IDE and exe:
"libs;data;reports;menus;progs;include;forms;..\CommonLibs;..\CommonProgs"

Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform