working with FormExDesktop_1.2

Cableguy

Expert
Licensed User
Longtime User
Hi,

I'm trying to make the "main" form of B4PPC a windows Like form, but can't get around to it...
Since the v1.2 Dll has no help file, and the v1 help file has no pratical examples other than the Demo file, I don't really know how to set the minimize and box to be enable, and the maximize to only restore to the form size...
Any help?
 

agraham

Expert
Licensed User
Longtime User
Since the v1.2 Dll has no help file,
There IS an updated help file in the version 1.2 zip at post #20 here http://www.b4x.com/forum/showthread.php?t=1175&page=2 However the only difference over version 1 is that the resize event was added.

B4X:
   FormEx1.MaximumHeight = 600
   FormEx1.MaximumWidth = 600
   FormEx1.MinimumHeight = 300
   FormEx1.MinimumWidth = 400
   FormEx1.HasMaximizeBox = false
   FormEx1.HasMinimizeBox = false
You will find these lines in App_Start in the "Build FormEx1" region of the demo app. Comment them all out and the defaults give you a fully resizable window with Maximize and Minimize boxes.
 

Cableguy

Expert
Licensed User
Longtime User
Ok, but should theese lines go before of after the show command.?
 

Cableguy

Expert
Licensed User
Longtime User
This is y code

B4X:
Sub App_Start
LoadINI
XForm.New1("Main")
XForm.MaximumHeight = 600
   XForm.MaximumWidth = 600
   XForm.MinimumHeight = 300
   XForm.MinimumWidth = 400
   XForm.HasMaximizeBox = false
   XForm.HasMinimizeBox = false
Main.Show

End Sub

Main is a basic4ppc designer created form, 800x600
When I run the code, there's no error but the form shows has if the dll was not beeing called at all...
 

agraham

Expert
Licensed User
Longtime User
Main is a basic4ppc designer created form, 800x600
When I run the code, there's no error but the form shows has if the dll was not beeing called at all...
You are right, it is not being called because you are showing your original Main form with "Main.Show" not the XForm.

To show only your FormEx use "XForm.Run". This is documented in the comments in the "Start Application" region of the example and also under the help for Run in the "FormExDesktop advanced topic".

To get a window that Maximises and Minimises all you need is this
B4X:
Sub App_Start
  LoadINI
  XForm.New1("Main")
  XForm.Run
End Sub
 

Cableguy

Expert
Licensed User
Longtime User
Thaks agraham, got it working...
It a great lib, but a bit confusing with all the available options...
An embeed dll option is starting to be needed in the Designer, a bit like VB,and to have a small panel/form were to seet the most commom props of the control...just a thought...
 

agraham

Expert
Licensed User
Longtime User
to seet the most commom props of the control...
I usually try to make the defaults the most common values so you don't need to worry too much about the properties.

A good simplifying tip is to not set any properties at all to begin with. Just try it using the defaults and if the behaviour is not what you want/expect then explore the help for inspiration!
 

Cableguy

Expert
Licensed User
Longtime User
one last question:

Since it is easyer to create the form in the designer and then pass it to the dll, can i have two froms inherited from the designer, show up with diferent sizes?
This second form not beeing the main form, what to use to show it? (show vs Run)
 

agraham

Expert
Licensed User
Longtime User
can i have two froms inherited from the designer, show up with diferent sizes? This second form not beeing the main form, what to use to show it? (show vs Run)
You can have as many FormEx forms as you want, all inheriting from their own B4PPC Form object produced in the Designer.

You "Show" them, not "Run" them and they will all close when the main form (the first one that is "Run") is closed. Note that "Close" truly closes and disposes a FormEx and does not "Hide" it like a B4PPC Close does. If you want the Close button on the form to emulate B4PPC and let a form be reshown then check help for "Closing" and the comments in the example region "Closing events - makes it more like B4PPC" for more information.
 

Cableguy

Expert
Licensed User
Longtime User
you mean that if i close one form, i cannot show it again, if it was an inherit form?
But if I create a form in runtime I ccan create it any time I need, right?
 

Cableguy

