Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Basic Form Class Question - Name for Show/Hide
Message
From
23/08/1999 04:18:09
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00256436
Message ID:
00256476
Views:
33
>My steps
>
>1. Create a blank form to be base for 7 forms, white background, certain width/height/left/top dimentions.
>
>2. Choose save as class
>
>3. At command window 'create form as blahblah' to make a new form based on the class I created.
>
>4. Create all 7 forms, each with show window/hide window code in them.
>
>5. The show/hide window language does not work because all my forms seem to have the same name (looking in the "Window" menu, although I specified different things in the Name property of each form.
>
>? How do I get them to be uniquely named? What I want to do is load all the forms at startup and show/hide them as needed so there is no client delay.
>
>Help?

Steve,
Names that way wouldn't help you. Here is why. If you name a specific form as frmMyform, what its name would really be at runtime depends how you instantiate them. Suppose you only keep them as scx.
-If you "do form myscxname.scx" for 5 times all 5 forms would have the same name "frmMyForm" as you named them before. And only the first activated one is accesible by directly using its scxname (ie: myscxname.show).
-If you "oForm = createobject('SavedFormClassName')" for five times then forms would be named as frmMyForm1...frmMyForm5.
Latter seems to be more dependable but it's not a safe way to choose IMHO. Instead create a custom oApp object in your main program and use it to save instances of forms. Make it have a custom array to hold forms ie:aForms. Also have it a procedure to launch your forms. You would then be enable to refer to any form launched at anytime. Well code talks better, but be warned this is a very rough code just for demo :
* Main.prg
on key label "F12" clear events
oApp = createobject("myApplication")
WITH oApp
  .FormLauncher("myform","frm1")
  .FormLauncher("myform","frm2")
  .FormLauncher("myform","frm3")
  .FormLauncher("myform","frm4")
  *Cascade forms
  for ix = 1 to alen(.aForms,1)
  	.aForms[ix].left = (ix - 1) * 30
  	.aForms[ix].top = (ix - 1) * 30
  	.aForms[ix].caption = "Form no :"+padl(ix,1)
  endfor
  WAIT window "showing forms 1,3"
  .aForms[1].show
  .Aforms[3].show
  WAIT window "hiding form 3"
  .aForms[3].hide
  WAIT window "showing form 4"
  .aForms[4].show
  WAIT window "hiding 1, showing form 2"
  .Aforms[1].hide
  .Aforms[2].show
ENDWITH
read events

DEFINE class myApplication as custom
  DIMENSION aForms[1]
  PROCEDURE  FormLauncher
    LPARAMETERS tcSCXName, tcFormName
    IF type("oApp.aForms[1]") = "O" and !isnull(oApp.aForms[1])
      DIMENSION oApp.aForms[alen(oApp.aForms,1)+1] && Make room for new form
    ENDIF
    oApp.aForms[alen(oApp.aForms,1)] = tcFormName
    DO form (tcSCXName) ;
      name oApp.aForms[alen(oApp.aForms,1)] ;
      linked noshow && Launch form - do not show
  ENDPROC
ENDDEFINE
-On key label is not a good habit but was suitable for this quick demo.
-All forms were launched from the same scx "myform.scx" but you're not limited to it. It's there to show you what would happen even if all were based on same scx (check solution.app for multipl instance form).
-oApp.aForms collection is much safer then _screen.forms collection because :
unlike _screen.forms collection, oApp.Forms[ix] is always oApp.aForms[ix]. That's if ix = 1 you always get "frm1" in sample not the last form shown (_screen.forms(1) always refers the last shown and their ix changes in forms stack).

But last, to prevent client delay, it doesn't always seem to be a wise way to initialize and hide all. There might be other ways of preventing it. ie: For pageframe forms, a well known tip is to save each page as class and on page activate check its existence. If it doesn't exist addobject on activate. That means ie: if page3 is never activated, its content is never loaded. As an outcome it behaves like it was a non pageframe form loading quickly.
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
Reply
Map
View

Click here to load this message in the networking platform