Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread |
Messages 1 to 8 of 8 total |
Swapping out sections of forms |
Thu, Aug 18 2016 1:37 PM | Permanent Link |
TD Advanced Data Systems, Inc. | I am wondering if there is a way to swap-out part of a form. What I mean by this is the main section of the form will not change but depending on the selections made by the user, a section of the form would change to reflect the new selection. I am guessing that one would have to pro-grammatically create panels that would then be swapped out.
Any thoughts on this? TD. |
Thu, Aug 18 2016 2:47 PM | Permanent Link |
Trinione | TD wrote:
<< Any thoughts on this? >> I currently use PagePanels to do this. Making them Visible accordingly. But, I guess this is effectively what you are saying. Any other suggestions/ideas/approaches would be quite interesting. |
Thu, Aug 18 2016 5:31 PM | Permanent Link |
Matthew Jones | <Trinione> wrote:
> TD wrote: > << Any thoughts on this? >> > > I currently use PagePanels to do this. Making them Visible accordingly. > But, I guess this is effectively what you are saying. > > Any other suggestions/ideas/approaches would be quite interesting. > > You can create parented forms, and use multiples of required. This works very well. -- Matthew Jones |
Thu, Aug 18 2016 6:10 PM | Permanent Link |
TD Advanced Data Systems, Inc. | Matthew Jones wrote:
You can create parented forms, and use multiples of required. This works very well. I am new to EWB2 so could you please explain how to do this? Thanks, TD |
Thu, Aug 18 2016 6:50 PM | Permanent Link |
Raul Team Elevate | On 8/18/2016 6:10 PM, TD wrote:
> I am new to EWB2 so could you please explain how to do this? Super simple example - embeds 2 forms on 2 scrollpanels on the 3rd form and provides a button to swap the parent container. 1. create a new project (tform based) 2. on the main form place a button and 2 scrollpanels (position them side by side - this is just fixed positioning but you can use proper layout of course). We'll call this formMain. 3. add 2 additional forms - formOne and formTwo. - I would suggest dropping a label on these and give a unique caption and/or change background to unique color for each (so you can actually confirm it got embedded). - Make layout Position for both forms to be lpTopLeft and Stretch to be lsBottomRight so they fill their parent 4. make sure you go to project options and under "forms and databases" tab make sure only formMain is auto-created (formOne and formTwo should be on "available forms and databases" list). 5. in formMain add the unit names for formOne and formTwo into uses clause 6. in the form main create create the forms runtime and parent them to the scrollpanels: procedure TFormMain.FormMainCreate(Sender: TObject); begin formOne := TFormOne.Create(nil); formOne.Parent := ScrollPanel1; formTwo := TFormTwo.Create(nil); formTwo.Parent := ScrollPanel2; end; 7. Add an event to the button to switches parents for now (swaps the forms around) procedure TFormMain.ButtonEmbedSwapClick(Sender: TObject); var tmpParent:TControl; begin formOne.Hide; formTwo.Hide; tmpParent := formOne.Parent; formOne.Parent := formTwo.Parent; formTwo.Parent := tmpParent; formOne.Show; formTwo.Show; end; Raul NB! It's good practice to also free the 2 forms (for example in form main destroy call formOne.Free; formTwo.Free; but if you intend to create and free forms in your code then of course do it there in an appropriate place) |
Fri, Aug 19 2016 9:49 AM | Permanent Link |
TD Advanced Data Systems, Inc. | Thanks guys !
TD |
Fri, Aug 19 2016 11:19 AM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Raul,
Excellent response, as always. I would just like to point out one additional thing. With the following code: procedure TFormMain.FormMainCreate(Sender: TObject); begin formOne := TFormOne.Create(nil); formOne.Parent := ScrollPanel1; formTwo := TFormTwo.Create(nil); formTwo.Parent := ScrollPanel2; end; Raul was very much correct to create the forms *without* an owner/parent in the Create call. This is especially important if you intend to move forms around between different parent controls. If you *do* pass an owner/parent into the Create call, you run the risk of the owner control being destroyed and inadvertently destroying your form due to the ownership. Tim Young Elevate Software www.elevatesoft.com |
Fri, Aug 19 2016 12:58 PM | Permanent Link |
Trinione | << Raul was very much correct to create the forms *without* an owner/parent in the Create call. This is especially important if you intend to move forms around between different parent controls. If you *do* pass an owner/parent into the Create call, you run the risk of the owner control being destroyed and inadvertently destroying your form due to the ownership. >>
Ah! Ok. I was actually about to ask a question on exactly this as I was wondering why not just put formOne := TFormOne.Create(ScrollPanel1). Now I know. |
This web page was last updated on Thursday, December 5, 2024 at 09:15 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |