Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1]
  Reply  |  Print  
Author Topic: Is it possible to open a group from one form inside another form?  (Read 20238 times)
Bryce S.
Posts: 52


« on: February 28, 2008, 01:35:08 am »

Hi,

I've just started modifying old bds code to run with genero, adapting it to open much of its content within the main window/form of the program by hiding or unhiding of the form's groups  (the old code would pop a fresh window to show the various content when selected).

It looks really tidy using the form's groups in this way, but one of the functions is in a common module with it's own form.

Is it possible, when I call this modules functions, to open a particular group from that modules form and have it display in my currently open form (instead of having to use that modules 'open window' and have a new window overlay my current form)?

I guess in my .per file I want a group that is just a placeholder for the group from the module's form so it knows where to display, and to be able to tell it to open there instead of opening a new window (I don't want to clone the module's form into my existing form).

Hope this makes sense :)

Regards,
  Bryce Stenberg.
  Harness Racing New Zealand Inc.


Reuben B.
Four Js
Posts: 1119


« Reply #1 on: February 28, 2008, 05:34:38 am »

Hi,

I've just started modifying old bds code to run with genero, adapting it to open much of its content within the main window/form of the program by hiding or unhiding of the form's groups  (the old code would pop a fresh window to show the various content when selected).

It looks really tidy using the form's groups in this way, but one of the functions is in a common module with it's own form.

Is it possible, when I call this modules functions, to open a particular group from that modules form and have it display in my currently open form (instead of having to use that modules 'open window' and have a new window overlay my current form)?

I guess in my .per file I want a group that is just a placeholder for the group from the module's form so it knows where to display, and to be able to tell it to open there instead of opening a new window (I don't want to clone the module's form into my existing form).

Hope this makes sense :)

Regards,
  Bryce Stenberg.
  Harness Racing New Zealand Inc.






Bryce,

I was curious when you said you were hiding/showing groups to replace the content in the main window.  If you want to keep your .pers smaller and more maintainable you can use DISPLAY FORM to replace the current form in the current window with another form.


Code
  1. MAIN
  2. DEFINE current_form STRING  # keep track of current form
  3.   CLOSE WINDOW SCREEN
  4.  
  5.   # replace with any of your forms that you can tell the difference between
  6.   OPEN FORM aaa FROM  "example005_aaa"
  7.   OPEN FORM bbb FROM  "example005_bbb"
  8.  
  9.   # Doesn't matter what the blank form is, as it never gets displayed
  10.   # although if you make it the appropriate size and add a ui.Interface.Refresh()
  11.   # in the next line then that is the size of the window
  12.   OPEN WINDOW w WITH FORM "example005_blank"  
  13.  
  14.   # First form
  15.   DISPLAY FORM aaa
  16.   LET current_form = "aaa"
  17.  
  18.   WHILE TRUE
  19.      MENU ""
  20.         ON ACTION aaa
  21.            LET current_form = "aaa"
  22.            DISPLAY FORM aaa
  23.            EXIT MENU
  24.         ON ACTION bbb        
  25.            LET current_form = "bbb"
  26.            DISPLAY FORM bbb
  27.            EXIT MENU
  28.         ON ACTION common
  29.            CALL common()
  30.            # after calling common, have to reset form back to what it was
  31.            CASE current_form
  32.               WHEN "aaa" DISPLAY FORM aaa
  33.               WHEN "bbb" DISPLAY FORM bbb
  34.            END CASE
  35.         ON ACTION common_window
  36.            CALL common_window()            
  37.         ON ACTION close
  38.            EXIT WHILE
  39.      END MENU
  40.   END WHILE
  41. END MAIN
  42.  
  43.  
  44.  
  45. FUNCTION common()
  46.   # common routine displays its form
  47.   OPEN FORM common FROM "example005_common"
  48.   DISPLAY FORM common
  49.   MENU
  50.      ON ACTION continue
  51.         EXIT MENU
  52.      ON ACTION close
  53.         EXIT MENU
  54.   END MENU
  55.   CLOSE FORM common
  56.   # calling routine has to execute DISPLAY FORM to set the form
  57.   # back to what it was
  58. END FUNCTION
  59.  
  60.  
  61.  
  62. FUNCTION common_window()
  63.   # common routine displays its form
  64.   OPEN WINDOW common_window WITH FORM  "example005_common"
  65.   MENU
  66.      ON ACTION continue
  67.         EXIT MENU
  68.      ON ACTION close
  69.         EXIT MENU
  70.   END MENU
  71.   # and then sets its form back to what it was
  72.    CLOSE WINDOW common_window
  73. END FUNCTION



