Gambas Equivalent of MDI

Post

Posted
Rating:
#1 (In Topic #1501)
Regular
tailkinker is in the usergroup ‘Regular’
my recipe program, I would like to have more than one open at a time, hence the need for multiple instances of the main output form. In Visual Basic I would use MDI. How do I achieve this in Gambas?

BTW… a few sites say create a workspace -  but instructions aren't working from this site:

/comp/gb.form.mdi/workspace/_new - Gambas Documentation

In the parent form, I put in public sub form_open()

dim dwork as workspace  (I also tried dim work as new workspace)

and get the error "unknown identifier: workspace (disparent.class:7)
Online now: No Back to the top

Post

Posted
Rating:
#2
Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’
Make a form and add a WorkSpace.
Make this form your main form. And add a menu to open recipes (mnuOpen)

I guess you already  have a form that shows the recipes now and does all the magic. That is the form you want multiple instances of and don't want to be your main form.
Make sure it has a:

Code (gambas)

  1. 'FrmRecipe code
  2.  
  3. Public Sub _new(FilePath As String)
  4.  
  5.   'your code here: FilePath is argument you could use to pass recipe location (you can add more if needed)
  6.  
so you can actually instantiate it with a new recipe.

Let's call your recipe form FrmRecipe and the workspace on main form Workspace1. On the event of opening a recipe (from your main form mnuOpen) you could do this:

Code (gambas)

  1. 'Main form code
  2.  
  3. Public Sub mnuOpen_Click()
  4.  
  5.   Dim hForm As FrmRecipe
  6.  
  7.   hForm = New FrmRecipe("/home/user/Recipes/Cookies")
  8.  
  9.   Workspace1.Add(hForm)
  10.   Workspace1.ActiveWindow = hForm
  11.   Workspace1.Refresh
  12.  

So, now all you need to do is code the FrmRecipe once for all recipes and reuse by opening an instance for each recipe. Add arguments to _new() of FrmRecipe, so you can pass what you need to the instance just created.

I hope this will get you started. Feel free to ask questions.

gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories


… there is always a Catch if things go wrong!
Online now: No Back to the top

Post

Posted
Rating:
#4
Regular
tailkinker is in the usergroup ‘Regular’
 Thankyou for getting back to me on this.

How do I create a workspace to begin with?  I think I may need to add some components, but it isn't recognizing gb.form.mdi.
Online now: No Back to the top

Post

Posted
Rating:
#5
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’

tailkinker said

How do I create a workspace to begin with?  I think I may need to add some components, but it isn't recognizing gb.form.mdi.
In project properties, tab components select gb.form.mdi
Image

Workspace icon

Workspace icon

(Click to enlarge)

Next select you Main form (as mentioned in previous post) and under the 'Properties/Hierachy' box, select tab Special and you will find the Workspace icon
Image

Project properties -> Components

Project properties -> Components

(Click to enlarge)


Enjoy…

gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories


… there is always a Catch if things go wrong!
Online now: No Back to the top

Post

Posted
Rating:
#6
Regular
tailkinker is in the usergroup ‘Regular’
 Thankyou - I just found the workspace icon.  I do believe their will be magic in my nutrition program today!
Online now: No Back to the top

Post

Posted
Rating:
#7
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’

tailkinker said

I do believe their will be magic in my nutrition program today!
:lol: Enjoy…

gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories


… there is always a Catch if things go wrong!
Online now: No Back to the top
1 guest and 0 members have just viewed this.