Code Monkey home page Code Monkey logo

Comments (26)

Alexey-T avatar Alexey-T commented on August 24, 2024

https://wiki.freepascal.org/ATTabs#How_to_use_it_like_TPageControl

from atflatcontrols.

JacoFourie avatar JacoFourie commented on August 24, 2024

Hi. I saw that but I don't understand how to do it.

Do you not have a sample with the Frames in already? I don't know how to use frames.

from atflatcontrols.

Alexey-T avatar Alexey-T commented on August 24, 2024

Use Forms instead of Frames. like this

var F: TForm;
begin
F:= TForm.CreateNew;
F.Parent:= MainForm;
F.Align:= alClient;
F.BorderStyle:= bsNone;
F.Show;

from atflatcontrols.

JacoFourie avatar JacoFourie commented on August 24, 2024

How do I show the content of the form I build at design time as the tab if I creat a blank form like in your sample? And If I use more than one form as tabs how do I send data between the tabs like with a TPageContol item. With PageControl everything is in one form and I can get to each item on every tab.

from atflatcontrols.

Alexey-T avatar Alexey-T commented on August 24, 2024

you cannot design ui on Tabs in design time. you have to design all forms as separate forms, then in RUNTIME you embed them into one host panel.

from atflatcontrols.

JacoFourie avatar JacoFourie commented on August 24, 2024

I like your controls but I am a beginner and I don't know what you are talking about. If you had a sample with Frames or Forms that work like PageControl I would understand what you are saying.

from atflatcontrols.

Alexey-T avatar Alexey-T commented on August 24, 2024

I made new demo
https://github.com/Alexey-T/ATFlatControls/tree/master/app/demo_tabs_as_pagecontrol
OK?

from atflatcontrols.

Alexey-T avatar Alexey-T commented on August 24, 2024

It is for Lazarus, but you can see source code for Delphi

from atflatcontrols.

JacoFourie avatar JacoFourie commented on August 24, 2024

Thank you very much. I am using Lazarus on the Raspberry Pi. The sample won't run. It is complaining that it can not find Interfaces in the uses clause. all your other sample work.

from atflatcontrols.

JacoFourie avatar JacoFourie commented on August 24, 2024

OK I got it working on windows. But the app seems very slow. why would that be.
If I type text into the text box the text will lag way behind. Anyway thanks for the sample.

from atflatcontrols.

JacoFourie avatar JacoFourie commented on August 24, 2024

OK how do you interface between the forms?
With PageControl all items are in one form and I can get to all items with code.
Lets say there is a text item on tab3 and a button on tab1. If I click on Button on tab1 then the textbox on tab3 but show "Hello World". If I use a PageControl I do it like this.

procedure TForm1.Button1Click(Sender: TObject);
begin

Form1.Edit1.Caption := 'Hello World";

end;

How do I do that if you have separate forms?

from atflatcontrols.

Alexey-T avatar Alexey-T commented on August 24, 2024

Thank you very much. I am using Lazarus on the Raspberry Pi. The sample won't run. It is complaining that it can not find Interfaces in the uses clause. all your other sample work.

I cannot see this error here in Lazarus 2.1 trunk. linux. project uses LCL package so its ok.

from atflatcontrols.

Alexey-T avatar Alexey-T commented on August 24, 2024
  • I dont see that it's slow- all ok here on Linux
  • you can write Form_Frame1.Button1.Caption:= '...' or Form_Frame3.Edit1.Text:= '..'

from atflatcontrols.

JacoFourie avatar JacoFourie commented on August 24, 2024

This is on the Raspberry Pi. Also using 2.1.0

image

from atflatcontrols.

JacoFourie avatar JacoFourie commented on August 24, 2024

OK I got it working on the Pi

image

from atflatcontrols.

JacoFourie avatar JacoFourie commented on August 24, 2024

Thank you Alexey. You have shown me a lot about how to use your controls and how to use Forms in Lazarus. I just neet to understand this last part then I will go off and do my own thing. I updated your sample to have a button on Tab1 / Frm1 . Button1 and a Textbox on Tab2 / Frm2. I want to update the text in the textbox on Tab2 if I click on the Button on Tab1. Where do I put the code and how should I address it?

Here is the button on Tab1 called Button1

image

Here is the text box called Edit1 on Frm2

image

I also want to know if I can update items on the Forms from the main Form. Lets say data is comming into the Main Form via a Rest call. The main form will have a callback that will be called if there is data. Then I want to send that data to one of the Tabs / Forms. So for a test I will just add a timer to the main form like this . every second I want to update a text box on Tab3 from the timer event on the main form.

image

Is what I ask possible ?

from atflatcontrols.

JacoFourie avatar JacoFourie commented on August 24, 2024

Also, Can I call code in the main form from the 3 other forms? Let's say the main form creates a database connection and has some procedures to update the database. Can I call the code to update the database from the 3 forms/tabs?

from atflatcontrols.

Alexey-T avatar Alexey-T commented on August 24, 2024

seems, IDE has new format of LPI file so my LPI file is read on your PC without LCL package.
my file has

    <RequiredPackages>
      <Item>
        <PackageName Value="atflatcontrols_package"/>
      </Item>
      <Item>
        <PackageName Value="LCL"/>
      </Item>

from atflatcontrols.

JacoFourie avatar JacoFourie commented on August 24, 2024

If I try to update the textbox on Form 3 in the timer I get errors. I don't know how to reference the item

image

from atflatcontrols.

Alexey-T avatar Alexey-T commented on August 24, 2024
  • you cannot call code in mainform from child forms
  • your code "f3.Edit1.Caption:= ..." is ok, so maybe you miss smth, e.g. "Edit1" is missed on f3? use only those names which defined in f3.

from atflatcontrols.

JacoFourie avatar JacoFourie commented on August 24, 2024

Mmm OK that is a problem then. Do I have to make a new connection on the child form then if I can not call code on Parent Form.

Here is Form 3

image

If I try to update its text I get this error. It does not see the text box.

image

from atflatcontrols.

Alexey-T avatar Alexey-T commented on August 24, 2024

Reason is type of variable f3. Change it to actual type

from atflatcontrols.

Alexey-T avatar Alexey-T commented on August 24, 2024

Access to main form- ask it at the Lazarus forum

from atflatcontrols.

JacoFourie avatar JacoFourie commented on August 24, 2024

OK I can update the main form from the child form. I write some code now and it works. I now still need to know how to access the child form from the main form. What do you mean by "Change it to actual type" ?

from atflatcontrols.

JacoFourie avatar JacoFourie commented on August 24, 2024

OK I got it working. Thanks a lot. Now I know how to do it all.

from atflatcontrols.

Alexey-T avatar Alexey-T commented on August 24, 2024

F3 has actual type TFormFrame3 or the like

from atflatcontrols.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.