However I will add a disclaimer that the manual does at one point say "A program can load a Form file with the OPEN FORM instruction, then display the Form with DISPLAY FORM into the current window, and release resources with CLOSE FORM. However, it is recommended that you dedicate a window for each form. Programs typically create the window and load the form in a unique instruction: OPEN WINDOW WITH FORM."  I don't know why it says that.

You have also got the option of folder pages to get lots of content in one window rather than showing/hiding groups.

Could I also ask why you don't want to open a window for a common routine and then close it when the user has finished the common routine (as per common_window in the above code)

Reuben

Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
.
Four Js
Posts: 115


« Reply #2 on: February 28, 2008, 09:01:29 am »


However I will add a disclaimer that the manual does at one point say "A program can load a Form file with the OPEN FORM instruction, then display the Form with DISPLAY FORM into the current window, and release resources with CLOSE FORM. However, it is recommended that you dedicate a window for each form. Programs typically create the window and load the form in a unique instruction: OPEN WINDOW WITH FORM."  I don't know why it says that.


Actually, the main reason why we do not advice OPEN FORM DISPLAY FORM is the following:
when you do several OPEN FORM / DISPLAY FORM, the previous form is simply hidden. Therefore, on the front-end side, you have all the forms, but only the last one is visible.

And this could be heavy for GDC if your forms are pretty large - specially for Windows where USER/GDI Objects are limited by the system.

Using a new window for each form gives you a visual hint: I see there are multiple windows, I see that my application is pretty large.
If I use only one window with multiple forms, I may not understand why GDC is suffering while there is only one visible form.

Of course, we could change the current implementation (remove hidden forms instead of hiding them for instance), but for now this is not the case. This is why we have this point in the doc.
Sebastien F.
Four Js
Posts: 545


« Reply #3 on: February 28, 2008, 12:45:57 pm »

However I will add a disclaimer that the manual does at one point say "A program can load a Form file with the OPEN FORM instruction, then display the Form with DISPLAY FORM into the current window, and release resources with CLOSE FORM. However, it is recommended that you dedicate a window for each form. Programs typically create the window and load the form in a unique instruction: OPEN WINDOW WITH FORM."  I don't know why it says that.

Maybe this sentence is not clear...

You are free to use one or more OPEN FORM / DISPLAY FORM in the same Window, or dedicate a new window for each form with OPEN WINDOW WITH FORM.

Actually it depends if you are in the main window or in a temporary popup window.

Typically, you do OPEN WINDOW WITH FORM to show a new (resizable) popup window to let the user select in a list of records.
In this case the window must be dedicated to the form, and it's expected to have it appears at the top of the main (parent) window.

For main (SCREEN) window, you are free to use one unique form or display several forms in cascade with OPEN FORM / DISPLAY FORM.

Note also that in the past we suggested to close the SCREEN window at the beginning of the programs, but you can actually keep this default window and use OPEN FORM / DISPLAY FORM to show the main form.

Seb
Leo S.
Four Js
Posts: 129


« Reply #4 on: February 28, 2008, 12:49:14 pm »

One other reason why OPEN FORM/ DISPLAY FORM is hard to use for the moment is that unfortunately GDC doesn't adapt the window size if the 2nd form is much smaller than the previous one. This is especially annoying when trying to switch between a form containing a table and a form containing just labels and entries. But it's internally discussed to create a GDC window style which keeps track of the form size .
If the previous form is not used in an interaction(in the stack) it is *not* held at the GDC side, the VM destroys it.
In general , having a way to do a similar thing to OPEN FORM/DISPLAY FORM inside a GROUP or FOLDER (or another placeholder one could define in the .per) would make much sense to me because it would prevent putting everything inside a large folder tabbed form and hence allow a more modular approach also in the forms.  
Kind Regards, Leo













Rene S.
Four Js
Posts: 112


« Reply #5 on: February 28, 2008, 01:09:24 pm »

Hello,
just some technical background.
Multiple OPEN FORM ... DISPLAY FROM will not DISPLAY all forms.
What happens?

Each FORM has a internal flag, if it's currently used by a screen interaction statement (INPUT, MENU, DISPLAY ARRAY, CONSTRUCT).
If a form "b" is displayed over form "a" the runtime hides the form "a" if this form is attached by a dialog else it removes the form completely.

Next example: GDC will see only one form.