Expert
Licensed User
Longtime User
I know I do not need to add the dll twice to work with 2 inherited forms, but waht about the component? do i need to create a component for each form?
 

agraham

Expert
Licensed User
Longtime User
but waht about the component? do i need to create a component for each form?
Lets be pedantic about terminology :). Add Component adds the dll, which as you say you do once. You need to add an FormEx object for every B4PPC form that you inherit from.
 

agraham

Expert
Licensed User
Longtime User
you mean that if i close one form, i cannot show it again, if it was an inherit form?
But if I create a form in runtime I ccan create it any time I need, right?
Lets again be a bit pedantic. There is no real difference between a FormEx produced by the two sorts of "New". One inherits controls from a normal form, the other doesn't - that is the only difference. Both can have controls added or removed at runtime, inheriting from a B4PPC form is just a convenience to avoid adding everything at run time.

Once you close a FormEx with inherited controls those controls are lost. The original donor form will now be blank so you cannot inherit anything from it again.

I will have to get back to you tomorrow about re-using FormEx objects to be sure to give you a good answer. I've forgotten that level of detail about the code. You can always try it to see if it works ;)
 

Cableguy

Expert
Licensed User
Longtime User
sorry agraham, another issue...
Controls must be donated from an inherited form, when using new2...
But when the created form (with new2) is closed, all controls are disposed as well,...
Anyway to go around this issue?
 

agraham

Expert
Licensed User
Longtime User
Controls must be donated from an inherited form, when using new2
Actually New1 to be pedantic again :) New2 creates a blank form. I don't understand "must be donated", why must? You can either opt to inherit controls from a Form with New1 or create a blank FormEx with New2, the choice is yours. In both cases you can add further controls at runtime.

But when the created form (with new2) is closed, all controls are disposed as well,...Anyway to go around this issue?
I assume you mean New1! Unless I am misunderstanding I thought that I covered this in post #9 of this thread. Trap the Closing event, call CancelClose and Hide the Form. It can then be reshown if required.
 

Cableguy

Expert
Licensed User
Longtime User
I don't understand "must be donated", why must? You can either opt to inherit controls from a Form with New1 or create a blank FormEx with New2, the choice is yours. In both cases you can add further controls at runtime.
In the help file it say the controls MUST be borowed from a B4PPC form, so i thought we could not created/add to the New2 form...in runtime...
 

agraham

Expert
Licensed User
Longtime User
In the help file it say the controls MUST be borowed from a B4PPC form
I can't find must in the help but it DOES say that in the example program. The region "Build FormEx2" shows an empty FormEx2 being created by a New2 and then having controls added at runtime. This is your must I think. OK I could have made this a bit clearer, sorry for any confusion. AddControl is used to add B4PPC native controls like Button and TextBox etc. to a FormEx. The only way to bring such controls into existence is to first have B4PPC create them on a normal Form and then add them to a FormEx with AddControl, this is the reason for saying they must be added from a donor form. This region demonstrates adding BOTH a pre-existing and a runtime created Button to FormEx2.

Controls from a library don't need to go through this route as they have the Form on which to be created specified in their New constructor.If you look at the example the region "Build FormEx1" shows FormEx1 inheriting controls from a Form1 by a New1 and then demonstrates how to use controls from a library, in this case a ProgressBar from ControlsEx.dll at runtime.
 

agraham

Expert
Licensed User
Longtime User
I will have to get back to you tomorrow about re-using FormEx objects to be sure to give you a good answer.
The FormEx object created in B4PPC by the menu Tools->AddObject is a B4PPC container for an instance of a FormEx. That FormEx instance is created by either New1 or New2. When a FormEx is "Hidden" that instance of a FormEx still exists with its' controls intact and may be reshown with "Show".

When a FormEx is "Closed" the FormEx instance that the B4PPC FormEx contained is destroyed together with all its' controls. If you try to access it you will get a "Cannot access a disposed object" exception. However you can reuse the B4PPC FormEx container by using New1 or New2 to create another FormEx instance which you will need to populate with controls.
 

Cableguy

Expert
Licensed User
Longtime User
Thank's Agraham, I'm completly clarified...
 
Top