Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2010-01

How do I Show Dynamically Created Visual Components?

5 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Dennis M. Linton

I am having trouble figuring out how to show visual components created programmatically. I seem to be able to, for example, do this:

An integer, i, is declared in the public section.

    with TEdit.Create(Form1) do begin
        Visible:=True;
`      Enabled:=True;
        Name:='TestEdit"+IntToStr(i);
        Show;    //tried this in desperation but no success.
        Form1.Refresh    //this did not produce a visible new component
either.
    end;

The edit box seems to be created as Form1.ComponentCount increases and the Name generated is shown in another edit box.

My problem is that I cannot get the new edit box to be visible (I even had code to ensure that .Top and .Left were such that the new component would be located within the Form1 coordinates. Can anyone tell me what I am doing wrong.

Thanks in advance.

Best regards,
Dennis

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20100115/0da8260e/attachment.html>

Reply by email

ik
to Dennis M. Linton

What about adding position of left and top and also Form1 as parent ?

with TEdit.Create(Form1) do begin
        Visible:=True;
        Enabled:=True;
        Name:='TestEdit"+IntToStr(i);
        ///////////////////////////////
        Left := 50;
        top := 100;
        Parent := Form1;
        ////////////////////////////////
        Show;    //tried this in desperation but no success.
        Form1.Refresh    //this did not produce a visible new component
either.
    end;

http://ik.homelinux.org/

2010/1/15 Dennis M. Linton

Show quoted text 35 lines
I am having trouble figuring out how to show visual components created programmatically. I seem to be able to, for example, do this: An integer, i, is declared in the public section. with TEdit.Create(Form1) do begin Visible:=True; ` Enabled:=True; Name:='TestEdit"+IntToStr(i); Show; //tried this in desperation but no success. Form1.Refresh //this did not produce a visible new component either. end; The edit box seems to be created as Form1.ComponentCount increases and the Name generated is shown in another edit box. My problem is that I cannot get the new edit box to be visible (I even had code to ensure that .Top and .Left were such that the new component would be located within the Form1 coordinates. Can anyone tell me what I am doing wrong. Thanks in advance. Best regards, Dennis -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20100115/87125a2d/attachment.html>

Reply by email

Andrew Brunner
to Dennis M. Linton: I am having trouble figuring out how to show visual components created programmatically. …

You have to set the parent of the component before you will be able to see it.
SetParent(Form1)
or Parent:=Form1 should do.

2010/1/15 Dennis M. Linton

Show quoted text 35 lines
I am having trouble figuring out how to show visual components created programmatically. I seem to be able to, for example, do this: An integer, i, is declared in the public section. with TEdit.Create(Form1) do begin Visible:=True; ` Enabled:=True; Name:='TestEdit"+IntToStr(i); Show; //tried this in desperation but no success. Form1.Refresh //this did not produce a visible new component either. end; The edit box seems to be created as Form1.ComponentCount increases and the Name generated is shown in another edit box. My problem is that I cannot get the new edit box to be visible (I even had code to ensure that .Top and .Left were such that the new component would be located within the Form1 coordinates. Can anyone tell me what I am doing wrong. Thanks in advance. Best regards, Dennis -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20100115/f23b1d18/attachment-0001.html>

Reply by email

Dennis M. Linton
to ik: What about adding position of left and top and also Form1 as parent ? with…

Thanks, IK and also to Andew Brunner who also replied.

For some reason, I was thinking that the TEdit.Create(Form1) established Form1 as parent. Anyhow, I set the parent and life is good again. Many thanks.

Best regards,
Dennis

ik wrote 69 lines
What about adding position of left and top and also Form1 as parent ? with TEdit.Create(Form1) do begin Visible:=True; Enabled:=True; Name:='TestEdit"+IntToStr(i); /////////////////////////////// Left := 50; top := 100; Parent := Form1; //////////////////////////////// Show; //tried this in desperation but no success. Form1.Refresh //this did not produce a visible new component either. end; http://ik.homelinux.org/ 2010/1/15 Dennis M. Linton I am having trouble figuring out how to show visual components created programmatically. I seem to be able to, for example, do this: An integer, i, is declared in the public section. with TEdit.Create(Form1) do begin Visible:=True; ` Enabled:=True; Name:='TestEdit"+IntToStr(i); Show; //tried this in desperation but no success. Form1.Refresh //this did not produce a visible new component either. end; The edit box seems to be created as Form1.ComponentCount increases and the Name generated is shown in another edit box. My problem is that I cannot get the new edit box to be visible (I even had code to ensure that .Top and .Left were such that the new component would be located within the Form1 coordinates. Can anyone tell me what I am doing wrong. Thanks in advance. Best regards, Dennis -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Dennis M. Linton, P.Eng. Tel: +1 (613) 473-1015 Cell: +1 (705) 312-1336 SMS: +1 (613) 922-2838 Skype: thedmlinton -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20100115/539be6b7/attachment.html>

Reply by email