Code
  1. MAIN
  2.    DEFINE f1 INTEGER
  3.    DEFINE f2 INTEGER
  4.  
  5.    OPEN FORM form_a FROM "a"
  6.    DISPLAY FORM form_a
  7.    INPUT BY NAME f1;
  8.  
  9.    OPEN FORM form_b FROM "b"  -- the form_a is removed automatically
  10.    DISPLAY FORM form_b
  11.    INPUT BY NAME f2;
  12. END MAIN
  13.  

Next example: When stating the second INPUT, the first INPUT is still active: the runtime will hide form_a. When returning to the first INPUT, form_b will be removed and form_a shown.

Code
  1. MAIN
  2.    DEFINE f1 INTEGER
  3.    DEFINE f2 INTEGER
  4.  
  5.    OPEN FORM form_a FROM "a"
  6.    DISPLAY FORM form_a
  7.    INPUT BY NAME f1
  8.    ON KEY(f5)
  9.        OPEN FORM form_b FROM "b"
  10.        DISPLAY FORM form_b -- the form_a is still alive, but hidden
  11.        INPUT BY NAME f2;
  12.        -- new the parent INPUT gets active again
  13.        -- no need to display form_a again
  14.        -- the runtime will remove form_b and show form_a automatically
  15.    END INPUT
  16. END MAIN
  17.  

Display multiple FORMs in one WINDOW can be an interesting feature, to avoid too many inactive windows. Especially when migrating from TUI or BDL.

Rene
Bryce S.
Posts: 52


« Reply #6 on: February 28, 2008, 08:53:12 pm »

Thanks for all the suggestions.
I know about the tabbed forms but I would end up hiding or unhiding the tabs instead of groups and still be in the same boat when I call the other module with its own window. I don't want to change forms, as the current one is already loaded with info. I just want to change the groups happening at bottom.

Attached is some examples that may highlight what I'm meaning (using radio buttons in this form as choices change depending on person input, can remove or add appropriate radio options on the fly)...

Attachment '1':  starting view in form - user can pick function from radio buttons.

Attachment '2':  user picks 'driver details' function - radio button group hidden and details group shown (user returns to attachment '1' view when finished here).

Attachment '3': user picks 'driver extension' function - again different group shows at bottom of form (user returns to attachment '1' view when finished here).

Attachment '4':  user picks 'employer' function - pop up window as from different module - how do I get it to open as a group in my existing form?

I can live with it if it is not possible - just thought it would be nice (as in look better) if it opened in my current form by use of a place holder or something.

Does what I'm trying to do have any relation to code or form 'snippets' - I think that was the term used at an introducing genero seminar I attended several years back, but memory very vague on that now.

Regards,
  Bryce Stenberg
  Harness Racing New Zealand Inc.


* 1.jpg (40.68 KB, 778x616 - viewed 2846 times.)

* 2.jpg (38.75 KB, 778x611 - viewed 2860 times.)

* 3.jpg (31.35 KB, 755x612 - viewed 2883 times.)

* 4.jpg (40.51 KB, 805x689 - viewed 2969 times.)
Reuben B.
Four Js
Posts: 1119


« Reply #7 on: February 29, 2008, 03:44:11 am »

Quote
Attached is some examples that may highlight what I'm meaning (using radio buttons in this form as choices change depending on person input, can remove or add appropriate radio options on the fly)...

you can also add or remove buttons on the fly.  However what you've done may have a benefit in terms of what code is executed when the user presses ENTER, or are you using ON CHANGE

Quote
Attachment '1':  starting view in form - user can pick function from radio buttons.

Attachment '2':  user picks 'driver details' function - radio button group hidden and details group shown (user returns to attachment '1' view when finished here).

Attachment '3': user picks 'driver extension' function - again different group shows at bottom of form (user returns to attachment '1' view when finished here).

Attachment '4':  user picks 'employer' function - pop up window as from different module - how do I get it to open as a group in my existing form?

I can live with it if it is not possible - just thought it would be nice (as in look better) if it opened in my current form by use of a place holder or something.


OK I can see what you are trying to achieve.  A similar question was posed a year or two ago to do with folder pages but I can't find the post in the archives.  That person wanted a common page to appear in many different folders.

The only way I can think of involves a lot of typing and/or DOM Tree manipulation and may not lead to very maintainable code.  Pre-processor isn't suitable for the contents of a LAYOUT section as its line by line.



Quote
Does what I'm trying to do have any relation to code or form 'snippets' - I think that was the term used at an introducing genero seminar I attended several years back, but memory very vague on that now.
Snippets are to do with the Genero Web Client 2.1x

Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines