• Welcome to PlanetSquires Forums.
 

Child Forms vs Regular Forms

Started by Petrus Vorster, October 12, 2022, 03:15:43 PM

Previous topic - Next topic

Petrus Vorster

Hi All

When you click on a form properties to make it a child form, what are the significant changes that happen in the background? How do they differ, other than having a parent form?

Are there some significant difference in how its properties are internally retrieved?

I have played with clayout and found that the child forms reacts differently than normal forms to placing the objects.  A Child form in a Tabcontrol as well as a childform with a main form a parent does the same.

Anchoring to the Width and Height exceeds form borders on a child form.

Perhaps a better understanding of the internal workings of the two may explain to me what is happening.

Kind regards,

Peter
-Regards
Peter

Paul Squires

I have not done any testing with child forms and controls with anchors. I will do some testing to see if there is any funny business going on that needs to be corrected.

Also, I have not added the Anchor property to the Form object which in hindsight could be quite useful for child forms.

I'll get back to you on this topic with better answers once I have tested.
 
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Paul Squires

Hi Peter,

I have looked at this and there are two things that I need to do:

(1) Add the Anchor property to the Form control (this is now done and complete).

(2) Add a "Parent" property to the Form control so you can set the parent form for any form that you have designated as a ChildForm. Need to do this because WinFBE needs to know the parent form at *design time* in order to add it to the Anchor/layout data during code generation.

I hope to have this all working very soon. It will make working with projects like the "Panels" project that I posted even easier. You would just need to set the ChildForm parent form and Left/Top/Width/Height properties and set the Anchor to RIGHT, BOTTOM.

Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Petrus Vorster

Great. THanks Paul.

But now I am curious how the child form process works.
THat is the problem with drag-and-drop 'Programmers', we dont have that core understanding on what really brings the entire process together.

Regards, Peter
-Regards
Peter

Paul Squires

Hi Peter,

WinFBE uses the terminology of "Form" similar to that used in the old Visual Basic (granted, in VB, Forms were a lot more than a simple wrapper around CreateWindowEx that WinFBE uses).

In WinFBE, a Form is simply a "Window". Much like any other control in Windows and is created using the same process as other windows (controls) by using CreateWindowEx. That function takes many different class names that are used to create the many different "controls" such as labels, comboboxes, listboxes, etc. However, to create a "Form" you need to create your own class via the RegisterClass function and then pass that to the CreateWindowEx function. Pretty simple once you've done it a few times.

More to your point, now that we can create "Forms" just like any other control, then all we need to do is add the window style WS_CHILD as we are creating the Form. We use WS_CHILD for all controls on the form as well. We also remove the Form's titlebar and min/max/close buttons, etc so that we are left with something akin to a blank container that will display as a child control within a parent Form. We can now create controls on this "child form" and show/hide that child form and thereby show/hide all of the controls on that child form all at one time.

I designed Tab Controls to use child forms for each page of a tab control, but you can use child forms for many other purposes like the "Panels" demo project that I posted.

Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Paul Squires

Hi Peter,

I have finally been able to get child forms working with Anchor properties. Here is what that example "Panels" code will look like now once you use this new functionality.

''
''
function frmMain_PositionWindows() as long
   
   ' Hide all panels and then only show the active panel
   Panel1.Visible = false
   Panel2.Visible = false
   Panel3.Visible = false
   
   select case gActivePanel
      case 0:  Panel1.Visible = true
      case 1:  Panel2.Visible = true
      case 2:  Panel3.Visible = true
   end select
   
   return 0
end function

Pretty easy. You just need to position your controls at design time and set the Anchor properties. Everything resizes at runtime and you only have to show/hide the panels based on whatever listbox item you clicked on.

Look for this new functionality when I post BETA 2.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Petrus Vorster

Great!

It is amazing at which rate you churn out your wizzardry....
This is so much simpler that in Powerbasic.

At work right now. (Yes, someone has to work Saturdays)
Will spend most of tonight playing with this.

Regards,

Peter
-Regards
Peter