Icon View Thread

The following is the text of the current message along with any replies.
Messages 11 to 17 of 17 total
Thread Removing Control
Wed, Jun 28 2017 12:17 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Mark,

<< Tim - is this procedure ok - do I need to set the Parent to nil - thanks  >>

No, you shouldn't need to do so, which is what I'm trying to confirm with Chris because he's saying that it's required in his case.

Tim Young
Elevate Software
www.elevatesoft.com
Wed, Jun 28 2017 1:47 PMPermanent Link

Mark Brooks

Slikware

Avatar

Tim Young [Elevate Software] wrote:

>>No, you shouldn't need to do so, which is what I'm trying to confirm with Chris because he's saying that it's required >>in his case.

Ok. Will wait on your guidance and leave it in for now.
Thu, Jun 29 2017 9:07 AMPermanent Link

Chris Holland

SEC Solutions Ltd.

Avatar

Team Elevate Team Elevate

Hi Tim,

Sorry for the delay, been on an extended holiday Smiley

I used the code that Mark posted and changed my TComponent to a TControl
and set the parent to nil and then the error went away.

When I created the panels in the first place I didn't do it the way you
showed in your code:

 TBasicPanel.Create(Self);

Because they were placed on another top level panel they were created
using this:

      TempPanel := TBasicPanel.Create(JobListSubPanel);
      TempPanel.Layout.Position := lpTopLeft;
      TempPanel.Layout.Consumption := lcBottom;
      TempPanel.Layout.Reset := true;
      TempPanel.Layout.Stretch := lsRight;

      TempPanel.Width := PanelWidth;
      TempPanel.Height := 100;
      TempPanel.Tag := PanelCount;
      TempPanel.Name := 'AppointmentPanel' + IntToStr(PanelCount);
      TempPanel.OnClick := AppointmentPanelClicked;

      TempPanel.Border.Top.Visible := true;
      TempPanel.Border.Bottom.Visible := true;
      TempPanel.Border.Left.Visible := true;
      TempPanel.Border.Right.Visible := true;

      TempPanel.Background.Fill.FillType := ftSolid;
      TempPanel.Background.Fill.Color := clCornSilk;

      if Appointment.StartDate < Now then
         TempPanel.Background.Fill.Color := clPink;

Hope this helps.
(Although it is all working fine now with those changes)

Chris Holland
[Team Elevate]
Thu, Jun 29 2017 11:14 AMPermanent Link

Mark Brooks

Slikware

Avatar

Hi Chris

I have also seen "strange" behaviour if I didn't set the Parent to nil, but that was some time ago and maybe has been fixed / enhanced now. Hence my question about whether I need to or not.

Cheers
Mark
Mon, Jul 3 2017 2:04 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Chris,

<< Sorry for the delay, been on an extended holiday Smiley>>

I hope you had a great time. Smile

I tried this again with no ill effects, and this is the code that I'm using:

// Creation

procedure TForm1.Button1Click(Sender: TObject);
var
  I: Integer;
  TempPanel: TBasicPanel;
begin
  for I:=0 to 4 do
     begin
     TempPanel := TBasicPanel.Create(BasicPanel1);
     TempPanel.Layout.Position := lpTopLeft;
     TempPanel.Layout.Consumption := lcBottom;
     TempPanel.Layout.Reset := true;
     TempPanel.Layout.Stretch := lsRight;

     TempPanel.Width := BasicPanel1.ClientWidth;
     TempPanel.Height := 100;
     TempPanel.Tag := I;
     TempPanel.Name := 'AppointmentPanel' + IntToStr(I);
//      TempPanel.OnClick := AppointmentPanelClicked;

     TempPanel.Border.Top.Visible := true;
     TempPanel.Border.Bottom.Visible := true;
     TempPanel.Border.Left.Visible := true;
     TempPanel.Border.Right.Visible := true;

     TempPanel.Background.Fill.FillType := ftSolid;
     TempPanel.Background.Fill.Color := clCornSilk;
     end;
end;

// Removal

procedure TForm1.Button2Click(Sender: TObject);
var
  i: Integer;
  c: TComponent;
begin
 for i := BasicPanel1.ControlCount - 1 downto 0 do
  begin
     c := BasicPanel1.Controls[i];
     if c is TBasicPanel then
     begin
        c.Free;
     end;
  end;
end;

Could you possibly try the code there and see if you're still seeing any issues with closing the form/deleting the panels ?

Thanks,

Tim Young
Elevate Software
www.elevatesoft.com
Wed, Jul 5 2017 7:53 AMPermanent Link

Chris Holland

SEC Solutions Ltd.

Avatar

Team Elevate Team Elevate

Hi Tim,

That all appears to work fine.

I can't test the original code as having been on holiday I can't
remember which part of my code I was having problems with as I found a
solution so didn't keep a not of it Smiley

Chris Holland
[Team Elevate]

On 03/07/2017 19:04, Tim Young [Elevate Software] wrote:
> Chris,
>
> << Sorry for the delay, been on an extended holiday Smiley>>
>
> I hope you had a great time. Smile
>
> I tried this again with no ill effects, and this is the code that I'm using:
>
> // Creation
>
> procedure TForm1.Button1Click(Sender: TObject);
> var
>     I: Integer;
>     TempPanel: TBasicPanel;
> begin
>     for I:=0 to 4 do
>        begin
>        TempPanel := TBasicPanel.Create(BasicPanel1);
>        TempPanel.Layout.Position := lpTopLeft;
>        TempPanel.Layout.Consumption := lcBottom;
>        TempPanel.Layout.Reset := true;
>        TempPanel.Layout.Stretch := lsRight;
>
>        TempPanel.Width := BasicPanel1.ClientWidth;
>        TempPanel.Height := 100;
>        TempPanel.Tag := I;
>        TempPanel.Name := 'AppointmentPanel' + IntToStr(I);
> //      TempPanel.OnClick := AppointmentPanelClicked;
>
>        TempPanel.Border.Top.Visible := true;
>        TempPanel.Border.Bottom.Visible := true;
>        TempPanel.Border.Left.Visible := true;
>        TempPanel.Border.Right.Visible := true;
>
>        TempPanel.Background.Fill.FillType := ftSolid;
>        TempPanel.Background.Fill.Color := clCornSilk;
>        end;
> end;
>
> // Removal
>
> procedure TForm1.Button2Click(Sender: TObject);
> var
>     i: Integer;
>     c: TComponent;
> begin
>    for i := BasicPanel1.ControlCount - 1 downto 0 do
>     begin
>        c := BasicPanel1.Controls[i];
>        if c is TBasicPanel then
>        begin
>           c.Free;
>        end;
>     end;
> end;
>
> Could you possibly try the code there and see if you're still seeing any issues with closing the form/deleting the panels ?
>
> Thanks,
>
> Tim Young
> Elevate Software
> www.elevatesoft.com
>
Wed, Jul 5 2017 10:30 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Chris,

<< I can't test the original code as having been on holiday I can't remember which part of my code I was having problems with as I found a solution so didn't keep a not of it Smiley>>

No worries, I'll just chalk it up to chance at this point.  If you see something weird again, please let me know.

Tim Young
Elevate Software
www.elevatesoft.com
« Previous PagePage 2 of 2
Jump to Page:  1 2
Image